Skip to content

Commit

Permalink
Return menu item(s) when removing from menu; fix typo in contextmenu.…
Browse files Browse the repository at this point in the history
…select event
  • Loading branch information
aratcliffe committed Mar 9, 2017
1 parent ba0ed2d commit e1c1c5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<html>
<head>
<title>Leaflet Context Menu</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css"/>
<link rel="stylesheet" href="../dist/leaflet.contextmenu.css"/>
</head>
<body>
<div id="map" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>
<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js"></script>
<script src="../dist/leaflet.contextmenu.js"></script>
<script src="../src/Map.ContextMenu.js"></script>
<script>
Expand Down Expand Up @@ -36,7 +36,7 @@
center: ll,
zoom: 15,
contextmenu: true,
contextmenuWidth: 140,
contextmenuWidth: 140,
contextmenuItems: [{
text: 'Show coordinates',
callback: showCoordinates
Expand All @@ -51,7 +51,7 @@
text: 'Zoom out',
icon: 'images/zoom-out.png',
callback: zoomOut
}]
}]
});

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-contextmenu",
"version": "1.2.1",
"version": "1.3.0",
"description": "A context menu for Leaflet",
"main": "dist/leaflet.contextmenu.js",
"directories": {
Expand Down
14 changes: 10 additions & 4 deletions src/Map.ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,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 () {
Expand Down Expand Up @@ -297,7 +303,7 @@ L.Map.ContextMenu = L.Handler.extend({
func.call(context || map, me._showLocation);
}

me._map.fire('contextmenu:select', {
me._map.fire('contextmenu.select', {
contextmenu: me,
el: el
});
Expand Down

0 comments on commit e1c1c5f

Please sign in to comment.