From b41b9c7c6ebcc026aa90b88e7ca8f39b9057bddd Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 21 Jun 2013 13:52:57 +0100 Subject: add reposition button that appears if map is dragged after location has been set --- www/js/map-OpenLayers.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'www/js/map-OpenLayers.js') diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js index 2be1f48..0dcfe7d 100644 --- a/www/js/map-OpenLayers.js +++ b/www/js/map-OpenLayers.js @@ -220,6 +220,7 @@ function fixmystreet_onload() { }); if (fixmystreet.page == 'around' ) { + fixmystreet.map.addControl( new OpenLayers.Control.ActionAfterDrag({'autoActivate': true}) ); fixmystreet.map.addControl( new OpenLayers.Control.Crosshairs(null) ); } } @@ -433,3 +434,34 @@ OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, { }, CLASS_NAME: "OpenLayers.Format.FixMyStreet" }); + +OpenLayers.Control.ActionAfterDrag = OpenLayers.Class(OpenLayers.Control, { + + defaultHandlerOptions: { + 'stopDown': false + /* important, otherwise it prevent the click-drag event from + triggering the normal click-drag behavior on the map to pan it */ + }, + + initialize: function(options) { + this.handlerOptions = OpenLayers.Util.extend( + {}, this.defaultHandlerOptions + ); + OpenLayers.Control.prototype.initialize.apply( + this, arguments + ); + this.handler = new OpenLayers.Handler.Drag( + this, { + 'up': this.onDragEnd //could be also 'move', 'up' or 'out' + }, this.handlerOptions + ); + }, + + onDragEnd: function(evt) { + // do something when the user clic on the map (so on drag start) + console.log('drag ended'); + if ( $('#confirm').css('display') == 'block' ) { + $('#reposition').show(); + } + } +}); -- cgit v1.2.3