ol-contextmenu 5.1.4 → 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 +11 -13
- package/dist/helpers/dom.d.ts +2 -2
- package/dist/ol-contextmenu.css +2 -2
- package/dist/ol-contextmenu.iife.js +8 -0
- package/dist/ol-contextmenu.js +778 -198
- package/dist/ol-contextmenu.umd.cjs +3 -3
- package/dist/types.d.ts +9 -8
- package/package.json +22 -19
- package/dist/vite-env.d.ts +0 -1
package/dist/ol-contextmenu.js
CHANGED
|
@@ -1,45 +1,624 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
* ol-contextmenu - v5.
|
|
3
|
+
* ol-contextmenu - v5.2.0
|
|
4
4
|
* https://github.com/jonataswalker/ol-contextmenu
|
|
5
|
-
* Built: Mon
|
|
5
|
+
* Built: Mon Mar 13 2023 13:25:53 GMT-0300 (Brasilia Standard Time)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var l = (s,
|
|
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
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);
|
|
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);
|
|
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;
|
|
18
467
|
}
|
|
19
|
-
|
|
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: (s,
|
|
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
623
|
center: s.coordinate
|
|
45
624
|
});
|
|
@@ -47,125 +626,120 @@ const _ = {
|
|
|
47
626
|
},
|
|
48
627
|
{
|
|
49
628
|
text: "Zoom Out",
|
|
50
|
-
classname: `${
|
|
51
|
-
callback: (s,
|
|
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
635
|
center: s.coordinate
|
|
57
636
|
});
|
|
58
637
|
}
|
|
59
638
|
}
|
|
60
639
|
];
|
|
61
|
-
var
|
|
640
|
+
var M = {}, ue = {
|
|
62
641
|
get exports() {
|
|
63
|
-
return
|
|
642
|
+
return M;
|
|
64
643
|
},
|
|
65
644
|
set exports(s) {
|
|
66
|
-
|
|
645
|
+
M = s;
|
|
67
646
|
}
|
|
68
647
|
};
|
|
69
|
-
function
|
|
648
|
+
function A() {
|
|
70
649
|
}
|
|
71
|
-
|
|
72
|
-
on: function(s,
|
|
73
|
-
var
|
|
74
|
-
return (
|
|
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(s,
|
|
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
665
|
emit: function(s) {
|
|
87
|
-
var
|
|
88
|
-
for (
|
|
89
|
-
|
|
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(s,
|
|
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
|
|
103
|
-
function
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
n
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (a = s.parentNode) == null || a.removeChild(n), m;
|
|
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;
|
|
117
695
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
if (typeof
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
), a;
|
|
696
|
+
function $(s, e, t = !1, n = !1) {
|
|
697
|
+
const i = `_${Math.random().toString(36).slice(2, 11)}`;
|
|
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 = {
|
|
702
|
+
id: i,
|
|
703
|
+
isSubmenu: t,
|
|
704
|
+
isInsideSubmenu: n,
|
|
705
|
+
isSeparator: !1,
|
|
706
|
+
callback: "callback" in e ? e.callback : null,
|
|
707
|
+
data: "data" in e ? e.data : null
|
|
708
|
+
};
|
|
709
|
+
return g.emit(m.ADD_MENU_ENTRY, N, h), h;
|
|
133
710
|
}
|
|
134
|
-
const
|
|
711
|
+
const r = `<li id="${i}" class="${a.separator}"><hr></li>`, o = y(r);
|
|
135
712
|
s.append(o);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
},
|
|
146
|
-
c
|
|
147
|
-
), c;
|
|
713
|
+
const u = s.lastChild, d = {
|
|
714
|
+
id: i,
|
|
715
|
+
isSubmenu: !1,
|
|
716
|
+
isInsideSubmenu: !1,
|
|
717
|
+
isSeparator: !0,
|
|
718
|
+
callback: null,
|
|
719
|
+
data: null
|
|
720
|
+
};
|
|
721
|
+
return g.emit(m.ADD_MENU_ENTRY, d, u), u;
|
|
148
722
|
}
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
if (typeof
|
|
152
|
-
const
|
|
153
|
-
|
|
723
|
+
function C(s, e, t, n) {
|
|
724
|
+
e.forEach((i) => {
|
|
725
|
+
if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
|
|
726
|
+
const r = $(s, i, !0);
|
|
727
|
+
r.classList.add(a.submenu);
|
|
154
728
|
const o = document.createElement("ul");
|
|
155
|
-
o.classList.add(
|
|
729
|
+
o.classList.add(a.container), o.style.width = `${t}px`, r.append(o), C(o, i.items, t, !0);
|
|
156
730
|
} else
|
|
157
|
-
|
|
731
|
+
$(s, i, !1, n);
|
|
158
732
|
});
|
|
159
733
|
}
|
|
160
|
-
function
|
|
734
|
+
function L(s, e) {
|
|
161
735
|
if (!s)
|
|
162
|
-
throw new Error(
|
|
736
|
+
throw new Error(e);
|
|
163
737
|
}
|
|
164
|
-
class
|
|
165
|
-
constructor(
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
super({ element:
|
|
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 });
|
|
169
743
|
l(this, "map");
|
|
170
744
|
l(this, "container");
|
|
171
745
|
l(this, "coordinate", []);
|
|
@@ -179,23 +753,29 @@ class B extends O {
|
|
|
179
753
|
l(this, "items", []);
|
|
180
754
|
l(this, "menuEntries", /* @__PURE__ */ new Map());
|
|
181
755
|
l(this, "options");
|
|
182
|
-
this.options = { ...
|
|
756
|
+
this.options = { ...ce, ...t };
|
|
183
757
|
const i = document.createElement("ul");
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
), this.container =
|
|
189
|
-
this.handleContextMenu(
|
|
190
|
-
}, this.entryCallbackEventListener = (
|
|
191
|
-
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);
|
|
192
766
|
}, this.mapMoveListener = () => {
|
|
193
767
|
this.handleMapMove();
|
|
194
|
-
}, this.disabled = !1, this.opened = !1
|
|
768
|
+
}, this.disabled = !1, this.opened = !1, window.addEventListener(
|
|
769
|
+
"beforeunload",
|
|
770
|
+
() => {
|
|
771
|
+
this.removeListeners();
|
|
772
|
+
},
|
|
773
|
+
{ once: !0 }
|
|
774
|
+
);
|
|
195
775
|
}
|
|
196
776
|
clear() {
|
|
197
|
-
for (const
|
|
198
|
-
this.removeMenuEntry(
|
|
777
|
+
for (const t of this.menuEntries.keys())
|
|
778
|
+
this.removeMenuEntry(t);
|
|
199
779
|
this.container.replaceChildren(), this.container.append(document.createElement("ul"));
|
|
200
780
|
}
|
|
201
781
|
enable() {
|
|
@@ -205,141 +785,141 @@ class B extends O {
|
|
|
205
785
|
this.disabled = !0;
|
|
206
786
|
}
|
|
207
787
|
getDefaultItems() {
|
|
208
|
-
return
|
|
788
|
+
return P;
|
|
209
789
|
}
|
|
210
790
|
countItems() {
|
|
211
791
|
return this.menuEntries.size;
|
|
212
792
|
}
|
|
213
|
-
extend(
|
|
214
|
-
|
|
793
|
+
extend(t) {
|
|
794
|
+
L(Array.isArray(t), "@param `items` should be an Array."), C(
|
|
215
795
|
this.container.firstElementChild,
|
|
216
|
-
|
|
796
|
+
t,
|
|
217
797
|
this.options.width
|
|
218
798
|
);
|
|
219
799
|
}
|
|
220
800
|
closeMenu() {
|
|
221
|
-
this.opened = !1, this.container.classList.add(
|
|
801
|
+
this.opened = !1, this.container.classList.add(a.hidden), this.dispatchEvent(m.CLOSE);
|
|
222
802
|
}
|
|
223
803
|
isOpen() {
|
|
224
804
|
return this.opened;
|
|
225
805
|
}
|
|
226
|
-
updatePosition(
|
|
227
|
-
|
|
806
|
+
updatePosition(t) {
|
|
807
|
+
L(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
|
|
228
808
|
}
|
|
229
809
|
pop() {
|
|
230
|
-
const
|
|
231
|
-
|
|
810
|
+
const t = Array.from(this.menuEntries.keys()).pop();
|
|
811
|
+
t && this.removeMenuEntry(t);
|
|
232
812
|
}
|
|
233
813
|
shift() {
|
|
234
|
-
const
|
|
235
|
-
|
|
814
|
+
const t = Array.from(this.menuEntries.keys()).shift();
|
|
815
|
+
t && this.removeMenuEntry(t);
|
|
236
816
|
}
|
|
237
|
-
push(
|
|
238
|
-
|
|
817
|
+
push(t) {
|
|
818
|
+
t && this.extend([t]);
|
|
239
819
|
}
|
|
240
|
-
setMap(
|
|
241
|
-
if (super.setMap(
|
|
242
|
-
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", () => {
|
|
243
823
|
this.handleMapMove();
|
|
244
|
-
}),
|
|
245
|
-
|
|
246
|
-
(i,
|
|
247
|
-
this.handleAddMenuEntry(i,
|
|
824
|
+
}), g.on(
|
|
825
|
+
m.ADD_MENU_ENTRY,
|
|
826
|
+
(i, r) => {
|
|
827
|
+
this.handleAddMenuEntry(i, r);
|
|
248
828
|
},
|
|
249
829
|
this
|
|
250
|
-
), this.items = this.options.defaultItems ? this.options.items.concat(
|
|
830
|
+
), this.items = this.options.defaultItems ? this.options.items.concat(P) : this.options.items, C(
|
|
251
831
|
this.container.firstElementChild,
|
|
252
832
|
this.items,
|
|
253
833
|
this.options.width
|
|
254
834
|
);
|
|
255
|
-
const
|
|
256
|
-
this.lineHeight =
|
|
835
|
+
const n = this.getMenuEntriesLength();
|
|
836
|
+
this.lineHeight = n > 0 ? this.container.offsetHeight / n : pe(this.container);
|
|
257
837
|
} else
|
|
258
838
|
this.removeListeners(), this.clear();
|
|
259
839
|
}
|
|
260
840
|
removeListeners() {
|
|
261
|
-
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1),
|
|
841
|
+
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), g.off(m.ADD_MENU_ENTRY);
|
|
262
842
|
}
|
|
263
|
-
removeMenuEntry(
|
|
264
|
-
const
|
|
265
|
-
|
|
843
|
+
removeMenuEntry(t) {
|
|
844
|
+
const n = document.getElementById(t);
|
|
845
|
+
n?.remove(), n?.removeEventListener("click", this.entryCallbackEventListener), this.menuEntries.delete(t);
|
|
266
846
|
}
|
|
267
|
-
handleContextMenu(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
type: p.BEFOREOPEN,
|
|
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.
|
|
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 = {
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
884
|
+
// a cheap way to recalculate container height
|
|
885
|
+
// since offsetHeight is like cached
|
|
886
|
+
h: Math.round(this.lineHeight * i)
|
|
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)
|
|
310
891
|
);
|
|
311
|
-
let
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
`ul.${
|
|
316
|
-
),
|
|
317
|
-
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
|
|
318
899
|
);
|
|
319
|
-
|
|
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);
|
|
320
901
|
});
|
|
321
902
|
};
|
|
322
|
-
|
|
903
|
+
c(this.container.firstElementChild, n.w);
|
|
323
904
|
}
|
|
324
905
|
handleMapMove() {
|
|
325
906
|
this.closeMenu();
|
|
326
907
|
}
|
|
327
|
-
handleEntryCallback(
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const t = e.currentTarget, i = this.menuEntries.get(t.id);
|
|
908
|
+
handleEntryCallback(t) {
|
|
909
|
+
t.preventDefault(), t.stopPropagation();
|
|
910
|
+
const n = t.currentTarget, i = this.menuEntries.get(n.id);
|
|
331
911
|
if (!i)
|
|
332
912
|
return;
|
|
333
|
-
const
|
|
913
|
+
const r = {
|
|
334
914
|
coordinate: this.coordinate,
|
|
335
915
|
data: i.data
|
|
336
916
|
};
|
|
337
|
-
this.closeMenu(),
|
|
917
|
+
this.closeMenu(), i.callback?.(r, this.map);
|
|
338
918
|
}
|
|
339
|
-
handleAddMenuEntry(
|
|
340
|
-
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);
|
|
341
921
|
}
|
|
342
922
|
}
|
|
343
923
|
export {
|
|
344
|
-
|
|
924
|
+
me as default
|
|
345
925
|
};
|