ol-contextmenu 5.1.5 → 5.2.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 +10 -10
- package/dist/ol-contextmenu.css +2 -2
- package/dist/ol-contextmenu.iife.js +3 -3
- package/dist/ol-contextmenu.js +773 -194
- package/dist/ol-contextmenu.umd.cjs +3 -3
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/ol-contextmenu.js
CHANGED
|
@@ -1,137 +1,716 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
* ol-contextmenu - v5.
|
|
3
|
+
* ol-contextmenu - v5.2.0
|
|
4
4
|
* https://github.com/jonataswalker/ol-contextmenu
|
|
5
|
-
* Built:
|
|
5
|
+
* Built: Mon Mar 13 2023 13:25:53 GMT-0300 (Brasilia Standard Time)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
|
|
8
|
+
var z = Object.defineProperty;
|
|
9
|
+
var B = (s, e, t) => e in s ? z(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
10
|
+
var l = (s, e, t) => (B(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
11
|
+
class F {
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} type Type.
|
|
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
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const X = Z, W = {
|
|
163
|
+
/**
|
|
164
|
+
* Generic change event. Triggered when the revision counter is increased.
|
|
165
|
+
* @event module:ol/events/Event~BaseEvent#change
|
|
166
|
+
* @api
|
|
167
|
+
*/
|
|
168
|
+
CHANGE: "change",
|
|
169
|
+
/**
|
|
170
|
+
* Generic error event. Triggered when an error occurs.
|
|
171
|
+
* @event module:ol/events/Event~BaseEvent#error
|
|
172
|
+
* @api
|
|
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);
|
|
17
294
|
}
|
|
18
295
|
}
|
|
19
|
-
|
|
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);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
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
|
+
};
|
|
465
|
+
function D(s) {
|
|
466
|
+
return s && s.parentNode ? s.parentNode.removeChild(s) : null;
|
|
467
|
+
}
|
|
468
|
+
class ie extends ne {
|
|
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();
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
const he = le;
|
|
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 = {
|
|
20
599
|
width: 150,
|
|
21
600
|
scrollAt: 4,
|
|
22
|
-
eventType:
|
|
601
|
+
eventType: w.CONTEXTMENU,
|
|
23
602
|
defaultItems: !0,
|
|
24
603
|
items: []
|
|
25
|
-
},
|
|
26
|
-
namespace:
|
|
27
|
-
container: `${
|
|
28
|
-
separator: `${
|
|
29
|
-
submenu: `${
|
|
30
|
-
hidden: `${
|
|
31
|
-
icon: `${
|
|
32
|
-
zoomIn: `${
|
|
33
|
-
zoomOut: `${
|
|
604
|
+
}, f = "ol-ctx-menu", a = {
|
|
605
|
+
namespace: f,
|
|
606
|
+
container: `${f}-container`,
|
|
607
|
+
separator: `${f}-separator`,
|
|
608
|
+
submenu: `${f}-submenu`,
|
|
609
|
+
hidden: `${f}-hidden`,
|
|
610
|
+
icon: `${f}-icon`,
|
|
611
|
+
zoomIn: `${f}-zoom-in`,
|
|
612
|
+
zoomOut: `${f}-zoom-out`,
|
|
34
613
|
unselectable: "ol-unselectable"
|
|
35
|
-
},
|
|
614
|
+
}, P = [
|
|
36
615
|
{
|
|
37
616
|
text: "Zoom In",
|
|
38
|
-
classname: `${
|
|
39
|
-
callback: (
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
zoom: Number(
|
|
617
|
+
classname: `${a.zoomIn} ${a.icon}`,
|
|
618
|
+
callback: (s, e) => {
|
|
619
|
+
const t = e.getView();
|
|
620
|
+
t.animate({
|
|
621
|
+
zoom: Number(t.getZoom()) + 1,
|
|
43
622
|
duration: 700,
|
|
44
|
-
center:
|
|
623
|
+
center: s.coordinate
|
|
45
624
|
});
|
|
46
625
|
}
|
|
47
626
|
},
|
|
48
627
|
{
|
|
49
628
|
text: "Zoom Out",
|
|
50
|
-
classname: `${
|
|
51
|
-
callback: (
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
zoom: Number(
|
|
629
|
+
classname: `${a.zoomOut} ${a.icon}`,
|
|
630
|
+
callback: (s, e) => {
|
|
631
|
+
const t = e.getView();
|
|
632
|
+
t.animate({
|
|
633
|
+
zoom: Number(t.getZoom()) - 1,
|
|
55
634
|
duration: 700,
|
|
56
|
-
center:
|
|
635
|
+
center: s.coordinate
|
|
57
636
|
});
|
|
58
637
|
}
|
|
59
638
|
}
|
|
60
639
|
];
|
|
61
|
-
var M = {},
|
|
640
|
+
var M = {}, ue = {
|
|
62
641
|
get exports() {
|
|
63
642
|
return M;
|
|
64
643
|
},
|
|
65
|
-
set exports(
|
|
66
|
-
M =
|
|
644
|
+
set exports(s) {
|
|
645
|
+
M = s;
|
|
67
646
|
}
|
|
68
647
|
};
|
|
69
|
-
function
|
|
648
|
+
function A() {
|
|
70
649
|
}
|
|
71
|
-
|
|
72
|
-
on: function(
|
|
73
|
-
var
|
|
74
|
-
return (s
|
|
75
|
-
fn:
|
|
76
|
-
ctx:
|
|
650
|
+
A.prototype = {
|
|
651
|
+
on: function(s, e, t) {
|
|
652
|
+
var n = this.e || (this.e = {});
|
|
653
|
+
return (n[s] || (n[s] = [])).push({
|
|
654
|
+
fn: e,
|
|
655
|
+
ctx: t
|
|
77
656
|
}), this;
|
|
78
657
|
},
|
|
79
|
-
once: function(
|
|
80
|
-
var
|
|
658
|
+
once: function(s, e, t) {
|
|
659
|
+
var n = this;
|
|
81
660
|
function i() {
|
|
82
|
-
|
|
661
|
+
n.off(s, i), e.apply(t, arguments);
|
|
83
662
|
}
|
|
84
|
-
return i._ =
|
|
663
|
+
return i._ = e, this.on(s, i, t);
|
|
85
664
|
},
|
|
86
|
-
emit: function(
|
|
87
|
-
var
|
|
88
|
-
for (
|
|
89
|
-
|
|
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);
|
|
90
669
|
return this;
|
|
91
670
|
},
|
|
92
|
-
off: function(
|
|
93
|
-
var
|
|
94
|
-
if (
|
|
95
|
-
for (var
|
|
96
|
-
|
|
97
|
-
return i.length ?
|
|
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;
|
|
98
677
|
}
|
|
99
678
|
};
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
const g = new
|
|
103
|
-
function y(
|
|
104
|
-
const
|
|
105
|
-
for (
|
|
106
|
-
|
|
107
|
-
return
|
|
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;
|
|
108
687
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
return
|
|
688
|
+
function pe(s) {
|
|
689
|
+
const e = document.importNode(s), t = s.offsetWidth;
|
|
690
|
+
e.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;
|
|
691
|
+
const n = y("<span>Foo</span>"), i = y("<span>Foo</span>"), r = document.createElement("li"), o = document.createElement("li");
|
|
692
|
+
r.append(n), o.append(i), e.append(r), e.append(o), s.parentNode?.append(e);
|
|
693
|
+
const u = e.offsetHeight / 2;
|
|
694
|
+
return s.parentNode?.removeChild(e), u;
|
|
116
695
|
}
|
|
117
|
-
function
|
|
696
|
+
function $(s, e, t = !1, n = !1) {
|
|
118
697
|
const i = `_${Math.random().toString(36).slice(2, 11)}`;
|
|
119
|
-
if (typeof
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const
|
|
698
|
+
if (typeof e != "string" && "text" in e) {
|
|
699
|
+
const c = `<span>${e.text}</span>`, E = y(c), h = document.createElement("li");
|
|
700
|
+
e.classname = e.classname || "", e.icon && (e.classname === "" ? e.classname = a.icon : e.classname.includes(a.icon) === !1 && (e.classname += ` ${a.icon}`), h.setAttribute("style", `background-image:url(${e.icon})`)), h.id = i, h.className = e.classname, h.append(E), s.append(h);
|
|
701
|
+
const N = {
|
|
123
702
|
id: i,
|
|
124
|
-
isSubmenu:
|
|
125
|
-
isInsideSubmenu:
|
|
703
|
+
isSubmenu: t,
|
|
704
|
+
isInsideSubmenu: n,
|
|
126
705
|
isSeparator: !1,
|
|
127
|
-
callback: "callback" in
|
|
128
|
-
data: "data" in
|
|
706
|
+
callback: "callback" in e ? e.callback : null,
|
|
707
|
+
data: "data" in e ? e.data : null
|
|
129
708
|
};
|
|
130
|
-
return g.emit(
|
|
709
|
+
return g.emit(m.ADD_MENU_ENTRY, N, h), h;
|
|
131
710
|
}
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const
|
|
711
|
+
const r = `<li id="${i}" class="${a.separator}"><hr></li>`, o = y(r);
|
|
712
|
+
s.append(o);
|
|
713
|
+
const u = s.lastChild, d = {
|
|
135
714
|
id: i,
|
|
136
715
|
isSubmenu: !1,
|
|
137
716
|
isInsideSubmenu: !1,
|
|
@@ -139,51 +718,51 @@ function N(n, t, e = !1, s = !1) {
|
|
|
139
718
|
callback: null,
|
|
140
719
|
data: null
|
|
141
720
|
};
|
|
142
|
-
return g.emit(
|
|
721
|
+
return g.emit(m.ADD_MENU_ENTRY, d, u), u;
|
|
143
722
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
723
|
+
function C(s, e, t, n) {
|
|
724
|
+
e.forEach((i) => {
|
|
146
725
|
if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
726
|
+
const r = $(s, i, !0);
|
|
727
|
+
r.classList.add(a.submenu);
|
|
728
|
+
const o = document.createElement("ul");
|
|
729
|
+
o.classList.add(a.container), o.style.width = `${t}px`, r.append(o), C(o, i.items, t, !0);
|
|
151
730
|
} else
|
|
152
|
-
|
|
731
|
+
$(s, i, !1, n);
|
|
153
732
|
});
|
|
154
733
|
}
|
|
155
|
-
function
|
|
156
|
-
if (!
|
|
157
|
-
throw new Error(
|
|
734
|
+
function L(s, e) {
|
|
735
|
+
if (!s)
|
|
736
|
+
throw new Error(e);
|
|
158
737
|
}
|
|
159
|
-
class
|
|
160
|
-
constructor(
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
super({ element:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
this.options = { ...
|
|
738
|
+
class me extends re {
|
|
739
|
+
constructor(t = {}) {
|
|
740
|
+
L(typeof t == "object", "@param `opts` should be object type!");
|
|
741
|
+
const n = document.createElement("div");
|
|
742
|
+
super({ element: n });
|
|
743
|
+
l(this, "map");
|
|
744
|
+
l(this, "container");
|
|
745
|
+
l(this, "coordinate", []);
|
|
746
|
+
l(this, "pixel", []);
|
|
747
|
+
l(this, "contextMenuEventListener");
|
|
748
|
+
l(this, "entryCallbackEventListener");
|
|
749
|
+
l(this, "mapMoveListener");
|
|
750
|
+
l(this, "lineHeight", 0);
|
|
751
|
+
l(this, "disabled");
|
|
752
|
+
l(this, "opened");
|
|
753
|
+
l(this, "items", []);
|
|
754
|
+
l(this, "menuEntries", /* @__PURE__ */ new Map());
|
|
755
|
+
l(this, "options");
|
|
756
|
+
this.options = { ...ce, ...t };
|
|
178
757
|
const i = document.createElement("ul");
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
), this.container =
|
|
184
|
-
this.handleContextMenu(
|
|
185
|
-
}, this.entryCallbackEventListener = (
|
|
186
|
-
this.handleEntryCallback(
|
|
758
|
+
n.append(i), n.style.width = `${this.options.width}px`, n.classList.add(
|
|
759
|
+
a.container,
|
|
760
|
+
a.unselectable,
|
|
761
|
+
a.hidden
|
|
762
|
+
), this.container = n, this.contextMenuEventListener = (r) => {
|
|
763
|
+
this.handleContextMenu(r);
|
|
764
|
+
}, this.entryCallbackEventListener = (r) => {
|
|
765
|
+
this.handleEntryCallback(r);
|
|
187
766
|
}, this.mapMoveListener = () => {
|
|
188
767
|
this.handleMapMove();
|
|
189
768
|
}, this.disabled = !1, this.opened = !1, window.addEventListener(
|
|
@@ -195,8 +774,8 @@ class Y extends I {
|
|
|
195
774
|
);
|
|
196
775
|
}
|
|
197
776
|
clear() {
|
|
198
|
-
for (const
|
|
199
|
-
this.removeMenuEntry(
|
|
777
|
+
for (const t of this.menuEntries.keys())
|
|
778
|
+
this.removeMenuEntry(t);
|
|
200
779
|
this.container.replaceChildren(), this.container.append(document.createElement("ul"));
|
|
201
780
|
}
|
|
202
781
|
enable() {
|
|
@@ -206,141 +785,141 @@ class Y extends I {
|
|
|
206
785
|
this.disabled = !0;
|
|
207
786
|
}
|
|
208
787
|
getDefaultItems() {
|
|
209
|
-
return
|
|
788
|
+
return P;
|
|
210
789
|
}
|
|
211
790
|
countItems() {
|
|
212
791
|
return this.menuEntries.size;
|
|
213
792
|
}
|
|
214
|
-
extend(
|
|
215
|
-
|
|
793
|
+
extend(t) {
|
|
794
|
+
L(Array.isArray(t), "@param `items` should be an Array."), C(
|
|
216
795
|
this.container.firstElementChild,
|
|
217
|
-
|
|
796
|
+
t,
|
|
218
797
|
this.options.width
|
|
219
798
|
);
|
|
220
799
|
}
|
|
221
800
|
closeMenu() {
|
|
222
|
-
this.opened = !1, this.container.classList.add(
|
|
801
|
+
this.opened = !1, this.container.classList.add(a.hidden), this.dispatchEvent(m.CLOSE);
|
|
223
802
|
}
|
|
224
803
|
isOpen() {
|
|
225
804
|
return this.opened;
|
|
226
805
|
}
|
|
227
|
-
updatePosition(
|
|
228
|
-
|
|
806
|
+
updatePosition(t) {
|
|
807
|
+
L(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
|
|
229
808
|
}
|
|
230
809
|
pop() {
|
|
231
|
-
const
|
|
232
|
-
|
|
810
|
+
const t = Array.from(this.menuEntries.keys()).pop();
|
|
811
|
+
t && this.removeMenuEntry(t);
|
|
233
812
|
}
|
|
234
813
|
shift() {
|
|
235
|
-
const
|
|
236
|
-
|
|
814
|
+
const t = Array.from(this.menuEntries.keys()).shift();
|
|
815
|
+
t && this.removeMenuEntry(t);
|
|
237
816
|
}
|
|
238
|
-
push(
|
|
239
|
-
|
|
817
|
+
push(t) {
|
|
818
|
+
t && this.extend([t]);
|
|
240
819
|
}
|
|
241
|
-
setMap(
|
|
242
|
-
if (super.setMap(
|
|
243
|
-
this.map =
|
|
820
|
+
setMap(t) {
|
|
821
|
+
if (super.setMap(t), t) {
|
|
822
|
+
this.map = t, this.map.getViewport().addEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.map.on("movestart", () => {
|
|
244
823
|
this.handleMapMove();
|
|
245
824
|
}), g.on(
|
|
246
|
-
|
|
247
|
-
(i,
|
|
248
|
-
this.handleAddMenuEntry(i,
|
|
825
|
+
m.ADD_MENU_ENTRY,
|
|
826
|
+
(i, r) => {
|
|
827
|
+
this.handleAddMenuEntry(i, r);
|
|
249
828
|
},
|
|
250
829
|
this
|
|
251
|
-
), this.items = this.options.defaultItems ? this.options.items.concat(
|
|
830
|
+
), this.items = this.options.defaultItems ? this.options.items.concat(P) : this.options.items, C(
|
|
252
831
|
this.container.firstElementChild,
|
|
253
832
|
this.items,
|
|
254
833
|
this.options.width
|
|
255
834
|
);
|
|
256
|
-
const
|
|
257
|
-
this.lineHeight =
|
|
835
|
+
const n = this.getMenuEntriesLength();
|
|
836
|
+
this.lineHeight = n > 0 ? this.container.offsetHeight / n : pe(this.container);
|
|
258
837
|
} else
|
|
259
838
|
this.removeListeners(), this.clear();
|
|
260
839
|
}
|
|
261
840
|
removeListeners() {
|
|
262
|
-
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(
|
|
841
|
+
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(m.ADD_MENU_ENTRY);
|
|
263
842
|
}
|
|
264
|
-
removeMenuEntry(
|
|
265
|
-
const
|
|
266
|
-
|
|
843
|
+
removeMenuEntry(t) {
|
|
844
|
+
const n = document.getElementById(t);
|
|
845
|
+
n?.remove(), n?.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(t);
|
|
267
846
|
}
|
|
268
|
-
handleContextMenu(
|
|
269
|
-
this.coordinate = this.map.getEventCoordinate(
|
|
270
|
-
new
|
|
271
|
-
type:
|
|
847
|
+
handleContextMenu(t) {
|
|
848
|
+
this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent(
|
|
849
|
+
new R({
|
|
850
|
+
type: m.BEFOREOPEN,
|
|
272
851
|
map: this.map,
|
|
273
|
-
originalEvent:
|
|
852
|
+
originalEvent: t
|
|
274
853
|
})
|
|
275
|
-
), !this.disabled && (this.options.eventType ===
|
|
276
|
-
this.openMenu(
|
|
277
|
-
}),
|
|
854
|
+
), !this.disabled && (this.options.eventType === w.CONTEXTMENU && (t.stopPropagation(), t.preventDefault()), setTimeout(() => {
|
|
855
|
+
this.openMenu(t);
|
|
856
|
+
}), t.target?.addEventListener(
|
|
278
857
|
"pointerdown",
|
|
279
|
-
(
|
|
280
|
-
this.opened && (
|
|
858
|
+
(n) => {
|
|
859
|
+
this.opened && (n.stopPropagation(), this.closeMenu());
|
|
281
860
|
},
|
|
282
861
|
{ once: !0 }
|
|
283
862
|
));
|
|
284
863
|
}
|
|
285
|
-
openMenu(
|
|
286
|
-
this.opened = !0, this.positionContainer(), this.container.classList.remove(
|
|
287
|
-
new
|
|
288
|
-
type:
|
|
864
|
+
openMenu(t) {
|
|
865
|
+
this.opened = !0, this.positionContainer(), this.container.classList.remove(a.hidden), this.dispatchEvent(
|
|
866
|
+
new R({
|
|
867
|
+
type: m.OPEN,
|
|
289
868
|
map: this.map,
|
|
290
|
-
originalEvent:
|
|
869
|
+
originalEvent: t
|
|
291
870
|
})
|
|
292
871
|
);
|
|
293
872
|
}
|
|
294
873
|
getMenuEntriesLength() {
|
|
295
874
|
return Array.from(this.menuEntries).filter(
|
|
296
|
-
([,
|
|
875
|
+
([, t]) => t.isSeparator === !1 && t.isSubmenu === !1 && t.isInsideSubmenu === !1
|
|
297
876
|
).length;
|
|
298
877
|
}
|
|
299
878
|
positionContainer() {
|
|
300
|
-
const
|
|
301
|
-
w:
|
|
302
|
-
h:
|
|
303
|
-
}, i = this.getMenuEntriesLength(),
|
|
879
|
+
const t = this.map.getSize() || [0, 0], n = {
|
|
880
|
+
w: t[0] - this.pixel[0],
|
|
881
|
+
h: t[1] - this.pixel[1]
|
|
882
|
+
}, i = this.getMenuEntriesLength(), r = {
|
|
304
883
|
w: this.container.offsetWidth,
|
|
305
884
|
// a cheap way to recalculate container height
|
|
306
885
|
// since offsetHeight is like cached
|
|
307
886
|
h: Math.round(this.lineHeight * i)
|
|
308
|
-
},
|
|
309
|
-
this.container.style.left = `${
|
|
310
|
-
const
|
|
311
|
-
(
|
|
887
|
+
}, o = n.w >= r.w ? this.pixel[0] + 5 : this.pixel[0] - r.w;
|
|
888
|
+
this.container.style.left = `${o}px`, this.container.style.top = n.h >= r.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - r.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", n.w -= r.w;
|
|
889
|
+
const u = (E) => Array.from(E.children).filter(
|
|
890
|
+
(h) => h.tagName === "LI" && h.classList.contains(a.submenu)
|
|
312
891
|
);
|
|
313
|
-
let
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
`ul.${
|
|
318
|
-
),
|
|
319
|
-
this.lineHeight * Array.from(
|
|
892
|
+
let d = 0;
|
|
893
|
+
const c = (E, h) => {
|
|
894
|
+
d += 1, u(E).forEach((k) => {
|
|
895
|
+
const H = h >= r.w ? r.w - 8 : (r.w + 8) * -1, p = k.querySelector(
|
|
896
|
+
`ul.${a.container}`
|
|
897
|
+
), K = Math.round(
|
|
898
|
+
this.lineHeight * Array.from(p.children).filter((U) => U.tagName === "LI").length
|
|
320
899
|
);
|
|
321
|
-
|
|
900
|
+
p.style.left = `${H}px`, p.style.right = "auto", p.style.top = n.h >= K + r.h ? "0" : `-${p.offsetHeight - 25}px`, p.style.bottom = "auto", p.style.zIndex = String(d), u(p).length > 0 && c(p, h - r.w);
|
|
322
901
|
});
|
|
323
902
|
};
|
|
324
|
-
|
|
903
|
+
c(this.container.firstElementChild, n.w);
|
|
325
904
|
}
|
|
326
905
|
handleMapMove() {
|
|
327
906
|
this.closeMenu();
|
|
328
907
|
}
|
|
329
|
-
handleEntryCallback(
|
|
330
|
-
|
|
331
|
-
const
|
|
908
|
+
handleEntryCallback(t) {
|
|
909
|
+
t.preventDefault(), t.stopPropagation();
|
|
910
|
+
const n = t.currentTarget, i = this.menuEntries.get(n.id);
|
|
332
911
|
if (!i)
|
|
333
912
|
return;
|
|
334
|
-
const
|
|
913
|
+
const r = {
|
|
335
914
|
coordinate: this.coordinate,
|
|
336
915
|
data: i.data
|
|
337
916
|
};
|
|
338
|
-
this.closeMenu(), i.callback?.(
|
|
917
|
+
this.closeMenu(), i.callback?.(r, this.map);
|
|
339
918
|
}
|
|
340
|
-
handleAddMenuEntry(
|
|
341
|
-
this.menuEntries.set(
|
|
919
|
+
handleAddMenuEntry(t, n) {
|
|
920
|
+
this.menuEntries.set(t.id, t), this.positionContainer(), "callback" in t && typeof t.callback == "function" && n.addEventListener("click", this.entryCallbackEventListener, !1);
|
|
342
921
|
}
|
|
343
922
|
}
|
|
344
923
|
export {
|
|
345
|
-
|
|
924
|
+
me as default
|
|
346
925
|
};
|