vrembem 1.40.1 → 1.41.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/LICENSE +1 -1
- package/dev/scripts.esm.js +633 -510
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +633 -510
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +529 -438
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +633 -510
- package/dev/scripts.umd.js.map +1 -1
- package/dev/styles.css.map +1 -1
- package/dist/scripts.esm.js +1 -1
- package/dist/scripts.esm.js.map +1 -1
- package/dist/scripts.js +1 -1
- package/dist/scripts.js.map +1 -1
- package/dist/scripts.modern.js +1 -1
- package/dist/scripts.modern.js.map +1 -1
- package/dist/scripts.umd.js +1 -1
- package/dist/scripts.umd.js.map +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +26 -26
package/dev/scripts.umd.js
CHANGED
|
@@ -39,10 +39,9 @@
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Adds a class or classes to
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param {String || Array} cl - Class(es) to add
|
|
42
|
+
* Adds a class or classes to a Node or NodeList.
|
|
43
|
+
* @param {Node || NodeList} el - Element(s) to add class(es) to.
|
|
44
|
+
* @param {String || Array} cl - Class(es) to add.
|
|
46
45
|
*/
|
|
47
46
|
var addClass = function addClass(el) {
|
|
48
47
|
var _arguments = arguments;
|
|
@@ -55,10 +54,9 @@
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
|
-
* Takes a hyphen cased string and converts it to camel case
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @returns {Boolean} - returns a camel cased string
|
|
57
|
+
* Takes a hyphen cased string and converts it to camel case.
|
|
58
|
+
* @param {String } str - the string to convert to camel case.
|
|
59
|
+
* @returns {Boolean} - returns a camel cased string.
|
|
62
60
|
*/
|
|
63
61
|
var camelCase = function camelCase(str) {
|
|
64
62
|
return str.replace(/-([a-z])/g, function (g) {
|
|
@@ -184,27 +182,25 @@
|
|
|
184
182
|
}();
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
|
-
* Get an element(s) from a selector or return value if not a string
|
|
188
|
-
*
|
|
189
|
-
* @param {
|
|
190
|
-
* @param {Boolean} single - Whether to return a single or all matches
|
|
185
|
+
* Get an element(s) from a selector or return value if not a string.
|
|
186
|
+
* @param {String} selector - Selector to query.
|
|
187
|
+
* @param {Boolean} single - Whether to return a single or all matches.
|
|
191
188
|
*/
|
|
192
189
|
var getElement = function getElement(selector, single) {
|
|
193
190
|
if (single === void 0) {
|
|
194
191
|
single = 0;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
if (typeof selector
|
|
194
|
+
if (typeof selector !== 'string') return selector;
|
|
198
195
|
return single ? document.querySelector(selector) : document.querySelectorAll(selector);
|
|
199
196
|
};
|
|
200
197
|
|
|
201
198
|
/**
|
|
202
|
-
* Checks an element or NodeList whether they contain a class or classes
|
|
199
|
+
* Checks an element or NodeList whether they contain a class or classes.
|
|
203
200
|
* Ref: https://davidwalsh.name/nodelist-array
|
|
204
|
-
*
|
|
205
|
-
* @param {
|
|
206
|
-
* @
|
|
207
|
-
* @returns {Boolean} - Returns true if class exists, otherwise false
|
|
201
|
+
* @param {Node} el - Element(s) to check class(es) on.
|
|
202
|
+
* @param {String || Array} c - Class(es) to check.
|
|
203
|
+
* @returns {Boolean} - Returns true if class exists, otherwise false.
|
|
208
204
|
*/
|
|
209
205
|
var hasClass = function hasClass(el) {
|
|
210
206
|
el = el.forEach ? el : [el];
|
|
@@ -217,10 +213,9 @@
|
|
|
217
213
|
};
|
|
218
214
|
|
|
219
215
|
/**
|
|
220
|
-
* Takes a camel cased string and converts it to hyphen case
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
223
|
-
* @returns {Boolean} - returns a hyphen cased string
|
|
216
|
+
* Takes a camel cased string and converts it to hyphen case.
|
|
217
|
+
* @param {String } str - the string to convert to hyphen case.
|
|
218
|
+
* @returns {Boolean} - returns a hyphen cased string.
|
|
224
219
|
*/
|
|
225
220
|
var hyphenCase = function hyphenCase(str) {
|
|
226
221
|
return str.replace(/([a-z][A-Z])/g, function (g) {
|
|
@@ -229,11 +224,10 @@
|
|
|
229
224
|
};
|
|
230
225
|
|
|
231
226
|
/**
|
|
232
|
-
* Moves element(s) in the DOM based on a reference and move type
|
|
233
|
-
*
|
|
234
|
-
* @param {String}
|
|
235
|
-
* @param {String}
|
|
236
|
-
* @param {String} reference - The reference element the move is relative to
|
|
227
|
+
* Moves element(s) in the DOM based on a reference and move type.
|
|
228
|
+
* @param {String} target - The element(s) to move.
|
|
229
|
+
* @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'.
|
|
230
|
+
* @param {String} reference - The reference element the move is relative to.
|
|
237
231
|
*/
|
|
238
232
|
|
|
239
233
|
function moveElement(target, type, reference) {
|
|
@@ -288,10 +282,9 @@
|
|
|
288
282
|
}
|
|
289
283
|
|
|
290
284
|
/**
|
|
291
|
-
* Remove a class or classes from an element or NodeList
|
|
292
|
-
*
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {String || Array} cl - Class(es) to remove
|
|
285
|
+
* Remove a class or classes from an element or NodeList.
|
|
286
|
+
* @param {Node || NodeList} el - Element(s) to remove class(es) from.
|
|
287
|
+
* @param {String || Array} cl - Class(es) to remove.
|
|
295
288
|
*/
|
|
296
289
|
var removeClass = function removeClass(el) {
|
|
297
290
|
var _arguments = arguments;
|
|
@@ -304,10 +297,9 @@
|
|
|
304
297
|
};
|
|
305
298
|
|
|
306
299
|
/**
|
|
307
|
-
* Toggle a class or classes on an element or NodeList
|
|
308
|
-
*
|
|
309
|
-
* @param {
|
|
310
|
-
* @param {String || Array} cl - Class(es) to toggle
|
|
300
|
+
* Toggle a class or classes on an element or NodeList.
|
|
301
|
+
* @param {Node || NodeList} el - Element(s) to toggle class(es) on.
|
|
302
|
+
* @param {String || Array} cl - Class(es) to toggle.
|
|
311
303
|
*/
|
|
312
304
|
var toggleClass = function toggleClass(el) {
|
|
313
305
|
var _arguments = arguments;
|
|
@@ -394,13 +386,39 @@
|
|
|
394
386
|
return _extends.apply(this, arguments);
|
|
395
387
|
}
|
|
396
388
|
|
|
389
|
+
function _inheritsLoose(subClass, superClass) {
|
|
390
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
391
|
+
subClass.prototype.constructor = subClass;
|
|
392
|
+
|
|
393
|
+
_setPrototypeOf(subClass, superClass);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function _setPrototypeOf(o, p) {
|
|
397
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
398
|
+
o.__proto__ = p;
|
|
399
|
+
return o;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
return _setPrototypeOf(o, p);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function _assertThisInitialized(self) {
|
|
406
|
+
if (self === void 0) {
|
|
407
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return self;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var defaults$3 = {
|
|
414
|
+
autoInit: false,
|
|
415
|
+
stateAttr: 'aria-checked',
|
|
416
|
+
stateValue: 'mixed'
|
|
417
|
+
};
|
|
418
|
+
|
|
397
419
|
var Checkbox = /*#__PURE__*/function () {
|
|
398
420
|
function Checkbox(options) {
|
|
399
|
-
this.defaults =
|
|
400
|
-
autoInit: false,
|
|
401
|
-
stateAttr: 'aria-checked',
|
|
402
|
-
stateValue: 'mixed'
|
|
403
|
-
};
|
|
421
|
+
this.defaults = defaults$3;
|
|
404
422
|
this.settings = _extends({}, this.defaults, options);
|
|
405
423
|
this.__handlerClick = this.handlerClick.bind(this);
|
|
406
424
|
if (this.settings.autoInit) this.init();
|
|
@@ -500,55 +518,6 @@
|
|
|
500
518
|
transition: true
|
|
501
519
|
};
|
|
502
520
|
|
|
503
|
-
var switchToDefault = function switchToDefault(drawerKey, obj) {
|
|
504
|
-
try {
|
|
505
|
-
// Initial guards
|
|
506
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
507
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
508
|
-
if (!hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
509
|
-
|
|
510
|
-
setInert(false, obj.settings.selectorInert);
|
|
511
|
-
setOverflowHidden(false, obj.settings.selectorOverflow);
|
|
512
|
-
removeClass(drawer, obj.settings.classModal);
|
|
513
|
-
obj.focusTrap.destroy(); // Restore drawers saved state
|
|
514
|
-
|
|
515
|
-
drawerKey = drawer.getAttribute("data-" + obj.settings.dataDrawer);
|
|
516
|
-
var drawerState = obj.state[drawerKey];
|
|
517
|
-
|
|
518
|
-
if (drawerState == obj.settings.stateOpened) {
|
|
519
|
-
addClass(drawer, obj.settings.stateOpened);
|
|
520
|
-
removeClass(drawer, obj.settings.stateClosed);
|
|
521
|
-
} // Dispatch custom event
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toDefault', {
|
|
525
|
-
bubbles: true
|
|
526
|
-
}));
|
|
527
|
-
return Promise.resolve(drawer);
|
|
528
|
-
} catch (e) {
|
|
529
|
-
return Promise.reject(e);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
var switchToModal = function switchToModal(drawerKey, obj) {
|
|
533
|
-
try {
|
|
534
|
-
// Initial guards
|
|
535
|
-
var drawer = obj.getDrawer(drawerKey);
|
|
536
|
-
if (!drawer) return Promise.resolve(obj.drawerNotFound(drawerKey));
|
|
537
|
-
if (hasClass(drawer, obj.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
538
|
-
|
|
539
|
-
addClass(drawer, obj.settings.classModal);
|
|
540
|
-
addClass(drawer, obj.settings.stateClosed);
|
|
541
|
-
removeClass(drawer, obj.settings.stateOpened); // Dispatch custom event
|
|
542
|
-
|
|
543
|
-
drawer.dispatchEvent(new CustomEvent(obj.settings.customEventPrefix + 'toModal', {
|
|
544
|
-
bubbles: true
|
|
545
|
-
}));
|
|
546
|
-
return Promise.resolve(drawer);
|
|
547
|
-
} catch (e) {
|
|
548
|
-
return Promise.reject(e);
|
|
549
|
-
}
|
|
550
|
-
};
|
|
551
|
-
|
|
552
521
|
var Breakpoint = /*#__PURE__*/function () {
|
|
553
522
|
function Breakpoint(parent) {
|
|
554
523
|
this.mediaQueryLists = [];
|
|
@@ -564,16 +533,23 @@
|
|
|
564
533
|
|
|
565
534
|
var drawers = document.querySelectorAll("[data-" + this.parent.settings.dataBreakpoint + "]");
|
|
566
535
|
drawers.forEach(function (drawer) {
|
|
536
|
+
// Setup mediaQueryList object
|
|
567
537
|
var id = drawer.getAttribute("data-" + _this.parent.settings.dataDrawer);
|
|
568
538
|
var key = drawer.getAttribute("data-" + _this.parent.settings.dataBreakpoint);
|
|
569
539
|
|
|
570
540
|
var bp = _this.getBreakpoint(key);
|
|
571
541
|
|
|
572
|
-
var mql = window.matchMedia('(min-width:' + bp + ')');
|
|
542
|
+
var mql = window.matchMedia('(min-width:' + bp + ')'); // Run match check
|
|
573
543
|
|
|
574
|
-
_this.match(mql, drawer);
|
|
544
|
+
_this.match(mql, drawer); // Conditionally use addListner() for IE11 support
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
if (typeof mql.addEventListener === 'function') {
|
|
548
|
+
mql.addEventListener('change', _this.__check);
|
|
549
|
+
} else {
|
|
550
|
+
mql.addListener(_this.__check);
|
|
551
|
+
} // Push to mediaQueryLists array along with drawer ID
|
|
575
552
|
|
|
576
|
-
mql.addEventListener('change', _this.__check);
|
|
577
553
|
|
|
578
554
|
_this.mediaQueryLists.push({
|
|
579
555
|
'mql': mql,
|
|
@@ -618,9 +594,9 @@
|
|
|
618
594
|
|
|
619
595
|
_proto.match = function match(mql, drawer) {
|
|
620
596
|
if (mql.matches) {
|
|
621
|
-
switchToDefault(drawer
|
|
597
|
+
this.parent.switchToDefault(drawer);
|
|
622
598
|
} else {
|
|
623
|
-
switchToModal(drawer
|
|
599
|
+
this.parent.switchToModal(drawer);
|
|
624
600
|
}
|
|
625
601
|
};
|
|
626
602
|
|
|
@@ -646,6 +622,52 @@
|
|
|
646
622
|
return Breakpoint;
|
|
647
623
|
}();
|
|
648
624
|
|
|
625
|
+
function getDrawer(drawerKey) {
|
|
626
|
+
if (typeof drawerKey !== 'string') return drawerKey;
|
|
627
|
+
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
628
|
+
}
|
|
629
|
+
function drawerNotFound(key) {
|
|
630
|
+
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
var close$2 = function close(drawerKey) {
|
|
634
|
+
try {
|
|
635
|
+
var _this2 = this;
|
|
636
|
+
|
|
637
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
638
|
+
|
|
639
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
640
|
+
|
|
641
|
+
if (hasClass(drawer, _this2.settings.stateOpened)) {
|
|
642
|
+
_this2.working = true;
|
|
643
|
+
|
|
644
|
+
if (hasClass(drawer, _this2.settings.classModal)) {
|
|
645
|
+
setInert(false, _this2.settings.selectorInert);
|
|
646
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
return Promise.resolve(closeTransition(drawer, _this2.settings)).then(function () {
|
|
650
|
+
_this2.stateSave(drawer);
|
|
651
|
+
|
|
652
|
+
focusTrigger(_this2);
|
|
653
|
+
|
|
654
|
+
_this2.focusTrap.destroy();
|
|
655
|
+
|
|
656
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
657
|
+
detail: _this2,
|
|
658
|
+
bubbles: true
|
|
659
|
+
}));
|
|
660
|
+
_this2.working = false;
|
|
661
|
+
return drawer;
|
|
662
|
+
});
|
|
663
|
+
} else {
|
|
664
|
+
return Promise.resolve(drawer);
|
|
665
|
+
}
|
|
666
|
+
} catch (e) {
|
|
667
|
+
return Promise.reject(e);
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
649
671
|
function handlerClick$2(event) {
|
|
650
672
|
// Working catch
|
|
651
673
|
if (this.working) return; // Toggle data trigger
|
|
@@ -709,6 +731,48 @@
|
|
|
709
731
|
}
|
|
710
732
|
}
|
|
711
733
|
|
|
734
|
+
var open$2 = function open(drawerKey) {
|
|
735
|
+
try {
|
|
736
|
+
var _this2 = this;
|
|
737
|
+
|
|
738
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
739
|
+
|
|
740
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
741
|
+
|
|
742
|
+
if (!hasClass(drawer, _this2.settings.stateOpened)) {
|
|
743
|
+
_this2.working = true;
|
|
744
|
+
var isModal = hasClass(drawer, _this2.settings.classModal);
|
|
745
|
+
|
|
746
|
+
if (isModal) {
|
|
747
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return Promise.resolve(openTransition(drawer, _this2.settings)).then(function () {
|
|
751
|
+
_this2.stateSave(drawer);
|
|
752
|
+
|
|
753
|
+
if (isModal) {
|
|
754
|
+
_this2.focusTrap.init(drawer);
|
|
755
|
+
|
|
756
|
+
setInert(true, _this2.settings.selectorInert);
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
focusTarget(drawer, _this2.settings);
|
|
760
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
761
|
+
detail: _this2,
|
|
762
|
+
bubbles: true
|
|
763
|
+
}));
|
|
764
|
+
_this2.working = false;
|
|
765
|
+
return drawer;
|
|
766
|
+
});
|
|
767
|
+
} else {
|
|
768
|
+
focusTarget(drawer, _this2.settings);
|
|
769
|
+
return Promise.resolve(drawer);
|
|
770
|
+
}
|
|
771
|
+
} catch (e) {
|
|
772
|
+
return Promise.reject(e);
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
|
|
712
776
|
function stateSet(settings) {
|
|
713
777
|
// If save state is disabled
|
|
714
778
|
if (!settings.stateSave) return stateClear(settings); // If there isn't an existing state to set
|
|
@@ -753,6 +817,82 @@
|
|
|
753
817
|
return {};
|
|
754
818
|
}
|
|
755
819
|
|
|
820
|
+
var switchToDefault = function switchToDefault(drawerKey) {
|
|
821
|
+
try {
|
|
822
|
+
var _this4 = this;
|
|
823
|
+
|
|
824
|
+
// Initial guards
|
|
825
|
+
var drawer = _this4.getDrawer(drawerKey);
|
|
826
|
+
|
|
827
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
828
|
+
if (!hasClass(drawer, _this4.settings.classModal)) return Promise.resolve(); // Tear down modal state
|
|
829
|
+
|
|
830
|
+
setInert(false, _this4.settings.selectorInert);
|
|
831
|
+
setOverflowHidden(false, _this4.settings.selectorOverflow);
|
|
832
|
+
removeClass(drawer, _this4.settings.classModal);
|
|
833
|
+
|
|
834
|
+
_this4.focusTrap.destroy(); // Restore drawers saved state
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
drawerKey = drawer.getAttribute("data-" + _this4.settings.dataDrawer);
|
|
838
|
+
var drawerState = _this4.state[drawerKey];
|
|
839
|
+
|
|
840
|
+
if (drawerState == _this4.settings.stateOpened) {
|
|
841
|
+
addClass(drawer, _this4.settings.stateOpened);
|
|
842
|
+
removeClass(drawer, _this4.settings.stateClosed);
|
|
843
|
+
} // Dispatch custom event
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'toDefault', {
|
|
847
|
+
bubbles: true
|
|
848
|
+
}));
|
|
849
|
+
return Promise.resolve(drawer);
|
|
850
|
+
} catch (e) {
|
|
851
|
+
return Promise.reject(e);
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var switchToModal = function switchToModal(drawerKey) {
|
|
855
|
+
try {
|
|
856
|
+
var _this2 = this;
|
|
857
|
+
|
|
858
|
+
// Initial guards
|
|
859
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
860
|
+
|
|
861
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
862
|
+
if (hasClass(drawer, _this2.settings.classModal)) return Promise.resolve(); // Enable modal state
|
|
863
|
+
|
|
864
|
+
addClass(drawer, _this2.settings.classModal);
|
|
865
|
+
addClass(drawer, _this2.settings.stateClosed);
|
|
866
|
+
removeClass(drawer, _this2.settings.stateOpened); // Dispatch custom event
|
|
867
|
+
|
|
868
|
+
drawer.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'toModal', {
|
|
869
|
+
bubbles: true
|
|
870
|
+
}));
|
|
871
|
+
return Promise.resolve(drawer);
|
|
872
|
+
} catch (e) {
|
|
873
|
+
return Promise.reject(e);
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
|
|
877
|
+
var toggle = function toggle(drawerKey) {
|
|
878
|
+
try {
|
|
879
|
+
var _this2 = this;
|
|
880
|
+
|
|
881
|
+
var drawer = _this2.getDrawer(drawerKey);
|
|
882
|
+
|
|
883
|
+
if (!drawer) return Promise.resolve(drawerNotFound(drawerKey));
|
|
884
|
+
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
885
|
+
|
|
886
|
+
if (isClosed) {
|
|
887
|
+
return Promise.resolve(_this2.open(drawer));
|
|
888
|
+
} else {
|
|
889
|
+
return Promise.resolve(_this2.close(drawer));
|
|
890
|
+
}
|
|
891
|
+
} catch (e) {
|
|
892
|
+
return Promise.reject(e);
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
|
|
756
896
|
var Drawer = /*#__PURE__*/function () {
|
|
757
897
|
function Drawer(options) {
|
|
758
898
|
this.defaults = defaults$2;
|
|
@@ -819,19 +959,12 @@
|
|
|
819
959
|
*/
|
|
820
960
|
;
|
|
821
961
|
|
|
822
|
-
_proto.getDrawer = function getDrawer(drawerKey) {
|
|
823
|
-
|
|
824
|
-
return document.querySelector("[data-" + this.settings.dataDrawer + "=\"" + drawerKey + "\"]");
|
|
825
|
-
};
|
|
826
|
-
|
|
827
|
-
_proto.drawerNotFound = function drawerNotFound(key) {
|
|
828
|
-
return Promise.reject(new Error("Did not find drawer with key: \"" + key + "\""));
|
|
962
|
+
_proto.getDrawer = function getDrawer$1(drawerKey) {
|
|
963
|
+
return getDrawer.call(this, drawerKey);
|
|
829
964
|
};
|
|
830
965
|
|
|
831
966
|
_proto.setTabindex = function setTabindex$1() {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
setTabindex(selectorTabindex);
|
|
967
|
+
return setTabindex("\n [data-" + this.settings.dataDrawer + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
835
968
|
}
|
|
836
969
|
/**
|
|
837
970
|
* Save state functionality
|
|
@@ -859,114 +992,27 @@
|
|
|
859
992
|
;
|
|
860
993
|
|
|
861
994
|
_proto.switchToDefault = function switchToDefault$1(drawerKey) {
|
|
862
|
-
return switchToDefault(
|
|
995
|
+
return switchToDefault.call(this, drawerKey);
|
|
863
996
|
};
|
|
864
997
|
|
|
865
998
|
_proto.switchToModal = function switchToModal$1(drawerKey) {
|
|
866
|
-
return switchToModal(
|
|
999
|
+
return switchToModal.call(this, drawerKey);
|
|
867
1000
|
}
|
|
868
1001
|
/**
|
|
869
1002
|
* Change state functionality
|
|
870
1003
|
*/
|
|
871
1004
|
;
|
|
872
1005
|
|
|
873
|
-
_proto.toggle = function toggle(drawerKey) {
|
|
874
|
-
|
|
875
|
-
var _this2 = this;
|
|
876
|
-
|
|
877
|
-
var drawer = _this2.getDrawer(drawerKey);
|
|
878
|
-
|
|
879
|
-
if (!drawer) return Promise.resolve(_this2.drawerNotFound(drawerKey));
|
|
880
|
-
var isClosed = !hasClass(drawer, _this2.settings.stateOpened);
|
|
881
|
-
|
|
882
|
-
if (isClosed) {
|
|
883
|
-
return Promise.resolve(_this2.open(drawer));
|
|
884
|
-
} else {
|
|
885
|
-
return Promise.resolve(_this2.close(drawer));
|
|
886
|
-
}
|
|
887
|
-
} catch (e) {
|
|
888
|
-
return Promise.reject(e);
|
|
889
|
-
}
|
|
1006
|
+
_proto.toggle = function toggle$1(drawerKey) {
|
|
1007
|
+
return toggle.call(this, drawerKey);
|
|
890
1008
|
};
|
|
891
1009
|
|
|
892
1010
|
_proto.open = function open(drawerKey) {
|
|
893
|
-
|
|
894
|
-
var _this4 = this;
|
|
895
|
-
|
|
896
|
-
var drawer = _this4.getDrawer(drawerKey);
|
|
897
|
-
|
|
898
|
-
if (!drawer) return Promise.resolve(_this4.drawerNotFound(drawerKey));
|
|
899
|
-
|
|
900
|
-
if (!hasClass(drawer, _this4.settings.stateOpened)) {
|
|
901
|
-
_this4.working = true;
|
|
902
|
-
var isModal = hasClass(drawer, _this4.settings.classModal);
|
|
903
|
-
|
|
904
|
-
if (isModal) {
|
|
905
|
-
setOverflowHidden(true, _this4.settings.selectorOverflow);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
return Promise.resolve(openTransition(drawer, _this4.settings)).then(function () {
|
|
909
|
-
_this4.stateSave(drawer);
|
|
910
|
-
|
|
911
|
-
if (isModal) {
|
|
912
|
-
_this4.focusTrap.init(drawer);
|
|
913
|
-
|
|
914
|
-
setInert(true, _this4.settings.selectorInert);
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
focusTarget(drawer, _this4.settings);
|
|
918
|
-
drawer.dispatchEvent(new CustomEvent(_this4.settings.customEventPrefix + 'opened', {
|
|
919
|
-
detail: _this4,
|
|
920
|
-
bubbles: true
|
|
921
|
-
}));
|
|
922
|
-
_this4.working = false;
|
|
923
|
-
return drawer;
|
|
924
|
-
});
|
|
925
|
-
} else {
|
|
926
|
-
focusTarget(drawer, _this4.settings);
|
|
927
|
-
return Promise.resolve(drawer);
|
|
928
|
-
}
|
|
929
|
-
} catch (e) {
|
|
930
|
-
return Promise.reject(e);
|
|
931
|
-
}
|
|
1011
|
+
return open$2.call(this, drawerKey);
|
|
932
1012
|
};
|
|
933
1013
|
|
|
934
1014
|
_proto.close = function close(drawerKey) {
|
|
935
|
-
|
|
936
|
-
var _this6 = this;
|
|
937
|
-
|
|
938
|
-
var drawer = _this6.getDrawer(drawerKey);
|
|
939
|
-
|
|
940
|
-
if (!drawer) return Promise.resolve(_this6.drawerNotFound(drawerKey));
|
|
941
|
-
|
|
942
|
-
if (hasClass(drawer, _this6.settings.stateOpened)) {
|
|
943
|
-
_this6.working = true;
|
|
944
|
-
|
|
945
|
-
if (hasClass(drawer, _this6.settings.classModal)) {
|
|
946
|
-
setInert(false, _this6.settings.selectorInert);
|
|
947
|
-
setOverflowHidden(false, _this6.settings.selectorOverflow);
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
return Promise.resolve(closeTransition(drawer, _this6.settings)).then(function () {
|
|
951
|
-
_this6.stateSave(drawer);
|
|
952
|
-
|
|
953
|
-
focusTrigger(_this6);
|
|
954
|
-
|
|
955
|
-
_this6.focusTrap.destroy();
|
|
956
|
-
|
|
957
|
-
drawer.dispatchEvent(new CustomEvent(_this6.settings.customEventPrefix + 'closed', {
|
|
958
|
-
detail: _this6,
|
|
959
|
-
bubbles: true
|
|
960
|
-
}));
|
|
961
|
-
_this6.working = false;
|
|
962
|
-
return drawer;
|
|
963
|
-
});
|
|
964
|
-
} else {
|
|
965
|
-
return Promise.resolve(drawer);
|
|
966
|
-
}
|
|
967
|
-
} catch (e) {
|
|
968
|
-
return Promise.reject(e);
|
|
969
|
-
}
|
|
1015
|
+
return close$2.call(this, drawerKey);
|
|
970
1016
|
};
|
|
971
1017
|
|
|
972
1018
|
return Drawer;
|
|
@@ -1000,6 +1046,40 @@
|
|
|
1000
1046
|
transition: true
|
|
1001
1047
|
};
|
|
1002
1048
|
|
|
1049
|
+
var close$1 = function close(returnFocus) {
|
|
1050
|
+
if (returnFocus === void 0) {
|
|
1051
|
+
returnFocus = true;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
try {
|
|
1055
|
+
var _this2 = this;
|
|
1056
|
+
|
|
1057
|
+
var modal = document.querySelector("[data-" + _this2.settings.dataModal + "]." + _this2.settings.stateOpened);
|
|
1058
|
+
|
|
1059
|
+
if (modal) {
|
|
1060
|
+
_this2.working = true;
|
|
1061
|
+
setInert(false, _this2.settings.selectorInert);
|
|
1062
|
+
setOverflowHidden(false, _this2.settings.selectorOverflow);
|
|
1063
|
+
return Promise.resolve(closeTransition(modal, _this2.settings)).then(function () {
|
|
1064
|
+
if (returnFocus) focusTrigger(_this2);
|
|
1065
|
+
|
|
1066
|
+
_this2.focusTrap.destroy();
|
|
1067
|
+
|
|
1068
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'closed', {
|
|
1069
|
+
detail: _this2,
|
|
1070
|
+
bubbles: true
|
|
1071
|
+
}));
|
|
1072
|
+
_this2.working = false;
|
|
1073
|
+
return modal;
|
|
1074
|
+
});
|
|
1075
|
+
} else {
|
|
1076
|
+
return Promise.resolve(modal);
|
|
1077
|
+
}
|
|
1078
|
+
} catch (e) {
|
|
1079
|
+
return Promise.reject(e);
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1003
1083
|
var handlerClick$1 = function handlerClick(event) {
|
|
1004
1084
|
try {
|
|
1005
1085
|
var _temp3 = function _temp3(_result) {
|
|
@@ -1061,21 +1141,76 @@
|
|
|
1061
1141
|
}
|
|
1062
1142
|
}
|
|
1063
1143
|
|
|
1064
|
-
function
|
|
1065
|
-
|
|
1144
|
+
function getModal(modalKey) {
|
|
1145
|
+
if (typeof modalKey !== 'string') return modalKey;
|
|
1146
|
+
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1147
|
+
}
|
|
1148
|
+
function modalNotFound(key) {
|
|
1149
|
+
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1150
|
+
}
|
|
1151
|
+
function moveModals(type, ref) {
|
|
1152
|
+
if (type === void 0) {
|
|
1153
|
+
type = this.settings.moveModals.type;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (ref === void 0) {
|
|
1157
|
+
ref = this.settings.moveModals.ref;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1161
|
+
if (modals.length) moveElement(modals, type, ref);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
function setInitialState() {
|
|
1165
|
+
var _this = this;
|
|
1166
|
+
|
|
1167
|
+
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1066
1168
|
modals.forEach(function (el) {
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1169
|
+
// Remove opened state setup
|
|
1170
|
+
if (el.classList.contains(_this.settings.stateOpened)) {
|
|
1171
|
+
setInert(false, _this.settings.selectorInert);
|
|
1172
|
+
setOverflowHidden(false, _this.settings.selectorOverflow);
|
|
1173
|
+
focusTrigger(_this);
|
|
1073
1174
|
|
|
1074
|
-
|
|
1075
|
-
|
|
1175
|
+
_this.focusTrap.destroy();
|
|
1176
|
+
} // Remove all state classes and add the default state (closed)
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
removeClass(el, _this.settings.stateOpened, _this.settings.stateOpening, _this.settings.stateClosing);
|
|
1180
|
+
addClass(el, _this.settings.stateClosed);
|
|
1076
1181
|
});
|
|
1077
1182
|
}
|
|
1078
1183
|
|
|
1184
|
+
var open$1 = function open(modalKey) {
|
|
1185
|
+
try {
|
|
1186
|
+
var _this2 = this;
|
|
1187
|
+
|
|
1188
|
+
var modal = getModal.call(_this2, modalKey);
|
|
1189
|
+
if (!modal) return Promise.resolve(modalNotFound(modalKey));
|
|
1190
|
+
|
|
1191
|
+
if (hasClass(modal, _this2.settings.stateClosed)) {
|
|
1192
|
+
_this2.working = true;
|
|
1193
|
+
setOverflowHidden(true, _this2.settings.selectorOverflow);
|
|
1194
|
+
return Promise.resolve(openTransition(modal, _this2.settings)).then(function () {
|
|
1195
|
+
_this2.focusTrap.init(modal);
|
|
1196
|
+
|
|
1197
|
+
focusTarget(modal, _this2.settings);
|
|
1198
|
+
setInert(true, _this2.settings.selectorInert);
|
|
1199
|
+
modal.dispatchEvent(new CustomEvent(_this2.settings.customEventPrefix + 'opened', {
|
|
1200
|
+
detail: _this2,
|
|
1201
|
+
bubbles: true
|
|
1202
|
+
}));
|
|
1203
|
+
_this2.working = false;
|
|
1204
|
+
return modal;
|
|
1205
|
+
});
|
|
1206
|
+
} else {
|
|
1207
|
+
return Promise.resolve(modal);
|
|
1208
|
+
}
|
|
1209
|
+
} catch (e) {
|
|
1210
|
+
return Promise.reject(e);
|
|
1211
|
+
}
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1079
1214
|
var Modal = /*#__PURE__*/function () {
|
|
1080
1215
|
function Modal(options) {
|
|
1081
1216
|
this.defaults = defaults$1;
|
|
@@ -1097,13 +1232,12 @@
|
|
|
1097
1232
|
|
|
1098
1233
|
if (options) this.settings = _extends({}, this.settings, options);
|
|
1099
1234
|
this.moveModals();
|
|
1235
|
+
this.setInitialState();
|
|
1100
1236
|
|
|
1101
1237
|
if (this.settings.setTabindex) {
|
|
1102
1238
|
this.setTabindex();
|
|
1103
1239
|
}
|
|
1104
1240
|
|
|
1105
|
-
this.setInitialState();
|
|
1106
|
-
|
|
1107
1241
|
if (this.settings.eventListeners) {
|
|
1108
1242
|
this.initEventListeners();
|
|
1109
1243
|
}
|
|
@@ -1137,36 +1271,20 @@
|
|
|
1137
1271
|
*/
|
|
1138
1272
|
;
|
|
1139
1273
|
|
|
1140
|
-
_proto.getModal = function getModal(modalKey) {
|
|
1141
|
-
|
|
1142
|
-
return document.querySelector("[data-" + this.settings.dataModal + "=\"" + modalKey + "\"]");
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
_proto.modalNotFound = function modalNotFound(key) {
|
|
1146
|
-
return Promise.reject(new Error("Did not find modal with key: \"" + key + "\""));
|
|
1274
|
+
_proto.getModal = function getModal$1(modalKey) {
|
|
1275
|
+
return getModal.call(this, modalKey);
|
|
1147
1276
|
};
|
|
1148
1277
|
|
|
1149
1278
|
_proto.setTabindex = function setTabindex$1() {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
setTabindex(selectorTabindex);
|
|
1279
|
+
return setTabindex("\n [data-" + this.settings.dataModal + "]\n [data-" + this.settings.dataDialog + "]\n ");
|
|
1153
1280
|
};
|
|
1154
1281
|
|
|
1155
1282
|
_proto.setInitialState = function setInitialState$1() {
|
|
1156
|
-
setInitialState(this);
|
|
1283
|
+
return setInitialState.call(this);
|
|
1157
1284
|
};
|
|
1158
1285
|
|
|
1159
|
-
_proto.moveModals = function moveModals(type, ref) {
|
|
1160
|
-
|
|
1161
|
-
type = this.settings.moveModals.type;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (ref === void 0) {
|
|
1165
|
-
ref = this.settings.moveModals.ref;
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
var modals = document.querySelectorAll("[data-" + this.settings.dataModal + "]");
|
|
1169
|
-
if (modals.length) moveElement(modals, type, ref);
|
|
1286
|
+
_proto.moveModals = function moveModals$1(type, ref) {
|
|
1287
|
+
return moveModals.call(this, type, ref);
|
|
1170
1288
|
}
|
|
1171
1289
|
/**
|
|
1172
1290
|
* Change state functionality
|
|
@@ -1174,92 +1292,92 @@
|
|
|
1174
1292
|
;
|
|
1175
1293
|
|
|
1176
1294
|
_proto.open = function open(modalKey) {
|
|
1177
|
-
|
|
1178
|
-
|
|
1295
|
+
return open$1.call(this, modalKey);
|
|
1296
|
+
};
|
|
1179
1297
|
|
|
1180
|
-
|
|
1298
|
+
_proto.close = function close(returnFocus) {
|
|
1299
|
+
return close$1.call(this, returnFocus);
|
|
1300
|
+
};
|
|
1181
1301
|
|
|
1182
|
-
|
|
1302
|
+
return Modal;
|
|
1303
|
+
}();
|
|
1183
1304
|
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
_this2.focusTrap.init(modal);
|
|
1305
|
+
var Collection = /*#__PURE__*/function () {
|
|
1306
|
+
function Collection() {
|
|
1307
|
+
this.collection = [];
|
|
1308
|
+
}
|
|
1189
1309
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
_this2.working = false;
|
|
1197
|
-
return modal;
|
|
1198
|
-
});
|
|
1199
|
-
} else {
|
|
1200
|
-
return Promise.resolve(modal);
|
|
1201
|
-
}
|
|
1202
|
-
} catch (e) {
|
|
1203
|
-
return Promise.reject(e);
|
|
1204
|
-
}
|
|
1310
|
+
var _proto = Collection.prototype;
|
|
1311
|
+
|
|
1312
|
+
_proto.register = function register(item) {
|
|
1313
|
+
this.deregister(item);
|
|
1314
|
+
this.collection.push(item);
|
|
1315
|
+
return this.collection;
|
|
1205
1316
|
};
|
|
1206
1317
|
|
|
1207
|
-
_proto.
|
|
1208
|
-
|
|
1209
|
-
|
|
1318
|
+
_proto.deregister = function deregister(ref) {
|
|
1319
|
+
var index = this.collection.findIndex(function (entry) {
|
|
1320
|
+
return entry === ref;
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
if (index >= 0) {
|
|
1324
|
+
var entry = this.collection[index];
|
|
1325
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
1326
|
+
delete entry[prop];
|
|
1327
|
+
});
|
|
1328
|
+
this.collection.splice(index, 1);
|
|
1210
1329
|
}
|
|
1211
1330
|
|
|
1212
|
-
|
|
1213
|
-
|
|
1331
|
+
return this.collection;
|
|
1332
|
+
};
|
|
1214
1333
|
|
|
1215
|
-
|
|
1334
|
+
_proto.registerCollection = function registerCollection(items) {
|
|
1335
|
+
var _this = this;
|
|
1216
1336
|
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
if (returnFocus) focusTrigger(_this4);
|
|
1337
|
+
items.forEach(function (item) {
|
|
1338
|
+
_this.register(item);
|
|
1339
|
+
});
|
|
1340
|
+
return this.collection;
|
|
1341
|
+
};
|
|
1223
1342
|
|
|
1224
|
-
|
|
1343
|
+
_proto.deregisterCollection = function deregisterCollection() {
|
|
1344
|
+
while (this.collection.length > 0) {
|
|
1345
|
+
this.deregister(this.collection[0]);
|
|
1346
|
+
}
|
|
1225
1347
|
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
});
|
|
1233
|
-
} else {
|
|
1234
|
-
return Promise.resolve(modal);
|
|
1235
|
-
}
|
|
1236
|
-
} catch (e) {
|
|
1237
|
-
return Promise.reject(e);
|
|
1348
|
+
return this.collection;
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
_proto.get = function get(query, key) {
|
|
1352
|
+
if (key === void 0) {
|
|
1353
|
+
key = 'id';
|
|
1238
1354
|
}
|
|
1355
|
+
|
|
1356
|
+
var result = this.collection.find(function (item) {
|
|
1357
|
+
return item[key] === query;
|
|
1358
|
+
});
|
|
1359
|
+
return result || null;
|
|
1239
1360
|
};
|
|
1240
1361
|
|
|
1241
|
-
return
|
|
1362
|
+
return Collection;
|
|
1242
1363
|
}();
|
|
1243
1364
|
|
|
1244
1365
|
var defaults = {
|
|
1245
1366
|
autoInit: false,
|
|
1246
|
-
//
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
dataArrow: 'popover-arrow',
|
|
1250
|
-
dataEventType: 'popover-event',
|
|
1251
|
-
dataPlacement: 'popover-placement',
|
|
1367
|
+
// Selectors
|
|
1368
|
+
selectorPopover: '.popover',
|
|
1369
|
+
selectorArrow: '.popover__arrow',
|
|
1252
1370
|
// State classes
|
|
1253
1371
|
stateActive: 'is-active',
|
|
1254
1372
|
// Feature toggles
|
|
1255
|
-
eventType: 'click',
|
|
1256
1373
|
eventListeners: true,
|
|
1257
|
-
|
|
1374
|
+
eventType: 'click',
|
|
1375
|
+
placement: 'bottom'
|
|
1258
1376
|
};
|
|
1259
1377
|
|
|
1260
|
-
function
|
|
1378
|
+
function close(popover) {
|
|
1261
1379
|
// Update state class
|
|
1262
|
-
popover.target.classList.remove(
|
|
1380
|
+
popover.target.classList.remove(this.settings.stateActive); // Update a11y attributes
|
|
1263
1381
|
|
|
1264
1382
|
popover.trigger.setAttribute('aria-expanded', 'false'); // Disable popper event listeners
|
|
1265
1383
|
|
|
@@ -1268,41 +1386,38 @@
|
|
|
1268
1386
|
name: 'eventListeners',
|
|
1269
1387
|
enabled: false
|
|
1270
1388
|
}]
|
|
1271
|
-
}); // Update
|
|
1389
|
+
}); // Update popover state
|
|
1272
1390
|
|
|
1273
|
-
|
|
1274
|
-
return item.target === popover.target;
|
|
1275
|
-
});
|
|
1276
|
-
obj.collection[index].state = 'hide'; // Clear the memory if popover trigger matches the ones saved in memory
|
|
1391
|
+
popover.state = 'closed'; // Clear memory if popover trigger matches the one saved in memory
|
|
1277
1392
|
|
|
1278
|
-
if (popover.trigger ===
|
|
1279
|
-
|
|
1393
|
+
if (popover.trigger === this.memory.trigger) {
|
|
1394
|
+
this.memory.trigger = null;
|
|
1280
1395
|
} // Return the popover
|
|
1281
1396
|
|
|
1282
1397
|
|
|
1283
1398
|
return popover;
|
|
1284
1399
|
}
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
if (popover.state === '
|
|
1288
|
-
|
|
1400
|
+
function closeAll() {
|
|
1401
|
+
this.collection.forEach(function (popover) {
|
|
1402
|
+
if (popover.state === 'opened') {
|
|
1403
|
+
popover.close();
|
|
1289
1404
|
}
|
|
1290
1405
|
}); // Return the collection
|
|
1291
1406
|
|
|
1292
|
-
return
|
|
1407
|
+
return this.collection;
|
|
1293
1408
|
}
|
|
1294
|
-
function
|
|
1295
|
-
// Only run
|
|
1296
|
-
if (popover.state != '
|
|
1409
|
+
function closeCheck(popover) {
|
|
1410
|
+
// Only run closeCheck if provided popover is currently open
|
|
1411
|
+
if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
|
|
1297
1412
|
|
|
1298
1413
|
setTimeout(function () {
|
|
1299
1414
|
// Check if trigger or target are being hovered
|
|
1300
1415
|
var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
|
|
1301
1416
|
|
|
1302
|
-
var isFocused = document.activeElement.closest("
|
|
1417
|
+
var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]"); // Close if the trigger and target are not currently hovered or focused
|
|
1303
1418
|
|
|
1304
1419
|
if (!isHovered && !isFocused) {
|
|
1305
|
-
|
|
1420
|
+
popover.close();
|
|
1306
1421
|
} // Return the popover
|
|
1307
1422
|
|
|
1308
1423
|
|
|
@@ -1310,6 +1425,59 @@
|
|
|
1310
1425
|
}, 1);
|
|
1311
1426
|
}
|
|
1312
1427
|
|
|
1428
|
+
function handlerClick(popover) {
|
|
1429
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1430
|
+
popover.close();
|
|
1431
|
+
} else {
|
|
1432
|
+
this.memory.trigger = popover.trigger;
|
|
1433
|
+
popover.open();
|
|
1434
|
+
documentClick.call(this, popover);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
function handlerKeydown(event) {
|
|
1438
|
+
var _this = this;
|
|
1439
|
+
|
|
1440
|
+
switch (event.key) {
|
|
1441
|
+
case 'Escape':
|
|
1442
|
+
if (this.memory.trigger) {
|
|
1443
|
+
this.memory.trigger.focus();
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
closeAll.call(this);
|
|
1447
|
+
return;
|
|
1448
|
+
|
|
1449
|
+
case 'Tab':
|
|
1450
|
+
this.collection.forEach(function (popover) {
|
|
1451
|
+
closeCheck.call(_this, popover);
|
|
1452
|
+
});
|
|
1453
|
+
return;
|
|
1454
|
+
|
|
1455
|
+
default:
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
function documentClick(popover) {
|
|
1460
|
+
var root = this;
|
|
1461
|
+
document.addEventListener('click', function _f(event) {
|
|
1462
|
+
// Check if a popover was clicked
|
|
1463
|
+
var result = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]");
|
|
1464
|
+
|
|
1465
|
+
if (!result) {
|
|
1466
|
+
// If it doesn't match and popover is open, close it and remove event listener
|
|
1467
|
+
if (popover.target && popover.target.classList.contains(root.settings.stateActive)) {
|
|
1468
|
+
popover.close();
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
this.removeEventListener('click', _f);
|
|
1472
|
+
} else {
|
|
1473
|
+
// If it does match and popover isn't currently active, remove event listener
|
|
1474
|
+
if (popover.target && !popover.target.classList.contains(root.settings.stateActive)) {
|
|
1475
|
+
this.removeEventListener('click', _f);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1313
1481
|
function getConfig(el, settings) {
|
|
1314
1482
|
// Get the computed styles of the popover
|
|
1315
1483
|
var styles = getComputedStyle(el); // Setup the config obj with default values
|
|
@@ -1320,30 +1488,23 @@
|
|
|
1320
1488
|
'offset': 0,
|
|
1321
1489
|
'overflow-padding': 0,
|
|
1322
1490
|
'flip-padding': 0,
|
|
1323
|
-
'arrow-element':
|
|
1491
|
+
'arrow-element': settings.selectorArrow,
|
|
1324
1492
|
'arrow-padding': 0
|
|
1325
1493
|
}; // Loop through config obj
|
|
1326
1494
|
|
|
1327
1495
|
for (var prop in config) {
|
|
1328
1496
|
// Get the CSS variable property values
|
|
1329
1497
|
var prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
|
|
1330
|
-
var
|
|
1498
|
+
var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj
|
|
1331
1499
|
|
|
1332
|
-
if (
|
|
1333
|
-
config[prop] =
|
|
1500
|
+
if (value) {
|
|
1501
|
+
config[prop] = value;
|
|
1334
1502
|
}
|
|
1335
1503
|
} // Return the config obj
|
|
1336
1504
|
|
|
1337
1505
|
|
|
1338
1506
|
return config;
|
|
1339
1507
|
}
|
|
1340
|
-
function getData(el, attr, fallback) {
|
|
1341
|
-
if (fallback === void 0) {
|
|
1342
|
-
fallback = false;
|
|
1343
|
-
}
|
|
1344
|
-
|
|
1345
|
-
return el.hasAttribute("data-" + attr) ? el.getAttribute("data-" + attr) : fallback;
|
|
1346
|
-
}
|
|
1347
1508
|
function getPadding(value) {
|
|
1348
1509
|
var padding; // Split the value by spaces if it's a string
|
|
1349
1510
|
|
|
@@ -1417,97 +1578,53 @@
|
|
|
1417
1578
|
}
|
|
1418
1579
|
}];
|
|
1419
1580
|
}
|
|
1420
|
-
function
|
|
1421
|
-
//
|
|
1422
|
-
|
|
1581
|
+
function getPopoverID(obj) {
|
|
1582
|
+
// If it's a string
|
|
1583
|
+
if (typeof obj === 'string') {
|
|
1584
|
+
return obj;
|
|
1585
|
+
} // If it's an HTML element
|
|
1586
|
+
else if (typeof obj.hasAttribute === 'function') {
|
|
1587
|
+
// If it's a popover trigger
|
|
1588
|
+
if (obj.hasAttribute('aria-controls')) {
|
|
1589
|
+
return obj.getAttribute('aria-controls');
|
|
1590
|
+
} // If it's a popover target
|
|
1591
|
+
else if (obj.closest(this.settings.selectorPopover)) {
|
|
1592
|
+
return obj.id;
|
|
1593
|
+
} // Return false if no id was found
|
|
1594
|
+
else return false;
|
|
1595
|
+
} // If it has an ID property
|
|
1596
|
+
else if (obj.id) {
|
|
1597
|
+
return obj.id;
|
|
1598
|
+
} // Return false if no id was found
|
|
1599
|
+
else return false;
|
|
1600
|
+
}
|
|
1601
|
+
function getPopoverElements(query) {
|
|
1602
|
+
var id = getPopoverID.call(this, query);
|
|
1423
1603
|
|
|
1424
1604
|
if (id) {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return document.querySelector("[data-" + settings.dataPopover + "=\"" + id + "\"]");
|
|
1428
|
-
} else {
|
|
1429
|
-
// If trigger attribute value doesn't exist, check if
|
|
1430
|
-
// - There is a nextElementSibling relative to the trigger
|
|
1431
|
-
// - And it has the popover data attribute.
|
|
1432
|
-
return trigger.nextElementSibling && trigger.nextElementSibling.hasAttribute("data-" + settings.dataPopover) ? // Return the element or false if the two checks fail
|
|
1433
|
-
trigger.nextElementSibling : false;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
function show(popover, obj) {
|
|
1438
|
-
// Update state class
|
|
1439
|
-
popover.target.classList.add(obj.settings.stateActive); // Update a11y attributes
|
|
1605
|
+
var trigger = document.querySelector("[aria-controls=\"" + id + "\"]");
|
|
1606
|
+
var target = document.querySelector("#" + id);
|
|
1440
1607
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
name: 'eventListeners',
|
|
1449
|
-
enabled: true
|
|
1450
|
-
}].concat(getModifiers(popover.config))
|
|
1451
|
-
}); // Update popover's position
|
|
1452
|
-
|
|
1453
|
-
popover.popper.update(); // Update collection status with new state
|
|
1454
|
-
|
|
1455
|
-
var index = obj.collection.findIndex(function (item) {
|
|
1456
|
-
return item.target === popover.target;
|
|
1457
|
-
});
|
|
1458
|
-
obj.collection[index].state = 'show'; // Return the popover
|
|
1459
|
-
|
|
1460
|
-
return popover;
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
function handlerClick(popover) {
|
|
1464
|
-
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1465
|
-
hide$2(popover, this);
|
|
1466
|
-
} else {
|
|
1467
|
-
this.memory.trigger = popover.trigger;
|
|
1468
|
-
show(popover, this);
|
|
1469
|
-
documentClick(popover, this);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
function handlerKeydown(event) {
|
|
1473
|
-
var _this = this;
|
|
1474
|
-
|
|
1475
|
-
switch (event.key) {
|
|
1476
|
-
case 'Escape':
|
|
1477
|
-
if (this.memory.trigger) {
|
|
1478
|
-
this.memory.trigger.focus();
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
hideAll(this);
|
|
1482
|
-
return;
|
|
1483
|
-
|
|
1484
|
-
case 'Tab':
|
|
1485
|
-
this.collection.forEach(function (popover) {
|
|
1486
|
-
hideCheck(popover, _this);
|
|
1487
|
-
});
|
|
1488
|
-
return;
|
|
1489
|
-
|
|
1490
|
-
default:
|
|
1491
|
-
return;
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
function documentClick(popover, obj) {
|
|
1495
|
-
document.addEventListener('click', function _f(event) {
|
|
1496
|
-
var result = event.target.closest("[data-" + obj.settings.dataPopover + "], [data-" + obj.settings.dataTrigger + "]");
|
|
1497
|
-
var match = result === popover.target || result === popover.trigger;
|
|
1498
|
-
|
|
1499
|
-
if (!match) {
|
|
1500
|
-
if (popover.target.classList.contains(obj.settings.stateActive)) {
|
|
1501
|
-
hide$2(popover, obj);
|
|
1502
|
-
}
|
|
1608
|
+
if (!trigger && !target) {
|
|
1609
|
+
console.error('No popover elements found using the provided ID:', id);
|
|
1610
|
+
} else if (!trigger) {
|
|
1611
|
+
console.error('No popover trigger associated with the provided popover:', target);
|
|
1612
|
+
} else if (!target) {
|
|
1613
|
+
console.error('No popover associated with the provided popover trigger:', trigger);
|
|
1614
|
+
}
|
|
1503
1615
|
|
|
1504
|
-
|
|
1616
|
+
if (!trigger || !target) {
|
|
1617
|
+
return false;
|
|
1505
1618
|
} else {
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1619
|
+
return {
|
|
1620
|
+
trigger: trigger,
|
|
1621
|
+
target: target
|
|
1622
|
+
};
|
|
1509
1623
|
}
|
|
1510
|
-
}
|
|
1624
|
+
} else {
|
|
1625
|
+
console.error('Could not resolve the popover ID:', query);
|
|
1626
|
+
return false;
|
|
1627
|
+
}
|
|
1511
1628
|
}
|
|
1512
1629
|
|
|
1513
1630
|
var top = 'top';
|
|
@@ -3293,95 +3410,118 @@
|
|
|
3293
3410
|
defaultModifiers: defaultModifiers
|
|
3294
3411
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
3295
3412
|
|
|
3296
|
-
function
|
|
3297
|
-
//
|
|
3298
|
-
|
|
3299
|
-
// Try and get the target
|
|
3300
|
-
target = getPopover(trigger, obj.settings); // If still no target is returned, log an error and return false
|
|
3413
|
+
function open(popover) {
|
|
3414
|
+
// Update state class
|
|
3415
|
+
popover.target.classList.add(this.settings.stateActive); // Update a11y attribute
|
|
3301
3416
|
|
|
3302
|
-
|
|
3303
|
-
console.error('No popover associated with the provided trigger:', trigger);
|
|
3304
|
-
return false;
|
|
3305
|
-
}
|
|
3306
|
-
} // Check if this item has already been registered in the collection
|
|
3417
|
+
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
3307
3418
|
|
|
3419
|
+
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
3308
3420
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3421
|
+
popover.popper.setOptions({
|
|
3422
|
+
placement: popover.config['placement'],
|
|
3423
|
+
modifiers: [{
|
|
3424
|
+
name: 'eventListeners',
|
|
3425
|
+
enabled: true
|
|
3426
|
+
}].concat(getModifiers(popover.config))
|
|
3427
|
+
}); // Update popover position
|
|
3312
3428
|
|
|
3313
|
-
|
|
3429
|
+
popover.popper.update(); // Update popover state
|
|
3314
3430
|
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3431
|
+
popover.state = 'opened'; // Return the popover
|
|
3432
|
+
|
|
3433
|
+
return popover;
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3436
|
+
function register(trigger, target) {
|
|
3437
|
+
// Deregister popover if it already exists in the collection
|
|
3438
|
+
this.deregister(target.id); // Create popper instance
|
|
3439
|
+
|
|
3440
|
+
var popperInstance = createPopper(trigger, target); // Save root this for use inside object & create methods API
|
|
3321
3441
|
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3442
|
+
var root = this;
|
|
3443
|
+
var methods = {
|
|
3444
|
+
open: function open$1() {
|
|
3445
|
+
open.call(root, this);
|
|
3446
|
+
},
|
|
3447
|
+
close: function close$1() {
|
|
3448
|
+
close.call(root, this);
|
|
3449
|
+
},
|
|
3450
|
+
deregister: function deregister() {
|
|
3451
|
+
_deregister.call(root, this);
|
|
3452
|
+
}
|
|
3453
|
+
}; // Build popover object and push to collection array
|
|
3329
3454
|
|
|
3330
|
-
|
|
3331
|
-
|
|
3455
|
+
var popover = _extends({
|
|
3456
|
+
id: target.id,
|
|
3457
|
+
state: 'closed',
|
|
3458
|
+
trigger: trigger,
|
|
3459
|
+
target: target,
|
|
3460
|
+
popper: popperInstance,
|
|
3461
|
+
config: getConfig(target, this.settings)
|
|
3462
|
+
}, methods); // Setup event listeners
|
|
3332
3463
|
|
|
3333
3464
|
|
|
3334
|
-
registerEventListeners(
|
|
3465
|
+
registerEventListeners.call(this, popover); // Set initial state of popover
|
|
3335
3466
|
|
|
3336
|
-
if (popover.target.classList.contains(
|
|
3337
|
-
|
|
3338
|
-
documentClick(
|
|
3467
|
+
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
3468
|
+
popover.open();
|
|
3469
|
+
documentClick.call(this, popover);
|
|
3339
3470
|
} else {
|
|
3340
|
-
|
|
3341
|
-
} //
|
|
3471
|
+
popover.close();
|
|
3472
|
+
} // Add item to collection
|
|
3473
|
+
|
|
3342
3474
|
|
|
3475
|
+
this.collection.push(popover); // Return the popover object
|
|
3343
3476
|
|
|
3344
3477
|
return popover;
|
|
3345
3478
|
}
|
|
3346
|
-
|
|
3479
|
+
|
|
3480
|
+
function _deregister(popover) {
|
|
3347
3481
|
// Check if this item has been registered in the collection
|
|
3348
|
-
var index =
|
|
3349
|
-
return
|
|
3350
|
-
}); // If the
|
|
3482
|
+
var index = this.collection.findIndex(function (entry) {
|
|
3483
|
+
return entry.id === popover.id;
|
|
3484
|
+
}); // If the entry exists in the collection
|
|
3351
3485
|
|
|
3352
3486
|
if (index >= 0) {
|
|
3353
|
-
//
|
|
3354
|
-
|
|
3355
|
-
|
|
3487
|
+
// Get the collection entry
|
|
3488
|
+
var entry = this.collection[index]; // Close the collection entry if it's open
|
|
3489
|
+
|
|
3490
|
+
if (entry.state === 'opened') {
|
|
3491
|
+
entry.close();
|
|
3356
3492
|
} // Clean up the popper instance
|
|
3357
3493
|
|
|
3358
3494
|
|
|
3359
|
-
|
|
3495
|
+
entry.popper.destroy(); // Remove event listeners
|
|
3360
3496
|
|
|
3361
|
-
deregisterEventListeners(
|
|
3497
|
+
deregisterEventListeners(entry); // Delete properties from collection entry
|
|
3362
3498
|
|
|
3363
|
-
|
|
3499
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
3500
|
+
delete entry[prop];
|
|
3501
|
+
}); // Remove entry from collection
|
|
3502
|
+
|
|
3503
|
+
this.collection.splice(index, 1);
|
|
3364
3504
|
} // Return the new collection
|
|
3365
3505
|
|
|
3366
3506
|
|
|
3367
|
-
return
|
|
3507
|
+
return this.collection;
|
|
3368
3508
|
}
|
|
3369
|
-
function registerEventListeners(popover
|
|
3509
|
+
function registerEventListeners(popover) {
|
|
3370
3510
|
// If event listeners aren't already setup
|
|
3371
3511
|
if (!popover.__eventListeners) {
|
|
3372
3512
|
// Add event listeners based on event type
|
|
3373
|
-
var eventType =
|
|
3513
|
+
var eventType = popover.config['event'];
|
|
3374
3514
|
|
|
3375
3515
|
if (eventType === 'hover') {
|
|
3376
3516
|
// Setup event listeners object for hover
|
|
3377
3517
|
popover.__eventListeners = [{
|
|
3378
3518
|
el: ['trigger'],
|
|
3379
3519
|
type: ['mouseenter', 'focus'],
|
|
3380
|
-
listener:
|
|
3520
|
+
listener: open.bind(this, popover)
|
|
3381
3521
|
}, {
|
|
3382
3522
|
el: ['trigger', 'target'],
|
|
3383
3523
|
type: ['mouseleave', 'focusout'],
|
|
3384
|
-
listener:
|
|
3524
|
+
listener: closeCheck.bind(this, popover)
|
|
3385
3525
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3386
3526
|
|
|
3387
3527
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3396,7 +3536,7 @@
|
|
|
3396
3536
|
popover.__eventListeners = [{
|
|
3397
3537
|
el: ['trigger'],
|
|
3398
3538
|
type: ['click'],
|
|
3399
|
-
listener: handlerClick.bind(
|
|
3539
|
+
listener: handlerClick.bind(this, popover)
|
|
3400
3540
|
}]; // Loop through listeners and apply to appropriate elements
|
|
3401
3541
|
|
|
3402
3542
|
popover.__eventListeners.forEach(function (evObj) {
|
|
@@ -3431,36 +3571,23 @@
|
|
|
3431
3571
|
|
|
3432
3572
|
return popover;
|
|
3433
3573
|
}
|
|
3434
|
-
function registerCollection(obj) {
|
|
3435
|
-
// Get all the triggers
|
|
3436
|
-
var triggers = document.querySelectorAll("[data-" + obj.settings.dataTrigger + "]");
|
|
3437
|
-
triggers.forEach(function (trigger) {
|
|
3438
|
-
// Register the popover and save to collection array
|
|
3439
|
-
register(trigger, false, obj);
|
|
3440
|
-
}); // Return the popover collection
|
|
3441
3574
|
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
function deregisterCollection(obj) {
|
|
3445
|
-
// Loop through all items within the collection and pass them to deregister()
|
|
3446
|
-
while (obj.collection.length > 0) {
|
|
3447
|
-
deregister(obj.collection[0], obj);
|
|
3448
|
-
} // Return the popover collection
|
|
3575
|
+
var Popover = /*#__PURE__*/function (_Collection) {
|
|
3576
|
+
_inheritsLoose(Popover, _Collection);
|
|
3449
3577
|
|
|
3578
|
+
function Popover(options) {
|
|
3579
|
+
var _this;
|
|
3450
3580
|
|
|
3451
|
-
|
|
3452
|
-
|
|
3581
|
+
_this = _Collection.call(this) || this;
|
|
3582
|
+
_this.defaults = defaults;
|
|
3583
|
+
_this.settings = _extends({}, _this.defaults, options); // this.collection = [];
|
|
3453
3584
|
|
|
3454
|
-
|
|
3455
|
-
function Popover(options) {
|
|
3456
|
-
this.defaults = defaults;
|
|
3457
|
-
this.settings = _extends({}, this.defaults, options);
|
|
3458
|
-
this.collection = [];
|
|
3459
|
-
this.memory = {
|
|
3585
|
+
_this.memory = {
|
|
3460
3586
|
trigger: null
|
|
3461
3587
|
};
|
|
3462
|
-
|
|
3463
|
-
if (
|
|
3588
|
+
_this.__handlerKeydown = handlerKeydown.bind(_assertThisInitialized(_this));
|
|
3589
|
+
if (_this.settings.autoInit) _this.init();
|
|
3590
|
+
return _this;
|
|
3464
3591
|
}
|
|
3465
3592
|
|
|
3466
3593
|
var _proto = Popover.prototype;
|
|
@@ -3471,10 +3598,11 @@
|
|
|
3471
3598
|
}
|
|
3472
3599
|
|
|
3473
3600
|
// Update settings with passed options
|
|
3474
|
-
if (options) this.settings = _extends({}, this.settings, options); //
|
|
3601
|
+
if (options) this.settings = _extends({}, this.settings, options); // Get all the popovers
|
|
3475
3602
|
|
|
3476
|
-
|
|
3603
|
+
var popovers = document.querySelectorAll(this.settings.selectorPopover); // Build the collections array with popover instances
|
|
3477
3604
|
|
|
3605
|
+
this.registerCollection(popovers); // If eventListeners is enabled
|
|
3478
3606
|
|
|
3479
3607
|
if (this.settings.eventListeners) {
|
|
3480
3608
|
// Pass false to initEventListeners() since registerCollection()
|
|
@@ -3485,8 +3613,7 @@
|
|
|
3485
3613
|
|
|
3486
3614
|
_proto.destroy = function destroy() {
|
|
3487
3615
|
// Deregister all popovers from collection
|
|
3488
|
-
deregisterCollection(
|
|
3489
|
-
|
|
3616
|
+
this.deregisterCollection(); // If eventListeners is enabled
|
|
3490
3617
|
|
|
3491
3618
|
if (this.settings.eventListeners) {
|
|
3492
3619
|
// Pass false to destroyEventListeners() since deregisterCollection()
|
|
@@ -3500,7 +3627,7 @@
|
|
|
3500
3627
|
;
|
|
3501
3628
|
|
|
3502
3629
|
_proto.initEventListeners = function initEventListeners(processCollection) {
|
|
3503
|
-
var
|
|
3630
|
+
var _this2 = this;
|
|
3504
3631
|
|
|
3505
3632
|
if (processCollection === void 0) {
|
|
3506
3633
|
processCollection = true;
|
|
@@ -3509,7 +3636,7 @@
|
|
|
3509
3636
|
if (processCollection) {
|
|
3510
3637
|
// Loop through collection and setup event listeners
|
|
3511
3638
|
this.collection.forEach(function (popover) {
|
|
3512
|
-
registerEventListeners(
|
|
3639
|
+
registerEventListeners.call(_this2, popover);
|
|
3513
3640
|
});
|
|
3514
3641
|
} // Add keydown global event listener
|
|
3515
3642
|
|
|
@@ -3537,44 +3664,40 @@
|
|
|
3537
3664
|
*/
|
|
3538
3665
|
;
|
|
3539
3666
|
|
|
3540
|
-
_proto.register = function register$1(
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
return register(trigger, target, this);
|
|
3546
|
-
};
|
|
3547
|
-
|
|
3548
|
-
_proto.deregister = function deregister$1(popover) {
|
|
3549
|
-
return deregister(popover, this);
|
|
3550
|
-
};
|
|
3551
|
-
|
|
3552
|
-
_proto.registerCollection = function registerCollection$1() {
|
|
3553
|
-
return registerCollection(this);
|
|
3667
|
+
_proto.register = function register$1(query) {
|
|
3668
|
+
var els = getPopoverElements.call(this, query);
|
|
3669
|
+
if (!els) return false;
|
|
3670
|
+
return register.call(this, els.trigger, els.target);
|
|
3554
3671
|
};
|
|
3555
3672
|
|
|
3556
|
-
_proto.
|
|
3557
|
-
|
|
3673
|
+
_proto.deregister = function deregister(query) {
|
|
3674
|
+
var popover = this.get(getPopoverID(query));
|
|
3675
|
+
if (!popover) return false;
|
|
3676
|
+
return _deregister.call(this, popover);
|
|
3558
3677
|
}
|
|
3559
3678
|
/**
|
|
3560
3679
|
* Change state functionality
|
|
3561
3680
|
*/
|
|
3562
3681
|
;
|
|
3563
3682
|
|
|
3564
|
-
_proto.
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
_proto.hide = function hide(popover) {
|
|
3569
|
-
return hide$2(popover, this);
|
|
3683
|
+
_proto.open = function open(id) {
|
|
3684
|
+
var popover = this.get(id);
|
|
3685
|
+
if (!popover) return false;
|
|
3686
|
+
return popover.open();
|
|
3570
3687
|
};
|
|
3571
3688
|
|
|
3572
|
-
_proto.
|
|
3573
|
-
|
|
3689
|
+
_proto.close = function close(id) {
|
|
3690
|
+
if (id) {
|
|
3691
|
+
var popover = this.get(id);
|
|
3692
|
+
if (!popover) return false;
|
|
3693
|
+
return popover.close();
|
|
3694
|
+
} else {
|
|
3695
|
+
return closeAll.call(this);
|
|
3696
|
+
}
|
|
3574
3697
|
};
|
|
3575
3698
|
|
|
3576
3699
|
return Popover;
|
|
3577
|
-
}();
|
|
3700
|
+
}(Collection);
|
|
3578
3701
|
|
|
3579
3702
|
exports.Checkbox = Checkbox;
|
|
3580
3703
|
exports.Drawer = Drawer;
|