ol-contextmenu 4.0.0 → 5.0.0-alpha

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.
@@ -1,809 +0,0 @@
1
-
2
- /*!
3
- * ol-contextmenu - v4.0.0
4
- * https://github.com/jonataswalker/ol-contextmenu
5
- * Built: Wed Nov 20 2019 13:29:37 GMT-0300 (Brasilia Standard Time)
6
- */
7
-
8
- (function (global, factory) {
9
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('ol/control/Control')) :
10
- typeof define === 'function' && define.amd ? define(['ol/control/Control'], factory) :
11
- (global = global || self, global.ContextMenu = factory(global.ol.control.Control));
12
- }(this, (function (Control) { 'use strict';
13
-
14
- Control = Control && Control.hasOwnProperty('default') ? Control['default'] : Control;
15
-
16
- var namespace = 'ol-ctx-menu';
17
-
18
- var cssVars = {
19
- namespace: namespace,
20
- container: (namespace + "-container"),
21
- separator: (namespace + "-separator"),
22
- submenu: (namespace + "-submenu"),
23
- hidden: (namespace + "-hidden"),
24
- icon: (namespace + "-icon"),
25
- zoomIn: (namespace + "-zoom-in"),
26
- zoomOut: (namespace + "-zoom-out"),
27
- unselectable: 'ol-unselectable',
28
- };
29
-
30
- var CSS_VARS = cssVars;
31
-
32
- var EVENT_TYPE = {
33
- /**
34
- * Triggered before context menu is open.
35
- */
36
- BEFOREOPEN: 'beforeopen',
37
- /**
38
- * Triggered when context menu is open.
39
- */
40
- OPEN: 'open',
41
- /**
42
- * Triggered when context menu is closed.
43
- */
44
- CLOSE: 'close',
45
- /**
46
- * Internal. Triggered when a menu entry is added.
47
- */
48
- ADD_MENU_ENTRY: 'add-menu-entry',
49
- /**
50
- * Internal.
51
- */
52
- CONTEXTMENU: 'contextmenu',
53
- /**
54
- * Internal.
55
- */
56
- HOVER: 'mouseover',
57
- };
58
-
59
- var DEFAULT_OPTIONS = {
60
- width: 150,
61
- scrollAt: 4,
62
- eventType: EVENT_TYPE.CONTEXTMENU,
63
- defaultItems: true,
64
- };
65
-
66
- var DEFAULT_ITEMS = [
67
- {
68
- text: 'Zoom In',
69
- classname: ((cssVars.zoomIn) + " " + (cssVars.icon)),
70
- callback: function (obj, map) {
71
- var view = map.getView();
72
- view.animate({
73
- zoom: +view.getZoom() + 1,
74
- duration: 700,
75
- center: obj.coordinate,
76
- });
77
- },
78
- },
79
- {
80
- text: 'Zoom Out',
81
- classname: ((cssVars.zoomOut) + " " + (cssVars.icon)),
82
- callback: function (obj, map) {
83
- var view = map.getView();
84
- view.animate({
85
- zoom: +view.getZoom() - 1,
86
- duration: 700,
87
- center: obj.coordinate,
88
- });
89
- },
90
- } ];
91
-
92
- /**
93
- * Overwrites obj1's values with obj2's and adds
94
- * obj2's if non existent in obj1
95
- * @returns obj3 a new object based on obj1 and obj2
96
- */
97
- function mergeOptions(obj1, obj2) {
98
- var obj3 = {};
99
- for (var attr1 in obj1) { obj3[attr1] = obj1[attr1]; }
100
- for (var attr2 in obj2) { obj3[attr2] = obj2[attr2]; }
101
- return obj3;
102
- }
103
-
104
- function assert(condition, message) {
105
- if ( message === void 0 ) message = 'Assertion failed';
106
-
107
- if (!condition) {
108
- if (typeof Error !== 'undefined') { throw new Error(message); }
109
- throw message; // Fallback
110
- }
111
- }
112
-
113
- /**
114
- * Does str contain test?
115
- * @param {String} str_test
116
- * @param {String} str
117
- * @returns Boolean
118
- */
119
- function contains(str_test, str) {
120
- return !!~str.indexOf(str_test);
121
- }
122
-
123
- function getUniqueId() {
124
- return (
125
- '_' +
126
- Math.random()
127
- .toString(36)
128
- .substr(2, 9)
129
- );
130
- }
131
-
132
- function isDefAndNotNull(val) {
133
- // Note that undefined == null.
134
- return val != null; // eslint-disable-line no-eq-null
135
- }
136
-
137
- function isNumeric(str) {
138
- return /^\d+$/.test(str);
139
- }
140
-
141
- /**
142
- * @param {Element|Array<Element>} element DOM node or array of nodes.
143
- * @param {String|Array<String>} classname Class or array of classes.
144
- * For example: 'class1 class2' or ['class1', 'class2']
145
- * @param {Number|undefined} timeout Timeout to remove a class.
146
- */
147
- function addClass(element, classname, timeout) {
148
- if (Array.isArray(element)) {
149
- element.forEach(function (each) { return addClass(each, classname); });
150
- return;
151
- }
152
-
153
- var array = Array.isArray(classname) ? classname : classname.split(/\s+/);
154
- var i = array.length;
155
-
156
- while (i--) {
157
- if (!hasClass(element, array[i])) {
158
- _addClass(element, array[i], timeout);
159
- }
160
- }
161
- }
162
-
163
- /**
164
- * @param {Element|Array<Element>} element DOM node or array of nodes.
165
- * @param {String|Array<String>} classname Class or array of classes.
166
- * For example: 'class1 class2' or ['class1', 'class2']
167
- * @param {Number|undefined} timeout Timeout to add a class.
168
- */
169
- function removeClass(element, classname, timeout) {
170
- if (Array.isArray(element)) {
171
- element.forEach(function (each) { return removeClass(each, classname, timeout); });
172
- return;
173
- }
174
-
175
- var array = Array.isArray(classname) ? classname : classname.split(/\s+/);
176
- var i = array.length;
177
-
178
- while (i--) {
179
- if (hasClass(element, array[i])) {
180
- _removeClass(element, array[i], timeout);
181
- }
182
- }
183
- }
184
-
185
- /**
186
- * @param {Element} element DOM node.
187
- * @param {String} classname Classname.
188
- * @return {Boolean}
189
- */
190
- function hasClass(element, c) {
191
- // use native if available
192
- return element.classList
193
- ? element.classList.contains(c)
194
- : classRegex(c).test(element.className);
195
- }
196
-
197
- /**
198
- * Abstraction to querySelectorAll for increased
199
- * performance and greater usability
200
- * @param {String} selector
201
- * @param {Element} context (optional)
202
- * @param {Boolean} find_all (optional)
203
- * @return (find_all) {Element} : {Array}
204
- */
205
- function find(selector, context, find_all) {
206
- if ( context === void 0 ) context = window.document;
207
-
208
- var simpleRe = /^(#?[\w-]+|\.[\w-.]+)$/,
209
- periodRe = /\./g,
210
- slice = Array.prototype.slice,
211
- matches = [];
212
-
213
- // Redirect call to the more performant function
214
- // if it's a simple selector and return an array
215
- // for easier usage
216
- if (simpleRe.test(selector)) {
217
- switch (selector[0]) {
218
- case '#':
219
- matches = [$(selector.substr(1))];
220
- break;
221
- case '.':
222
- matches = slice.call(
223
- context.getElementsByClassName(
224
- selector.substr(1).replace(periodRe, ' ')
225
- )
226
- );
227
- break;
228
- default:
229
- matches = slice.call(context.getElementsByTagName(selector));
230
- }
231
- } else {
232
- // If not a simple selector, query the DOM as usual
233
- // and return an array for easier usage
234
- matches = slice.call(context.querySelectorAll(selector));
235
- }
236
-
237
- return find_all ? matches : matches[0];
238
- }
239
-
240
- function $(id) {
241
- id = id[0] === '#' ? id.substr(1, id.length) : id;
242
- return document.getElementById(id);
243
- }
244
-
245
- function offset(element) {
246
- var rect = element.getBoundingClientRect();
247
- var docEl = document.documentElement;
248
- return {
249
- left: rect.left + window.pageXOffset - docEl.clientLeft,
250
- top: rect.top + window.pageYOffset - docEl.clientTop,
251
- width: element.offsetWidth,
252
- height: element.offsetHeight,
253
- };
254
- }
255
-
256
- function getViewportSize() {
257
- return {
258
- w: window.innerWidth || document.documentElement.clientWidth,
259
- h: window.innerHeight || document.documentElement.clientHeight,
260
- };
261
- }
262
-
263
- function createFragment(html) {
264
- var frag = document.createDocumentFragment(),
265
- temp = document.createElement('div');
266
- temp.innerHTML = html;
267
- while (temp.firstChild) {
268
- frag.appendChild(temp.firstChild);
269
- }
270
- return frag;
271
- }
272
-
273
- function classRegex(classname) {
274
- return new RegExp(("(^|\\s+) " + classname + " (\\s+|$)"));
275
- }
276
-
277
- function _addClass(el, klass, timeout) {
278
- // use native if available
279
- if (el.classList) {
280
- el.classList.add(klass);
281
- } else {
282
- el.className = (el.className + ' ' + klass).trim();
283
- }
284
-
285
- if (timeout && isNumeric(timeout)) {
286
- window.setTimeout(function () { return _removeClass(el, klass); }, timeout);
287
- }
288
- }
289
-
290
- function _removeClass(el, klass, timeout) {
291
- if (el.classList) {
292
- el.classList.remove(klass);
293
- } else {
294
- el.className = el.className.replace(classRegex(klass), ' ').trim();
295
- }
296
- if (timeout && isNumeric(timeout)) {
297
- window.setTimeout(function () { return _addClass(el, klass); }, timeout);
298
- }
299
- }
300
-
301
- /**
302
- * @class Internal
303
- */
304
- var Internal = function Internal(base) {
305
- /**
306
- * @type {ol.control.Control}
307
- */
308
- this.Base = base;
309
- /**
310
- * @type {ol.Map}
311
- */
312
- this.map = undefined;
313
- /**
314
- * @type {Element}
315
- */
316
- this.viewport = undefined;
317
- /**
318
- * @type {ol.Coordinate}
319
- */
320
- this.coordinateClicked = undefined;
321
- /**
322
- * @type {ol.Pixel}
323
- */
324
- this.pixelClicked = undefined;
325
- /**
326
- * @type {Number}
327
- */
328
- this.lineHeight = 0;
329
- /**
330
- * @type {Object}
331
- */
332
- this.items = {};
333
- /**
334
- * @type {Boolean}
335
- */
336
- this.opened = false;
337
- /**
338
- * @type {Object}
339
- */
340
- this.submenu = {
341
- left: base.options.width - 15 + 'px',
342
- lastLeft: '', // string + px
343
- };
344
- /**
345
- * @type {Function}
346
- */
347
- this.eventHandler = this.handleEvent.bind(this);
348
- return this;
349
- };
350
-
351
- Internal.prototype.init = function init (map) {
352
- this.map = map;
353
- this.viewport = map.getViewport();
354
- this.setListeners();
355
- this.Base.Html.createMenu();
356
-
357
- this.lineHeight =
358
- this.getItemsLength() > 0
359
- ? this.Base.container.offsetHeight / this.getItemsLength()
360
- : this.Base.Html.cloneAndGetLineHeight();
361
- };
362
-
363
- Internal.prototype.getItemsLength = function getItemsLength () {
364
- var this$1 = this;
365
-
366
- var count = 0;
367
- Object.keys(this.items).forEach(function (k) {
368
- if (this$1.items[k].submenu || this$1.items[k].separator) { return; }
369
- count++;
370
- });
371
- return count;
372
- };
373
-
374
- Internal.prototype.getPixelClicked = function getPixelClicked () {
375
- return this.pixelClicked;
376
- };
377
-
378
- Internal.prototype.getCoordinateClicked = function getCoordinateClicked () {
379
- return this.coordinateClicked;
380
- };
381
-
382
- Internal.prototype.positionContainer = function positionContainer (pixel) {
383
- var this$1 = this;
384
-
385
- var container = this.Base.container;
386
- var mapSize = this.map.getSize();
387
- // how much (width) space left over
388
- var space_left_h = mapSize[1] - pixel[1];
389
- // how much (height) space left over
390
- var space_left_w = mapSize[0] - pixel[0];
391
-
392
- var menuSize = {
393
- w: container.offsetWidth,
394
- // a cheap way to recalculate container height
395
- // since offsetHeight is like cached
396
- h: Math.round(this.lineHeight * this.getItemsLength()),
397
- };
398
- // submenus
399
- var subs = find(("li." + (CSS_VARS.submenu) + ">div"), container, true);
400
-
401
- if (space_left_w >= menuSize.w) {
402
- container.style.right = 'auto';
403
- container.style.left = (pixel[0] + 5) + "px";
404
- } else {
405
- container.style.left = 'auto';
406
- container.style.right = '15px';
407
- }
408
- // set top or bottom
409
- if (space_left_h >= menuSize.h) {
410
- container.style.bottom = 'auto';
411
- container.style.top = (pixel[1] - 10) + "px";
412
- } else {
413
- container.style.top = 'auto';
414
- container.style.bottom = 0;
415
- }
416
-
417
- removeClass(container, CSS_VARS.hidden);
418
-
419
- if (subs.length) {
420
- if (space_left_w < menuSize.w * 2) {
421
- // no space (at right) for submenu
422
- // position them at left
423
- this.submenu.lastLeft = "-" + (menuSize.w) + "px";
424
- } else {
425
- this.submenu.lastLeft = this.submenu.left;
426
- }
427
- subs.forEach(function (sub) {
428
- // is there enough space for submenu height?
429
- var viewport = getViewportSize();
430
- var sub_offset = offset(sub);
431
- var sub_height = sub_offset.height;
432
- var sub_top = space_left_h - sub_height;
433
-
434
- if (sub_top < 0) {
435
- sub_top = sub_height - (viewport.h - sub_offset.top);
436
- sub.style.top = "-" + sub_top + "px";
437
- }
438
- sub.style.left = this$1.submenu.lastLeft;
439
- });
440
- }
441
- };
442
-
443
- Internal.prototype.openMenu = function openMenu (pixel, coordinate) {
444
- this.Base.dispatchEvent({
445
- type: EVENT_TYPE.OPEN,
446
- pixel: pixel,
447
- coordinate: coordinate,
448
- });
449
- this.opened = true;
450
- this.positionContainer(pixel);
451
- };
452
-
453
- Internal.prototype.closeMenu = function closeMenu () {
454
- this.opened = false;
455
- addClass(this.Base.container, CSS_VARS.hidden);
456
- this.Base.dispatchEvent({
457
- type: EVENT_TYPE.CLOSE,
458
- });
459
- };
460
-
461
- Internal.prototype.setListeners = function setListeners () {
462
- this.viewport.addEventListener(
463
- this.Base.options.eventType,
464
- this.eventHandler,
465
- false
466
- );
467
- };
468
-
469
- Internal.prototype.removeListeners = function removeListeners () {
470
- this.viewport.removeEventListener(
471
- this.Base.options.eventType,
472
- this.eventHandler,
473
- false
474
- );
475
- };
476
-
477
- Internal.prototype.handleEvent = function handleEvent (evt) {
478
- var this_ = this;
479
-
480
- this.coordinateClicked = this.map.getEventCoordinate(evt);
481
- this.pixelClicked = this.map.getEventPixel(evt);
482
-
483
- this.Base.dispatchEvent({
484
- type: EVENT_TYPE.BEFOREOPEN,
485
- pixel: this.pixelClicked,
486
- coordinate: this.coordinateClicked,
487
- });
488
-
489
- if (this.Base.disabled) { return; }
490
-
491
- if (this.Base.options.eventType === EVENT_TYPE.CONTEXTMENU) {
492
- // don't be intrusive with other event types
493
- evt.stopPropagation();
494
- evt.preventDefault();
495
- }
496
-
497
- this.openMenu(this.pixelClicked, this.coordinateClicked);
498
-
499
- //one-time fire
500
- evt.target.addEventListener(
501
- 'click',
502
- {
503
- handleEvent: function(e) {
504
- this_.closeMenu();
505
- evt.target.removeEventListener(e.type, this, false);
506
- },
507
- },
508
- false
509
- );
510
- };
511
-
512
- Internal.prototype.setItemListener = function setItemListener (li, index) {
513
- var this_ = this;
514
- if (li && typeof this.items[index].callback === 'function') {
515
- (function(callback) {
516
- li.addEventListener(
517
- 'click',
518
- function(evt) {
519
- evt.preventDefault();
520
- var obj = {
521
- coordinate: this_.getCoordinateClicked(),
522
- data: this_.items[index].data || null,
523
- };
524
- this_.closeMenu();
525
- callback(obj, this_.map);
526
- },
527
- false
528
- );
529
- })(this.items[index].callback);
530
- }
531
- };
532
-
533
- /**
534
- * @class Html
535
- */
536
- var Html = function Html(base) {
537
- this.Base = base;
538
- this.Base.container = this.container = this.createContainer(true);
539
- return this;
540
- };
541
-
542
- Html.prototype.createContainer = function createContainer (hidden) {
543
- var container = document.createElement('div');
544
- var ul = document.createElement('ul');
545
- var klasses = [CSS_VARS.container, CSS_VARS.unselectable];
546
-
547
- hidden && klasses.push(CSS_VARS.hidden);
548
- container.className = klasses.join(' ');
549
- container.style.width = parseInt(this.Base.options.width, 10) + 'px';
550
- container.appendChild(ul);
551
- return container;
552
- };
553
-
554
- Html.prototype.createMenu = function createMenu () {
555
- var items = [];
556
-
557
- if ('items' in this.Base.options) {
558
- items = this.Base.options.defaultItems
559
- ? this.Base.options.items.concat(DEFAULT_ITEMS)
560
- : this.Base.options.items;
561
- } else if (this.Base.options.defaultItems) {
562
- items = DEFAULT_ITEMS;
563
- }
564
- // no item
565
- if (items.length === 0) { return false; }
566
- // create entries
567
- items.forEach(this.addMenuEntry, this);
568
- };
569
-
570
- Html.prototype.addMenuEntry = function addMenuEntry (item) {
571
- var this$1 = this;
572
-
573
- if (item.items && Array.isArray(item.items)) {
574
- // submenu - only a second level
575
- item.classname = item.classname || '';
576
- if (!contains(CSS_VARS.submenu, item.classname)) {
577
- item.classname = item.classname.length
578
- ? ' ' + CSS_VARS.submenu
579
- : CSS_VARS.submenu;
580
- }
581
-
582
- var li = this.generateHtmlAndPublish(this.container, item);
583
- var sub = this.createContainer();
584
- sub.style.left =
585
- this.Base.Internal.submenu.lastLeft || this.Base.Internal.submenu.left;
586
- li.appendChild(sub);
587
-
588
- item.items.forEach(function (each) {
589
- this$1.generateHtmlAndPublish(sub, each, true);
590
- });
591
- } else {
592
- this.generateHtmlAndPublish(this.container, item);
593
- }
594
- };
595
-
596
- Html.prototype.generateHtmlAndPublish = function generateHtmlAndPublish (parent, item, submenu) {
597
- var index = getUniqueId();
598
- var html,
599
- frag,
600
- element,
601
- separator = false;
602
-
603
- // separator
604
- if (typeof item === 'string' && item.trim() === '-') {
605
- html = "<li id=\"" + index + "\" class=\"" + (CSS_VARS.separator) + "\"><hr></li>";
606
- frag = createFragment(html);
607
- // http://stackoverflow.com/a/13347298/4640499
608
- element = [].slice.call(frag.childNodes, 0)[0];
609
- parent.firstChild.appendChild(frag);
610
- // to exclude from lineHeight calculation
611
- separator = true;
612
- } else {
613
- item.classname = item.classname || '';
614
- html = "<span>" + (item.text) + "</span>";
615
- frag = createFragment(html);
616
- element = document.createElement('li');
617
-
618
- if (item.icon) {
619
- if (item.classname === '') {
620
- item.classname = CSS_VARS.icon;
621
- } else if (item.classname.indexOf(CSS_VARS.icon) === -1) {
622
- item.classname += " " + (CSS_VARS.icon);
623
- }
624
- element.setAttribute('style', ("background-image:url(" + (item.icon) + ")"));
625
- }
626
-
627
- element.id = index;
628
- element.className = item.classname;
629
- element.appendChild(frag);
630
- parent.firstChild.appendChild(element);
631
- }
632
-
633
- this.Base.Internal.items[index] = {
634
- id: index,
635
- submenu: submenu || 0,
636
- separator: separator,
637
- callback: item.callback,
638
- data: item.data || null,
639
- };
640
- this.Base.Internal.setItemListener(element, index);
641
- return element;
642
- };
643
-
644
- Html.prototype.removeMenuEntry = function removeMenuEntry (index) {
645
- var element = find('#' + index, this.container.firstChild);
646
- element && this.container.firstChild.removeChild(element);
647
- delete this.Base.Internal.items[index];
648
- };
649
-
650
- Html.prototype.cloneAndGetLineHeight = function cloneAndGetLineHeight () {
651
- // for some reason I have to calculate with 2 items
652
- var cloned = this.container.cloneNode();
653
- var frag = createFragment('<span>Foo</span>');
654
- var frag2 = createFragment('<span>Foo</span>');
655
- var element = document.createElement('li');
656
- var element2 = document.createElement('li');
657
-
658
- element.appendChild(frag);
659
- element2.appendChild(frag2);
660
- cloned.appendChild(element);
661
- cloned.appendChild(element2);
662
-
663
- this.container.parentNode.appendChild(cloned);
664
- var height = cloned.offsetHeight / 2;
665
- this.container.parentNode.removeChild(cloned);
666
- return height;
667
- };
668
-
669
- /**
670
- * @class Base
671
- * @extends {ol.control.Control}
672
- */
673
- var Base = /*@__PURE__*/(function (Control) {
674
- function Base(opt_options) {
675
- if ( opt_options === void 0 ) opt_options = {};
676
-
677
- assert(
678
- typeof opt_options == 'object',
679
- '@param `opt_options` should be object type!'
680
- );
681
-
682
- this.options = mergeOptions(DEFAULT_OPTIONS, opt_options);
683
- this.disabled = false;
684
-
685
- this.Internal = new Internal(this);
686
- this.Html = new Html(this);
687
-
688
- Control.call(this, { element: this.container });
689
- }
690
-
691
- if ( Control ) Base.__proto__ = Control;
692
- Base.prototype = Object.create( Control && Control.prototype );
693
- Base.prototype.constructor = Base;
694
-
695
- /**
696
- * Remove all elements from the menu.
697
- */
698
- Base.prototype.clear = function clear () {
699
- Object.keys(this.Internal.items).forEach(
700
- this.Html.removeMenuEntry,
701
- this.Html
702
- );
703
- };
704
-
705
- /**
706
- * Close the menu programmatically.
707
- */
708
- Base.prototype.close = function close () {
709
- this.Internal.closeMenu();
710
- };
711
-
712
- /**
713
- * Enable menu
714
- */
715
- Base.prototype.enable = function enable () {
716
- this.disabled = false;
717
- };
718
-
719
- /**
720
- * Disable menu
721
- */
722
- Base.prototype.disable = function disable () {
723
- this.disabled = true;
724
- };
725
-
726
- /**
727
- * @return {Array} Returns default items
728
- */
729
- Base.prototype.getDefaultItems = function getDefaultItems () {
730
- return DEFAULT_ITEMS;
731
- };
732
-
733
- /**
734
- * @return {Number} Returns how many items
735
- */
736
- Base.prototype.countItems = function countItems () {
737
- return Object.keys(this.Internal.items).length;
738
- };
739
-
740
- /**
741
- * Add items to the menu. This pushes each item in the provided array
742
- * to the end of the menu.
743
- * @param {Array} arr Array.
744
- */
745
- Base.prototype.extend = function extend (arr) {
746
- assert(Array.isArray(arr), '@param `arr` should be an Array.');
747
- arr.forEach(this.push, this);
748
- };
749
-
750
- Base.prototype.isOpen = function isOpen () {
751
- return this.Internal.opened;
752
- };
753
-
754
- /**
755
- * Update the menu's position.
756
- */
757
- Base.prototype.updatePosition = function updatePosition (pixel) {
758
- assert(Array.isArray(pixel), '@param `pixel` should be an Array.');
759
-
760
- if (this.isOpen()) {
761
- this.Internal.positionContainer(pixel);
762
- }
763
- };
764
-
765
- /**
766
- * Remove the last item of the menu.
767
- */
768
- Base.prototype.pop = function pop () {
769
- var keys = Object.keys(this.Internal.items);
770
- this.Html.removeMenuEntry(keys[keys.length - 1]);
771
- };
772
-
773
- /**
774
- * Insert the provided item at the end of the menu.
775
- * @param {Object|String} item Item.
776
- */
777
- Base.prototype.push = function push (item) {
778
- assert(isDefAndNotNull(item), '@param `item` must be informed.');
779
- this.Html.addMenuEntry(item);
780
- };
781
-
782
- /**
783
- * Remove the first item of the menu.
784
- */
785
- Base.prototype.shift = function shift () {
786
- this.Html.removeMenuEntry(Object.keys(this.Internal.items)[0]);
787
- };
788
-
789
- /**
790
- * Not supposed to be used on app.
791
- */
792
- Base.prototype.setMap = function setMap (map) {
793
- Control.prototype.setMap.call(this, map);
794
-
795
- if (map) {
796
- // let's start since now we have the map
797
- this.Internal.init(map, this);
798
- } else {
799
- // I'm removed from the map - remove listeners
800
- this.Internal.removeListeners();
801
- }
802
- };
803
-
804
- return Base;
805
- }(Control));
806
-
807
- return Base;
808
-
809
- })));