ol-contextmenu 5.1.5 → 5.2.1
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 +12 -11
- package/dist/helpers/dom.d.ts +15 -2
- package/dist/main.d.ts +7 -5
- package/dist/ol-contextmenu.css +2 -2
- package/dist/ol-contextmenu.iife.js +3 -3
- package/dist/ol-contextmenu.js +829 -220
- package/dist/ol-contextmenu.umd.cjs +3 -3
- package/dist/types.d.ts +2 -1
- package/package.json +12 -12
- package/dist/emitter.d.ts +0 -3
package/dist/ol-contextmenu.js
CHANGED
|
@@ -1,137 +1,721 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
* ol-contextmenu - v5.1
|
|
3
|
+
* ol-contextmenu - v5.2.1
|
|
4
4
|
* https://github.com/jonataswalker/ol-contextmenu
|
|
5
|
-
* Built:
|
|
5
|
+
* Built: Fri Mar 31 2023 20:27:32 GMT-0300 (Brasilia Standard Time)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
|
|
8
|
+
var U = Object.defineProperty;
|
|
9
|
+
var z = (s, e, t) => e in s ? U(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
10
|
+
var h = (s, e, t) => (z(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
11
|
+
class B {
|
|
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 w = B, F = {
|
|
35
|
+
/**
|
|
36
|
+
* Triggered when a property is changed.
|
|
37
|
+
* @event module:ol/Object.ObjectEvent#propertychange
|
|
38
|
+
* @api
|
|
39
|
+
*/
|
|
40
|
+
PROPERTYCHANGE: "propertychange"
|
|
41
|
+
};
|
|
42
|
+
class V {
|
|
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 j = V;
|
|
60
|
+
function x() {
|
|
61
|
+
}
|
|
62
|
+
function I(s) {
|
|
63
|
+
for (const e in s)
|
|
64
|
+
delete s[e];
|
|
65
|
+
}
|
|
66
|
+
function Y(s) {
|
|
67
|
+
let e;
|
|
68
|
+
for (e in s)
|
|
69
|
+
return !1;
|
|
70
|
+
return !e;
|
|
71
|
+
}
|
|
72
|
+
class G extends j {
|
|
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_ = {}), r = n[e] || (n[e] = []);
|
|
87
|
+
r.includes(t) || r.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, r = this.listeners_ && this.listeners_[n];
|
|
101
|
+
if (!r)
|
|
102
|
+
return;
|
|
103
|
+
const i = t ? new w(e) : (
|
|
104
|
+
/** @type {Event} */
|
|
105
|
+
e
|
|
106
|
+
);
|
|
107
|
+
i.target || (i.target = this.eventTarget_ || this);
|
|
108
|
+
const o = this.dispatching_ || (this.dispatching_ = {}), l = this.pendingRemovals_ || (this.pendingRemovals_ = {});
|
|
109
|
+
n in o || (o[n] = 0, l[n] = 0), ++o[n];
|
|
110
|
+
let u;
|
|
111
|
+
for (let c = 0, E = r.length; c < E; ++c)
|
|
112
|
+
if ("handleEvent" in r[c] ? u = /** @type {import("../events.js").ListenerObject} */
|
|
113
|
+
r[c].handleEvent(i) : u = /** @type {import("../events.js").ListenerFunction} */
|
|
114
|
+
r[c].call(this, i), u === !1 || i.propagationStopped) {
|
|
115
|
+
u = !1;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
if (--o[n] === 0) {
|
|
119
|
+
let c = l[n];
|
|
120
|
+
for (delete l[n]; c--; )
|
|
121
|
+
this.removeEventListener(n, x);
|
|
122
|
+
delete o[n];
|
|
123
|
+
}
|
|
124
|
+
return u;
|
|
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 r = n.indexOf(t);
|
|
158
|
+
r !== -1 && (this.pendingRemovals_ && e in this.pendingRemovals_ ? (n[r] = x, ++this.pendingRemovals_[e]) : (n.splice(r, 1), n.length === 0 && delete this.listeners_[e]));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const Z = G, 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 g(s, e, t, n, r) {
|
|
192
|
+
if (n && n !== s && (t = t.bind(n)), r) {
|
|
193
|
+
const o = t;
|
|
194
|
+
t = function() {
|
|
195
|
+
s.removeEventListener(e, t), o.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const i = {
|
|
199
|
+
target: s,
|
|
200
|
+
type: e,
|
|
201
|
+
listener: t
|
|
202
|
+
};
|
|
203
|
+
return s.addEventListener(e, t), i;
|
|
204
|
+
}
|
|
205
|
+
function S(s, e, t, n) {
|
|
206
|
+
return g(s, e, t, n, !0);
|
|
207
|
+
}
|
|
208
|
+
function M(s) {
|
|
209
|
+
s && s.target && (s.target.removeEventListener(s.type, s.listener), I(s));
|
|
210
|
+
}
|
|
211
|
+
class y extends Z {
|
|
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, r = new Array(n);
|
|
243
|
+
for (let i = 0; i < n; ++i)
|
|
244
|
+
r[i] = g(this, e[i], t);
|
|
245
|
+
return r;
|
|
246
|
+
}
|
|
247
|
+
return g(
|
|
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 r = e.length;
|
|
264
|
+
n = new Array(r);
|
|
265
|
+
for (let i = 0; i < r; ++i)
|
|
266
|
+
n[i] = S(this, e[i], t);
|
|
267
|
+
} else
|
|
268
|
+
n = S(
|
|
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
|
+
X(n);
|
|
289
|
+
else if (Array.isArray(e))
|
|
290
|
+
for (let r = 0, i = e.length; r < i; ++r)
|
|
291
|
+
this.removeEventListener(e[r], t);
|
|
292
|
+
else
|
|
293
|
+
this.removeEventListener(e, t);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
y.prototype.on;
|
|
297
|
+
y.prototype.once;
|
|
298
|
+
y.prototype.un;
|
|
299
|
+
function X(s) {
|
|
300
|
+
if (Array.isArray(s))
|
|
301
|
+
for (let e = 0, t = s.length; e < t; ++e)
|
|
302
|
+
M(s[e]);
|
|
303
|
+
else
|
|
304
|
+
M(
|
|
305
|
+
/** @type {import("./events.js").EventsKey} */
|
|
306
|
+
s
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
const q = y;
|
|
310
|
+
let J = 0;
|
|
311
|
+
function Q(s) {
|
|
312
|
+
return s.ol_uid || (s.ol_uid = String(++J));
|
|
313
|
+
}
|
|
314
|
+
class T extends w {
|
|
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 ee extends q {
|
|
325
|
+
/**
|
|
326
|
+
* @param {Object<string, *>} [values] An object with key-value pairs.
|
|
327
|
+
*/
|
|
328
|
+
constructor(e) {
|
|
329
|
+
super(), this.on, this.once, this.un, Q(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 T(n, e, t)), n = F.PROPERTYCHANGE, this.hasListener(n) && this.dispatchEvent(new T(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 r = this.values_ || (this.values_ = {});
|
|
394
|
+
if (n)
|
|
395
|
+
r[e] = t;
|
|
396
|
+
else {
|
|
397
|
+
const i = r[e];
|
|
398
|
+
r[e] = t, i !== t && this.notify(e, i);
|
|
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], Y(this.values_) && (this.values_ = null), t || this.notify(e, n);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
const te = ee, ne = {
|
|
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 se extends te {
|
|
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
|
+
M(this.listenerKeys[t]);
|
|
503
|
+
this.listenerKeys.length = 0, this.map_ = e, e && ((this.target_ ? this.target_ : e.getOverlayContainerStopEvent()).appendChild(this.element), this.render !== x && this.listenerKeys.push(
|
|
504
|
+
g(e, ne.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 ie = se;
|
|
528
|
+
var C = {}, re = {
|
|
529
|
+
get exports() {
|
|
530
|
+
return C;
|
|
531
|
+
},
|
|
532
|
+
set exports(s) {
|
|
533
|
+
C = s;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
function A() {
|
|
18
537
|
}
|
|
19
|
-
|
|
538
|
+
A.prototype = {
|
|
539
|
+
on: function(s, e, t) {
|
|
540
|
+
var n = this.e || (this.e = {});
|
|
541
|
+
return (n[s] || (n[s] = [])).push({
|
|
542
|
+
fn: e,
|
|
543
|
+
ctx: t
|
|
544
|
+
}), this;
|
|
545
|
+
},
|
|
546
|
+
once: function(s, e, t) {
|
|
547
|
+
var n = this;
|
|
548
|
+
function r() {
|
|
549
|
+
n.off(s, r), e.apply(t, arguments);
|
|
550
|
+
}
|
|
551
|
+
return r._ = e, this.on(s, r, t);
|
|
552
|
+
},
|
|
553
|
+
emit: function(s) {
|
|
554
|
+
var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[s] || []).slice(), n = 0, r = t.length;
|
|
555
|
+
for (n; n < r; n++)
|
|
556
|
+
t[n].fn.apply(t[n].ctx, e);
|
|
557
|
+
return this;
|
|
558
|
+
},
|
|
559
|
+
off: function(s, e) {
|
|
560
|
+
var t = this.e || (this.e = {}), n = t[s], r = [];
|
|
561
|
+
if (n && e)
|
|
562
|
+
for (var i = 0, o = n.length; i < o; i++)
|
|
563
|
+
n[i].fn !== e && n[i].fn._ !== e && r.push(n[i]);
|
|
564
|
+
return r.length ? t[s] = r : delete t[s], this;
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
re.exports = A;
|
|
568
|
+
var oe = C.TinyEmitter = A;
|
|
569
|
+
class ae extends w {
|
|
570
|
+
/**
|
|
571
|
+
* @param {string} type Event type.
|
|
572
|
+
* @param {import("./Map.js").default} map Map.
|
|
573
|
+
* @param {?import("./Map.js").FrameState} [frameState] Frame state.
|
|
574
|
+
*/
|
|
575
|
+
constructor(e, t, n) {
|
|
576
|
+
super(e), this.map = t, this.frameState = n !== void 0 ? n : null;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const le = ae;
|
|
580
|
+
class he extends le {
|
|
581
|
+
/**
|
|
582
|
+
* @param {string} type Event type.
|
|
583
|
+
* @param {import("./Map.js").default} map Map.
|
|
584
|
+
* @param {EVENT} originalEvent Original event.
|
|
585
|
+
* @param {boolean} [dragging] Is the map currently being dragged?
|
|
586
|
+
* @param {import("./Map.js").FrameState} [frameState] Frame state.
|
|
587
|
+
* @param {Array<PointerEvent>} [activePointers] Active pointers.
|
|
588
|
+
*/
|
|
589
|
+
constructor(e, t, n, r, i, o) {
|
|
590
|
+
super(e, t, i), this.originalEvent = n, this.pixel_ = null, this.coordinate_ = null, this.dragging = r !== void 0 ? r : !1, this.activePointers = o;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* The map pixel relative to the viewport corresponding to the original event.
|
|
594
|
+
* @type {import("./pixel.js").Pixel}
|
|
595
|
+
* @api
|
|
596
|
+
*/
|
|
597
|
+
get pixel() {
|
|
598
|
+
return this.pixel_ || (this.pixel_ = this.map.getEventPixel(this.originalEvent)), this.pixel_;
|
|
599
|
+
}
|
|
600
|
+
set pixel(e) {
|
|
601
|
+
this.pixel_ = e;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* The coordinate corresponding to the original browser event. This will be in the user
|
|
605
|
+
* projection if one is set. Otherwise it will be in the view projection.
|
|
606
|
+
* @type {import("./coordinate.js").Coordinate}
|
|
607
|
+
* @api
|
|
608
|
+
*/
|
|
609
|
+
get coordinate() {
|
|
610
|
+
return this.coordinate_ || (this.coordinate_ = this.map.getCoordinateFromPixel(this.pixel)), this.coordinate_;
|
|
611
|
+
}
|
|
612
|
+
set coordinate(e) {
|
|
613
|
+
this.coordinate_ = e;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Prevents the default browser action.
|
|
617
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault.
|
|
618
|
+
* @api
|
|
619
|
+
*/
|
|
620
|
+
preventDefault() {
|
|
621
|
+
super.preventDefault(), "preventDefault" in this.originalEvent && this.originalEvent.preventDefault();
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Prevents further propagation of the current event.
|
|
625
|
+
* See https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation.
|
|
626
|
+
* @api
|
|
627
|
+
*/
|
|
628
|
+
stopPropagation() {
|
|
629
|
+
super.stopPropagation(), "stopPropagation" in this.originalEvent && this.originalEvent.stopPropagation();
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
const ce = he;
|
|
633
|
+
var N = /* @__PURE__ */ ((s) => (s.CONTEXTMENU = "contextmenu", s.CLICK = "click", s.DBLCLICK = "dblclick", s))(N || {}), m = /* @__PURE__ */ ((s) => (s.BEFOREOPEN = "beforeopen", s.OPEN = "open", s.CLOSE = "close", s.ADD_MENU_ENTRY = "add-menu-entry", s))(m || {});
|
|
634
|
+
class R extends ce {
|
|
635
|
+
constructor(e) {
|
|
636
|
+
super(e.type, e.map, e.originalEvent);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
const ue = {
|
|
20
640
|
width: 150,
|
|
21
641
|
scrollAt: 4,
|
|
22
|
-
eventType:
|
|
642
|
+
eventType: N.CONTEXTMENU,
|
|
23
643
|
defaultItems: !0,
|
|
24
644
|
items: []
|
|
25
|
-
},
|
|
26
|
-
namespace:
|
|
27
|
-
container: `${
|
|
28
|
-
separator: `${
|
|
29
|
-
submenu: `${
|
|
30
|
-
hidden: `${
|
|
31
|
-
icon: `${
|
|
32
|
-
zoomIn: `${
|
|
33
|
-
zoomOut: `${
|
|
645
|
+
}, f = "ol-ctx-menu", a = {
|
|
646
|
+
namespace: f,
|
|
647
|
+
container: `${f}-container`,
|
|
648
|
+
separator: `${f}-separator`,
|
|
649
|
+
submenu: `${f}-submenu`,
|
|
650
|
+
hidden: `${f}-hidden`,
|
|
651
|
+
icon: `${f}-icon`,
|
|
652
|
+
zoomIn: `${f}-zoom-in`,
|
|
653
|
+
zoomOut: `${f}-zoom-out`,
|
|
34
654
|
unselectable: "ol-unselectable"
|
|
35
|
-
},
|
|
655
|
+
}, P = [
|
|
36
656
|
{
|
|
37
657
|
text: "Zoom In",
|
|
38
|
-
classname: `${
|
|
39
|
-
callback: (
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
zoom: Number(
|
|
658
|
+
classname: `${a.zoomIn} ${a.icon}`,
|
|
659
|
+
callback: (s, e) => {
|
|
660
|
+
const t = e.getView();
|
|
661
|
+
t.animate({
|
|
662
|
+
zoom: Number(t.getZoom()) + 1,
|
|
43
663
|
duration: 700,
|
|
44
|
-
center:
|
|
664
|
+
center: s.coordinate
|
|
45
665
|
});
|
|
46
666
|
}
|
|
47
667
|
},
|
|
48
668
|
{
|
|
49
669
|
text: "Zoom Out",
|
|
50
|
-
classname: `${
|
|
51
|
-
callback: (
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
zoom: Number(
|
|
670
|
+
classname: `${a.zoomOut} ${a.icon}`,
|
|
671
|
+
callback: (s, e) => {
|
|
672
|
+
const t = e.getView();
|
|
673
|
+
t.animate({
|
|
674
|
+
zoom: Number(t.getZoom()) - 1,
|
|
55
675
|
duration: 700,
|
|
56
|
-
center:
|
|
676
|
+
center: s.coordinate
|
|
57
677
|
});
|
|
58
678
|
}
|
|
59
679
|
}
|
|
60
680
|
];
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
M = n;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
function L() {
|
|
681
|
+
function _(s) {
|
|
682
|
+
const e = document.createDocumentFragment(), t = document.createElement("div");
|
|
683
|
+
for (t.innerHTML = s; t.firstChild; )
|
|
684
|
+
e.append(t.firstChild);
|
|
685
|
+
return e;
|
|
70
686
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
once: function(n, t, e) {
|
|
80
|
-
var s = this;
|
|
81
|
-
function i() {
|
|
82
|
-
s.off(n, i), t.apply(e, arguments);
|
|
83
|
-
}
|
|
84
|
-
return i._ = t, this.on(n, i, e);
|
|
85
|
-
},
|
|
86
|
-
emit: function(n) {
|
|
87
|
-
var t = [].slice.call(arguments, 1), e = ((this.e || (this.e = {}))[n] || []).slice(), s = 0, i = e.length;
|
|
88
|
-
for (s; s < i; s++)
|
|
89
|
-
e[s].fn.apply(e[s].ctx, t);
|
|
90
|
-
return this;
|
|
91
|
-
},
|
|
92
|
-
off: function(n, t) {
|
|
93
|
-
var e = this.e || (this.e = {}), s = e[n], i = [];
|
|
94
|
-
if (s && t)
|
|
95
|
-
for (var o = 0, l = s.length; o < l; o++)
|
|
96
|
-
s[o].fn !== t && s[o].fn._ !== t && i.push(s[o]);
|
|
97
|
-
return i.length ? e[n] = i : delete e[n], this;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
P.exports = L;
|
|
101
|
-
var H = M.TinyEmitter = L;
|
|
102
|
-
const g = new H();
|
|
103
|
-
function y(n) {
|
|
104
|
-
const t = document.createDocumentFragment(), e = document.createElement("div");
|
|
105
|
-
for (e.innerHTML = n; e.firstChild; )
|
|
106
|
-
t.append(e.firstChild);
|
|
107
|
-
return t;
|
|
108
|
-
}
|
|
109
|
-
function U(n) {
|
|
110
|
-
const t = document.importNode(n), e = n.offsetWidth;
|
|
111
|
-
t.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${e}px`;
|
|
112
|
-
const s = y("<span>Foo</span>"), i = y("<span>Foo</span>"), o = document.createElement("li"), l = document.createElement("li");
|
|
113
|
-
o.append(s), l.append(i), t.append(o), t.append(l), n.parentNode?.append(t);
|
|
114
|
-
const p = t.offsetHeight / 2;
|
|
115
|
-
return n.parentNode?.removeChild(t), p;
|
|
687
|
+
function de(s) {
|
|
688
|
+
const e = document.importNode(s), t = s.offsetWidth;
|
|
689
|
+
e.style.cssText = `position: fixed; top: 0; left: 0; overflow: auto; visibility: hidden; pointer-events: none; height: unset; max-height: unset; width: ${t}px`;
|
|
690
|
+
const n = _("<span>Foo</span>"), r = _("<span>Foo</span>"), i = document.createElement("li"), o = document.createElement("li");
|
|
691
|
+
i.append(n), o.append(r), e.append(i), e.append(o), s.parentNode?.append(e);
|
|
692
|
+
const l = e.offsetHeight / 2;
|
|
693
|
+
return s.parentNode?.removeChild(e), l;
|
|
116
694
|
}
|
|
117
|
-
function
|
|
695
|
+
function $({
|
|
696
|
+
parentNode: s,
|
|
697
|
+
item: e,
|
|
698
|
+
isSubmenu: t = !1,
|
|
699
|
+
isInsideSubmenu: n = !1,
|
|
700
|
+
emitter: r
|
|
701
|
+
}) {
|
|
118
702
|
const i = `_${Math.random().toString(36).slice(2, 11)}`;
|
|
119
|
-
if (typeof
|
|
120
|
-
const E = `<span>${
|
|
121
|
-
|
|
122
|
-
const
|
|
703
|
+
if (typeof e != "string" && "text" in e) {
|
|
704
|
+
const E = `<span>${e.text}</span>`, v = _(E), p = document.createElement("li");
|
|
705
|
+
e.classname = e.classname || "", e.icon && (e.classname === "" ? e.classname = a.icon : e.classname.includes(a.icon) === !1 && (e.classname += ` ${a.icon}`), p.setAttribute("style", `background-image:url(${e.icon})`)), p.id = i, p.className = e.classname, p.append(v), s.append(p);
|
|
706
|
+
const b = {
|
|
123
707
|
id: i,
|
|
124
|
-
isSubmenu:
|
|
125
|
-
isInsideSubmenu:
|
|
708
|
+
isSubmenu: t,
|
|
709
|
+
isInsideSubmenu: n,
|
|
126
710
|
isSeparator: !1,
|
|
127
|
-
callback: "callback" in
|
|
128
|
-
data: "data" in
|
|
711
|
+
callback: "callback" in e ? e.callback : null,
|
|
712
|
+
data: "data" in e ? e.data : null
|
|
129
713
|
};
|
|
130
|
-
return
|
|
714
|
+
return r.emit(m.ADD_MENU_ENTRY, b, p), p;
|
|
131
715
|
}
|
|
132
|
-
const o = `<li id="${i}" class="${
|
|
133
|
-
|
|
134
|
-
const
|
|
716
|
+
const o = `<li id="${i}" class="${a.separator}"><hr></li>`, l = _(o);
|
|
717
|
+
s.append(l);
|
|
718
|
+
const u = s.lastChild, c = {
|
|
135
719
|
id: i,
|
|
136
720
|
isSubmenu: !1,
|
|
137
721
|
isInsideSubmenu: !1,
|
|
@@ -139,51 +723,70 @@ function N(n, t, e = !1, s = !1) {
|
|
|
139
723
|
callback: null,
|
|
140
724
|
data: null
|
|
141
725
|
};
|
|
142
|
-
return
|
|
726
|
+
return r.emit(m.ADD_MENU_ENTRY, c, u), u;
|
|
143
727
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
728
|
+
function O({
|
|
729
|
+
container: s,
|
|
730
|
+
items: e,
|
|
731
|
+
menuWidth: t,
|
|
732
|
+
isInsideSubmenu: n,
|
|
733
|
+
emitter: r
|
|
734
|
+
}) {
|
|
735
|
+
e.forEach((i) => {
|
|
146
736
|
if (typeof i != "string" && "items" in i && Array.isArray(i.items)) {
|
|
147
|
-
const o =
|
|
148
|
-
o.classList.add(
|
|
737
|
+
const o = $({ parentNode: s, item: i, isSubmenu: !0, emitter: r });
|
|
738
|
+
o.classList.add(a.submenu);
|
|
149
739
|
const l = document.createElement("ul");
|
|
150
|
-
l.classList.add(
|
|
740
|
+
l.classList.add(a.container), l.style.width = `${t}px`, o.append(l), O({
|
|
741
|
+
emitter: r,
|
|
742
|
+
menuWidth: t,
|
|
743
|
+
container: l,
|
|
744
|
+
items: i.items,
|
|
745
|
+
isInsideSubmenu: !0
|
|
746
|
+
});
|
|
151
747
|
} else
|
|
152
|
-
|
|
748
|
+
$({
|
|
749
|
+
parentNode: s,
|
|
750
|
+
item: i,
|
|
751
|
+
isSubmenu: !1,
|
|
752
|
+
isInsideSubmenu: n,
|
|
753
|
+
emitter: r
|
|
754
|
+
});
|
|
153
755
|
});
|
|
154
756
|
}
|
|
155
|
-
function
|
|
156
|
-
if (!
|
|
157
|
-
throw new Error(
|
|
757
|
+
function L(s, e) {
|
|
758
|
+
if (!s)
|
|
759
|
+
throw new Error(e);
|
|
158
760
|
}
|
|
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
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
761
|
+
class fe extends ie {
|
|
762
|
+
constructor(t = {}) {
|
|
763
|
+
L(typeof t == "object", "@param `opts` should be object type!");
|
|
764
|
+
const n = document.createElement("div");
|
|
765
|
+
super({ element: n });
|
|
766
|
+
h(this, "map");
|
|
767
|
+
h(this, "emitter", new oe());
|
|
768
|
+
h(this, "container");
|
|
769
|
+
h(this, "coordinate", []);
|
|
770
|
+
h(this, "pixel", []);
|
|
771
|
+
h(this, "contextMenuEventListener");
|
|
772
|
+
h(this, "entryCallbackEventListener");
|
|
773
|
+
h(this, "mapMoveListener");
|
|
774
|
+
h(this, "lineHeight", 0);
|
|
775
|
+
h(this, "disabled");
|
|
776
|
+
h(this, "opened");
|
|
777
|
+
h(this, "items", []);
|
|
778
|
+
h(this, "menuEntries", /* @__PURE__ */ new Map());
|
|
779
|
+
h(this, "options");
|
|
780
|
+
this.options = { ...ue, ...t };
|
|
781
|
+
const r = document.createElement("ul");
|
|
782
|
+
n.append(r), n.style.width = `${this.options.width}px`, n.classList.add(
|
|
783
|
+
a.container,
|
|
784
|
+
a.unselectable,
|
|
785
|
+
a.hidden
|
|
786
|
+
), this.container = n, this.contextMenuEventListener = (i) => {
|
|
787
|
+
this.handleContextMenu(i);
|
|
788
|
+
}, this.entryCallbackEventListener = (i) => {
|
|
789
|
+
this.handleEntryCallback(i);
|
|
187
790
|
}, this.mapMoveListener = () => {
|
|
188
791
|
this.handleMapMove();
|
|
189
792
|
}, this.disabled = !1, this.opened = !1, window.addEventListener(
|
|
@@ -195,8 +798,8 @@ class Y extends I {
|
|
|
195
798
|
);
|
|
196
799
|
}
|
|
197
800
|
clear() {
|
|
198
|
-
for (const
|
|
199
|
-
this.removeMenuEntry(
|
|
801
|
+
for (const t of this.menuEntries.keys())
|
|
802
|
+
this.removeMenuEntry(t);
|
|
200
803
|
this.container.replaceChildren(), this.container.append(document.createElement("ul"));
|
|
201
804
|
}
|
|
202
805
|
enable() {
|
|
@@ -206,141 +809,147 @@ class Y extends I {
|
|
|
206
809
|
this.disabled = !0;
|
|
207
810
|
}
|
|
208
811
|
getDefaultItems() {
|
|
209
|
-
return
|
|
812
|
+
return P;
|
|
210
813
|
}
|
|
211
814
|
countItems() {
|
|
212
815
|
return this.menuEntries.size;
|
|
213
816
|
}
|
|
214
|
-
extend(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.options.width
|
|
219
|
-
|
|
817
|
+
extend(t) {
|
|
818
|
+
L(Array.isArray(t), "@param `items` should be an Array."), O({
|
|
819
|
+
items: t,
|
|
820
|
+
emitter: this.emitter,
|
|
821
|
+
menuWidth: this.options.width,
|
|
822
|
+
container: this.container.firstElementChild
|
|
823
|
+
});
|
|
220
824
|
}
|
|
221
825
|
closeMenu() {
|
|
222
|
-
this.opened = !1, this.container.classList.add(
|
|
826
|
+
this.opened = !1, this.container.classList.add(a.hidden), this.dispatchEvent(m.CLOSE);
|
|
223
827
|
}
|
|
224
828
|
isOpen() {
|
|
225
829
|
return this.opened;
|
|
226
830
|
}
|
|
227
|
-
updatePosition(
|
|
228
|
-
|
|
831
|
+
updatePosition(t) {
|
|
832
|
+
L(Array.isArray(t), "@param `pixel` should be an Array."), this.isOpen() && (this.pixel = t, this.positionContainer());
|
|
229
833
|
}
|
|
230
834
|
pop() {
|
|
231
|
-
const
|
|
232
|
-
|
|
835
|
+
const t = Array.from(this.menuEntries.keys()).pop();
|
|
836
|
+
t && this.removeMenuEntry(t);
|
|
233
837
|
}
|
|
234
838
|
shift() {
|
|
235
|
-
const
|
|
236
|
-
|
|
839
|
+
const t = Array.from(this.menuEntries.keys()).shift();
|
|
840
|
+
t && this.removeMenuEntry(t);
|
|
237
841
|
}
|
|
238
|
-
push(
|
|
239
|
-
|
|
842
|
+
push(t) {
|
|
843
|
+
t && this.extend([t]);
|
|
240
844
|
}
|
|
241
|
-
setMap(
|
|
242
|
-
if (super.setMap(
|
|
243
|
-
this.map =
|
|
845
|
+
setMap(t) {
|
|
846
|
+
if (super.setMap(t), t) {
|
|
847
|
+
this.map = t, t.getViewport().addEventListener(
|
|
848
|
+
this.options.eventType,
|
|
849
|
+
this.contextMenuEventListener,
|
|
850
|
+
!1
|
|
851
|
+
), t.on("movestart", () => {
|
|
244
852
|
this.handleMapMove();
|
|
245
|
-
}),
|
|
246
|
-
|
|
247
|
-
(
|
|
248
|
-
this.handleAddMenuEntry(
|
|
853
|
+
}), this.emitter.on(
|
|
854
|
+
m.ADD_MENU_ENTRY,
|
|
855
|
+
(r, i) => {
|
|
856
|
+
this.handleAddMenuEntry(r, i);
|
|
249
857
|
},
|
|
250
858
|
this
|
|
251
|
-
), this.items = this.options.defaultItems ? this.options.items.concat(
|
|
252
|
-
this.
|
|
253
|
-
this.
|
|
254
|
-
this.options.width
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
859
|
+
), this.items = this.options.defaultItems ? this.options.items.concat(P) : this.options.items, O({
|
|
860
|
+
items: this.items,
|
|
861
|
+
emitter: this.emitter,
|
|
862
|
+
menuWidth: this.options.width,
|
|
863
|
+
container: this.container.firstElementChild
|
|
864
|
+
});
|
|
865
|
+
const n = this.getMenuEntriesLength();
|
|
866
|
+
this.lineHeight = n > 0 ? this.container.offsetHeight / n : de(this.container);
|
|
258
867
|
} else
|
|
259
868
|
this.removeListeners(), this.clear();
|
|
260
869
|
}
|
|
261
870
|
removeListeners() {
|
|
262
|
-
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1),
|
|
871
|
+
this.map.getViewport().removeEventListener(this.options.eventType, this.contextMenuEventListener, !1), this.emitter.off(m.ADD_MENU_ENTRY);
|
|
263
872
|
}
|
|
264
|
-
removeMenuEntry(
|
|
265
|
-
|
|
266
|
-
|
|
873
|
+
removeMenuEntry(t) {
|
|
874
|
+
let n = document.getElementById(t);
|
|
875
|
+
n?.remove(), n = null, this.menuEntries.delete(t);
|
|
267
876
|
}
|
|
268
|
-
handleContextMenu(
|
|
269
|
-
this.coordinate = this.map.getEventCoordinate(
|
|
270
|
-
new
|
|
271
|
-
type: d.BEFOREOPEN,
|
|
877
|
+
handleContextMenu(t) {
|
|
878
|
+
this.coordinate = this.map.getEventCoordinate(t), this.pixel = this.map.getEventPixel(t), this.dispatchEvent(
|
|
879
|
+
new R({
|
|
272
880
|
map: this.map,
|
|
273
|
-
originalEvent:
|
|
881
|
+
originalEvent: t,
|
|
882
|
+
type: m.BEFOREOPEN
|
|
274
883
|
})
|
|
275
|
-
), !this.disabled && (this.options.eventType ===
|
|
276
|
-
this.openMenu(
|
|
277
|
-
}),
|
|
884
|
+
), !this.disabled && (this.options.eventType === N.CONTEXTMENU && (t.stopPropagation(), t.preventDefault()), setTimeout(() => {
|
|
885
|
+
this.openMenu(t);
|
|
886
|
+
}), t.target?.addEventListener(
|
|
278
887
|
"pointerdown",
|
|
279
|
-
(
|
|
280
|
-
this.opened && (
|
|
888
|
+
(n) => {
|
|
889
|
+
this.opened && (n.stopPropagation(), this.closeMenu());
|
|
281
890
|
},
|
|
282
891
|
{ once: !0 }
|
|
283
892
|
));
|
|
284
893
|
}
|
|
285
|
-
openMenu(
|
|
286
|
-
this.opened = !0, this.positionContainer(), this.container.classList.remove(
|
|
287
|
-
new
|
|
288
|
-
type: d.OPEN,
|
|
894
|
+
openMenu(t) {
|
|
895
|
+
this.opened = !0, this.positionContainer(), this.container.classList.remove(a.hidden), this.dispatchEvent(
|
|
896
|
+
new R({
|
|
289
897
|
map: this.map,
|
|
290
|
-
originalEvent:
|
|
898
|
+
originalEvent: t,
|
|
899
|
+
type: m.OPEN
|
|
291
900
|
})
|
|
292
901
|
);
|
|
293
902
|
}
|
|
294
903
|
getMenuEntriesLength() {
|
|
295
904
|
return Array.from(this.menuEntries).filter(
|
|
296
|
-
([,
|
|
905
|
+
([, t]) => t.isSeparator === !1 && t.isSubmenu === !1 && t.isInsideSubmenu === !1
|
|
297
906
|
).length;
|
|
298
907
|
}
|
|
299
908
|
positionContainer() {
|
|
300
|
-
const
|
|
301
|
-
w:
|
|
302
|
-
h:
|
|
303
|
-
},
|
|
909
|
+
const t = this.map.getSize() || [0, 0], n = {
|
|
910
|
+
w: t[0] - this.pixel[0],
|
|
911
|
+
h: t[1] - this.pixel[1]
|
|
912
|
+
}, r = this.getMenuEntriesLength(), i = {
|
|
304
913
|
w: this.container.offsetWidth,
|
|
305
914
|
// a cheap way to recalculate container height
|
|
306
915
|
// since offsetHeight is like cached
|
|
307
|
-
h: Math.round(this.lineHeight *
|
|
308
|
-
},
|
|
309
|
-
this.container.style.left = `${
|
|
310
|
-
const
|
|
311
|
-
(
|
|
916
|
+
h: Math.round(this.lineHeight * r)
|
|
917
|
+
}, o = n.w >= i.w ? this.pixel[0] + 5 : this.pixel[0] - i.w;
|
|
918
|
+
this.container.style.left = `${o}px`, this.container.style.top = n.h >= i.h ? `${this.pixel[1] - 10}px` : `${this.pixel[1] - i.h}px`, this.container.style.right = "auto", this.container.style.bottom = "auto", n.w -= i.w;
|
|
919
|
+
const l = (E) => Array.from(E.children).filter(
|
|
920
|
+
(v) => v.tagName === "LI" && v.classList.contains(a.submenu)
|
|
312
921
|
);
|
|
313
|
-
let
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
`ul.${
|
|
922
|
+
let u = 0;
|
|
923
|
+
const c = (E, v) => {
|
|
924
|
+
u += 1, l(E).forEach((b) => {
|
|
925
|
+
const H = v >= i.w ? i.w - 8 : (i.w + 8) * -1, d = b.querySelector(
|
|
926
|
+
`ul.${a.container}`
|
|
318
927
|
), k = Math.round(
|
|
319
|
-
this.lineHeight * Array.from(
|
|
928
|
+
this.lineHeight * Array.from(d.children).filter((K) => K.tagName === "LI").length
|
|
320
929
|
);
|
|
321
|
-
|
|
930
|
+
d.style.left = `${H}px`, d.style.right = "auto", d.style.top = n.h >= k + i.h ? "0" : `-${d.offsetHeight - 25}px`, d.style.bottom = "auto", d.style.zIndex = String(u), l(d).length > 0 && c(d, v - i.w);
|
|
322
931
|
});
|
|
323
932
|
};
|
|
324
|
-
|
|
933
|
+
c(this.container.firstElementChild, n.w);
|
|
325
934
|
}
|
|
326
935
|
handleMapMove() {
|
|
327
936
|
this.closeMenu();
|
|
328
937
|
}
|
|
329
|
-
handleEntryCallback(
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
938
|
+
handleEntryCallback(t) {
|
|
939
|
+
t.preventDefault(), t.stopPropagation();
|
|
940
|
+
const n = t.currentTarget, r = this.menuEntries.get(n.id);
|
|
941
|
+
if (!r)
|
|
333
942
|
return;
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
943
|
+
const i = {
|
|
944
|
+
data: r.data,
|
|
945
|
+
coordinate: this.coordinate
|
|
337
946
|
};
|
|
338
|
-
this.closeMenu(),
|
|
947
|
+
this.closeMenu(), r.callback?.(i, this.map);
|
|
339
948
|
}
|
|
340
|
-
handleAddMenuEntry(
|
|
341
|
-
this.menuEntries.set(
|
|
949
|
+
handleAddMenuEntry(t, n) {
|
|
950
|
+
this.menuEntries.set(t.id, t), this.positionContainer(), "callback" in t && typeof t.callback == "function" && n.addEventListener("click", this.entryCallbackEventListener, !1);
|
|
342
951
|
}
|
|
343
952
|
}
|
|
344
953
|
export {
|
|
345
|
-
|
|
954
|
+
fe as default
|
|
346
955
|
};
|