ol-contextmenu 5.2.0 → 5.3.0
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.
- package/README.md +2 -1
- package/dist/constants.d.ts +1 -1
- package/dist/helpers/dom.d.ts +16 -3
- package/dist/main.d.ts +10 -7
- package/dist/ol-contextmenu.css +2 -2
- package/dist/ol-contextmenu.iife.js +3 -3
- package/dist/ol-contextmenu.js +240 -797
- package/dist/ol-contextmenu.umd.cjs +3 -3
- package/dist/types.d.ts +1 -1
- package/package.json +31 -29
- package/dist/emitter.d.ts +0 -3
package/dist/ol-contextmenu.js
CHANGED
|
@@ -1,716 +1,134 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
* ol-contextmenu - v5.
|
|
3
|
+
* ol-contextmenu - v5.3.0
|
|
4
4
|
* https://github.com/jonataswalker/ol-contextmenu
|
|
5
|
-
* Built:
|
|
5
|
+
* Built: Fri Sep 22 2023 13:13:39 GMT-0300 (Brasilia Standard Time)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(e) {
|
|
16
|
-
this.propagationStopped, this.defaultPrevented, this.type = e, this.target = null;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
|
|
20
|
-
* will be fired.
|
|
21
|
-
* @api
|
|
22
|
-
*/
|
|
23
|
-
preventDefault() {
|
|
24
|
-
this.defaultPrevented = !0;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Stop event propagation.
|
|
28
|
-
* @api
|
|
29
|
-
*/
|
|
30
|
-
stopPropagation() {
|
|
31
|
-
this.propagationStopped = !0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const O = F, V = {
|
|
35
|
-
/**
|
|
36
|
-
* Triggered when a property is changed.
|
|
37
|
-
* @event module:ol/Object.ObjectEvent#propertychange
|
|
38
|
-
* @api
|
|
39
|
-
*/
|
|
40
|
-
PROPERTYCHANGE: "propertychange"
|
|
41
|
-
};
|
|
42
|
-
class j {
|
|
43
|
-
constructor() {
|
|
44
|
-
this.disposed = !1;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Clean up.
|
|
48
|
-
*/
|
|
49
|
-
dispose() {
|
|
50
|
-
this.disposed || (this.disposed = !0, this.disposeInternal());
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Extension point for disposable objects.
|
|
54
|
-
* @protected
|
|
55
|
-
*/
|
|
56
|
-
disposeInternal() {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
const Y = j;
|
|
60
|
-
function b() {
|
|
61
|
-
}
|
|
62
|
-
function I(s) {
|
|
63
|
-
for (const e in s)
|
|
64
|
-
delete s[e];
|
|
65
|
-
}
|
|
66
|
-
function G(s) {
|
|
67
|
-
let e;
|
|
68
|
-
for (e in s)
|
|
69
|
-
return !1;
|
|
70
|
-
return !e;
|
|
71
|
-
}
|
|
72
|
-
class Z extends Y {
|
|
73
|
-
/**
|
|
74
|
-
* @param {*} [target] Default event target for dispatched events.
|
|
75
|
-
*/
|
|
76
|
-
constructor(e) {
|
|
77
|
-
super(), this.eventTarget_ = e, this.pendingRemovals_ = null, this.dispatching_ = null, this.listeners_ = null;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @param {string} type Type.
|
|
81
|
-
* @param {import("../events.js").Listener} listener Listener.
|
|
82
|
-
*/
|
|
83
|
-
addEventListener(e, t) {
|
|
84
|
-
if (!e || !t)
|
|
85
|
-
return;
|
|
86
|
-
const n = this.listeners_ || (this.listeners_ = {}), i = n[e] || (n[e] = []);
|
|
87
|
-
i.includes(t) || i.push(t);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Dispatches an event and calls all listeners listening for events
|
|
91
|
-
* of this type. The event parameter can either be a string or an
|
|
92
|
-
* Object with a `type` property.
|
|
93
|
-
*
|
|
94
|
-
* @param {import("./Event.js").default|string} event Event object.
|
|
95
|
-
* @return {boolean|undefined} `false` if anyone called preventDefault on the
|
|
96
|
-
* event object or if any of the listeners returned false.
|
|
97
|
-
* @api
|
|
98
|
-
*/
|
|
99
|
-
dispatchEvent(e) {
|
|
100
|
-
const t = typeof e == "string", n = t ? e : e.type, i = this.listeners_ && this.listeners_[n];
|
|
101
|
-
if (!i)
|
|
102
|
-
return;
|
|
103
|
-
const r = t ? new O(e) : (
|
|
104
|
-
/** @type {Event} */
|
|
105
|
-
e
|
|
106
|
-
);
|
|
107
|
-
r.target || (r.target = this.eventTarget_ || this);
|
|
108
|
-
const o = this.dispatching_ || (this.dispatching_ = {}), u = this.pendingRemovals_ || (this.pendingRemovals_ = {});
|
|
109
|
-
n in o || (o[n] = 0, u[n] = 0), ++o[n];
|
|
110
|
-
let d;
|
|
111
|
-
for (let c = 0, E = i.length; c < E; ++c)
|
|
112
|
-
if ("handleEvent" in i[c] ? d = /** @type {import("../events.js").ListenerObject} */
|
|
113
|
-
i[c].handleEvent(r) : d = /** @type {import("../events.js").ListenerFunction} */
|
|
114
|
-
i[c].call(this, r), d === !1 || r.propagationStopped) {
|
|
115
|
-
d = !1;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (--o[n] === 0) {
|
|
119
|
-
let c = u[n];
|
|
120
|
-
for (delete u[n]; c--; )
|
|
121
|
-
this.removeEventListener(n, b);
|
|
122
|
-
delete o[n];
|
|
123
|
-
}
|
|
124
|
-
return d;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Clean up.
|
|
128
|
-
*/
|
|
129
|
-
disposeInternal() {
|
|
130
|
-
this.listeners_ && I(this.listeners_);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get the listeners for a specified event type. Listeners are returned in the
|
|
134
|
-
* order that they will be called in.
|
|
135
|
-
*
|
|
136
|
-
* @param {string} type Type.
|
|
137
|
-
* @return {Array<import("../events.js").Listener>|undefined} Listeners.
|
|
138
|
-
*/
|
|
139
|
-
getListeners(e) {
|
|
140
|
-
return this.listeners_ && this.listeners_[e] || void 0;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* @param {string} [type] Type. If not provided,
|
|
144
|
-
* `true` will be returned if this event target has any listeners.
|
|
145
|
-
* @return {boolean} Has listeners.
|
|
146
|
-
*/
|
|
147
|
-
hasListener(e) {
|
|
148
|
-
return this.listeners_ ? e ? e in this.listeners_ : Object.keys(this.listeners_).length > 0 : !1;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* @param {string} type Type.
|
|
152
|
-
* @param {import("../events.js").Listener} listener Listener.
|
|
153
|
-
*/
|
|
154
|
-
removeEventListener(e, t) {
|
|
155
|
-
const n = this.listeners_ && this.listeners_[e];
|
|
156
|
-
if (n) {
|
|
157
|
-
const i = n.indexOf(t);
|
|
158
|
-
i !== -1 && (this.pendingRemovals_ && e in this.pendingRemovals_ ? (n[i] = b, ++this.pendingRemovals_[e]) : (n.splice(i, 1), n.length === 0 && delete this.listeners_[e]));
|
|
159
|
-
}
|
|
160
|
-
}
|
|
8
|
+
var k = Object.defineProperty;
|
|
9
|
+
var I = (n, t, e) => t in n ? k(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
10
|
+
var a = (n, t, e) => (I(n, typeof t != "symbol" ? t + "" : t, e), e);
|
|
11
|
+
import O from "ol/control/Control";
|
|
12
|
+
import D from "ol/MapBrowserEvent";
|
|
13
|
+
var S = { exports: {} };
|
|
14
|
+
function x() {
|
|
161
15
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
ERROR: "error",
|
|
175
|
-
BLUR: "blur",
|
|
176
|
-
CLEAR: "clear",
|
|
177
|
-
CONTEXTMENU: "contextmenu",
|
|
178
|
-
CLICK: "click",
|
|
179
|
-
DBLCLICK: "dblclick",
|
|
180
|
-
DRAGENTER: "dragenter",
|
|
181
|
-
DRAGOVER: "dragover",
|
|
182
|
-
DROP: "drop",
|
|
183
|
-
FOCUS: "focus",
|
|
184
|
-
KEYDOWN: "keydown",
|
|
185
|
-
KEYPRESS: "keypress",
|
|
186
|
-
LOAD: "load",
|
|
187
|
-
RESIZE: "resize",
|
|
188
|
-
TOUCHMOVE: "touchmove",
|
|
189
|
-
WHEEL: "wheel"
|
|
190
|
-
};
|
|
191
|
-
function v(s, e, t, n, i) {
|
|
192
|
-
if (n && n !== s && (t = t.bind(n)), i) {
|
|
193
|
-
const o = t;
|
|
194
|
-
t = function() {
|
|
195
|
-
s.removeEventListener(e, t), o.apply(this, arguments);
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
const r = {
|
|
199
|
-
target: s,
|
|
200
|
-
type: e,
|
|
201
|
-
listener: t
|
|
202
|
-
};
|
|
203
|
-
return s.addEventListener(e, t), r;
|
|
204
|
-
}
|
|
205
|
-
function T(s, e, t, n) {
|
|
206
|
-
return v(s, e, t, n, !0);
|
|
207
|
-
}
|
|
208
|
-
function x(s) {
|
|
209
|
-
s && s.target && (s.target.removeEventListener(s.type, s.listener), I(s));
|
|
210
|
-
}
|
|
211
|
-
class _ extends X {
|
|
212
|
-
constructor() {
|
|
213
|
-
super(), this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
|
|
214
|
-
this.onInternal, this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
|
|
215
|
-
this.onceInternal, this.un = /** @type {ObservableOnSignature<void>} */
|
|
216
|
-
this.unInternal, this.revision_ = 0;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Increases the revision counter and dispatches a 'change' event.
|
|
220
|
-
* @api
|
|
221
|
-
*/
|
|
222
|
-
changed() {
|
|
223
|
-
++this.revision_, this.dispatchEvent(W.CHANGE);
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Get the version number for this object. Each time the object is modified,
|
|
227
|
-
* its version number will be incremented.
|
|
228
|
-
* @return {number} Revision.
|
|
229
|
-
* @api
|
|
230
|
-
*/
|
|
231
|
-
getRevision() {
|
|
232
|
-
return this.revision_;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* @param {string|Array<string>} type Type.
|
|
236
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
237
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
|
|
238
|
-
* @protected
|
|
239
|
-
*/
|
|
240
|
-
onInternal(e, t) {
|
|
241
|
-
if (Array.isArray(e)) {
|
|
242
|
-
const n = e.length, i = new Array(n);
|
|
243
|
-
for (let r = 0; r < n; ++r)
|
|
244
|
-
i[r] = v(this, e[r], t);
|
|
245
|
-
return i;
|
|
246
|
-
}
|
|
247
|
-
return v(
|
|
248
|
-
this,
|
|
249
|
-
/** @type {string} */
|
|
250
|
-
e,
|
|
251
|
-
t
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* @param {string|Array<string>} type Type.
|
|
256
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
257
|
-
* @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
|
|
258
|
-
* @protected
|
|
259
|
-
*/
|
|
260
|
-
onceInternal(e, t) {
|
|
261
|
-
let n;
|
|
262
|
-
if (Array.isArray(e)) {
|
|
263
|
-
const i = e.length;
|
|
264
|
-
n = new Array(i);
|
|
265
|
-
for (let r = 0; r < i; ++r)
|
|
266
|
-
n[r] = T(this, e[r], t);
|
|
267
|
-
} else
|
|
268
|
-
n = T(
|
|
269
|
-
this,
|
|
270
|
-
/** @type {string} */
|
|
271
|
-
e,
|
|
272
|
-
t
|
|
273
|
-
);
|
|
274
|
-
return t.ol_key = n, n;
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Unlisten for a certain type of event.
|
|
278
|
-
* @param {string|Array<string>} type Type.
|
|
279
|
-
* @param {function((Event|import("./events/Event").default)): ?} listener Listener.
|
|
280
|
-
* @protected
|
|
281
|
-
*/
|
|
282
|
-
unInternal(e, t) {
|
|
283
|
-
const n = (
|
|
284
|
-
/** @type {Object} */
|
|
285
|
-
t.ol_key
|
|
286
|
-
);
|
|
287
|
-
if (n)
|
|
288
|
-
q(n);
|
|
289
|
-
else if (Array.isArray(e))
|
|
290
|
-
for (let i = 0, r = e.length; i < r; ++i)
|
|
291
|
-
this.removeEventListener(e[i], t);
|
|
292
|
-
else
|
|
293
|
-
this.removeEventListener(e, t);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
_.prototype.on;
|
|
297
|
-
_.prototype.once;
|
|
298
|
-
_.prototype.un;
|
|
299
|
-
function q(s) {
|
|
300
|
-
if (Array.isArray(s))
|
|
301
|
-
for (let e = 0, t = s.length; e < t; ++e)
|
|
302
|
-
x(s[e]);
|
|
303
|
-
else
|
|
304
|
-
x(
|
|
305
|
-
/** @type {import("./events.js").EventsKey} */
|
|
306
|
-
s
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
const J = _;
|
|
310
|
-
let Q = 0;
|
|
311
|
-
function ee(s) {
|
|
312
|
-
return s.ol_uid || (s.ol_uid = String(++Q));
|
|
313
|
-
}
|
|
314
|
-
class S extends O {
|
|
315
|
-
/**
|
|
316
|
-
* @param {string} type The event type.
|
|
317
|
-
* @param {string} key The property name.
|
|
318
|
-
* @param {*} oldValue The old value for `key`.
|
|
319
|
-
*/
|
|
320
|
-
constructor(e, t, n) {
|
|
321
|
-
super(e), this.key = t, this.oldValue = n;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
class te extends J {
|
|
325
|
-
/**
|
|
326
|
-
* @param {Object<string, *>} [values] An object with key-value pairs.
|
|
327
|
-
*/
|
|
328
|
-
constructor(e) {
|
|
329
|
-
super(), this.on, this.once, this.un, ee(this), this.values_ = null, e !== void 0 && this.setProperties(e);
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Gets a value.
|
|
333
|
-
* @param {string} key Key name.
|
|
334
|
-
* @return {*} Value.
|
|
335
|
-
* @api
|
|
336
|
-
*/
|
|
337
|
-
get(e) {
|
|
338
|
-
let t;
|
|
339
|
-
return this.values_ && this.values_.hasOwnProperty(e) && (t = this.values_[e]), t;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Get a list of object property names.
|
|
343
|
-
* @return {Array<string>} List of property names.
|
|
344
|
-
* @api
|
|
345
|
-
*/
|
|
346
|
-
getKeys() {
|
|
347
|
-
return this.values_ && Object.keys(this.values_) || [];
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Get an object of all property names and values.
|
|
351
|
-
* @return {Object<string, *>} Object.
|
|
352
|
-
* @api
|
|
353
|
-
*/
|
|
354
|
-
getProperties() {
|
|
355
|
-
return this.values_ && Object.assign({}, this.values_) || {};
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* @return {boolean} The object has properties.
|
|
359
|
-
*/
|
|
360
|
-
hasProperties() {
|
|
361
|
-
return !!this.values_;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* @param {string} key Key name.
|
|
365
|
-
* @param {*} oldValue Old value.
|
|
366
|
-
*/
|
|
367
|
-
notify(e, t) {
|
|
368
|
-
let n;
|
|
369
|
-
n = `change:${e}`, this.hasListener(n) && this.dispatchEvent(new S(n, e, t)), n = V.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new S(n, e, t));
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* @param {string} key Key name.
|
|
373
|
-
* @param {import("./events.js").Listener} listener Listener.
|
|
374
|
-
*/
|
|
375
|
-
addChangeListener(e, t) {
|
|
376
|
-
this.addEventListener(`change:${e}`, t);
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @param {string} key Key name.
|
|
380
|
-
* @param {import("./events.js").Listener} listener Listener.
|
|
381
|
-
*/
|
|
382
|
-
removeChangeListener(e, t) {
|
|
383
|
-
this.removeEventListener(`change:${e}`, t);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Sets a value.
|
|
387
|
-
* @param {string} key Key name.
|
|
388
|
-
* @param {*} value Value.
|
|
389
|
-
* @param {boolean} [silent] Update without triggering an event.
|
|
390
|
-
* @api
|
|
391
|
-
*/
|
|
392
|
-
set(e, t, n) {
|
|
393
|
-
const i = this.values_ || (this.values_ = {});
|
|
394
|
-
if (n)
|
|
395
|
-
i[e] = t;
|
|
396
|
-
else {
|
|
397
|
-
const r = i[e];
|
|
398
|
-
i[e] = t, r !== t && this.notify(e, r);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Sets a collection of key-value pairs. Note that this changes any existing
|
|
403
|
-
* properties and adds new ones (it does not remove any existing properties).
|
|
404
|
-
* @param {Object<string, *>} values Values.
|
|
405
|
-
* @param {boolean} [silent] Update without triggering an event.
|
|
406
|
-
* @api
|
|
407
|
-
*/
|
|
408
|
-
setProperties(e, t) {
|
|
409
|
-
for (const n in e)
|
|
410
|
-
this.set(n, e[n], t);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Apply any properties from another object without triggering events.
|
|
414
|
-
* @param {BaseObject} source The source object.
|
|
415
|
-
* @protected
|
|
416
|
-
*/
|
|
417
|
-
applyProperties(e) {
|
|
418
|
-
e.values_ && Object.assign(this.values_ || (this.values_ = {}), e.values_);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Unsets a property.
|
|
422
|
-
* @param {string} key Key name.
|
|
423
|
-
* @param {boolean} [silent] Unset without triggering an event.
|
|
424
|
-
* @api
|
|
425
|
-
*/
|
|
426
|
-
unset(e, t) {
|
|
427
|
-
if (this.values_ && e in this.values_) {
|
|
428
|
-
const n = this.values_[e];
|
|
429
|
-
delete this.values_[e], G(this.values_) && (this.values_ = null), t || this.notify(e, n);
|
|
16
|
+
x.prototype = {
|
|
17
|
+
on: function(n, t, e) {
|
|
18
|
+
var s = this.e || (this.e = {});
|
|
19
|
+
return (s[n] || (s[n] = [])).push({
|
|
20
|
+
fn: t,
|
|
21
|
+
ctx: e
|
|
22
|
+
}), this;
|
|
23
|
+
},
|
|
24
|
+
once: function(n, t, e) {
|
|
25
|
+
var s = this;
|
|
26
|
+
function o() {
|
|
27
|
+
s.off(n, o), t.apply(e, arguments);
|
|
430
28
|
}
|
|
29
|
+
return o._ = t, this.on(n, o, e);
|
|
30
|
+
},
|
|
31
|
+
emit: function(n) {
|
|
32
|
+
var t = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[n] || []).slice(), s = 0, o = e.length;
|
|
33
|
+
for (s; s < o; s++)
|
|
34
|
+
e[s].fn.apply(e[s].ctx, t);
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
off: function(n, t) {
|
|
38
|
+
var e = this.e || (this.e = {}), s = e[n], o = [];
|
|
39
|
+
if (s && t)
|
|
40
|
+
for (var i = 0, l = s.length; i < l; i++)
|
|
41
|
+
s[i].fn !== t && s[i].fn._ !== t && o.push(s[i]);
|
|
42
|
+
return o.length ? e[n] = o : delete e[n], this;
|
|
431
43
|
}
|
|
432
|
-
}
|
|
433
|
-
const ne = te, se = {
|
|
434
|
-
/**
|
|
435
|
-
* Triggered after a map frame is rendered.
|
|
436
|
-
* @event module:ol/MapEvent~MapEvent#postrender
|
|
437
|
-
* @api
|
|
438
|
-
*/
|
|
439
|
-
POSTRENDER: "postrender",
|
|
440
|
-
/**
|
|
441
|
-
* Triggered when the map starts moving.
|
|
442
|
-
* @event module:ol/MapEvent~MapEvent#movestart
|
|
443
|
-
* @api
|
|
444
|
-
*/
|
|
445
|
-
MOVESTART: "movestart",
|
|
446
|
-
/**
|
|
447
|
-
* Triggered after the map is moved.
|
|
448
|
-
* @event module:ol/MapEvent~MapEvent#moveend
|
|
449
|
-
* @api
|
|
450
|
-
*/
|
|
451
|
-
MOVEEND: "moveend",
|
|
452
|
-
/**
|
|
453
|
-
* Triggered when loading of additional map data (tiles, images, features) starts.
|
|
454
|
-
* @event module:ol/MapEvent~MapEvent#loadstart
|
|
455
|
-
* @api
|
|
456
|
-
*/
|
|
457
|
-
LOADSTART: "loadstart",
|
|
458
|
-
/**
|
|
459
|
-
* Triggered when loading of additional map data has completed.
|
|
460
|
-
* @event module:ol/MapEvent~MapEvent#loadend
|
|
461
|
-
* @api
|
|
462
|
-
*/
|
|
463
|
-
LOADEND: "loadend"
|
|
464
44
|
};
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
* @param {Options} options Control options.
|
|
471
|
-
*/
|
|
472
|
-
constructor(e) {
|
|
473
|
-
super();
|
|
474
|
-
const t = e.element;
|
|
475
|
-
t && !e.target && !t.style.pointerEvents && (t.style.pointerEvents = "auto"), this.element = t || null, this.target_ = null, this.map_ = null, this.listenerKeys = [], e.render && (this.render = e.render), e.target && this.setTarget(e.target);
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Clean up.
|
|
479
|
-
*/
|
|
480
|
-
disposeInternal() {
|
|
481
|
-
D(this.element), super.disposeInternal();
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Get the map associated with this control.
|
|
485
|
-
* @return {import("../Map.js").default|null} Map.
|
|
486
|
-
* @api
|
|
487
|
-
*/
|
|
488
|
-
getMap() {
|
|
489
|
-
return this.map_;
|
|
490
|
-
}
|
|
491
|
-
/**
|
|
492
|
-
* Remove the control from its current map and attach it to the new map.
|
|
493
|
-
* Pass `null` to just remove the control from the current map.
|
|
494
|
-
* Subclasses may set up event handlers to get notified about changes to
|
|
495
|
-
* the map here.
|
|
496
|
-
* @param {import("../Map.js").default|null} map Map.
|
|
497
|
-
* @api
|
|
498
|
-
*/
|
|
499
|
-
setMap(e) {
|
|
500
|
-
this.map_ && D(this.element);
|
|
501
|
-
for (let t = 0, n = this.listenerKeys.length; t < n; ++t)
|
|
502
|
-
x(this.listenerKeys[t]);
|
|
503
|
-
this.listenerKeys.length = 0, this.map_ = e, e && ((this.target_ ? this.target_ : e.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== b && this.listenerKeys.push(
|
|
504
|
-
v(e, se.POSTRENDER, this.render, this)
|
|
505
|
-
), e.render());
|
|
506
|
-
}
|
|
507
|
-
/**
|
|
508
|
-
* Renders the control.
|
|
509
|
-
* @param {import("../MapEvent.js").default} mapEvent Map event.
|
|
510
|
-
* @api
|
|
511
|
-
*/
|
|
512
|
-
render(e) {
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* This function is used to set a target element for the control. It has no
|
|
516
|
-
* effect if it is called after the control has been added to the map (i.e.
|
|
517
|
-
* after `setMap` is called on the control). If no `target` is set in the
|
|
518
|
-
* options passed to the control constructor and if `setTarget` is not called
|
|
519
|
-
* then the control is added to the map's overlay container.
|
|
520
|
-
* @param {HTMLElement|string} target Target.
|
|
521
|
-
* @api
|
|
522
|
-
*/
|
|
523
|
-
setTarget(e) {
|
|
524
|
-
this.target_ = typeof e == "string" ? document.getElementById(e) : e;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
const re = ie;
|
|
528
|
-
class oe extends O {
|
|
529
|
-
/**
|
|
530
|
-
* @param {string} type Event type.
|
|
531
|
-
* @param {import("./Map.js").default} map Map.
|
|
532
|
-
* @param {?import("./Map.js").FrameState} [frameState] Frame state.
|
|
533
|
-
*/
|
|
534
|
-
constructor(e, t, n) {
|
|
535
|
-
super(e), this.map = t, this.frameState = n !== void 0 ? n : null;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
const ae = oe;
|
|
539
|
-
class le extends ae {
|
|
540
|
-
/**
|
|
541
|
-
* @param {string} type Event type.
|
|
542
|
-
* @param {import("./Map.js").default} map Map.
|
|
543
|
-
* @param {EVENT} originalEvent Original event.
|
|
544
|
-
* @param {boolean} [dragging] Is the map currently being dragged?
|
|
545
|
-
* @param {import("./Map.js").FrameState} [frameState] Frame state.
|
|
546
|
-
* @param {Array<PointerEvent>} [activePointers] Active pointers.
|
|
547
|
-
*/
|
|
548
|
-
constructor(e, t, n, i, r, o) {
|
|
549
|
-
super(e, t, r), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = i !== void 0 ? i : !1, this.activePointers = o;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* The map pixel relative to the viewport corresponding to the original event.
|
|
553
|
-
* @type {import("./pixel.js").Pixel}
|
|
554
|
-
* @api
|
|
555
|
-
*/
|
|
556
|
-
get pixel() {
|
|
557
|
-
return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_;
|
|
558
|
-
}
|
|
559
|
-
set pixel(e) {
|
|
560
|
-
this.pixel_ = e;
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* The coordinate corresponding to the original browser event. This will be in the user
|
|
564
|
-
* projection if one is set. Otherwise it will be in the view projection.
|
|
565
|
-
* @type {import("./coordinate.js").Coordinate}
|
|
566
|
-
* @api
|
|
567
|
-
*/
|
|
568
|
-
get coordinate() {
|
|
569
|
-
return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_;
|
|
570
|
-
}
|
|
571
|
-
set coordinate(e) {
|
|
572
|
-
this.coordinate_ = e;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Prevents the default browser action.
|
|
576
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
|
|
577
|
-
* @api
|
|
578
|
-
*/
|
|
579
|
-
preventDefault() {
|
|
580
|
-
super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault();
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Prevents further propagation of the current event.
|
|
584
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation.
|
|
585
|
-
* @api
|
|
586
|
-
*/
|
|
587
|
-
stopPropagation() {
|
|
588
|
-
super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation();
|
|
45
|
+
S.exports = x;
|
|
46
|
+
var _ = S.exports.TinyEmitter = x, L = /* @__PURE__ */ ((n) => (n.CONTEXTMENU = "contextmenu", n.CLICK = "click", n.DBLCLICK = "dblclick", n))(L || {}), p = /* @__PURE__ */ ((n) => (n.BEFOREOPEN = "beforeopen", n.OPEN = "open", n.CLOSE = "close", n.ADD_MENU_ENTRY = "add-menu-entry", n))(p || {});
|
|
47
|
+
class w extends D {
|
|
48
|
+
constructor(t) {
|
|
49
|
+
super(t.type, t.map, t.originalEvent);
|
|
589
50
|
}
|
|
590
51
|
}
|
|
591
|
-
const
|
|
592
|
-
var w = /* @__PURE__ */ ((s) => (s.CONTEXTMENU = "contextmenu", s.CLICK = "click", s.DBLCLICK = "dblclick", s))(w || {}), m = /* @__PURE__ */ ((s) => (s.BEFOREOPEN = "beforeopen", s.OPEN = "open", s.CLOSE = "close", s.ADD_MENU_ENTRY = "add-menu-entry", s))(m || {});
|
|
593
|
-
class R extends he {
|
|
594
|
-
constructor(e) {
|
|
595
|
-
super(e.type, e.map, e.originalEvent);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
const ce = {
|
|
52
|
+
const z = {
|
|
599
53
|
width: 150,
|
|
600
54
|
scrollAt: 4,
|
|
601
|
-
eventType:
|
|
55
|
+
eventType: L.CONTEXTMENU,
|
|
602
56
|
defaultItems: !0,
|
|
603
57
|
items: []
|
|
604
|
-
},
|
|
605
|
-
namespace:
|
|
606
|
-
container: `${
|
|
607
|
-
separator: `${
|
|
608
|
-
submenu: `${
|
|
609
|
-
hidden: `${
|
|
610
|
-
icon: `${
|
|
611
|
-
zoomIn: `${
|
|
612
|
-
zoomOut: `${
|
|
58
|
+
}, d = "ol-ctx-menu", r = {
|
|
59
|
+
namespace: d,
|
|
60
|
+
container: `${d}-container`,
|
|
61
|
+
separator: `${d}-separator`,
|
|
62
|
+
submenu: `${d}-submenu`,
|
|
63
|
+
hidden: `${d}-hidden`,
|
|
64
|
+
icon: `${d}-icon`,
|
|
65
|
+
zoomIn: `${d}-zoom-in`,
|
|
66
|
+
zoomOut: `${d}-zoom-out`,
|
|
613
67
|
unselectable: "ol-unselectable"
|
|
614
|
-
},
|
|
68
|
+
}, C = [
|
|
615
69
|
{
|
|
616
70
|
text: "Zoom In",
|
|
617
|
-
classname: `${
|
|
618
|
-
callback: (
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
zoom: Number(
|
|
71
|
+
classname: `${r.zoomIn} ${r.icon}`,
|
|
72
|
+
callback: (n, t) => {
|
|
73
|
+
const e = t.getView();
|
|
74
|
+
e.animate({
|
|
75
|
+
zoom: Number(e.getZoom()) + 1,
|
|
622
76
|
duration: 700,
|
|
623
|
-
center:
|
|
77
|
+
center: n.coordinate
|
|
624
78
|
});
|
|
625
79
|
}
|
|
626
80
|
},
|
|
627
81
|
{
|
|
628
82
|
text: "Zoom Out",
|
|
629
|
-
classname: `${
|
|
630
|
-
callback: (
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
zoom: Number(
|
|
83
|
+
classname: `${r.zoomOut} ${r.icon}`,
|
|
84
|
+
callback: (n, t) => {
|
|
85
|
+
const e = t.getView();
|
|
86
|
+
e.animate({
|
|
87
|
+
zoom: Number(e.getZoom()) - 1,
|
|
634
88
|
duration: 700,
|
|
635
|
-
center:
|
|
89
|
+
center: n.coordinate
|
|
636
90
|
});
|
|
637
91
|
}
|
|
638
92
|
}
|
|
639
93
|
];
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
M = s;
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
function A() {
|
|
94
|
+
function y(n) {
|
|
95
|
+
const t = document.createDocumentFragment(), e = document.createElement("div");
|
|
96
|
+
for (e.innerHTML = n; e.firstChild; )
|
|
97
|
+
t.append(e.firstChild);
|
|
98
|
+
return t;
|
|
649
99
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
},
|
|
658
|
-
once: function(s, e, t) {
|
|
659
|
-
var n = this;
|
|
660
|
-
function i() {
|
|
661
|
-
n.off(s, i), e.apply(t, arguments);
|
|
662
|
-
}
|
|
663
|
-
return i._ = e, this.on(s, i, t);
|
|
664
|
-
},
|
|
665
|
-
emit: function(s) {
|
|
666
|
-
var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[s] || []).slice(), n = 0, i = t.length;
|
|
667
|
-
for (n; n < i; n++)
|
|
668
|
-
t[n].fn.apply(t[n].ctx, e);
|
|
669
|
-
return this;
|
|
670
|
-
},
|
|
671
|
-
off: function(s, e) {
|
|
672
|
-
var t = this.e || (this.e = {}), n = t[s], i = [];
|
|
673
|
-
if (n && e)
|
|
674
|
-
for (var r = 0, o = n.length; r < o; r++)
|
|
675
|
-
n[r].fn !== e && n[r].fn._ !== e && i.push(n[r]);
|
|
676
|
-
return i.length ? t[s] = i : delete t[s], this;
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
ue.exports = A;
|
|
680
|
-
var de = M.TinyEmitter = A;
|
|
681
|
-
const g = new de();
|
|
682
|
-
function y(s) {
|
|
683
|
-
const e = document.createDocumentFragment(), t = document.createElement("div");
|
|
684
|
-
for (t.innerHTML = s; t.firstChild; )
|
|
685
|
-
e.append(t.firstChild);
|
|
686
|
-
return e;
|
|
100
|
+
function P(n) {
|
|
101
|
+
const t = document.importNode(n), e = n.offsetWidth;
|
|
102
|
+
t.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;
|
|
103
|
+
const s = y("<span>Foo</span>"), o = y("<span>Foo</span>"), i = document.createElement("li"), l = document.createElement("li");
|
|
104
|
+
i.append(s), l.append(o), t.append(i), t.append(l), n.parentNode?.append(t);
|
|
105
|
+
const c = t.offsetHeight / 2;
|
|
106
|
+
return n.parentNode?.removeChild(t), c;
|
|
687
107
|
}
|
|
688
|
-
function
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
}
|
|
696
|
-
function $(s, e, t = !1, n = !1) {
|
|
108
|
+
function N({
|
|
109
|
+
parentNode: n,
|
|
110
|
+
item: t,
|
|
111
|
+
isSubmenu: e = !1,
|
|
112
|
+
isInsideSubmenu: s = !1,
|
|
113
|
+
emitter: o
|
|
114
|
+
}) {
|
|
697
115
|
const i = `_${Math.random().toString(36).slice(2, 11)}`;
|
|
698
|
-
if (typeof
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
const
|
|
116
|
+
if (typeof t != "string" && "text" in t) {
|
|
117
|
+
const E = `<span>${t.text}</span>`, m = y(E), u = document.createElement("li");
|
|
118
|
+
t.classname = t.classname || "", t.icon && (t.classname === "" ? t.classname = r.icon : t.classname.includes(r.icon) === !1 && (t.classname += ` ${r.icon}`), u.setAttribute("style", `background-image:url(${t.icon})`)), u.id = i, u.className = t.classname, u.append(m), n.append(u);
|
|
119
|
+
const v = {
|
|
702
120
|
id: i,
|
|
703
|
-
isSubmenu:
|
|
704
|
-
isInsideSubmenu:
|
|
121
|
+
isSubmenu: e,
|
|
122
|
+
isInsideSubmenu: s,
|
|
705
123
|
isSeparator: !1,
|
|
706
|
-
callback: "callback" in
|
|
707
|
-
data: "data" in
|
|
124
|
+
callback: "callback" in t ? t.callback : null,
|
|
125
|
+
data: "data" in t ? t.data : null
|
|
708
126
|
};
|
|
709
|
-
return
|
|
127
|
+
return o.emit(p.ADD_MENU_ENTRY, v, u), u;
|
|
710
128
|
}
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
const
|
|
129
|
+
const l = `<li id="${i}" class="${r.separator}"><hr></li>`, c = y(l);
|
|
130
|
+
n.append(c);
|
|
131
|
+
const f = n.lastChild, g = {
|
|
714
132
|
id: i,
|
|
715
133
|
isSubmenu: !1,
|
|
716
134
|
isInsideSubmenu: !1,
|
|
@@ -718,51 +136,70 @@ function $(s, e, t = !1, n = !1) {
|
|
|
718
136
|
callback: null,
|
|
719
137
|
data: null
|
|
720
138
|
};
|
|
721
|
-
return
|
|
139
|
+
return o.emit(p.ADD_MENU_ENTRY, g, f), f;
|
|
722
140
|
}
|
|
723
|
-
function
|
|
724
|
-
|
|
141
|
+
function M({
|
|
142
|
+
container: n,
|
|
143
|
+
items: t,
|
|
144
|
+
menuWidth: e,
|
|
145
|
+
isInsideSubmenu: s,
|
|
146
|
+
emitter: o
|
|
147
|
+
}) {
|
|
148
|
+
t.forEach((i) => {
|
|
725
149
|
if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
const
|
|
729
|
-
|
|
150
|
+
const l = N({ parentNode: n, item: i, isSubmenu: !0, emitter: o });
|
|
151
|
+
l.classList.add(r.submenu);
|
|
152
|
+
const c = document.createElement("ul");
|
|
153
|
+
c.classList.add(r.container), c.style.width = `${e}px`, l.append(c), M({
|
|
154
|
+
emitter: o,
|
|
155
|
+
menuWidth: e,
|
|
156
|
+
container: c,
|
|
157
|
+
items: i.items,
|
|
158
|
+
isInsideSubmenu: !0
|
|
159
|
+
});
|
|
730
160
|
} else
|
|
731
|
-
|
|
161
|
+
N({
|
|
162
|
+
parentNode: n,
|
|
163
|
+
item: i,
|
|
164
|
+
isSubmenu: !1,
|
|
165
|
+
isInsideSubmenu: s,
|
|
166
|
+
emitter: o
|
|
167
|
+
});
|
|
732
168
|
});
|
|
733
169
|
}
|
|
734
|
-
function
|
|
735
|
-
if (!
|
|
736
|
-
throw new Error(
|
|
170
|
+
function b(n, t) {
|
|
171
|
+
if (!n)
|
|
172
|
+
throw new Error(t);
|
|
737
173
|
}
|
|
738
|
-
class
|
|
739
|
-
constructor(
|
|
740
|
-
|
|
741
|
-
const
|
|
742
|
-
super({ element:
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
this
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
174
|
+
class R extends O {
|
|
175
|
+
constructor(e = {}) {
|
|
176
|
+
b(typeof e == "object", "@param `opts` should be object type!");
|
|
177
|
+
const s = document.createElement("div");
|
|
178
|
+
super({ element: s });
|
|
179
|
+
a(this, "map");
|
|
180
|
+
a(this, "emitter", new _());
|
|
181
|
+
a(this, "container");
|
|
182
|
+
a(this, "coordinate", []);
|
|
183
|
+
a(this, "pixel", []);
|
|
184
|
+
a(this, "contextMenuEventListener");
|
|
185
|
+
a(this, "entryCallbackEventListener");
|
|
186
|
+
a(this, "mapMoveListener");
|
|
187
|
+
a(this, "lineHeight", 0);
|
|
188
|
+
a(this, "disabled");
|
|
189
|
+
a(this, "opened");
|
|
190
|
+
a(this, "items", []);
|
|
191
|
+
a(this, "menuEntries", /* @__PURE__ */ new Map());
|
|
192
|
+
a(this, "options");
|
|
193
|
+
this.options = { ...z, ...e };
|
|
194
|
+
const o = document.createElement("ul");
|
|
195
|
+
s.append(o), s.style.width = `${this.options.width}px`, s.classList.add(
|
|
196
|
+
r.container,
|
|
197
|
+
r.unselectable,
|
|
198
|
+
r.hidden
|
|
199
|
+
), this.container = s, this.contextMenuEventListener = (i) => {
|
|
200
|
+
this.handleContextMenu(i);
|
|
201
|
+
}, this.entryCallbackEventListener = (i) => {
|
|
202
|
+
this.handleEntryCallback(i);
|
|
766
203
|
}, this.mapMoveListener = () => {
|
|
767
204
|
this.handleMapMove();
|
|
768
205
|
}, this.disabled = !1, this.opened = !1, window.addEventListener(
|
|
@@ -774,8 +211,8 @@ class me extends re {
|
|
|
774
211
|
);
|
|
775
212
|
}
|
|
776
213
|
clear() {
|
|
777
|
-
for (const
|
|
778
|
-
this.removeMenuEntry(
|
|
214
|
+
for (const e of this.menuEntries.keys())
|
|
215
|
+
this.removeMenuEntry(e);
|
|
779
216
|
this.container.replaceChildren(), this.container.append(document.createElement("ul"));
|
|
780
217
|
}
|
|
781
218
|
enable() {
|
|
@@ -785,141 +222,147 @@ class me extends re {
|
|
|
785
222
|
this.disabled = !0;
|
|
786
223
|
}
|
|
787
224
|
getDefaultItems() {
|
|
788
|
-
return
|
|
225
|
+
return C;
|
|
789
226
|
}
|
|
790
227
|
countItems() {
|
|
791
228
|
return this.menuEntries.size;
|
|
792
229
|
}
|
|
793
|
-
extend(
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
this.options.width
|
|
798
|
-
|
|
230
|
+
extend(e) {
|
|
231
|
+
b(Array.isArray(e), "@param `items` should be an Array."), M({
|
|
232
|
+
items: e,
|
|
233
|
+
emitter: this.emitter,
|
|
234
|
+
menuWidth: this.options.width,
|
|
235
|
+
container: this.container.firstElementChild
|
|
236
|
+
});
|
|
799
237
|
}
|
|
800
238
|
closeMenu() {
|
|
801
|
-
this.opened = !1, this.container.classList.add(
|
|
239
|
+
this.opened = !1, this.container.classList.add(r.hidden), this.dispatchEvent(p.CLOSE);
|
|
802
240
|
}
|
|
803
241
|
isOpen() {
|
|
804
242
|
return this.opened;
|
|
805
243
|
}
|
|
806
|
-
updatePosition(
|
|
807
|
-
|
|
244
|
+
updatePosition(e) {
|
|
245
|
+
b(Array.isArray(e), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = e, this.positionContainer());
|
|
808
246
|
}
|
|
809
247
|
pop() {
|
|
810
|
-
const
|
|
811
|
-
|
|
248
|
+
const e = Array.from(this.menuEntries.keys()).pop();
|
|
249
|
+
e && this.removeMenuEntry(e);
|
|
812
250
|
}
|
|
813
251
|
shift() {
|
|
814
|
-
const
|
|
815
|
-
|
|
252
|
+
const e = Array.from(this.menuEntries.keys()).shift();
|
|
253
|
+
e && this.removeMenuEntry(e);
|
|
816
254
|
}
|
|
817
|
-
push(
|
|
818
|
-
|
|
255
|
+
push(e) {
|
|
256
|
+
e && this.extend([e]);
|
|
819
257
|
}
|
|
820
|
-
setMap(
|
|
821
|
-
if (super.setMap(
|
|
822
|
-
this.map =
|
|
258
|
+
setMap(e) {
|
|
259
|
+
if (super.setMap(e), e) {
|
|
260
|
+
this.map = e, e.getViewport().addEventListener(
|
|
261
|
+
this.options.eventType,
|
|
262
|
+
this.contextMenuEventListener,
|
|
263
|
+
!1
|
|
264
|
+
), e.on("movestart", () => {
|
|
823
265
|
this.handleMapMove();
|
|
824
|
-
}),
|
|
825
|
-
|
|
826
|
-
(
|
|
827
|
-
this.handleAddMenuEntry(
|
|
266
|
+
}), this.emitter.on(
|
|
267
|
+
p.ADD_MENU_ENTRY,
|
|
268
|
+
(o, i) => {
|
|
269
|
+
this.handleAddMenuEntry(o, i);
|
|
828
270
|
},
|
|
829
271
|
this
|
|
830
|
-
), this.items = this.options.defaultItems ? this.options.items.concat(
|
|
831
|
-
this.
|
|
832
|
-
this.
|
|
833
|
-
this.options.width
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
272
|
+
), this.items = this.options.defaultItems ? this.options.items.concat(C) : this.options.items, M({
|
|
273
|
+
items: this.items,
|
|
274
|
+
emitter: this.emitter,
|
|
275
|
+
menuWidth: this.options.width,
|
|
276
|
+
container: this.container.firstElementChild
|
|
277
|
+
});
|
|
278
|
+
const s = this.getMenuEntriesLength();
|
|
279
|
+
this.lineHeight = s > 0 ? this.container.offsetHeight / s : P(this.container);
|
|
837
280
|
} else
|
|
838
281
|
this.removeListeners(), this.clear();
|
|
839
282
|
}
|
|
840
283
|
removeListeners() {
|
|
841
|
-
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1),
|
|
284
|
+
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.emitter.off(p.ADD_MENU_ENTRY);
|
|
842
285
|
}
|
|
843
|
-
removeMenuEntry(
|
|
844
|
-
|
|
845
|
-
|
|
286
|
+
removeMenuEntry(e) {
|
|
287
|
+
let s = document.getElementById(e);
|
|
288
|
+
s?.remove(), s = null, this.menuEntries.delete(e);
|
|
846
289
|
}
|
|
847
|
-
handleContextMenu(
|
|
848
|
-
this.coordinate = this.map.getEventCoordinate(
|
|
849
|
-
new
|
|
850
|
-
type: m.BEFOREOPEN,
|
|
290
|
+
handleContextMenu(e) {
|
|
291
|
+
this.coordinate = this.map.getEventCoordinate(e), this.pixel = this.map.getEventPixel(e), this.dispatchEvent(
|
|
292
|
+
new w({
|
|
851
293
|
map: this.map,
|
|
852
|
-
originalEvent:
|
|
294
|
+
originalEvent: e,
|
|
295
|
+
type: p.BEFOREOPEN
|
|
853
296
|
})
|
|
854
|
-
), !this.disabled && (this.options.eventType ===
|
|
855
|
-
this.openMenu(
|
|
856
|
-
}),
|
|
297
|
+
), !this.disabled && (this.options.eventType === L.CONTEXTMENU && (e.stopPropagation(), e.preventDefault()), setTimeout(() => {
|
|
298
|
+
this.openMenu(e);
|
|
299
|
+
}), e.target?.addEventListener(
|
|
857
300
|
"pointerdown",
|
|
858
|
-
(
|
|
859
|
-
this.opened && (
|
|
301
|
+
(s) => {
|
|
302
|
+
this.opened && (s.stopPropagation(), this.closeMenu());
|
|
860
303
|
},
|
|
861
304
|
{ once: !0 }
|
|
862
305
|
));
|
|
863
306
|
}
|
|
864
|
-
openMenu(
|
|
865
|
-
this.opened = !0, this.positionContainer(), this.container.classList.remove(
|
|
866
|
-
new
|
|
867
|
-
type: m.OPEN,
|
|
307
|
+
openMenu(e) {
|
|
308
|
+
this.opened = !0, this.positionContainer(), this.container.classList.remove(r.hidden), this.dispatchEvent(
|
|
309
|
+
new w({
|
|
868
310
|
map: this.map,
|
|
869
|
-
originalEvent:
|
|
311
|
+
originalEvent: e,
|
|
312
|
+
type: p.OPEN
|
|
870
313
|
})
|
|
871
314
|
);
|
|
872
315
|
}
|
|
873
316
|
getMenuEntriesLength() {
|
|
874
317
|
return Array.from(this.menuEntries).filter(
|
|
875
|
-
([,
|
|
318
|
+
([, e]) => e.isSeparator === !1 && e.isSubmenu === !1 && e.isInsideSubmenu === !1
|
|
876
319
|
).length;
|
|
877
320
|
}
|
|
878
321
|
positionContainer() {
|
|
879
|
-
const
|
|
880
|
-
w:
|
|
881
|
-
h:
|
|
882
|
-
},
|
|
322
|
+
const e = this.map.getSize() || [0, 0], s = {
|
|
323
|
+
w: e[0] - this.pixel[0],
|
|
324
|
+
h: e[1] - this.pixel[1]
|
|
325
|
+
}, o = this.getMenuEntriesLength(), i = {
|
|
883
326
|
w: this.container.offsetWidth,
|
|
884
327
|
// a cheap way to recalculate container height
|
|
885
328
|
// since offsetHeight is like cached
|
|
886
|
-
h: Math.round(this.lineHeight *
|
|
887
|
-
},
|
|
888
|
-
this.container.style.left = `${
|
|
889
|
-
const
|
|
890
|
-
(
|
|
329
|
+
h: Math.round(this.lineHeight * o)
|
|
330
|
+
}, l = s.w >= i.w ? this.pixel[0] + 5 : this.pixel[0] - i.w;
|
|
331
|
+
this.container.style.left = `${l}px`, this.container.style.top = s.h >= i.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - i.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", s.w -= i.w;
|
|
332
|
+
const c = (E) => Array.from(E.children).filter(
|
|
333
|
+
(m) => m.tagName === "LI" && m.classList.contains(r.submenu)
|
|
891
334
|
);
|
|
892
|
-
let
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
const
|
|
896
|
-
`ul.${
|
|
897
|
-
),
|
|
898
|
-
this.lineHeight * Array.from(
|
|
335
|
+
let f = 0;
|
|
336
|
+
const g = (E, m) => {
|
|
337
|
+
f += 1, c(E).forEach((v) => {
|
|
338
|
+
const A = m >= i.w ? i.w - 8 : (i.w + 8) * -1, h = v.querySelector(
|
|
339
|
+
`ul.${r.container}`
|
|
340
|
+
), $ = Math.round(
|
|
341
|
+
this.lineHeight * Array.from(h.children).filter((T) => T.tagName === "LI").length
|
|
899
342
|
);
|
|
900
|
-
|
|
343
|
+
h.style.left = `${A}px`, h.style.right = "auto", h.style.top = s.h >= $ + i.h ? "0" : `-${h.offsetHeight - 25}px`, h.style.bottom = "auto", h.style.zIndex = String(f), c(h).length > 0 && g(h, m - i.w);
|
|
901
344
|
});
|
|
902
345
|
};
|
|
903
|
-
|
|
346
|
+
g(this.container.firstElementChild, s.w);
|
|
904
347
|
}
|
|
905
348
|
handleMapMove() {
|
|
906
349
|
this.closeMenu();
|
|
907
350
|
}
|
|
908
|
-
handleEntryCallback(
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
if (!
|
|
351
|
+
handleEntryCallback(e) {
|
|
352
|
+
e.preventDefault(), e.stopPropagation();
|
|
353
|
+
const s = e.currentTarget, o = this.menuEntries.get(s.id);
|
|
354
|
+
if (!o)
|
|
912
355
|
return;
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
356
|
+
const i = {
|
|
357
|
+
data: o.data,
|
|
358
|
+
coordinate: this.coordinate
|
|
916
359
|
};
|
|
917
|
-
this.closeMenu(),
|
|
360
|
+
this.closeMenu(), o.callback?.(i, this.map);
|
|
918
361
|
}
|
|
919
|
-
handleAddMenuEntry(
|
|
920
|
-
this.menuEntries.set(
|
|
362
|
+
handleAddMenuEntry(e, s) {
|
|
363
|
+
this.menuEntries.set(e.id, e), this.positionContainer(), "callback" in e && typeof e.callback == "function" && s.addEventListener("click", this.entryCallbackEventListener, !1);
|
|
921
364
|
}
|
|
922
365
|
}
|
|
923
366
|
export {
|
|
924
|
-
|
|
367
|
+
R as default
|
|
925
368
|
};
|