umap-project 1.14.0a5__py3-none-any.whl → 2.0.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/decorators.py +0 -14
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +137 -85
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +136 -84
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +136 -84
- umap/locale/en/LC_MESSAGES/django.po +128 -88
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +136 -84
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +131 -91
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +137 -85
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +136 -84
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +136 -84
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +136 -84
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +135 -83
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +143 -91
- umap/models.py +23 -1
- umap/settings/__init__.py +1 -4
- umap/settings/base.py +1 -0
- umap/static/umap/base.css +5 -0
- umap/static/umap/content.css +185 -13
- umap/static/umap/favicons/icon.svg +2 -2
- umap/static/umap/img/edit.svg +3 -3
- umap/static/umap/img/icon-delete.svg +4 -0
- umap/static/umap/img/icon-download.svg +13 -0
- umap/static/umap/img/icon-duplicate.svg +5 -0
- umap/static/umap/img/icon-edit.svg +12 -0
- umap/static/umap/img/icon-share.svg +11 -0
- umap/static/umap/img/icon-view.svg +12 -0
- umap/static/umap/img/logo.svg +2 -2
- umap/static/umap/img/logo_small.svg +2 -2
- umap/static/umap/img/marker.svg +4 -0
- umap/static/umap/img/opensource.svg +2 -2
- umap/static/umap/img/osm.svg +2 -2
- umap/static/umap/js/components/fragment.js +1 -1
- umap/static/umap/js/modules/browser.js +159 -0
- umap/static/umap/js/modules/global.js +3 -1
- umap/static/umap/js/modules/request.js +155 -0
- umap/static/umap/js/umap.autocomplete.js +28 -38
- umap/static/umap/js/umap.controls.js +73 -58
- umap/static/umap/js/umap.core.js +4 -9
- umap/static/umap/js/umap.datalayer.permissions.js +13 -12
- umap/static/umap/js/umap.features.js +51 -49
- umap/static/umap/js/umap.forms.js +19 -19
- umap/static/umap/js/umap.icon.js +17 -17
- umap/static/umap/js/umap.importer.js +2 -1
- umap/static/umap/js/umap.js +242 -291
- umap/static/umap/js/umap.layer.js +173 -141
- umap/static/umap/js/umap.permissions.js +24 -25
- umap/static/umap/js/umap.popup.js +14 -14
- umap/static/umap/js/umap.share.js +4 -4
- umap/static/umap/js/umap.slideshow.js +4 -4
- umap/static/umap/js/umap.tableeditor.js +2 -2
- umap/static/umap/js/umap.ui.js +1 -1
- umap/static/umap/locale/am_ET.js +1 -11
- umap/static/umap/locale/am_ET.json +1 -11
- umap/static/umap/locale/ar.js +1 -11
- umap/static/umap/locale/ar.json +1 -11
- umap/static/umap/locale/ast.js +1 -11
- umap/static/umap/locale/ast.json +1 -11
- umap/static/umap/locale/bg.js +1 -11
- umap/static/umap/locale/bg.json +1 -11
- umap/static/umap/locale/br.js +1 -11
- umap/static/umap/locale/br.json +1 -11
- umap/static/umap/locale/ca.js +1 -11
- umap/static/umap/locale/ca.json +1 -11
- umap/static/umap/locale/cs_CZ.js +1 -11
- umap/static/umap/locale/cs_CZ.json +1 -11
- umap/static/umap/locale/da.js +1 -11
- umap/static/umap/locale/da.json +1 -11
- umap/static/umap/locale/de.js +1 -11
- umap/static/umap/locale/de.json +1 -11
- umap/static/umap/locale/el.js +1 -11
- umap/static/umap/locale/el.json +1 -11
- umap/static/umap/locale/en.js +1 -11
- umap/static/umap/locale/en.json +1 -11
- umap/static/umap/locale/en_US.json +1 -11
- umap/static/umap/locale/es.js +1 -11
- umap/static/umap/locale/es.json +1 -11
- umap/static/umap/locale/et.js +1 -11
- umap/static/umap/locale/et.json +1 -11
- umap/static/umap/locale/fa_IR.js +6 -16
- umap/static/umap/locale/fa_IR.json +6 -16
- umap/static/umap/locale/fi.js +1 -11
- umap/static/umap/locale/fi.json +1 -11
- umap/static/umap/locale/fr.js +1 -11
- umap/static/umap/locale/fr.json +1 -11
- umap/static/umap/locale/gl.js +1 -11
- umap/static/umap/locale/gl.json +1 -11
- umap/static/umap/locale/he.js +1 -11
- umap/static/umap/locale/he.json +1 -11
- umap/static/umap/locale/hr.js +1 -11
- umap/static/umap/locale/hr.json +1 -11
- umap/static/umap/locale/hu.js +1 -11
- umap/static/umap/locale/hu.json +1 -11
- umap/static/umap/locale/id.js +1 -11
- umap/static/umap/locale/id.json +1 -11
- umap/static/umap/locale/is.js +1 -11
- umap/static/umap/locale/is.json +1 -11
- umap/static/umap/locale/it.js +1 -11
- umap/static/umap/locale/it.json +1 -11
- umap/static/umap/locale/ja.js +1 -11
- umap/static/umap/locale/ja.json +1 -11
- umap/static/umap/locale/ko.js +1 -11
- umap/static/umap/locale/ko.json +1 -11
- umap/static/umap/locale/lt.js +1 -11
- umap/static/umap/locale/lt.json +1 -11
- umap/static/umap/locale/ms.js +1 -11
- umap/static/umap/locale/ms.json +1 -11
- umap/static/umap/locale/nl.js +1 -11
- umap/static/umap/locale/nl.json +1 -11
- umap/static/umap/locale/no.js +1 -11
- umap/static/umap/locale/no.json +1 -11
- umap/static/umap/locale/pl.js +1 -11
- umap/static/umap/locale/pl.json +1 -11
- umap/static/umap/locale/pl_PL.json +1 -11
- umap/static/umap/locale/pt.js +1 -11
- umap/static/umap/locale/pt.json +1 -11
- umap/static/umap/locale/pt_BR.js +1 -11
- umap/static/umap/locale/pt_BR.json +1 -11
- umap/static/umap/locale/pt_PT.js +1 -11
- umap/static/umap/locale/pt_PT.json +1 -11
- umap/static/umap/locale/ro.js +1 -11
- umap/static/umap/locale/ro.json +1 -11
- umap/static/umap/locale/ru.js +1 -11
- umap/static/umap/locale/ru.json +1 -11
- umap/static/umap/locale/sk_SK.js +1 -11
- umap/static/umap/locale/sk_SK.json +1 -11
- umap/static/umap/locale/sl.js +1 -11
- umap/static/umap/locale/sl.json +1 -11
- umap/static/umap/locale/sr.js +1 -11
- umap/static/umap/locale/sr.json +1 -11
- umap/static/umap/locale/sv.js +1 -11
- umap/static/umap/locale/sv.json +1 -11
- umap/static/umap/locale/th_TH.js +1 -11
- umap/static/umap/locale/th_TH.json +1 -11
- umap/static/umap/locale/tr.js +1 -11
- umap/static/umap/locale/tr.json +1 -11
- umap/static/umap/locale/uk_UA.js +1 -11
- umap/static/umap/locale/uk_UA.json +1 -11
- umap/static/umap/locale/vi.js +1 -11
- umap/static/umap/locale/vi.json +1 -11
- umap/static/umap/locale/vi_VN.json +1 -11
- umap/static/umap/locale/zh.js +1 -11
- umap/static/umap/locale/zh.json +1 -11
- umap/static/umap/locale/zh_CN.json +1 -11
- umap/static/umap/locale/zh_TW.Big5.json +1 -11
- umap/static/umap/locale/zh_TW.js +17 -27
- umap/static/umap/locale/zh_TW.json +17 -27
- umap/static/umap/map.css +2 -2
- umap/static/umap/nav.css +2 -1
- umap/static/umap/test/.eslintrc +0 -1
- umap/static/umap/test/Choropleth.js +29 -27
- umap/static/umap/test/DataLayer.js +207 -239
- umap/static/umap/test/Feature.js +33 -58
- umap/static/umap/test/Map.Export.js +11 -11
- umap/static/umap/test/Map.js +66 -67
- umap/static/umap/test/Marker.js +36 -32
- umap/static/umap/test/Polygon.js +95 -95
- umap/static/umap/test/Polyline.js +31 -31
- umap/static/umap/test/TableEditor.js +29 -25
- umap/static/umap/test/_pre.js +2 -7
- umap/static/umap/test/index.html +4 -4
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.css +54 -0
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.js +586 -0
- umap/static/umap/vendors/csv2geojson/index.js +259 -0
- umap/static/umap/vendors/dompurify/purify.js +1633 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.css +63 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.js +950 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.css +88 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.js +352 -0
- umap/static/umap/vendors/togeojson/togeojson.js +2 -0
- umap/templates/auth/user_form.html +3 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +51 -36
- umap/templates/umap/about_summary.html +1 -1
- umap/templates/umap/branding.html +3 -0
- umap/templates/umap/content.html +15 -39
- umap/templates/umap/header.html +0 -0
- umap/templates/umap/home.html +4 -2
- umap/templates/umap/js.html +0 -1
- umap/templates/umap/map_detail.html +9 -0
- umap/templates/umap/map_init.html +1 -1
- umap/templates/umap/map_messages.html +4 -2
- umap/templates/umap/map_table.html +130 -69
- umap/templates/umap/navigation.html +2 -4
- umap/templates/umap/user_dashboard.html +29 -6
- umap/tests/base.py +1 -1
- umap/tests/integration/conftest.py +18 -0
- umap/tests/integration/test_anonymous_owned_map.py +6 -3
- umap/tests/integration/test_browser.py +166 -6
- umap/tests/integration/test_collaborative_editing.py +23 -5
- umap/tests/integration/test_dashboard.py +17 -0
- umap/tests/integration/test_edit_datalayer.py +4 -3
- umap/tests/integration/test_export_map.py +1 -1
- umap/tests/integration/test_import.py +9 -4
- umap/tests/integration/test_map.py +64 -0
- umap/tests/integration/test_map_preview.py +75 -0
- umap/tests/integration/test_owned_map.py +11 -25
- umap/tests/integration/test_picto.py +3 -3
- umap/tests/integration/test_querystring.py +52 -0
- umap/tests/integration/test_share.py +22 -0
- umap/tests/test_map_views.py +157 -14
- umap/tests/test_views.py +50 -11
- umap/urls.py +6 -12
- umap/views.py +170 -47
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/METADATA +13 -15
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/RECORD +220 -199
- umap/static/umap/js/umap.browser.js +0 -148
- umap/static/umap/js/umap.xhr.js +0 -304
- umap/static/umap/test/Controls.js +0 -100
- umap/static/umap/test/Map.Init.js +0 -46
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Leaflet.contextmenu, a context menu for Leaflet.
|
|
3
|
+
(c) 2015, Adam Ratcliffe, GeoSmart Maps Limited
|
|
4
|
+
|
|
5
|
+
@preserve
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
(function(factory) {
|
|
9
|
+
// Packaging/modules magic dance
|
|
10
|
+
var L;
|
|
11
|
+
if (typeof define === 'function' && define.amd) {
|
|
12
|
+
// AMD
|
|
13
|
+
define(['leaflet'], factory);
|
|
14
|
+
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
|
15
|
+
// Node/CommonJS
|
|
16
|
+
L = require('leaflet');
|
|
17
|
+
module.exports = factory(L);
|
|
18
|
+
} else {
|
|
19
|
+
// Browser globals
|
|
20
|
+
if (typeof window.L === 'undefined') {
|
|
21
|
+
throw new Error('Leaflet must be loaded first');
|
|
22
|
+
}
|
|
23
|
+
factory(window.L);
|
|
24
|
+
}
|
|
25
|
+
})(function(L) {
|
|
26
|
+
L.Map.mergeOptions({
|
|
27
|
+
contextmenuItems: []
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
L.Map.ContextMenu = L.Handler.extend({
|
|
31
|
+
_touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
|
|
32
|
+
|
|
33
|
+
statics: {
|
|
34
|
+
BASE_CLS: 'leaflet-contextmenu'
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
initialize: function (map) {
|
|
38
|
+
L.Handler.prototype.initialize.call(this, map);
|
|
39
|
+
|
|
40
|
+
this._items = [];
|
|
41
|
+
this._visible = false;
|
|
42
|
+
|
|
43
|
+
var container = this._container = L.DomUtil.create('div', L.Map.ContextMenu.BASE_CLS, map._container);
|
|
44
|
+
container.style.zIndex = 10000;
|
|
45
|
+
container.style.position = 'absolute';
|
|
46
|
+
|
|
47
|
+
if (map.options.contextmenuWidth) {
|
|
48
|
+
container.style.width = map.options.contextmenuWidth + 'px';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this._createItems();
|
|
52
|
+
|
|
53
|
+
L.DomEvent
|
|
54
|
+
.on(container, 'click', L.DomEvent.stop)
|
|
55
|
+
.on(container, 'mousedown', L.DomEvent.stop)
|
|
56
|
+
.on(container, 'dblclick', L.DomEvent.stop)
|
|
57
|
+
.on(container, 'contextmenu', L.DomEvent.stop);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
addHooks: function () {
|
|
61
|
+
var container = this._map.getContainer();
|
|
62
|
+
|
|
63
|
+
L.DomEvent
|
|
64
|
+
.on(container, 'mouseleave', this._hide, this)
|
|
65
|
+
.on(document, 'keydown', this._onKeyDown, this);
|
|
66
|
+
|
|
67
|
+
if (L.Browser.touch) {
|
|
68
|
+
L.DomEvent.on(document, this._touchstart, this._hide, this);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this._map.on({
|
|
72
|
+
contextmenu: this._show,
|
|
73
|
+
mousedown: this._hide,
|
|
74
|
+
movestart: this._hide,
|
|
75
|
+
zoomstart: this._hide
|
|
76
|
+
}, this);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
removeHooks: function () {
|
|
80
|
+
var container = this._map.getContainer();
|
|
81
|
+
|
|
82
|
+
L.DomEvent
|
|
83
|
+
.off(container, 'mouseleave', this._hide, this)
|
|
84
|
+
.off(document, 'keydown', this._onKeyDown, this);
|
|
85
|
+
|
|
86
|
+
if (L.Browser.touch) {
|
|
87
|
+
L.DomEvent.off(document, this._touchstart, this._hide, this);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this._map.off({
|
|
91
|
+
contextmenu: this._show,
|
|
92
|
+
mousedown: this._hide,
|
|
93
|
+
movestart: this._hide,
|
|
94
|
+
zoomstart: this._hide
|
|
95
|
+
}, this);
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
showAt: function (point, data) {
|
|
99
|
+
if (point instanceof L.LatLng) {
|
|
100
|
+
point = this._map.latLngToContainerPoint(point);
|
|
101
|
+
}
|
|
102
|
+
this._showAtPoint(point, data);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
hide: function () {
|
|
106
|
+
this._hide();
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
addItem: function (options) {
|
|
110
|
+
return this.insertItem(options);
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
insertItem: function (options, index) {
|
|
114
|
+
index = index !== undefined ? index: this._items.length;
|
|
115
|
+
|
|
116
|
+
var item = this._createItem(this._container, options, index);
|
|
117
|
+
|
|
118
|
+
this._items.push(item);
|
|
119
|
+
|
|
120
|
+
this._sizeChanged = true;
|
|
121
|
+
|
|
122
|
+
this._map.fire('contextmenu.additem', {
|
|
123
|
+
contextmenu: this,
|
|
124
|
+
el: item.el,
|
|
125
|
+
index: index
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return item.el;
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
removeItem: function (item) {
|
|
132
|
+
var container = this._container;
|
|
133
|
+
|
|
134
|
+
if (!isNaN(item)) {
|
|
135
|
+
item = container.children[item];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (item) {
|
|
139
|
+
this._removeItem(L.Util.stamp(item));
|
|
140
|
+
|
|
141
|
+
this._sizeChanged = true;
|
|
142
|
+
|
|
143
|
+
this._map.fire('contextmenu.removeitem', {
|
|
144
|
+
contextmenu: this,
|
|
145
|
+
el: item
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return item;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return null;
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
removeAllItems: function () {
|
|
155
|
+
var items = this._container.children,
|
|
156
|
+
item;
|
|
157
|
+
|
|
158
|
+
while (items.length) {
|
|
159
|
+
item = items[0];
|
|
160
|
+
this._removeItem(L.Util.stamp(item));
|
|
161
|
+
}
|
|
162
|
+
return items;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
hideAllItems: function () {
|
|
166
|
+
var item, i, l;
|
|
167
|
+
|
|
168
|
+
for (i = 0, l = this._items.length; i < l; i++) {
|
|
169
|
+
item = this._items[i];
|
|
170
|
+
item.el.style.display = 'none';
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
showAllItems: function () {
|
|
175
|
+
var item, i, l;
|
|
176
|
+
|
|
177
|
+
for (i = 0, l = this._items.length; i < l; i++) {
|
|
178
|
+
item = this._items[i];
|
|
179
|
+
item.el.style.display = '';
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
setDisabled: function (item, disabled) {
|
|
184
|
+
var container = this._container,
|
|
185
|
+
itemCls = L.Map.ContextMenu.BASE_CLS + '-item';
|
|
186
|
+
|
|
187
|
+
if (!isNaN(item)) {
|
|
188
|
+
item = container.children[item];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (item && L.DomUtil.hasClass(item, itemCls)) {
|
|
192
|
+
if (disabled) {
|
|
193
|
+
L.DomUtil.addClass(item, itemCls + '-disabled');
|
|
194
|
+
this._map.fire('contextmenu.disableitem', {
|
|
195
|
+
contextmenu: this,
|
|
196
|
+
el: item
|
|
197
|
+
});
|
|
198
|
+
} else {
|
|
199
|
+
L.DomUtil.removeClass(item, itemCls + '-disabled');
|
|
200
|
+
this._map.fire('contextmenu.enableitem', {
|
|
201
|
+
contextmenu: this,
|
|
202
|
+
el: item
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
isVisible: function () {
|
|
209
|
+
return this._visible;
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
_createItems: function () {
|
|
213
|
+
var itemOptions = this._map.options.contextmenuItems,
|
|
214
|
+
item,
|
|
215
|
+
i, l;
|
|
216
|
+
|
|
217
|
+
for (i = 0, l = itemOptions.length; i < l; i++) {
|
|
218
|
+
this._items.push(this._createItem(this._container, itemOptions[i]));
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
_createItem: function (container, options, index) {
|
|
223
|
+
if (options.separator || options === '-') {
|
|
224
|
+
return this._createSeparator(container, index);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
var itemCls = L.Map.ContextMenu.BASE_CLS + '-item',
|
|
228
|
+
cls = options.disabled ? (itemCls + ' ' + itemCls + '-disabled') : itemCls,
|
|
229
|
+
el = this._insertElementAt('a', cls, container, index),
|
|
230
|
+
callback = this._createEventHandler(el, options.callback, options.context, options.hideOnSelect),
|
|
231
|
+
icon = this._getIcon(options),
|
|
232
|
+
iconCls = this._getIconCls(options),
|
|
233
|
+
html = '';
|
|
234
|
+
|
|
235
|
+
if (icon) {
|
|
236
|
+
html = '<img class="' + L.Map.ContextMenu.BASE_CLS + '-icon" src="' + icon + '"/>';
|
|
237
|
+
} else if (iconCls) {
|
|
238
|
+
html = '<span class="' + L.Map.ContextMenu.BASE_CLS + '-icon ' + iconCls + '"></span>';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
el.innerHTML = html + options.text;
|
|
242
|
+
el.href = '#';
|
|
243
|
+
|
|
244
|
+
L.DomEvent
|
|
245
|
+
.on(el, 'mouseover', this._onItemMouseOver, this)
|
|
246
|
+
.on(el, 'mouseout', this._onItemMouseOut, this)
|
|
247
|
+
.on(el, 'mousedown', L.DomEvent.stopPropagation)
|
|
248
|
+
.on(el, 'click', callback);
|
|
249
|
+
|
|
250
|
+
if (L.Browser.touch) {
|
|
251
|
+
L.DomEvent.on(el, this._touchstart, L.DomEvent.stopPropagation);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Devices without a mouse fire "mouseover" on tap, but never “mouseout"
|
|
255
|
+
if (!L.Browser.pointer) {
|
|
256
|
+
L.DomEvent.on(el, 'click', this._onItemMouseOut, this);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
id: L.Util.stamp(el),
|
|
261
|
+
el: el,
|
|
262
|
+
callback: callback
|
|
263
|
+
};
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
_removeItem: function (id) {
|
|
267
|
+
var item,
|
|
268
|
+
el,
|
|
269
|
+
i, l, callback;
|
|
270
|
+
|
|
271
|
+
for (i = 0, l = this._items.length; i < l; i++) {
|
|
272
|
+
item = this._items[i];
|
|
273
|
+
|
|
274
|
+
if (item.id === id) {
|
|
275
|
+
el = item.el;
|
|
276
|
+
callback = item.callback;
|
|
277
|
+
|
|
278
|
+
if (callback) {
|
|
279
|
+
L.DomEvent
|
|
280
|
+
.off(el, 'mouseover', this._onItemMouseOver, this)
|
|
281
|
+
.off(el, 'mouseover', this._onItemMouseOut, this)
|
|
282
|
+
.off(el, 'mousedown', L.DomEvent.stopPropagation)
|
|
283
|
+
.off(el, 'click', callback);
|
|
284
|
+
|
|
285
|
+
if (L.Browser.touch) {
|
|
286
|
+
L.DomEvent.off(el, this._touchstart, L.DomEvent.stopPropagation);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (!L.Browser.pointer) {
|
|
290
|
+
L.DomEvent.on(el, 'click', this._onItemMouseOut, this);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
this._container.removeChild(el);
|
|
295
|
+
this._items.splice(i, 1);
|
|
296
|
+
|
|
297
|
+
return item;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return null;
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
_createSeparator: function (container, index) {
|
|
304
|
+
var el = this._insertElementAt('div', L.Map.ContextMenu.BASE_CLS + '-separator', container, index);
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
id: L.Util.stamp(el),
|
|
308
|
+
el: el
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
_createEventHandler: function (el, func, context, hideOnSelect) {
|
|
313
|
+
var me = this,
|
|
314
|
+
map = this._map,
|
|
315
|
+
disabledCls = L.Map.ContextMenu.BASE_CLS + '-item-disabled',
|
|
316
|
+
hideOnSelect = (hideOnSelect !== undefined) ? hideOnSelect : true;
|
|
317
|
+
|
|
318
|
+
return function (e) {
|
|
319
|
+
if (L.DomUtil.hasClass(el, disabledCls)) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (hideOnSelect) {
|
|
324
|
+
me._hide();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (func) {
|
|
328
|
+
func.call(context || map, me._showLocation);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
me._map.fire('contextmenu.select', {
|
|
332
|
+
contextmenu: me,
|
|
333
|
+
el: el
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
_insertElementAt: function (tagName, className, container, index) {
|
|
339
|
+
var refEl,
|
|
340
|
+
el = document.createElement(tagName);
|
|
341
|
+
|
|
342
|
+
el.className = className;
|
|
343
|
+
|
|
344
|
+
if (index !== undefined) {
|
|
345
|
+
refEl = container.children[index];
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (refEl) {
|
|
349
|
+
container.insertBefore(el, refEl);
|
|
350
|
+
} else {
|
|
351
|
+
container.appendChild(el);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return el;
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
_show: function (e) {
|
|
358
|
+
this._showAtPoint(e.containerPoint, e);
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
_showAtPoint: function (pt, data) {
|
|
362
|
+
if (this._items.length) {
|
|
363
|
+
var map = this._map,
|
|
364
|
+
layerPoint = map.containerPointToLayerPoint(pt),
|
|
365
|
+
latlng = map.layerPointToLatLng(layerPoint),
|
|
366
|
+
event = L.extend(data || {}, {contextmenu: this});
|
|
367
|
+
|
|
368
|
+
this._showLocation = {
|
|
369
|
+
latlng: latlng,
|
|
370
|
+
layerPoint: layerPoint,
|
|
371
|
+
containerPoint: pt
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
if (data && data.relatedTarget){
|
|
375
|
+
this._showLocation.relatedTarget = data.relatedTarget;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
this._setPosition(pt);
|
|
379
|
+
|
|
380
|
+
if (!this._visible) {
|
|
381
|
+
this._container.style.display = 'block';
|
|
382
|
+
this._visible = true;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
this._map.fire('contextmenu.show', event);
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
_hide: function () {
|
|
390
|
+
if (this._visible) {
|
|
391
|
+
this._visible = false;
|
|
392
|
+
this._container.style.display = 'none';
|
|
393
|
+
this._map.fire('contextmenu.hide', {contextmenu: this});
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
_getIcon: function (options) {
|
|
398
|
+
return L.Browser.retina && options.retinaIcon || options.icon;
|
|
399
|
+
},
|
|
400
|
+
|
|
401
|
+
_getIconCls: function (options) {
|
|
402
|
+
return L.Browser.retina && options.retinaIconCls || options.iconCls;
|
|
403
|
+
},
|
|
404
|
+
|
|
405
|
+
_setPosition: function (pt) {
|
|
406
|
+
var mapSize = this._map.getSize(),
|
|
407
|
+
container = this._container,
|
|
408
|
+
containerSize = this._getElementSize(container),
|
|
409
|
+
anchor;
|
|
410
|
+
|
|
411
|
+
if (this._map.options.contextmenuAnchor) {
|
|
412
|
+
anchor = L.point(this._map.options.contextmenuAnchor);
|
|
413
|
+
pt = pt.add(anchor);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
container._leaflet_pos = pt;
|
|
417
|
+
|
|
418
|
+
if (pt.x + containerSize.x > mapSize.x) {
|
|
419
|
+
container.style.left = 'auto';
|
|
420
|
+
container.style.right = Math.min(Math.max(mapSize.x - pt.x, 0), mapSize.x - containerSize.x - 1) + 'px';
|
|
421
|
+
} else {
|
|
422
|
+
container.style.left = Math.max(pt.x, 0) + 'px';
|
|
423
|
+
container.style.right = 'auto';
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (pt.y + containerSize.y > mapSize.y) {
|
|
427
|
+
container.style.top = 'auto';
|
|
428
|
+
container.style.bottom = Math.min(Math.max(mapSize.y - pt.y, 0), mapSize.y - containerSize.y - 1) + 'px';
|
|
429
|
+
} else {
|
|
430
|
+
container.style.top = Math.max(pt.y, 0) + 'px';
|
|
431
|
+
container.style.bottom = 'auto';
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
_getElementSize: function (el) {
|
|
436
|
+
var size = this._size,
|
|
437
|
+
initialDisplay = el.style.display;
|
|
438
|
+
|
|
439
|
+
if (!size || this._sizeChanged) {
|
|
440
|
+
size = {};
|
|
441
|
+
|
|
442
|
+
el.style.left = '-999999px';
|
|
443
|
+
el.style.right = 'auto';
|
|
444
|
+
el.style.display = 'block';
|
|
445
|
+
|
|
446
|
+
size.x = el.offsetWidth;
|
|
447
|
+
size.y = el.offsetHeight;
|
|
448
|
+
|
|
449
|
+
el.style.left = 'auto';
|
|
450
|
+
el.style.display = initialDisplay;
|
|
451
|
+
|
|
452
|
+
this._sizeChanged = false;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
return size;
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
_onKeyDown: function (e) {
|
|
459
|
+
var key = e.keyCode;
|
|
460
|
+
|
|
461
|
+
// If ESC pressed and context menu is visible hide it
|
|
462
|
+
if (key === 27) {
|
|
463
|
+
this._hide();
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
_onItemMouseOver: function (e) {
|
|
468
|
+
L.DomUtil.addClass(e.target || e.srcElement, 'over');
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
_onItemMouseOut: function (e) {
|
|
472
|
+
L.DomUtil.removeClass(e.target || e.srcElement, 'over');
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
L.Map.addInitHook('addHandler', 'contextmenu', L.Map.ContextMenu);
|
|
477
|
+
L.Mixin.ContextMenu = {
|
|
478
|
+
bindContextMenu: function (options) {
|
|
479
|
+
L.setOptions(this, options);
|
|
480
|
+
this._initContextMenu();
|
|
481
|
+
|
|
482
|
+
return this;
|
|
483
|
+
},
|
|
484
|
+
|
|
485
|
+
unbindContextMenu: function (){
|
|
486
|
+
this.off('contextmenu', this._showContextMenu, this);
|
|
487
|
+
|
|
488
|
+
return this;
|
|
489
|
+
},
|
|
490
|
+
|
|
491
|
+
addContextMenuItem: function (item) {
|
|
492
|
+
this.options.contextmenuItems.push(item);
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
removeContextMenuItemWithIndex: function (index) {
|
|
496
|
+
var items = [];
|
|
497
|
+
for (var i = 0; i < this.options.contextmenuItems.length; i++) {
|
|
498
|
+
if (this.options.contextmenuItems[i].index == index){
|
|
499
|
+
items.push(i);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
var elem = items.pop();
|
|
503
|
+
while (elem !== undefined) {
|
|
504
|
+
this.options.contextmenuItems.splice(elem,1);
|
|
505
|
+
elem = items.pop();
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
replaceContextMenuItem: function (item) {
|
|
510
|
+
this.removeContextMenuItemWithIndex(item.index);
|
|
511
|
+
this.addContextMenuItem(item);
|
|
512
|
+
},
|
|
513
|
+
|
|
514
|
+
_initContextMenu: function () {
|
|
515
|
+
this._items = [];
|
|
516
|
+
|
|
517
|
+
this.on('contextmenu', this._showContextMenu, this);
|
|
518
|
+
},
|
|
519
|
+
|
|
520
|
+
_showContextMenu: function (e) {
|
|
521
|
+
var itemOptions,
|
|
522
|
+
data, pt, i, l;
|
|
523
|
+
|
|
524
|
+
if (this._map.contextmenu) {
|
|
525
|
+
data = L.extend({relatedTarget: this}, e);
|
|
526
|
+
|
|
527
|
+
pt = this._map.mouseEventToContainerPoint(e.originalEvent);
|
|
528
|
+
|
|
529
|
+
if (!this.options.contextmenuInheritItems) {
|
|
530
|
+
this._map.contextmenu.hideAllItems();
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
for (i = 0, l = this.options.contextmenuItems.length; i < l; i++) {
|
|
534
|
+
itemOptions = this.options.contextmenuItems[i];
|
|
535
|
+
this._items.push(this._map.contextmenu.insertItem(itemOptions, itemOptions.index));
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
this._map.once('contextmenu.hide', this._hideContextMenu, this);
|
|
539
|
+
|
|
540
|
+
this._map.contextmenu.showAt(pt, data);
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
_hideContextMenu: function () {
|
|
545
|
+
var i, l;
|
|
546
|
+
|
|
547
|
+
for (i = 0, l = this._items.length; i < l; i++) {
|
|
548
|
+
this._map.contextmenu.removeItem(this._items[i]);
|
|
549
|
+
}
|
|
550
|
+
this._items.length = 0;
|
|
551
|
+
|
|
552
|
+
if (!this.options.contextmenuInheritItems) {
|
|
553
|
+
this._map.contextmenu.showAllItems();
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
var classes = [L.Marker, L.Path],
|
|
559
|
+
defaultOptions = {
|
|
560
|
+
contextmenu: false,
|
|
561
|
+
contextmenuItems: [],
|
|
562
|
+
contextmenuInheritItems: true
|
|
563
|
+
},
|
|
564
|
+
cls, i, l;
|
|
565
|
+
|
|
566
|
+
for (i = 0, l = classes.length; i < l; i++) {
|
|
567
|
+
cls = classes[i];
|
|
568
|
+
|
|
569
|
+
// L.Class should probably provide an empty options hash, as it does not test
|
|
570
|
+
// for it here and add if needed
|
|
571
|
+
if (!cls.prototype.options) {
|
|
572
|
+
cls.prototype.options = defaultOptions;
|
|
573
|
+
} else {
|
|
574
|
+
cls.mergeOptions(defaultOptions);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
cls.addInitHook(function () {
|
|
578
|
+
if (this.options.contextmenu) {
|
|
579
|
+
this._initContextMenu();
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
|
|
583
|
+
cls.include(L.Mixin.ContextMenu);
|
|
584
|
+
}
|
|
585
|
+
return L.Map.ContextMenu;
|
|
586
|
+
});
|