From fa146ebbba39841b4847c9416f1d2df84bba67b8 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Mon, 23 Apr 2012 10:28:42 +0000 Subject: [PATCH] Ox.Map: meta+click on selected place now deselects it (fixes #655) --- source/Ox.UI/js/Core/Ox.Keyboard.js | 3 ++- source/Ox.UI/js/Map/Ox.Map.js | 11 ++++++++++- source/Ox.UI/js/Map/Ox.MapMarker.js | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Keyboard.js b/source/Ox.UI/js/Core/Ox.Keyboard.js index 18393f0d..5b9711d5 100644 --- a/source/Ox.UI/js/Core/Ox.Keyboard.js +++ b/source/Ox.UI/js/Core/Ox.Keyboard.js @@ -23,7 +23,8 @@ Ox.Keyboard = (function() { Ox.forEach(Ox.MODIFIER_KEYS, function(v, k) { // avoid pushing modifier twice - // using event.originalEvent since jquery always sets event.metaKey to event.ctrlKey + // using event.originalEvent since jquery always sets + // event.metaKey to event.ctrlKey if (event.originalEvent[k] && keyBasename != v) { keyNames.splice(-1, 0, v); } diff --git a/source/Ox.UI/js/Map/Ox.Map.js b/source/Ox.UI/js/Map/Ox.Map.js index cee19f4c..188c5580 100644 --- a/source/Ox.UI/js/Map/Ox.Map.js +++ b/source/Ox.UI/js/Map/Ox.Map.js @@ -142,7 +142,16 @@ Ox.Map = function(options, self) { key_left: function() { pan(-1, 0); }, - key_meta: function() { + // FIXME: + 'key_meta.left': function() { + self.metaKey = true; + $(document).one({ + keyup: function() { + self.metaKey = false; + } + }); + }, + 'key_meta.right': function() { self.metaKey = true; $(document).one({ keyup: function() { diff --git a/source/Ox.UI/js/Map/Ox.MapMarker.js b/source/Ox.UI/js/Map/Ox.MapMarker.js index 22f329a7..6fb69a6e 100644 --- a/source/Ox.UI/js/Map/Ox.MapMarker.js +++ b/source/Ox.UI/js/Map/Ox.MapMarker.js @@ -52,14 +52,17 @@ Ox.MapMarker = function(options) { setOptions(); function click() { + var key = that.map.getKey(), + place, bounds, southWest, northEast; if (!that.place.selected) { - if (that.map.getKey() == 'shift') { - var place = that.map.getSelectedPlace(), - bounds = new google.maps.LatLngBounds( - new google.maps.LatLng(place.south, place.west), - new google.maps.LatLng(place.north, place.east) - ), - southWest, northEast; + if (key == 'meta' || key == 'shift') { + place = that.map.getSelectedPlace(); + } + if (place) { + bounds = new google.maps.LatLngBounds( + new google.maps.LatLng(place.south, place.west), + new google.maps.LatLng(place.north, place.east) + ); bounds = bounds.union(that.place.bounds); southWest = bounds.getSouthWest(); northEast = bounds.getNorthEast(); @@ -77,12 +80,12 @@ Ox.MapMarker = function(options) { west: southWest.lng(), north: northEast.lat(), east: northEast.lng() - })); + })); } else { that.map.options({selected: that.place.id}); } } else { - if (that.map.getKey() == 'meta') { + if (key == 'meta') { that.map.options({selected: null}); } else { that.map.panToPlace();