Yaron Koren has uploaded a new change for review. https://gerrit.wikimedia.org/r/325242
Change subject: Added support for double-clicking to googlemaps input ...................................................................... Added support for double-clicking to googlemaps input Change-Id: I45999abeadd52b642ad4bc1db3ca163435ba34d4 --- M libs/PF_maps.js M libs/PF_maps.offline.js 2 files changed, 20 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms refs/changes/42/325242/2 diff --git a/libs/PF_maps.js b/libs/PF_maps.js index a0c781e..abc24d5 100644 --- a/libs/PF_maps.js +++ b/libs/PF_maps.js @@ -13,8 +13,16 @@ var marker; var geocoder = new google.maps.Geocoder(); - google.maps.event.addListener(map, 'click', function(event) { - googleMapsSetMarker(event.latLng); + // Let a click set the marker, while keeping the default + // behavior (zoom and center) for double clicks. + // Code copied from http://stackoverflow.com/a/8417447 + google.maps.event.addListener( map, 'click', function( event ) { + update_timeout = setTimeout( function() { + googleMapsSetMarker( event.latLng ); + }, 200 ); + }); + google.maps.event.addListener( map, 'dblclick', function( event ) { + clearTimeout( update_timeout ); }); } else { // if ( mapService == "OpenLayers" ) { var mapCanvasID = inputDiv.find('.pfMapCanvas').attr('id'); diff --git a/libs/PF_maps.offline.js b/libs/PF_maps.offline.js index 04267a9..310c6cc 100644 --- a/libs/PF_maps.offline.js +++ b/libs/PF_maps.offline.js @@ -63,9 +63,17 @@ map = new google.maps.Map( mapCanvas, mapOptions ); var geocoder = new google.maps.Geocoder(); + // Let a click set the marker, while keeping the default + // behavior (zoom and center) for double clicks. + // Code copied from http://stackoverflow.com/a/8417447 google.maps.event.addListener( map, 'click', function( event ) { - googleMapsSetMarker( event.latLng ); - } ); + update_timeout = setTimeout( function(){ + googleMapsSetMarker( event.latLng ); + }, 200 ); + }); + google.maps.event.addListener( map, 'dblclick', function( event ) { + clearTimeout( update_timeout ); + }); } else { // if ( mapService == "OpenLayers" ) { var mapCanvasID = inputDiv.find( '.pfMapCanvas' ).attr( 'id' ); map = new OpenLayers.Map( mapCanvasID ); -- To view, visit https://gerrit.wikimedia.org/r/325242 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I45999abeadd52b642ad4bc1db3ca163435ba34d4 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/PageForms Gerrit-Branch: master Gerrit-Owner: Yaron Koren <yaro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits