X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/aa1fb6dbb8c2e71b8ce8c231ae1272a2dfebd75a..a8020dc47555d4520b9218916693ca691ae7dbe1:/vendor/assets/leaflet/leaflet.contextmenu.js diff --git a/vendor/assets/leaflet/leaflet.contextmenu.js b/vendor/assets/leaflet/leaflet.contextmenu.js index a9b011d95..489da8755 100644 --- a/vendor/assets/leaflet/leaflet.contextmenu.js +++ b/vendor/assets/leaflet/leaflet.contextmenu.js @@ -29,14 +29,14 @@ L.Map.mergeOptions({ L.Map.ContextMenu = L.Handler.extend({ _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart', - + statics: { BASE_CLS: 'leaflet-contextmenu' }, - + initialize: function (map) { L.Handler.prototype.initialize.call(this, map); - + this._items = []; this._visible = false; @@ -71,7 +71,6 @@ L.Map.ContextMenu = L.Handler.extend({ this._map.on({ contextmenu: this._show, mousedown: this._hide, - movestart: this._hide, zoomstart: this._hide }, this); }, @@ -90,7 +89,6 @@ L.Map.ContextMenu = L.Handler.extend({ this._map.off({ contextmenu: this._show, mousedown: this._hide, - movestart: this._hide, zoomstart: this._hide }, this); }, @@ -144,16 +142,22 @@ L.Map.ContextMenu = L.Handler.extend({ contextmenu: this, el: item }); + + return item; } + + return null; }, removeAllItems: function () { - var item; + var items = this._container.children, + item; - while (this._container.children.length) { - item = this._container.children[0]; + while (items.length) { + item = items[0]; this._removeItem(L.Util.stamp(item)); } + return items; }, hideAllItems: function () { @@ -314,15 +318,27 @@ L.Map.ContextMenu = L.Handler.extend({ return; } + var map = me._map, + containerPoint = me._showLocation.containerPoint, + layerPoint = map.containerPointToLayerPoint(containerPoint), + latlng = map.layerPointToLatLng(layerPoint), + relatedTarget = me._showLocation.relatedTarget, + data = { + containerPoint: containerPoint, + layerPoint: layerPoint, + latlng: latlng, + relatedTarget: relatedTarget + }; + if (hideOnSelect) { me._hide(); } if (func) { - func.call(context || map, me._showLocation); + func.call(context || map, data); } - me._map.fire('contextmenu:select', { + me._map.fire('contextmenu.select', { contextmenu: me, el: el }); @@ -355,13 +371,9 @@ L.Map.ContextMenu = L.Handler.extend({ _showAtPoint: function (pt, data) { if (this._items.length) { var map = this._map, - layerPoint = map.containerPointToLayerPoint(pt), - latlng = map.layerPointToLatLng(layerPoint), event = L.extend(data || {}, {contextmenu: this}); this._showLocation = { - latlng: latlng, - layerPoint: layerPoint, containerPoint: pt };