diff options
Diffstat (limited to 'static/dist/js/bootstrap.bundle.js')
-rw-r--r-- | static/dist/js/bootstrap.bundle.js | 7013 |
1 files changed, 7013 insertions, 0 deletions
diff --git a/static/dist/js/bootstrap.bundle.js b/static/dist/js/bootstrap.bundle.js new file mode 100644 index 00000000..f4f23ead --- /dev/null +++ b/static/dist/js/bootstrap.bundle.js | |||
@@ -0,0 +1,7013 @@ | |||
1 | /*! | ||
2 | * Bootstrap v4.3.1 (https://getbootstrap.com/) | ||
3 | * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) | ||
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
5 | */ | ||
6 | (function (global, factory) { | ||
7 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) : | ||
8 | typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) : | ||
9 | (global = global || self, factory(global.bootstrap = {}, global.jQuery)); | ||
10 | }(this, function (exports, $) { 'use strict'; | ||
11 | |||
12 | $ = $ && $.hasOwnProperty('default') ? $['default'] : $; | ||
13 | |||
14 | function _defineProperties(target, props) { | ||
15 | for (var i = 0; i < props.length; i++) { | ||
16 | var descriptor = props[i]; | ||
17 | descriptor.enumerable = descriptor.enumerable || false; | ||
18 | descriptor.configurable = true; | ||
19 | if ("value" in descriptor) descriptor.writable = true; | ||
20 | Object.defineProperty(target, descriptor.key, descriptor); | ||
21 | } | ||
22 | } | ||
23 | |||
24 | function _createClass(Constructor, protoProps, staticProps) { | ||
25 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
26 | if (staticProps) _defineProperties(Constructor, staticProps); | ||
27 | return Constructor; | ||
28 | } | ||
29 | |||
30 | function _defineProperty(obj, key, value) { | ||
31 | if (key in obj) { | ||
32 | Object.defineProperty(obj, key, { | ||
33 | value: value, | ||
34 | enumerable: true, | ||
35 | configurable: true, | ||
36 | writable: true | ||
37 | }); | ||
38 | } else { | ||
39 | obj[key] = value; | ||
40 | } | ||
41 | |||
42 | return obj; | ||
43 | } | ||
44 | |||
45 | function _objectSpread(target) { | ||
46 | for (var i = 1; i < arguments.length; i++) { | ||
47 | var source = arguments[i] != null ? arguments[i] : {}; | ||
48 | var ownKeys = Object.keys(source); | ||
49 | |||
50 | if (typeof Object.getOwnPropertySymbols === 'function') { | ||
51 | ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { | ||
52 | return Object.getOwnPropertyDescriptor(source, sym).enumerable; | ||
53 | })); | ||
54 | } | ||
55 | |||
56 | ownKeys.forEach(function (key) { | ||
57 | _defineProperty(target, key, source[key]); | ||
58 | }); | ||
59 | } | ||
60 | |||
61 | return target; | ||
62 | } | ||
63 | |||
64 | function _inheritsLoose(subClass, superClass) { | ||
65 | subClass.prototype = Object.create(superClass.prototype); | ||
66 | subClass.prototype.constructor = subClass; | ||
67 | subClass.__proto__ = superClass; | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * -------------------------------------------------------------------------- | ||
72 | * Bootstrap (v4.3.1): util.js | ||
73 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
74 | * -------------------------------------------------------------------------- | ||
75 | */ | ||
76 | /** | ||
77 | * ------------------------------------------------------------------------ | ||
78 | * Private TransitionEnd Helpers | ||
79 | * ------------------------------------------------------------------------ | ||
80 | */ | ||
81 | |||
82 | var TRANSITION_END = 'transitionend'; | ||
83 | var MAX_UID = 1000000; | ||
84 | var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp) | ||
85 | |||
86 | function toType(obj) { | ||
87 | return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); | ||
88 | } | ||
89 | |||
90 | function getSpecialTransitionEndEvent() { | ||
91 | return { | ||
92 | bindType: TRANSITION_END, | ||
93 | delegateType: TRANSITION_END, | ||
94 | handle: function handle(event) { | ||
95 | if ($(event.target).is(this)) { | ||
96 | return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params | ||
97 | } | ||
98 | |||
99 | return undefined; // eslint-disable-line no-undefined | ||
100 | } | ||
101 | }; | ||
102 | } | ||
103 | |||
104 | function transitionEndEmulator(duration) { | ||
105 | var _this = this; | ||
106 | |||
107 | var called = false; | ||
108 | $(this).one(Util.TRANSITION_END, function () { | ||
109 | called = true; | ||
110 | }); | ||
111 | setTimeout(function () { | ||
112 | if (!called) { | ||
113 | Util.triggerTransitionEnd(_this); | ||
114 | } | ||
115 | }, duration); | ||
116 | return this; | ||
117 | } | ||
118 | |||
119 | function setTransitionEndSupport() { | ||
120 | $.fn.emulateTransitionEnd = transitionEndEmulator; | ||
121 | $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); | ||
122 | } | ||
123 | /** | ||
124 | * -------------------------------------------------------------------------- | ||
125 | * Public Util Api | ||
126 | * -------------------------------------------------------------------------- | ||
127 | */ | ||
128 | |||
129 | |||
130 | var Util = { | ||
131 | TRANSITION_END: 'bsTransitionEnd', | ||
132 | getUID: function getUID(prefix) { | ||
133 | do { | ||
134 | // eslint-disable-next-line no-bitwise | ||
135 | prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here | ||
136 | } while (document.getElementById(prefix)); | ||
137 | |||
138 | return prefix; | ||
139 | }, | ||
140 | getSelectorFromElement: function getSelectorFromElement(element) { | ||
141 | var selector = element.getAttribute('data-target'); | ||
142 | |||
143 | if (!selector || selector === '#') { | ||
144 | var hrefAttr = element.getAttribute('href'); | ||
145 | selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''; | ||
146 | } | ||
147 | |||
148 | try { | ||
149 | return document.querySelector(selector) ? selector : null; | ||
150 | } catch (err) { | ||
151 | return null; | ||
152 | } | ||
153 | }, | ||
154 | getTransitionDurationFromElement: function getTransitionDurationFromElement(element) { | ||
155 | if (!element) { | ||
156 | return 0; | ||
157 | } // Get transition-duration of the element | ||
158 | |||
159 | |||
160 | var transitionDuration = $(element).css('transition-duration'); | ||
161 | var transitionDelay = $(element).css('transition-delay'); | ||
162 | var floatTransitionDuration = parseFloat(transitionDuration); | ||
163 | var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found | ||
164 | |||
165 | if (!floatTransitionDuration && !floatTransitionDelay) { | ||
166 | return 0; | ||
167 | } // If multiple durations are defined, take the first | ||
168 | |||
169 | |||
170 | transitionDuration = transitionDuration.split(',')[0]; | ||
171 | transitionDelay = transitionDelay.split(',')[0]; | ||
172 | return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; | ||
173 | }, | ||
174 | reflow: function reflow(element) { | ||
175 | return element.offsetHeight; | ||
176 | }, | ||
177 | triggerTransitionEnd: function triggerTransitionEnd(element) { | ||
178 | $(element).trigger(TRANSITION_END); | ||
179 | }, | ||
180 | // TODO: Remove in v5 | ||
181 | supportsTransitionEnd: function supportsTransitionEnd() { | ||
182 | return Boolean(TRANSITION_END); | ||
183 | }, | ||
184 | isElement: function isElement(obj) { | ||
185 | return (obj[0] || obj).nodeType; | ||
186 | }, | ||
187 | typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { | ||
188 | for (var property in configTypes) { | ||
189 | if (Object.prototype.hasOwnProperty.call(configTypes, property)) { | ||
190 | var expectedTypes = configTypes[property]; | ||
191 | var value = config[property]; | ||
192 | var valueType = value && Util.isElement(value) ? 'element' : toType(value); | ||
193 | |||
194 | if (!new RegExp(expectedTypes).test(valueType)) { | ||
195 | throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\".")); | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | }, | ||
200 | findShadowRoot: function findShadowRoot(element) { | ||
201 | if (!document.documentElement.attachShadow) { | ||
202 | return null; | ||
203 | } // Can find the shadow root otherwise it'll return the document | ||
204 | |||
205 | |||
206 | if (typeof element.getRootNode === 'function') { | ||
207 | var root = element.getRootNode(); | ||
208 | return root instanceof ShadowRoot ? root : null; | ||
209 | } | ||
210 | |||
211 | if (element instanceof ShadowRoot) { | ||
212 | return element; | ||
213 | } // when we don't find a shadow root | ||
214 | |||
215 | |||
216 | if (!element.parentNode) { | ||
217 | return null; | ||
218 | } | ||
219 | |||
220 | return Util.findShadowRoot(element.parentNode); | ||
221 | } | ||
222 | }; | ||
223 | setTransitionEndSupport(); | ||
224 | |||
225 | /** | ||
226 | * ------------------------------------------------------------------------ | ||
227 | * Constants | ||
228 | * ------------------------------------------------------------------------ | ||
229 | */ | ||
230 | |||
231 | var NAME = 'alert'; | ||
232 | var VERSION = '4.3.1'; | ||
233 | var DATA_KEY = 'bs.alert'; | ||
234 | var EVENT_KEY = "." + DATA_KEY; | ||
235 | var DATA_API_KEY = '.data-api'; | ||
236 | var JQUERY_NO_CONFLICT = $.fn[NAME]; | ||
237 | var Selector = { | ||
238 | DISMISS: '[data-dismiss="alert"]' | ||
239 | }; | ||
240 | var Event = { | ||
241 | CLOSE: "close" + EVENT_KEY, | ||
242 | CLOSED: "closed" + EVENT_KEY, | ||
243 | CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY | ||
244 | }; | ||
245 | var ClassName = { | ||
246 | ALERT: 'alert', | ||
247 | FADE: 'fade', | ||
248 | SHOW: 'show' | ||
249 | /** | ||
250 | * ------------------------------------------------------------------------ | ||
251 | * Class Definition | ||
252 | * ------------------------------------------------------------------------ | ||
253 | */ | ||
254 | |||
255 | }; | ||
256 | |||
257 | var Alert = | ||
258 | /*#__PURE__*/ | ||
259 | function () { | ||
260 | function Alert(element) { | ||
261 | this._element = element; | ||
262 | } // Getters | ||
263 | |||
264 | |||
265 | var _proto = Alert.prototype; | ||
266 | |||
267 | // Public | ||
268 | _proto.close = function close(element) { | ||
269 | var rootElement = this._element; | ||
270 | |||
271 | if (element) { | ||
272 | rootElement = this._getRootElement(element); | ||
273 | } | ||
274 | |||
275 | var customEvent = this._triggerCloseEvent(rootElement); | ||
276 | |||
277 | if (customEvent.isDefaultPrevented()) { | ||
278 | return; | ||
279 | } | ||
280 | |||
281 | this._removeElement(rootElement); | ||
282 | }; | ||
283 | |||
284 | _proto.dispose = function dispose() { | ||
285 | $.removeData(this._element, DATA_KEY); | ||
286 | this._element = null; | ||
287 | } // Private | ||
288 | ; | ||
289 | |||
290 | _proto._getRootElement = function _getRootElement(element) { | ||
291 | var selector = Util.getSelectorFromElement(element); | ||
292 | var parent = false; | ||
293 | |||
294 | if (selector) { | ||
295 | parent = document.querySelector(selector); | ||
296 | } | ||
297 | |||
298 | if (!parent) { | ||
299 | parent = $(element).closest("." + ClassName.ALERT)[0]; | ||
300 | } | ||
301 | |||
302 | return parent; | ||
303 | }; | ||
304 | |||
305 | _proto._triggerCloseEvent = function _triggerCloseEvent(element) { | ||
306 | var closeEvent = $.Event(Event.CLOSE); | ||
307 | $(element).trigger(closeEvent); | ||
308 | return closeEvent; | ||
309 | }; | ||
310 | |||
311 | _proto._removeElement = function _removeElement(element) { | ||
312 | var _this = this; | ||
313 | |||
314 | $(element).removeClass(ClassName.SHOW); | ||
315 | |||
316 | if (!$(element).hasClass(ClassName.FADE)) { | ||
317 | this._destroyElement(element); | ||
318 | |||
319 | return; | ||
320 | } | ||
321 | |||
322 | var transitionDuration = Util.getTransitionDurationFromElement(element); | ||
323 | $(element).one(Util.TRANSITION_END, function (event) { | ||
324 | return _this._destroyElement(element, event); | ||
325 | }).emulateTransitionEnd(transitionDuration); | ||
326 | }; | ||
327 | |||
328 | _proto._destroyElement = function _destroyElement(element) { | ||
329 | $(element).detach().trigger(Event.CLOSED).remove(); | ||
330 | } // Static | ||
331 | ; | ||
332 | |||
333 | Alert._jQueryInterface = function _jQueryInterface(config) { | ||
334 | return this.each(function () { | ||
335 | var $element = $(this); | ||
336 | var data = $element.data(DATA_KEY); | ||
337 | |||
338 | if (!data) { | ||
339 | data = new Alert(this); | ||
340 | $element.data(DATA_KEY, data); | ||
341 | } | ||
342 | |||
343 | if (config === 'close') { | ||
344 | data[config](this); | ||
345 | } | ||
346 | }); | ||
347 | }; | ||
348 | |||
349 | Alert._handleDismiss = function _handleDismiss(alertInstance) { | ||
350 | return function (event) { | ||
351 | if (event) { | ||
352 | event.preventDefault(); | ||
353 | } | ||
354 | |||
355 | alertInstance.close(this); | ||
356 | }; | ||
357 | }; | ||
358 | |||
359 | _createClass(Alert, null, [{ | ||
360 | key: "VERSION", | ||
361 | get: function get() { | ||
362 | return VERSION; | ||
363 | } | ||
364 | }]); | ||
365 | |||
366 | return Alert; | ||
367 | }(); | ||
368 | /** | ||
369 | * ------------------------------------------------------------------------ | ||
370 | * Data Api implementation | ||
371 | * ------------------------------------------------------------------------ | ||
372 | */ | ||
373 | |||
374 | |||
375 | $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); | ||
376 | /** | ||
377 | * ------------------------------------------------------------------------ | ||
378 | * jQuery | ||
379 | * ------------------------------------------------------------------------ | ||
380 | */ | ||
381 | |||
382 | $.fn[NAME] = Alert._jQueryInterface; | ||
383 | $.fn[NAME].Constructor = Alert; | ||
384 | |||
385 | $.fn[NAME].noConflict = function () { | ||
386 | $.fn[NAME] = JQUERY_NO_CONFLICT; | ||
387 | return Alert._jQueryInterface; | ||
388 | }; | ||
389 | |||
390 | /** | ||
391 | * ------------------------------------------------------------------------ | ||
392 | * Constants | ||
393 | * ------------------------------------------------------------------------ | ||
394 | */ | ||
395 | |||
396 | var NAME$1 = 'button'; | ||
397 | var VERSION$1 = '4.3.1'; | ||
398 | var DATA_KEY$1 = 'bs.button'; | ||
399 | var EVENT_KEY$1 = "." + DATA_KEY$1; | ||
400 | var DATA_API_KEY$1 = '.data-api'; | ||
401 | var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1]; | ||
402 | var ClassName$1 = { | ||
403 | ACTIVE: 'active', | ||
404 | BUTTON: 'btn', | ||
405 | FOCUS: 'focus' | ||
406 | }; | ||
407 | var Selector$1 = { | ||
408 | DATA_TOGGLE_CARROT: '[data-toggle^="button"]', | ||
409 | DATA_TOGGLE: '[data-toggle="buttons"]', | ||
410 | INPUT: 'input:not([type="hidden"])', | ||
411 | ACTIVE: '.active', | ||
412 | BUTTON: '.btn' | ||
413 | }; | ||
414 | var Event$1 = { | ||
415 | CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1, | ||
416 | FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1) | ||
417 | /** | ||
418 | * ------------------------------------------------------------------------ | ||
419 | * Class Definition | ||
420 | * ------------------------------------------------------------------------ | ||
421 | */ | ||
422 | |||
423 | }; | ||
424 | |||
425 | var Button = | ||
426 | /*#__PURE__*/ | ||
427 | function () { | ||
428 | function Button(element) { | ||
429 | this._element = element; | ||
430 | } // Getters | ||
431 | |||
432 | |||
433 | var _proto = Button.prototype; | ||
434 | |||
435 | // Public | ||
436 | _proto.toggle = function toggle() { | ||
437 | var triggerChangeEvent = true; | ||
438 | var addAriaPressed = true; | ||
439 | var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLE)[0]; | ||
440 | |||
441 | if (rootElement) { | ||
442 | var input = this._element.querySelector(Selector$1.INPUT); | ||
443 | |||
444 | if (input) { | ||
445 | if (input.type === 'radio') { | ||
446 | if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) { | ||
447 | triggerChangeEvent = false; | ||
448 | } else { | ||
449 | var activeElement = rootElement.querySelector(Selector$1.ACTIVE); | ||
450 | |||
451 | if (activeElement) { | ||
452 | $(activeElement).removeClass(ClassName$1.ACTIVE); | ||
453 | } | ||
454 | } | ||
455 | } | ||
456 | |||
457 | if (triggerChangeEvent) { | ||
458 | if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) { | ||
459 | return; | ||
460 | } | ||
461 | |||
462 | input.checked = !this._element.classList.contains(ClassName$1.ACTIVE); | ||
463 | $(input).trigger('change'); | ||
464 | } | ||
465 | |||
466 | input.focus(); | ||
467 | addAriaPressed = false; | ||
468 | } | ||
469 | } | ||
470 | |||
471 | if (addAriaPressed) { | ||
472 | this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE)); | ||
473 | } | ||
474 | |||
475 | if (triggerChangeEvent) { | ||
476 | $(this._element).toggleClass(ClassName$1.ACTIVE); | ||
477 | } | ||
478 | }; | ||
479 | |||
480 | _proto.dispose = function dispose() { | ||
481 | $.removeData(this._element, DATA_KEY$1); | ||
482 | this._element = null; | ||
483 | } // Static | ||
484 | ; | ||
485 | |||
486 | Button._jQueryInterface = function _jQueryInterface(config) { | ||
487 | return this.each(function () { | ||
488 | var data = $(this).data(DATA_KEY$1); | ||
489 | |||
490 | if (!data) { | ||
491 | data = new Button(this); | ||
492 | $(this).data(DATA_KEY$1, data); | ||
493 | } | ||
494 | |||
495 | if (config === 'toggle') { | ||
496 | data[config](); | ||
497 | } | ||
498 | }); | ||
499 | }; | ||
500 | |||
501 | _createClass(Button, null, [{ | ||
502 | key: "VERSION", | ||
503 | get: function get() { | ||
504 | return VERSION$1; | ||
505 | } | ||
506 | }]); | ||
507 | |||
508 | return Button; | ||
509 | }(); | ||
510 | /** | ||
511 | * ------------------------------------------------------------------------ | ||
512 | * Data Api implementation | ||
513 | * ------------------------------------------------------------------------ | ||
514 | */ | ||
515 | |||
516 | |||
517 | $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) { | ||
518 | event.preventDefault(); | ||
519 | var button = event.target; | ||
520 | |||
521 | if (!$(button).hasClass(ClassName$1.BUTTON)) { | ||
522 | button = $(button).closest(Selector$1.BUTTON); | ||
523 | } | ||
524 | |||
525 | Button._jQueryInterface.call($(button), 'toggle'); | ||
526 | }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) { | ||
527 | var button = $(event.target).closest(Selector$1.BUTTON)[0]; | ||
528 | $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type)); | ||
529 | }); | ||
530 | /** | ||
531 | * ------------------------------------------------------------------------ | ||
532 | * jQuery | ||
533 | * ------------------------------------------------------------------------ | ||
534 | */ | ||
535 | |||
536 | $.fn[NAME$1] = Button._jQueryInterface; | ||
537 | $.fn[NAME$1].Constructor = Button; | ||
538 | |||
539 | $.fn[NAME$1].noConflict = function () { | ||
540 | $.fn[NAME$1] = JQUERY_NO_CONFLICT$1; | ||
541 | return Button._jQueryInterface; | ||
542 | }; | ||
543 | |||
544 | /** | ||
545 | * ------------------------------------------------------------------------ | ||
546 | * Constants | ||
547 | * ------------------------------------------------------------------------ | ||
548 | */ | ||
549 | |||
550 | var NAME$2 = 'carousel'; | ||
551 | var VERSION$2 = '4.3.1'; | ||
552 | var DATA_KEY$2 = 'bs.carousel'; | ||
553 | var EVENT_KEY$2 = "." + DATA_KEY$2; | ||
554 | var DATA_API_KEY$2 = '.data-api'; | ||
555 | var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2]; | ||
556 | var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key | ||
557 | |||
558 | var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key | ||
559 | |||
560 | var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch | ||
561 | |||
562 | var SWIPE_THRESHOLD = 40; | ||
563 | var Default = { | ||
564 | interval: 5000, | ||
565 | keyboard: true, | ||
566 | slide: false, | ||
567 | pause: 'hover', | ||
568 | wrap: true, | ||
569 | touch: true | ||
570 | }; | ||
571 | var DefaultType = { | ||
572 | interval: '(number|boolean)', | ||
573 | keyboard: 'boolean', | ||
574 | slide: '(boolean|string)', | ||
575 | pause: '(string|boolean)', | ||
576 | wrap: 'boolean', | ||
577 | touch: 'boolean' | ||
578 | }; | ||
579 | var Direction = { | ||
580 | NEXT: 'next', | ||
581 | PREV: 'prev', | ||
582 | LEFT: 'left', | ||
583 | RIGHT: 'right' | ||
584 | }; | ||
585 | var Event$2 = { | ||
586 | SLIDE: "slide" + EVENT_KEY$2, | ||
587 | SLID: "slid" + EVENT_KEY$2, | ||
588 | KEYDOWN: "keydown" + EVENT_KEY$2, | ||
589 | MOUSEENTER: "mouseenter" + EVENT_KEY$2, | ||
590 | MOUSELEAVE: "mouseleave" + EVENT_KEY$2, | ||
591 | TOUCHSTART: "touchstart" + EVENT_KEY$2, | ||
592 | TOUCHMOVE: "touchmove" + EVENT_KEY$2, | ||
593 | TOUCHEND: "touchend" + EVENT_KEY$2, | ||
594 | POINTERDOWN: "pointerdown" + EVENT_KEY$2, | ||
595 | POINTERUP: "pointerup" + EVENT_KEY$2, | ||
596 | DRAG_START: "dragstart" + EVENT_KEY$2, | ||
597 | LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2, | ||
598 | CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2 | ||
599 | }; | ||
600 | var ClassName$2 = { | ||
601 | CAROUSEL: 'carousel', | ||
602 | ACTIVE: 'active', | ||
603 | SLIDE: 'slide', | ||
604 | RIGHT: 'carousel-item-right', | ||
605 | LEFT: 'carousel-item-left', | ||
606 | NEXT: 'carousel-item-next', | ||
607 | PREV: 'carousel-item-prev', | ||
608 | ITEM: 'carousel-item', | ||
609 | POINTER_EVENT: 'pointer-event' | ||
610 | }; | ||
611 | var Selector$2 = { | ||
612 | ACTIVE: '.active', | ||
613 | ACTIVE_ITEM: '.active.carousel-item', | ||
614 | ITEM: '.carousel-item', | ||
615 | ITEM_IMG: '.carousel-item img', | ||
616 | NEXT_PREV: '.carousel-item-next, .carousel-item-prev', | ||
617 | INDICATORS: '.carousel-indicators', | ||
618 | DATA_SLIDE: '[data-slide], [data-slide-to]', | ||
619 | DATA_RIDE: '[data-ride="carousel"]' | ||
620 | }; | ||
621 | var PointerType = { | ||
622 | TOUCH: 'touch', | ||
623 | PEN: 'pen' | ||
624 | /** | ||
625 | * ------------------------------------------------------------------------ | ||
626 | * Class Definition | ||
627 | * ------------------------------------------------------------------------ | ||
628 | */ | ||
629 | |||
630 | }; | ||
631 | |||
632 | var Carousel = | ||
633 | /*#__PURE__*/ | ||
634 | function () { | ||
635 | function Carousel(element, config) { | ||
636 | this._items = null; | ||
637 | this._interval = null; | ||
638 | this._activeElement = null; | ||
639 | this._isPaused = false; | ||
640 | this._isSliding = false; | ||
641 | this.touchTimeout = null; | ||
642 | this.touchStartX = 0; | ||
643 | this.touchDeltaX = 0; | ||
644 | this._config = this._getConfig(config); | ||
645 | this._element = element; | ||
646 | this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS); | ||
647 | this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; | ||
648 | this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent); | ||
649 | |||
650 | this._addEventListeners(); | ||
651 | } // Getters | ||
652 | |||
653 | |||
654 | var _proto = Carousel.prototype; | ||
655 | |||
656 | // Public | ||
657 | _proto.next = function next() { | ||
658 | if (!this._isSliding) { | ||
659 | this._slide(Direction.NEXT); | ||
660 | } | ||
661 | }; | ||
662 | |||
663 | _proto.nextWhenVisible = function nextWhenVisible() { | ||
664 | // Don't call next when the page isn't visible | ||
665 | // or the carousel or its parent isn't visible | ||
666 | if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') { | ||
667 | this.next(); | ||
668 | } | ||
669 | }; | ||
670 | |||
671 | _proto.prev = function prev() { | ||
672 | if (!this._isSliding) { | ||
673 | this._slide(Direction.PREV); | ||
674 | } | ||
675 | }; | ||
676 | |||
677 | _proto.pause = function pause(event) { | ||
678 | if (!event) { | ||
679 | this._isPaused = true; | ||
680 | } | ||
681 | |||
682 | if (this._element.querySelector(Selector$2.NEXT_PREV)) { | ||
683 | Util.triggerTransitionEnd(this._element); | ||
684 | this.cycle(true); | ||
685 | } | ||
686 | |||
687 | clearInterval(this._interval); | ||
688 | this._interval = null; | ||
689 | }; | ||
690 | |||
691 | _proto.cycle = function cycle(event) { | ||
692 | if (!event) { | ||
693 | this._isPaused = false; | ||
694 | } | ||
695 | |||
696 | if (this._interval) { | ||
697 | clearInterval(this._interval); | ||
698 | this._interval = null; | ||
699 | } | ||
700 | |||
701 | if (this._config.interval && !this._isPaused) { | ||
702 | this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); | ||
703 | } | ||
704 | }; | ||
705 | |||
706 | _proto.to = function to(index) { | ||
707 | var _this = this; | ||
708 | |||
709 | this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); | ||
710 | |||
711 | var activeIndex = this._getItemIndex(this._activeElement); | ||
712 | |||
713 | if (index > this._items.length - 1 || index < 0) { | ||
714 | return; | ||
715 | } | ||
716 | |||
717 | if (this._isSliding) { | ||
718 | $(this._element).one(Event$2.SLID, function () { | ||
719 | return _this.to(index); | ||
720 | }); | ||
721 | return; | ||
722 | } | ||
723 | |||
724 | if (activeIndex === index) { | ||
725 | this.pause(); | ||
726 | this.cycle(); | ||
727 | return; | ||
728 | } | ||
729 | |||
730 | var direction = index > activeIndex ? Direction.NEXT : Direction.PREV; | ||
731 | |||
732 | this._slide(direction, this._items[index]); | ||
733 | }; | ||
734 | |||
735 | _proto.dispose = function dispose() { | ||
736 | $(this._element).off(EVENT_KEY$2); | ||
737 | $.removeData(this._element, DATA_KEY$2); | ||
738 | this._items = null; | ||
739 | this._config = null; | ||
740 | this._element = null; | ||
741 | this._interval = null; | ||
742 | this._isPaused = null; | ||
743 | this._isSliding = null; | ||
744 | this._activeElement = null; | ||
745 | this._indicatorsElement = null; | ||
746 | } // Private | ||
747 | ; | ||
748 | |||
749 | _proto._getConfig = function _getConfig(config) { | ||
750 | config = _objectSpread({}, Default, config); | ||
751 | Util.typeCheckConfig(NAME$2, config, DefaultType); | ||
752 | return config; | ||
753 | }; | ||
754 | |||
755 | _proto._handleSwipe = function _handleSwipe() { | ||
756 | var absDeltax = Math.abs(this.touchDeltaX); | ||
757 | |||
758 | if (absDeltax <= SWIPE_THRESHOLD) { | ||
759 | return; | ||
760 | } | ||
761 | |||
762 | var direction = absDeltax / this.touchDeltaX; // swipe left | ||
763 | |||
764 | if (direction > 0) { | ||
765 | this.prev(); | ||
766 | } // swipe right | ||
767 | |||
768 | |||
769 | if (direction < 0) { | ||
770 | this.next(); | ||
771 | } | ||
772 | }; | ||
773 | |||
774 | _proto._addEventListeners = function _addEventListeners() { | ||
775 | var _this2 = this; | ||
776 | |||
777 | if (this._config.keyboard) { | ||
778 | $(this._element).on(Event$2.KEYDOWN, function (event) { | ||
779 | return _this2._keydown(event); | ||
780 | }); | ||
781 | } | ||
782 | |||
783 | if (this._config.pause === 'hover') { | ||
784 | $(this._element).on(Event$2.MOUSEENTER, function (event) { | ||
785 | return _this2.pause(event); | ||
786 | }).on(Event$2.MOUSELEAVE, function (event) { | ||
787 | return _this2.cycle(event); | ||
788 | }); | ||
789 | } | ||
790 | |||
791 | if (this._config.touch) { | ||
792 | this._addTouchEventListeners(); | ||
793 | } | ||
794 | }; | ||
795 | |||
796 | _proto._addTouchEventListeners = function _addTouchEventListeners() { | ||
797 | var _this3 = this; | ||
798 | |||
799 | if (!this._touchSupported) { | ||
800 | return; | ||
801 | } | ||
802 | |||
803 | var start = function start(event) { | ||
804 | if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { | ||
805 | _this3.touchStartX = event.originalEvent.clientX; | ||
806 | } else if (!_this3._pointerEvent) { | ||
807 | _this3.touchStartX = event.originalEvent.touches[0].clientX; | ||
808 | } | ||
809 | }; | ||
810 | |||
811 | var move = function move(event) { | ||
812 | // ensure swiping with one touch and not pinching | ||
813 | if (event.originalEvent.touches && event.originalEvent.touches.length > 1) { | ||
814 | _this3.touchDeltaX = 0; | ||
815 | } else { | ||
816 | _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX; | ||
817 | } | ||
818 | }; | ||
819 | |||
820 | var end = function end(event) { | ||
821 | if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { | ||
822 | _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX; | ||
823 | } | ||
824 | |||
825 | _this3._handleSwipe(); | ||
826 | |||
827 | if (_this3._config.pause === 'hover') { | ||
828 | // If it's a touch-enabled device, mouseenter/leave are fired as | ||
829 | // part of the mouse compatibility events on first tap - the carousel | ||
830 | // would stop cycling until user tapped out of it; | ||
831 | // here, we listen for touchend, explicitly pause the carousel | ||
832 | // (as if it's the second time we tap on it, mouseenter compat event | ||
833 | // is NOT fired) and after a timeout (to allow for mouse compatibility | ||
834 | // events to fire) we explicitly restart cycling | ||
835 | _this3.pause(); | ||
836 | |||
837 | if (_this3.touchTimeout) { | ||
838 | clearTimeout(_this3.touchTimeout); | ||
839 | } | ||
840 | |||
841 | _this3.touchTimeout = setTimeout(function (event) { | ||
842 | return _this3.cycle(event); | ||
843 | }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval); | ||
844 | } | ||
845 | }; | ||
846 | |||
847 | $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) { | ||
848 | return e.preventDefault(); | ||
849 | }); | ||
850 | |||
851 | if (this._pointerEvent) { | ||
852 | $(this._element).on(Event$2.POINTERDOWN, function (event) { | ||
853 | return start(event); | ||
854 | }); | ||
855 | $(this._element).on(Event$2.POINTERUP, function (event) { | ||
856 | return end(event); | ||
857 | }); | ||
858 | |||
859 | this._element.classList.add(ClassName$2.POINTER_EVENT); | ||
860 | } else { | ||
861 | $(this._element).on(Event$2.TOUCHSTART, function (event) { | ||
862 | return start(event); | ||
863 | }); | ||
864 | $(this._element).on(Event$2.TOUCHMOVE, function (event) { | ||
865 | return move(event); | ||
866 | }); | ||
867 | $(this._element).on(Event$2.TOUCHEND, function (event) { | ||
868 | return end(event); | ||
869 | }); | ||
870 | } | ||
871 | }; | ||
872 | |||
873 | _proto._keydown = function _keydown(event) { | ||
874 | if (/input|textarea/i.test(event.target.tagName)) { | ||
875 | return; | ||
876 | } | ||
877 | |||
878 | switch (event.which) { | ||
879 | case ARROW_LEFT_KEYCODE: | ||
880 | event.preventDefault(); | ||
881 | this.prev(); | ||
882 | break; | ||
883 | |||
884 | case ARROW_RIGHT_KEYCODE: | ||
885 | event.preventDefault(); | ||
886 | this.next(); | ||
887 | break; | ||
888 | |||
889 | default: | ||
890 | } | ||
891 | }; | ||
892 | |||
893 | _proto._getItemIndex = function _getItemIndex(element) { | ||
894 | this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : []; | ||
895 | return this._items.indexOf(element); | ||
896 | }; | ||
897 | |||
898 | _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) { | ||
899 | var isNextDirection = direction === Direction.NEXT; | ||
900 | var isPrevDirection = direction === Direction.PREV; | ||
901 | |||
902 | var activeIndex = this._getItemIndex(activeElement); | ||
903 | |||
904 | var lastItemIndex = this._items.length - 1; | ||
905 | var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; | ||
906 | |||
907 | if (isGoingToWrap && !this._config.wrap) { | ||
908 | return activeElement; | ||
909 | } | ||
910 | |||
911 | var delta = direction === Direction.PREV ? -1 : 1; | ||
912 | var itemIndex = (activeIndex + delta) % this._items.length; | ||
913 | return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; | ||
914 | }; | ||
915 | |||
916 | _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { | ||
917 | var targetIndex = this._getItemIndex(relatedTarget); | ||
918 | |||
919 | var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM)); | ||
920 | |||
921 | var slideEvent = $.Event(Event$2.SLIDE, { | ||
922 | relatedTarget: relatedTarget, | ||
923 | direction: eventDirectionName, | ||
924 | from: fromIndex, | ||
925 | to: targetIndex | ||
926 | }); | ||
927 | $(this._element).trigger(slideEvent); | ||
928 | return slideEvent; | ||
929 | }; | ||
930 | |||
931 | _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { | ||
932 | if (this._indicatorsElement) { | ||
933 | var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE)); | ||
934 | $(indicators).removeClass(ClassName$2.ACTIVE); | ||
935 | |||
936 | var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; | ||
937 | |||
938 | if (nextIndicator) { | ||
939 | $(nextIndicator).addClass(ClassName$2.ACTIVE); | ||
940 | } | ||
941 | } | ||
942 | }; | ||
943 | |||
944 | _proto._slide = function _slide(direction, element) { | ||
945 | var _this4 = this; | ||
946 | |||
947 | var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM); | ||
948 | |||
949 | var activeElementIndex = this._getItemIndex(activeElement); | ||
950 | |||
951 | var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); | ||
952 | |||
953 | var nextElementIndex = this._getItemIndex(nextElement); | ||
954 | |||
955 | var isCycling = Boolean(this._interval); | ||
956 | var directionalClassName; | ||
957 | var orderClassName; | ||
958 | var eventDirectionName; | ||
959 | |||
960 | if (direction === Direction.NEXT) { | ||
961 | directionalClassName = ClassName$2.LEFT; | ||
962 | orderClassName = ClassName$2.NEXT; | ||
963 | eventDirectionName = Direction.LEFT; | ||
964 | } else { | ||
965 | directionalClassName = ClassName$2.RIGHT; | ||
966 | orderClassName = ClassName$2.PREV; | ||
967 | eventDirectionName = Direction.RIGHT; | ||
968 | } | ||
969 | |||
970 | if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) { | ||
971 | this._isSliding = false; | ||
972 | return; | ||
973 | } | ||
974 | |||
975 | var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); | ||
976 | |||
977 | if (slideEvent.isDefaultPrevented()) { | ||
978 | return; | ||
979 | } | ||
980 | |||
981 | if (!activeElement || !nextElement) { | ||
982 | // Some weirdness is happening, so we bail | ||
983 | return; | ||
984 | } | ||
985 | |||
986 | this._isSliding = true; | ||
987 | |||
988 | if (isCycling) { | ||
989 | this.pause(); | ||
990 | } | ||
991 | |||
992 | this._setActiveIndicatorElement(nextElement); | ||
993 | |||
994 | var slidEvent = $.Event(Event$2.SLID, { | ||
995 | relatedTarget: nextElement, | ||
996 | direction: eventDirectionName, | ||
997 | from: activeElementIndex, | ||
998 | to: nextElementIndex | ||
999 | }); | ||
1000 | |||
1001 | if ($(this._element).hasClass(ClassName$2.SLIDE)) { | ||
1002 | $(nextElement).addClass(orderClassName); | ||
1003 | Util.reflow(nextElement); | ||
1004 | $(activeElement).addClass(directionalClassName); | ||
1005 | $(nextElement).addClass(directionalClassName); | ||
1006 | var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10); | ||
1007 | |||
1008 | if (nextElementInterval) { | ||
1009 | this._config.defaultInterval = this._config.defaultInterval || this._config.interval; | ||
1010 | this._config.interval = nextElementInterval; | ||
1011 | } else { | ||
1012 | this._config.interval = this._config.defaultInterval || this._config.interval; | ||
1013 | } | ||
1014 | |||
1015 | var transitionDuration = Util.getTransitionDurationFromElement(activeElement); | ||
1016 | $(activeElement).one(Util.TRANSITION_END, function () { | ||
1017 | $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE); | ||
1018 | $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName); | ||
1019 | _this4._isSliding = false; | ||
1020 | setTimeout(function () { | ||
1021 | return $(_this4._element).trigger(slidEvent); | ||
1022 | }, 0); | ||
1023 | }).emulateTransitionEnd(transitionDuration); | ||
1024 | } else { | ||
1025 | $(activeElement).removeClass(ClassName$2.ACTIVE); | ||
1026 | $(nextElement).addClass(ClassName$2.ACTIVE); | ||
1027 | this._isSliding = false; | ||
1028 | $(this._element).trigger(slidEvent); | ||
1029 | } | ||
1030 | |||
1031 | if (isCycling) { | ||
1032 | this.cycle(); | ||
1033 | } | ||
1034 | } // Static | ||
1035 | ; | ||
1036 | |||
1037 | Carousel._jQueryInterface = function _jQueryInterface(config) { | ||
1038 | return this.each(function () { | ||
1039 | var data = $(this).data(DATA_KEY$2); | ||
1040 | |||
1041 | var _config = _objectSpread({}, Default, $(this).data()); | ||
1042 | |||
1043 | if (typeof config === 'object') { | ||
1044 | _config = _objectSpread({}, _config, config); | ||
1045 | } | ||
1046 | |||
1047 | var action = typeof config === 'string' ? config : _config.slide; | ||
1048 | |||
1049 | if (!data) { | ||
1050 | data = new Carousel(this, _config); | ||
1051 | $(this).data(DATA_KEY$2, data); | ||
1052 | } | ||
1053 | |||
1054 | if (typeof config === 'number') { | ||
1055 | data.to(config); | ||
1056 | } else if (typeof action === 'string') { | ||
1057 | if (typeof data[action] === 'undefined') { | ||
1058 | throw new TypeError("No method named \"" + action + "\""); | ||
1059 | } | ||
1060 | |||
1061 | data[action](); | ||
1062 | } else if (_config.interval && _config.ride) { | ||
1063 | data.pause(); | ||
1064 | data.cycle(); | ||
1065 | } | ||
1066 | }); | ||
1067 | }; | ||
1068 | |||
1069 | Carousel._dataApiClickHandler = function _dataApiClickHandler(event) { | ||
1070 | var selector = Util.getSelectorFromElement(this); | ||
1071 | |||
1072 | if (!selector) { | ||
1073 | return; | ||
1074 | } | ||
1075 | |||
1076 | var target = $(selector)[0]; | ||
1077 | |||
1078 | if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) { | ||
1079 | return; | ||
1080 | } | ||
1081 | |||
1082 | var config = _objectSpread({}, $(target).data(), $(this).data()); | ||
1083 | |||
1084 | var slideIndex = this.getAttribute('data-slide-to'); | ||
1085 | |||
1086 | if (slideIndex) { | ||
1087 | config.interval = false; | ||
1088 | } | ||
1089 | |||
1090 | Carousel._jQueryInterface.call($(target), config); | ||
1091 | |||
1092 | if (slideIndex) { | ||
1093 | $(target).data(DATA_KEY$2).to(slideIndex); | ||
1094 | } | ||
1095 | |||
1096 | event.preventDefault(); | ||
1097 | }; | ||
1098 | |||
1099 | _createClass(Carousel, null, [{ | ||
1100 | key: "VERSION", | ||
1101 | get: function get() { | ||
1102 | return VERSION$2; | ||
1103 | } | ||
1104 | }, { | ||
1105 | key: "Default", | ||
1106 | get: function get() { | ||
1107 | return Default; | ||
1108 | } | ||
1109 | }]); | ||
1110 | |||
1111 | return Carousel; | ||
1112 | }(); | ||
1113 | /** | ||
1114 | * ------------------------------------------------------------------------ | ||
1115 | * Data Api implementation | ||
1116 | * ------------------------------------------------------------------------ | ||
1117 | */ | ||
1118 | |||
1119 | |||
1120 | $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler); | ||
1121 | $(window).on(Event$2.LOAD_DATA_API, function () { | ||
1122 | var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE)); | ||
1123 | |||
1124 | for (var i = 0, len = carousels.length; i < len; i++) { | ||
1125 | var $carousel = $(carousels[i]); | ||
1126 | |||
1127 | Carousel._jQueryInterface.call($carousel, $carousel.data()); | ||
1128 | } | ||
1129 | }); | ||
1130 | /** | ||
1131 | * ------------------------------------------------------------------------ | ||
1132 | * jQuery | ||
1133 | * ------------------------------------------------------------------------ | ||
1134 | */ | ||
1135 | |||
1136 | $.fn[NAME$2] = Carousel._jQueryInterface; | ||
1137 | $.fn[NAME$2].Constructor = Carousel; | ||
1138 | |||
1139 | $.fn[NAME$2].noConflict = function () { | ||
1140 | $.fn[NAME$2] = JQUERY_NO_CONFLICT$2; | ||
1141 | return Carousel._jQueryInterface; | ||
1142 | }; | ||
1143 | |||
1144 | /** | ||
1145 | * ------------------------------------------------------------------------ | ||
1146 | * Constants | ||
1147 | * ------------------------------------------------------------------------ | ||
1148 | */ | ||
1149 | |||
1150 | var NAME$3 = 'collapse'; | ||
1151 | var VERSION$3 = '4.3.1'; | ||
1152 | var DATA_KEY$3 = 'bs.collapse'; | ||
1153 | var EVENT_KEY$3 = "." + DATA_KEY$3; | ||
1154 | var DATA_API_KEY$3 = '.data-api'; | ||
1155 | var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3]; | ||
1156 | var Default$1 = { | ||
1157 | toggle: true, | ||
1158 | parent: '' | ||
1159 | }; | ||
1160 | var DefaultType$1 = { | ||
1161 | toggle: 'boolean', | ||
1162 | parent: '(string|element)' | ||
1163 | }; | ||
1164 | var Event$3 = { | ||
1165 | SHOW: "show" + EVENT_KEY$3, | ||
1166 | SHOWN: "shown" + EVENT_KEY$3, | ||
1167 | HIDE: "hide" + EVENT_KEY$3, | ||
1168 | HIDDEN: "hidden" + EVENT_KEY$3, | ||
1169 | CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3 | ||
1170 | }; | ||
1171 | var ClassName$3 = { | ||
1172 | SHOW: 'show', | ||
1173 | COLLAPSE: 'collapse', | ||
1174 | COLLAPSING: 'collapsing', | ||
1175 | COLLAPSED: 'collapsed' | ||
1176 | }; | ||
1177 | var Dimension = { | ||
1178 | WIDTH: 'width', | ||
1179 | HEIGHT: 'height' | ||
1180 | }; | ||
1181 | var Selector$3 = { | ||
1182 | ACTIVES: '.show, .collapsing', | ||
1183 | DATA_TOGGLE: '[data-toggle="collapse"]' | ||
1184 | /** | ||
1185 | * ------------------------------------------------------------------------ | ||
1186 | * Class Definition | ||
1187 | * ------------------------------------------------------------------------ | ||
1188 | */ | ||
1189 | |||
1190 | }; | ||
1191 | |||
1192 | var Collapse = | ||
1193 | /*#__PURE__*/ | ||
1194 | function () { | ||
1195 | function Collapse(element, config) { | ||
1196 | this._isTransitioning = false; | ||
1197 | this._element = element; | ||
1198 | this._config = this._getConfig(config); | ||
1199 | this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); | ||
1200 | var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE)); | ||
1201 | |||
1202 | for (var i = 0, len = toggleList.length; i < len; i++) { | ||
1203 | var elem = toggleList[i]; | ||
1204 | var selector = Util.getSelectorFromElement(elem); | ||
1205 | var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) { | ||
1206 | return foundElem === element; | ||
1207 | }); | ||
1208 | |||
1209 | if (selector !== null && filterElement.length > 0) { | ||
1210 | this._selector = selector; | ||
1211 | |||
1212 | this._triggerArray.push(elem); | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | this._parent = this._config.parent ? this._getParent() : null; | ||
1217 | |||
1218 | if (!this._config.parent) { | ||
1219 | this._addAriaAndCollapsedClass(this._element, this._triggerArray); | ||
1220 | } | ||
1221 | |||
1222 | if (this._config.toggle) { | ||
1223 | this.toggle(); | ||
1224 | } | ||
1225 | } // Getters | ||
1226 | |||
1227 | |||
1228 | var _proto = Collapse.prototype; | ||
1229 | |||
1230 | // Public | ||
1231 | _proto.toggle = function toggle() { | ||
1232 | if ($(this._element).hasClass(ClassName$3.SHOW)) { | ||
1233 | this.hide(); | ||
1234 | } else { | ||
1235 | this.show(); | ||
1236 | } | ||
1237 | }; | ||
1238 | |||
1239 | _proto.show = function show() { | ||
1240 | var _this = this; | ||
1241 | |||
1242 | if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) { | ||
1243 | return; | ||
1244 | } | ||
1245 | |||
1246 | var actives; | ||
1247 | var activesData; | ||
1248 | |||
1249 | if (this._parent) { | ||
1250 | actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) { | ||
1251 | if (typeof _this._config.parent === 'string') { | ||
1252 | return elem.getAttribute('data-parent') === _this._config.parent; | ||
1253 | } | ||
1254 | |||
1255 | return elem.classList.contains(ClassName$3.COLLAPSE); | ||
1256 | }); | ||
1257 | |||
1258 | if (actives.length === 0) { | ||
1259 | actives = null; | ||
1260 | } | ||
1261 | } | ||
1262 | |||
1263 | if (actives) { | ||
1264 | activesData = $(actives).not(this._selector).data(DATA_KEY$3); | ||
1265 | |||
1266 | if (activesData && activesData._isTransitioning) { | ||
1267 | return; | ||
1268 | } | ||
1269 | } | ||
1270 | |||
1271 | var startEvent = $.Event(Event$3.SHOW); | ||
1272 | $(this._element).trigger(startEvent); | ||
1273 | |||
1274 | if (startEvent.isDefaultPrevented()) { | ||
1275 | return; | ||
1276 | } | ||
1277 | |||
1278 | if (actives) { | ||
1279 | Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide'); | ||
1280 | |||
1281 | if (!activesData) { | ||
1282 | $(actives).data(DATA_KEY$3, null); | ||
1283 | } | ||
1284 | } | ||
1285 | |||
1286 | var dimension = this._getDimension(); | ||
1287 | |||
1288 | $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING); | ||
1289 | this._element.style[dimension] = 0; | ||
1290 | |||
1291 | if (this._triggerArray.length) { | ||
1292 | $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true); | ||
1293 | } | ||
1294 | |||
1295 | this.setTransitioning(true); | ||
1296 | |||
1297 | var complete = function complete() { | ||
1298 | $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW); | ||
1299 | _this._element.style[dimension] = ''; | ||
1300 | |||
1301 | _this.setTransitioning(false); | ||
1302 | |||
1303 | $(_this._element).trigger(Event$3.SHOWN); | ||
1304 | }; | ||
1305 | |||
1306 | var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); | ||
1307 | var scrollSize = "scroll" + capitalizedDimension; | ||
1308 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); | ||
1309 | $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
1310 | this._element.style[dimension] = this._element[scrollSize] + "px"; | ||
1311 | }; | ||
1312 | |||
1313 | _proto.hide = function hide() { | ||
1314 | var _this2 = this; | ||
1315 | |||
1316 | if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) { | ||
1317 | return; | ||
1318 | } | ||
1319 | |||
1320 | var startEvent = $.Event(Event$3.HIDE); | ||
1321 | $(this._element).trigger(startEvent); | ||
1322 | |||
1323 | if (startEvent.isDefaultPrevented()) { | ||
1324 | return; | ||
1325 | } | ||
1326 | |||
1327 | var dimension = this._getDimension(); | ||
1328 | |||
1329 | this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; | ||
1330 | Util.reflow(this._element); | ||
1331 | $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW); | ||
1332 | var triggerArrayLength = this._triggerArray.length; | ||
1333 | |||
1334 | if (triggerArrayLength > 0) { | ||
1335 | for (var i = 0; i < triggerArrayLength; i++) { | ||
1336 | var trigger = this._triggerArray[i]; | ||
1337 | var selector = Util.getSelectorFromElement(trigger); | ||
1338 | |||
1339 | if (selector !== null) { | ||
1340 | var $elem = $([].slice.call(document.querySelectorAll(selector))); | ||
1341 | |||
1342 | if (!$elem.hasClass(ClassName$3.SHOW)) { | ||
1343 | $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false); | ||
1344 | } | ||
1345 | } | ||
1346 | } | ||
1347 | } | ||
1348 | |||
1349 | this.setTransitioning(true); | ||
1350 | |||
1351 | var complete = function complete() { | ||
1352 | _this2.setTransitioning(false); | ||
1353 | |||
1354 | $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN); | ||
1355 | }; | ||
1356 | |||
1357 | this._element.style[dimension] = ''; | ||
1358 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); | ||
1359 | $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
1360 | }; | ||
1361 | |||
1362 | _proto.setTransitioning = function setTransitioning(isTransitioning) { | ||
1363 | this._isTransitioning = isTransitioning; | ||
1364 | }; | ||
1365 | |||
1366 | _proto.dispose = function dispose() { | ||
1367 | $.removeData(this._element, DATA_KEY$3); | ||
1368 | this._config = null; | ||
1369 | this._parent = null; | ||
1370 | this._element = null; | ||
1371 | this._triggerArray = null; | ||
1372 | this._isTransitioning = null; | ||
1373 | } // Private | ||
1374 | ; | ||
1375 | |||
1376 | _proto._getConfig = function _getConfig(config) { | ||
1377 | config = _objectSpread({}, Default$1, config); | ||
1378 | config.toggle = Boolean(config.toggle); // Coerce string values | ||
1379 | |||
1380 | Util.typeCheckConfig(NAME$3, config, DefaultType$1); | ||
1381 | return config; | ||
1382 | }; | ||
1383 | |||
1384 | _proto._getDimension = function _getDimension() { | ||
1385 | var hasWidth = $(this._element).hasClass(Dimension.WIDTH); | ||
1386 | return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; | ||
1387 | }; | ||
1388 | |||
1389 | _proto._getParent = function _getParent() { | ||
1390 | var _this3 = this; | ||
1391 | |||
1392 | var parent; | ||
1393 | |||
1394 | if (Util.isElement(this._config.parent)) { | ||
1395 | parent = this._config.parent; // It's a jQuery object | ||
1396 | |||
1397 | if (typeof this._config.parent.jquery !== 'undefined') { | ||
1398 | parent = this._config.parent[0]; | ||
1399 | } | ||
1400 | } else { | ||
1401 | parent = document.querySelector(this._config.parent); | ||
1402 | } | ||
1403 | |||
1404 | var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]"; | ||
1405 | var children = [].slice.call(parent.querySelectorAll(selector)); | ||
1406 | $(children).each(function (i, element) { | ||
1407 | _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); | ||
1408 | }); | ||
1409 | return parent; | ||
1410 | }; | ||
1411 | |||
1412 | _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { | ||
1413 | var isOpen = $(element).hasClass(ClassName$3.SHOW); | ||
1414 | |||
1415 | if (triggerArray.length) { | ||
1416 | $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); | ||
1417 | } | ||
1418 | } // Static | ||
1419 | ; | ||
1420 | |||
1421 | Collapse._getTargetFromElement = function _getTargetFromElement(element) { | ||
1422 | var selector = Util.getSelectorFromElement(element); | ||
1423 | return selector ? document.querySelector(selector) : null; | ||
1424 | }; | ||
1425 | |||
1426 | Collapse._jQueryInterface = function _jQueryInterface(config) { | ||
1427 | return this.each(function () { | ||
1428 | var $this = $(this); | ||
1429 | var data = $this.data(DATA_KEY$3); | ||
1430 | |||
1431 | var _config = _objectSpread({}, Default$1, $this.data(), typeof config === 'object' && config ? config : {}); | ||
1432 | |||
1433 | if (!data && _config.toggle && /show|hide/.test(config)) { | ||
1434 | _config.toggle = false; | ||
1435 | } | ||
1436 | |||
1437 | if (!data) { | ||
1438 | data = new Collapse(this, _config); | ||
1439 | $this.data(DATA_KEY$3, data); | ||
1440 | } | ||
1441 | |||
1442 | if (typeof config === 'string') { | ||
1443 | if (typeof data[config] === 'undefined') { | ||
1444 | throw new TypeError("No method named \"" + config + "\""); | ||
1445 | } | ||
1446 | |||
1447 | data[config](); | ||
1448 | } | ||
1449 | }); | ||
1450 | }; | ||
1451 | |||
1452 | _createClass(Collapse, null, [{ | ||
1453 | key: "VERSION", | ||
1454 | get: function get() { | ||
1455 | return VERSION$3; | ||
1456 | } | ||
1457 | }, { | ||
1458 | key: "Default", | ||
1459 | get: function get() { | ||
1460 | return Default$1; | ||
1461 | } | ||
1462 | }]); | ||
1463 | |||
1464 | return Collapse; | ||
1465 | }(); | ||
1466 | /** | ||
1467 | * ------------------------------------------------------------------------ | ||
1468 | * Data Api implementation | ||
1469 | * ------------------------------------------------------------------------ | ||
1470 | */ | ||
1471 | |||
1472 | |||
1473 | $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) { | ||
1474 | // preventDefault only for <a> elements (which change the URL) not inside the collapsible element | ||
1475 | if (event.currentTarget.tagName === 'A') { | ||
1476 | event.preventDefault(); | ||
1477 | } | ||
1478 | |||
1479 | var $trigger = $(this); | ||
1480 | var selector = Util.getSelectorFromElement(this); | ||
1481 | var selectors = [].slice.call(document.querySelectorAll(selector)); | ||
1482 | $(selectors).each(function () { | ||
1483 | var $target = $(this); | ||
1484 | var data = $target.data(DATA_KEY$3); | ||
1485 | var config = data ? 'toggle' : $trigger.data(); | ||
1486 | |||
1487 | Collapse._jQueryInterface.call($target, config); | ||
1488 | }); | ||
1489 | }); | ||
1490 | /** | ||
1491 | * ------------------------------------------------------------------------ | ||
1492 | * jQuery | ||
1493 | * ------------------------------------------------------------------------ | ||
1494 | */ | ||
1495 | |||
1496 | $.fn[NAME$3] = Collapse._jQueryInterface; | ||
1497 | $.fn[NAME$3].Constructor = Collapse; | ||
1498 | |||
1499 | $.fn[NAME$3].noConflict = function () { | ||
1500 | $.fn[NAME$3] = JQUERY_NO_CONFLICT$3; | ||
1501 | return Collapse._jQueryInterface; | ||
1502 | }; | ||
1503 | |||
1504 | /**! | ||
1505 | * @fileOverview Kickass library to create and place poppers near their reference elements. | ||
1506 | * @version 1.14.7 | ||
1507 | * @license | ||
1508 | * Copyright (c) 2016 Federico Zivolo and contributors | ||
1509 | * | ||
1510 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
1511 | * of this software and associated documentation files (the "Software"), to deal | ||
1512 | * in the Software without restriction, including without limitation the rights | ||
1513 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
1514 | * copies of the Software, and to permit persons to whom the Software is | ||
1515 | * furnished to do so, subject to the following conditions: | ||
1516 | * | ||
1517 | * The above copyright notice and this permission notice shall be included in all | ||
1518 | * copies or substantial portions of the Software. | ||
1519 | * | ||
1520 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
1521 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
1522 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
1523 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
1524 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
1525 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
1526 | * SOFTWARE. | ||
1527 | */ | ||
1528 | var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined'; | ||
1529 | |||
1530 | var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; | ||
1531 | var timeoutDuration = 0; | ||
1532 | for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { | ||
1533 | if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { | ||
1534 | timeoutDuration = 1; | ||
1535 | break; | ||
1536 | } | ||
1537 | } | ||
1538 | |||
1539 | function microtaskDebounce(fn) { | ||
1540 | var called = false; | ||
1541 | return function () { | ||
1542 | if (called) { | ||
1543 | return; | ||
1544 | } | ||
1545 | called = true; | ||
1546 | window.Promise.resolve().then(function () { | ||
1547 | called = false; | ||
1548 | fn(); | ||
1549 | }); | ||
1550 | }; | ||
1551 | } | ||
1552 | |||
1553 | function taskDebounce(fn) { | ||
1554 | var scheduled = false; | ||
1555 | return function () { | ||
1556 | if (!scheduled) { | ||
1557 | scheduled = true; | ||
1558 | setTimeout(function () { | ||
1559 | scheduled = false; | ||
1560 | fn(); | ||
1561 | }, timeoutDuration); | ||
1562 | } | ||
1563 | }; | ||
1564 | } | ||
1565 | |||
1566 | var supportsMicroTasks = isBrowser && window.Promise; | ||
1567 | |||
1568 | /** | ||
1569 | * Create a debounced version of a method, that's asynchronously deferred | ||
1570 | * but called in the minimum time possible. | ||
1571 | * | ||
1572 | * @method | ||
1573 | * @memberof Popper.Utils | ||
1574 | * @argument {Function} fn | ||
1575 | * @returns {Function} | ||
1576 | */ | ||
1577 | var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce; | ||
1578 | |||
1579 | /** | ||
1580 | * Check if the given variable is a function | ||
1581 | * @method | ||
1582 | * @memberof Popper.Utils | ||
1583 | * @argument {Any} functionToCheck - variable to check | ||
1584 | * @returns {Boolean} answer to: is a function? | ||
1585 | */ | ||
1586 | function isFunction(functionToCheck) { | ||
1587 | var getType = {}; | ||
1588 | return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; | ||
1589 | } | ||
1590 | |||
1591 | /** | ||
1592 | * Get CSS computed property of the given element | ||
1593 | * @method | ||
1594 | * @memberof Popper.Utils | ||
1595 | * @argument {Eement} element | ||
1596 | * @argument {String} property | ||
1597 | */ | ||
1598 | function getStyleComputedProperty(element, property) { | ||
1599 | if (element.nodeType !== 1) { | ||
1600 | return []; | ||
1601 | } | ||
1602 | // NOTE: 1 DOM access here | ||
1603 | var window = element.ownerDocument.defaultView; | ||
1604 | var css = window.getComputedStyle(element, null); | ||
1605 | return property ? css[property] : css; | ||
1606 | } | ||
1607 | |||
1608 | /** | ||
1609 | * Returns the parentNode or the host of the element | ||
1610 | * @method | ||
1611 | * @memberof Popper.Utils | ||
1612 | * @argument {Element} element | ||
1613 | * @returns {Element} parent | ||
1614 | */ | ||
1615 | function getParentNode(element) { | ||
1616 | if (element.nodeName === 'HTML') { | ||
1617 | return element; | ||
1618 | } | ||
1619 | return element.parentNode || element.host; | ||
1620 | } | ||
1621 | |||
1622 | /** | ||
1623 | * Returns the scrolling parent of the given element | ||
1624 | * @method | ||
1625 | * @memberof Popper.Utils | ||
1626 | * @argument {Element} element | ||
1627 | * @returns {Element} scroll parent | ||
1628 | */ | ||
1629 | function getScrollParent(element) { | ||
1630 | // Return body, `getScroll` will take care to get the correct `scrollTop` from it | ||
1631 | if (!element) { | ||
1632 | return document.body; | ||
1633 | } | ||
1634 | |||
1635 | switch (element.nodeName) { | ||
1636 | case 'HTML': | ||
1637 | case 'BODY': | ||
1638 | return element.ownerDocument.body; | ||
1639 | case '#document': | ||
1640 | return element.body; | ||
1641 | } | ||
1642 | |||
1643 | // Firefox want us to check `-x` and `-y` variations as well | ||
1644 | |||
1645 | var _getStyleComputedProp = getStyleComputedProperty(element), | ||
1646 | overflow = _getStyleComputedProp.overflow, | ||
1647 | overflowX = _getStyleComputedProp.overflowX, | ||
1648 | overflowY = _getStyleComputedProp.overflowY; | ||
1649 | |||
1650 | if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) { | ||
1651 | return element; | ||
1652 | } | ||
1653 | |||
1654 | return getScrollParent(getParentNode(element)); | ||
1655 | } | ||
1656 | |||
1657 | var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); | ||
1658 | var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); | ||
1659 | |||
1660 | /** | ||
1661 | * Determines if the browser is Internet Explorer | ||
1662 | * @method | ||
1663 | * @memberof Popper.Utils | ||
1664 | * @param {Number} version to check | ||
1665 | * @returns {Boolean} isIE | ||
1666 | */ | ||
1667 | function isIE(version) { | ||
1668 | if (version === 11) { | ||
1669 | return isIE11; | ||
1670 | } | ||
1671 | if (version === 10) { | ||
1672 | return isIE10; | ||
1673 | } | ||
1674 | return isIE11 || isIE10; | ||
1675 | } | ||
1676 | |||
1677 | /** | ||
1678 | * Returns the offset parent of the given element | ||
1679 | * @method | ||
1680 | * @memberof Popper.Utils | ||
1681 | * @argument {Element} element | ||
1682 | * @returns {Element} offset parent | ||
1683 | */ | ||
1684 | function getOffsetParent(element) { | ||
1685 | if (!element) { | ||
1686 | return document.documentElement; | ||
1687 | } | ||
1688 | |||
1689 | var noOffsetParent = isIE(10) ? document.body : null; | ||
1690 | |||
1691 | // NOTE: 1 DOM access here | ||
1692 | var offsetParent = element.offsetParent || null; | ||
1693 | // Skip hidden elements which don't have an offsetParent | ||
1694 | while (offsetParent === noOffsetParent && element.nextElementSibling) { | ||
1695 | offsetParent = (element = element.nextElementSibling).offsetParent; | ||
1696 | } | ||
1697 | |||
1698 | var nodeName = offsetParent && offsetParent.nodeName; | ||
1699 | |||
1700 | if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') { | ||
1701 | return element ? element.ownerDocument.documentElement : document.documentElement; | ||
1702 | } | ||
1703 | |||
1704 | // .offsetParent will return the closest TH, TD or TABLE in case | ||
1705 | // no offsetParent is present, I hate this job... | ||
1706 | if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') { | ||
1707 | return getOffsetParent(offsetParent); | ||
1708 | } | ||
1709 | |||
1710 | return offsetParent; | ||
1711 | } | ||
1712 | |||
1713 | function isOffsetContainer(element) { | ||
1714 | var nodeName = element.nodeName; | ||
1715 | |||
1716 | if (nodeName === 'BODY') { | ||
1717 | return false; | ||
1718 | } | ||
1719 | return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element; | ||
1720 | } | ||
1721 | |||
1722 | /** | ||
1723 | * Finds the root node (document, shadowDOM root) of the given element | ||
1724 | * @method | ||
1725 | * @memberof Popper.Utils | ||
1726 | * @argument {Element} node | ||
1727 | * @returns {Element} root node | ||
1728 | */ | ||
1729 | function getRoot(node) { | ||
1730 | if (node.parentNode !== null) { | ||
1731 | return getRoot(node.parentNode); | ||
1732 | } | ||
1733 | |||
1734 | return node; | ||
1735 | } | ||
1736 | |||
1737 | /** | ||
1738 | * Finds the offset parent common to the two provided nodes | ||
1739 | * @method | ||
1740 | * @memberof Popper.Utils | ||
1741 | * @argument {Element} element1 | ||
1742 | * @argument {Element} element2 | ||
1743 | * @returns {Element} common offset parent | ||
1744 | */ | ||
1745 | function findCommonOffsetParent(element1, element2) { | ||
1746 | // This check is needed to avoid errors in case one of the elements isn't defined for any reason | ||
1747 | if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) { | ||
1748 | return document.documentElement; | ||
1749 | } | ||
1750 | |||
1751 | // Here we make sure to give as "start" the element that comes first in the DOM | ||
1752 | var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING; | ||
1753 | var start = order ? element1 : element2; | ||
1754 | var end = order ? element2 : element1; | ||
1755 | |||
1756 | // Get common ancestor container | ||
1757 | var range = document.createRange(); | ||
1758 | range.setStart(start, 0); | ||
1759 | range.setEnd(end, 0); | ||
1760 | var commonAncestorContainer = range.commonAncestorContainer; | ||
1761 | |||
1762 | // Both nodes are inside #document | ||
1763 | |||
1764 | if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) { | ||
1765 | if (isOffsetContainer(commonAncestorContainer)) { | ||
1766 | return commonAncestorContainer; | ||
1767 | } | ||
1768 | |||
1769 | return getOffsetParent(commonAncestorContainer); | ||
1770 | } | ||
1771 | |||
1772 | // one of the nodes is inside shadowDOM, find which one | ||
1773 | var element1root = getRoot(element1); | ||
1774 | if (element1root.host) { | ||
1775 | return findCommonOffsetParent(element1root.host, element2); | ||
1776 | } else { | ||
1777 | return findCommonOffsetParent(element1, getRoot(element2).host); | ||
1778 | } | ||
1779 | } | ||
1780 | |||
1781 | /** | ||
1782 | * Gets the scroll value of the given element in the given side (top and left) | ||
1783 | * @method | ||
1784 | * @memberof Popper.Utils | ||
1785 | * @argument {Element} element | ||
1786 | * @argument {String} side `top` or `left` | ||
1787 | * @returns {number} amount of scrolled pixels | ||
1788 | */ | ||
1789 | function getScroll(element) { | ||
1790 | var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top'; | ||
1791 | |||
1792 | var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft'; | ||
1793 | var nodeName = element.nodeName; | ||
1794 | |||
1795 | if (nodeName === 'BODY' || nodeName === 'HTML') { | ||
1796 | var html = element.ownerDocument.documentElement; | ||
1797 | var scrollingElement = element.ownerDocument.scrollingElement || html; | ||
1798 | return scrollingElement[upperSide]; | ||
1799 | } | ||
1800 | |||
1801 | return element[upperSide]; | ||
1802 | } | ||
1803 | |||
1804 | /* | ||
1805 | * Sum or subtract the element scroll values (left and top) from a given rect object | ||
1806 | * @method | ||
1807 | * @memberof Popper.Utils | ||
1808 | * @param {Object} rect - Rect object you want to change | ||
1809 | * @param {HTMLElement} element - The element from the function reads the scroll values | ||
1810 | * @param {Boolean} subtract - set to true if you want to subtract the scroll values | ||
1811 | * @return {Object} rect - The modifier rect object | ||
1812 | */ | ||
1813 | function includeScroll(rect, element) { | ||
1814 | var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
1815 | |||
1816 | var scrollTop = getScroll(element, 'top'); | ||
1817 | var scrollLeft = getScroll(element, 'left'); | ||
1818 | var modifier = subtract ? -1 : 1; | ||
1819 | rect.top += scrollTop * modifier; | ||
1820 | rect.bottom += scrollTop * modifier; | ||
1821 | rect.left += scrollLeft * modifier; | ||
1822 | rect.right += scrollLeft * modifier; | ||
1823 | return rect; | ||
1824 | } | ||
1825 | |||
1826 | /* | ||
1827 | * Helper to detect borders of a given element | ||
1828 | * @method | ||
1829 | * @memberof Popper.Utils | ||
1830 | * @param {CSSStyleDeclaration} styles | ||
1831 | * Result of `getStyleComputedProperty` on the given element | ||
1832 | * @param {String} axis - `x` or `y` | ||
1833 | * @return {number} borders - The borders size of the given axis | ||
1834 | */ | ||
1835 | |||
1836 | function getBordersSize(styles, axis) { | ||
1837 | var sideA = axis === 'x' ? 'Left' : 'Top'; | ||
1838 | var sideB = sideA === 'Left' ? 'Right' : 'Bottom'; | ||
1839 | |||
1840 | return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10); | ||
1841 | } | ||
1842 | |||
1843 | function getSize(axis, body, html, computedStyle) { | ||
1844 | return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0); | ||
1845 | } | ||
1846 | |||
1847 | function getWindowSizes(document) { | ||
1848 | var body = document.body; | ||
1849 | var html = document.documentElement; | ||
1850 | var computedStyle = isIE(10) && getComputedStyle(html); | ||
1851 | |||
1852 | return { | ||
1853 | height: getSize('Height', body, html, computedStyle), | ||
1854 | width: getSize('Width', body, html, computedStyle) | ||
1855 | }; | ||
1856 | } | ||
1857 | |||
1858 | var classCallCheck = function (instance, Constructor) { | ||
1859 | if (!(instance instanceof Constructor)) { | ||
1860 | throw new TypeError("Cannot call a class as a function"); | ||
1861 | } | ||
1862 | }; | ||
1863 | |||
1864 | var createClass = function () { | ||
1865 | function defineProperties(target, props) { | ||
1866 | for (var i = 0; i < props.length; i++) { | ||
1867 | var descriptor = props[i]; | ||
1868 | descriptor.enumerable = descriptor.enumerable || false; | ||
1869 | descriptor.configurable = true; | ||
1870 | if ("value" in descriptor) descriptor.writable = true; | ||
1871 | Object.defineProperty(target, descriptor.key, descriptor); | ||
1872 | } | ||
1873 | } | ||
1874 | |||
1875 | return function (Constructor, protoProps, staticProps) { | ||
1876 | if (protoProps) defineProperties(Constructor.prototype, protoProps); | ||
1877 | if (staticProps) defineProperties(Constructor, staticProps); | ||
1878 | return Constructor; | ||
1879 | }; | ||
1880 | }(); | ||
1881 | |||
1882 | |||
1883 | |||
1884 | |||
1885 | |||
1886 | var defineProperty = function (obj, key, value) { | ||
1887 | if (key in obj) { | ||
1888 | Object.defineProperty(obj, key, { | ||
1889 | value: value, | ||
1890 | enumerable: true, | ||
1891 | configurable: true, | ||
1892 | writable: true | ||
1893 | }); | ||
1894 | } else { | ||
1895 | obj[key] = value; | ||
1896 | } | ||
1897 | |||
1898 | return obj; | ||
1899 | }; | ||
1900 | |||
1901 | var _extends = Object.assign || function (target) { | ||
1902 | for (var i = 1; i < arguments.length; i++) { | ||
1903 | var source = arguments[i]; | ||
1904 | |||
1905 | for (var key in source) { | ||
1906 | if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
1907 | target[key] = source[key]; | ||
1908 | } | ||
1909 | } | ||
1910 | } | ||
1911 | |||
1912 | return target; | ||
1913 | }; | ||
1914 | |||
1915 | /** | ||
1916 | * Given element offsets, generate an output similar to getBoundingClientRect | ||
1917 | * @method | ||
1918 | * @memberof Popper.Utils | ||
1919 | * @argument {Object} offsets | ||
1920 | * @returns {Object} ClientRect like output | ||
1921 | */ | ||
1922 | function getClientRect(offsets) { | ||
1923 | return _extends({}, offsets, { | ||
1924 | right: offsets.left + offsets.width, | ||
1925 | bottom: offsets.top + offsets.height | ||
1926 | }); | ||
1927 | } | ||
1928 | |||
1929 | /** | ||
1930 | * Get bounding client rect of given element | ||
1931 | * @method | ||
1932 | * @memberof Popper.Utils | ||
1933 | * @param {HTMLElement} element | ||
1934 | * @return {Object} client rect | ||
1935 | */ | ||
1936 | function getBoundingClientRect(element) { | ||
1937 | var rect = {}; | ||
1938 | |||
1939 | // IE10 10 FIX: Please, don't ask, the element isn't | ||
1940 | // considered in DOM in some circumstances... | ||
1941 | // This isn't reproducible in IE10 compatibility mode of IE11 | ||
1942 | try { | ||
1943 | if (isIE(10)) { | ||
1944 | rect = element.getBoundingClientRect(); | ||
1945 | var scrollTop = getScroll(element, 'top'); | ||
1946 | var scrollLeft = getScroll(element, 'left'); | ||
1947 | rect.top += scrollTop; | ||
1948 | rect.left += scrollLeft; | ||
1949 | rect.bottom += scrollTop; | ||
1950 | rect.right += scrollLeft; | ||
1951 | } else { | ||
1952 | rect = element.getBoundingClientRect(); | ||
1953 | } | ||
1954 | } catch (e) {} | ||
1955 | |||
1956 | var result = { | ||
1957 | left: rect.left, | ||
1958 | top: rect.top, | ||
1959 | width: rect.right - rect.left, | ||
1960 | height: rect.bottom - rect.top | ||
1961 | }; | ||
1962 | |||
1963 | // subtract scrollbar size from sizes | ||
1964 | var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {}; | ||
1965 | var width = sizes.width || element.clientWidth || result.right - result.left; | ||
1966 | var height = sizes.height || element.clientHeight || result.bottom - result.top; | ||
1967 | |||
1968 | var horizScrollbar = element.offsetWidth - width; | ||
1969 | var vertScrollbar = element.offsetHeight - height; | ||
1970 | |||
1971 | // if an hypothetical scrollbar is detected, we must be sure it's not a `border` | ||
1972 | // we make this check conditional for performance reasons | ||
1973 | if (horizScrollbar || vertScrollbar) { | ||
1974 | var styles = getStyleComputedProperty(element); | ||
1975 | horizScrollbar -= getBordersSize(styles, 'x'); | ||
1976 | vertScrollbar -= getBordersSize(styles, 'y'); | ||
1977 | |||
1978 | result.width -= horizScrollbar; | ||
1979 | result.height -= vertScrollbar; | ||
1980 | } | ||
1981 | |||
1982 | return getClientRect(result); | ||
1983 | } | ||
1984 | |||
1985 | function getOffsetRectRelativeToArbitraryNode(children, parent) { | ||
1986 | var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
1987 | |||
1988 | var isIE10 = isIE(10); | ||
1989 | var isHTML = parent.nodeName === 'HTML'; | ||
1990 | var childrenRect = getBoundingClientRect(children); | ||
1991 | var parentRect = getBoundingClientRect(parent); | ||
1992 | var scrollParent = getScrollParent(children); | ||
1993 | |||
1994 | var styles = getStyleComputedProperty(parent); | ||
1995 | var borderTopWidth = parseFloat(styles.borderTopWidth, 10); | ||
1996 | var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10); | ||
1997 | |||
1998 | // In cases where the parent is fixed, we must ignore negative scroll in offset calc | ||
1999 | if (fixedPosition && isHTML) { | ||
2000 | parentRect.top = Math.max(parentRect.top, 0); | ||
2001 | parentRect.left = Math.max(parentRect.left, 0); | ||
2002 | } | ||
2003 | var offsets = getClientRect({ | ||
2004 | top: childrenRect.top - parentRect.top - borderTopWidth, | ||
2005 | left: childrenRect.left - parentRect.left - borderLeftWidth, | ||
2006 | width: childrenRect.width, | ||
2007 | height: childrenRect.height | ||
2008 | }); | ||
2009 | offsets.marginTop = 0; | ||
2010 | offsets.marginLeft = 0; | ||
2011 | |||
2012 | // Subtract margins of documentElement in case it's being used as parent | ||
2013 | // we do this only on HTML because it's the only element that behaves | ||
2014 | // differently when margins are applied to it. The margins are included in | ||
2015 | // the box of the documentElement, in the other cases not. | ||
2016 | if (!isIE10 && isHTML) { | ||
2017 | var marginTop = parseFloat(styles.marginTop, 10); | ||
2018 | var marginLeft = parseFloat(styles.marginLeft, 10); | ||
2019 | |||
2020 | offsets.top -= borderTopWidth - marginTop; | ||
2021 | offsets.bottom -= borderTopWidth - marginTop; | ||
2022 | offsets.left -= borderLeftWidth - marginLeft; | ||
2023 | offsets.right -= borderLeftWidth - marginLeft; | ||
2024 | |||
2025 | // Attach marginTop and marginLeft because in some circumstances we may need them | ||
2026 | offsets.marginTop = marginTop; | ||
2027 | offsets.marginLeft = marginLeft; | ||
2028 | } | ||
2029 | |||
2030 | if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') { | ||
2031 | offsets = includeScroll(offsets, parent); | ||
2032 | } | ||
2033 | |||
2034 | return offsets; | ||
2035 | } | ||
2036 | |||
2037 | function getViewportOffsetRectRelativeToArtbitraryNode(element) { | ||
2038 | var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
2039 | |||
2040 | var html = element.ownerDocument.documentElement; | ||
2041 | var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); | ||
2042 | var width = Math.max(html.clientWidth, window.innerWidth || 0); | ||
2043 | var height = Math.max(html.clientHeight, window.innerHeight || 0); | ||
2044 | |||
2045 | var scrollTop = !excludeScroll ? getScroll(html) : 0; | ||
2046 | var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0; | ||
2047 | |||
2048 | var offset = { | ||
2049 | top: scrollTop - relativeOffset.top + relativeOffset.marginTop, | ||
2050 | left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft, | ||
2051 | width: width, | ||
2052 | height: height | ||
2053 | }; | ||
2054 | |||
2055 | return getClientRect(offset); | ||
2056 | } | ||
2057 | |||
2058 | /** | ||
2059 | * Check if the given element is fixed or is inside a fixed parent | ||
2060 | * @method | ||
2061 | * @memberof Popper.Utils | ||
2062 | * @argument {Element} element | ||
2063 | * @argument {Element} customContainer | ||
2064 | * @returns {Boolean} answer to "isFixed?" | ||
2065 | */ | ||
2066 | function isFixed(element) { | ||
2067 | var nodeName = element.nodeName; | ||
2068 | if (nodeName === 'BODY' || nodeName === 'HTML') { | ||
2069 | return false; | ||
2070 | } | ||
2071 | if (getStyleComputedProperty(element, 'position') === 'fixed') { | ||
2072 | return true; | ||
2073 | } | ||
2074 | var parentNode = getParentNode(element); | ||
2075 | if (!parentNode) { | ||
2076 | return false; | ||
2077 | } | ||
2078 | return isFixed(parentNode); | ||
2079 | } | ||
2080 | |||
2081 | /** | ||
2082 | * Finds the first parent of an element that has a transformed property defined | ||
2083 | * @method | ||
2084 | * @memberof Popper.Utils | ||
2085 | * @argument {Element} element | ||
2086 | * @returns {Element} first transformed parent or documentElement | ||
2087 | */ | ||
2088 | |||
2089 | function getFixedPositionOffsetParent(element) { | ||
2090 | // This check is needed to avoid errors in case one of the elements isn't defined for any reason | ||
2091 | if (!element || !element.parentElement || isIE()) { | ||
2092 | return document.documentElement; | ||
2093 | } | ||
2094 | var el = element.parentElement; | ||
2095 | while (el && getStyleComputedProperty(el, 'transform') === 'none') { | ||
2096 | el = el.parentElement; | ||
2097 | } | ||
2098 | return el || document.documentElement; | ||
2099 | } | ||
2100 | |||
2101 | /** | ||
2102 | * Computed the boundaries limits and return them | ||
2103 | * @method | ||
2104 | * @memberof Popper.Utils | ||
2105 | * @param {HTMLElement} popper | ||
2106 | * @param {HTMLElement} reference | ||
2107 | * @param {number} padding | ||
2108 | * @param {HTMLElement} boundariesElement - Element used to define the boundaries | ||
2109 | * @param {Boolean} fixedPosition - Is in fixed position mode | ||
2110 | * @returns {Object} Coordinates of the boundaries | ||
2111 | */ | ||
2112 | function getBoundaries(popper, reference, padding, boundariesElement) { | ||
2113 | var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
2114 | |||
2115 | // NOTE: 1 DOM access here | ||
2116 | |||
2117 | var boundaries = { top: 0, left: 0 }; | ||
2118 | var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference); | ||
2119 | |||
2120 | // Handle viewport case | ||
2121 | if (boundariesElement === 'viewport') { | ||
2122 | boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition); | ||
2123 | } else { | ||
2124 | // Handle other cases based on DOM element used as boundaries | ||
2125 | var boundariesNode = void 0; | ||
2126 | if (boundariesElement === 'scrollParent') { | ||
2127 | boundariesNode = getScrollParent(getParentNode(reference)); | ||
2128 | if (boundariesNode.nodeName === 'BODY') { | ||
2129 | boundariesNode = popper.ownerDocument.documentElement; | ||
2130 | } | ||
2131 | } else if (boundariesElement === 'window') { | ||
2132 | boundariesNode = popper.ownerDocument.documentElement; | ||
2133 | } else { | ||
2134 | boundariesNode = boundariesElement; | ||
2135 | } | ||
2136 | |||
2137 | var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); | ||
2138 | |||
2139 | // In case of HTML, we need a different computation | ||
2140 | if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) { | ||
2141 | var _getWindowSizes = getWindowSizes(popper.ownerDocument), | ||
2142 | height = _getWindowSizes.height, | ||
2143 | width = _getWindowSizes.width; | ||
2144 | |||
2145 | boundaries.top += offsets.top - offsets.marginTop; | ||
2146 | boundaries.bottom = height + offsets.top; | ||
2147 | boundaries.left += offsets.left - offsets.marginLeft; | ||
2148 | boundaries.right = width + offsets.left; | ||
2149 | } else { | ||
2150 | // for all the other DOM elements, this one is good | ||
2151 | boundaries = offsets; | ||
2152 | } | ||
2153 | } | ||
2154 | |||
2155 | // Add paddings | ||
2156 | padding = padding || 0; | ||
2157 | var isPaddingNumber = typeof padding === 'number'; | ||
2158 | boundaries.left += isPaddingNumber ? padding : padding.left || 0; | ||
2159 | boundaries.top += isPaddingNumber ? padding : padding.top || 0; | ||
2160 | boundaries.right -= isPaddingNumber ? padding : padding.right || 0; | ||
2161 | boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0; | ||
2162 | |||
2163 | return boundaries; | ||
2164 | } | ||
2165 | |||
2166 | function getArea(_ref) { | ||
2167 | var width = _ref.width, | ||
2168 | height = _ref.height; | ||
2169 | |||
2170 | return width * height; | ||
2171 | } | ||
2172 | |||
2173 | /** | ||
2174 | * Utility used to transform the `auto` placement to the placement with more | ||
2175 | * available space. | ||
2176 | * @method | ||
2177 | * @memberof Popper.Utils | ||
2178 | * @argument {Object} data - The data object generated by update method | ||
2179 | * @argument {Object} options - Modifiers configuration and options | ||
2180 | * @returns {Object} The data object, properly modified | ||
2181 | */ | ||
2182 | function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) { | ||
2183 | var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; | ||
2184 | |||
2185 | if (placement.indexOf('auto') === -1) { | ||
2186 | return placement; | ||
2187 | } | ||
2188 | |||
2189 | var boundaries = getBoundaries(popper, reference, padding, boundariesElement); | ||
2190 | |||
2191 | var rects = { | ||
2192 | top: { | ||
2193 | width: boundaries.width, | ||
2194 | height: refRect.top - boundaries.top | ||
2195 | }, | ||
2196 | right: { | ||
2197 | width: boundaries.right - refRect.right, | ||
2198 | height: boundaries.height | ||
2199 | }, | ||
2200 | bottom: { | ||
2201 | width: boundaries.width, | ||
2202 | height: boundaries.bottom - refRect.bottom | ||
2203 | }, | ||
2204 | left: { | ||
2205 | width: refRect.left - boundaries.left, | ||
2206 | height: boundaries.height | ||
2207 | } | ||
2208 | }; | ||
2209 | |||
2210 | var sortedAreas = Object.keys(rects).map(function (key) { | ||
2211 | return _extends({ | ||
2212 | key: key | ||
2213 | }, rects[key], { | ||
2214 | area: getArea(rects[key]) | ||
2215 | }); | ||
2216 | }).sort(function (a, b) { | ||
2217 | return b.area - a.area; | ||
2218 | }); | ||
2219 | |||
2220 | var filteredAreas = sortedAreas.filter(function (_ref2) { | ||
2221 | var width = _ref2.width, | ||
2222 | height = _ref2.height; | ||
2223 | return width >= popper.clientWidth && height >= popper.clientHeight; | ||
2224 | }); | ||
2225 | |||
2226 | var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key; | ||
2227 | |||
2228 | var variation = placement.split('-')[1]; | ||
2229 | |||
2230 | return computedPlacement + (variation ? '-' + variation : ''); | ||
2231 | } | ||
2232 | |||
2233 | /** | ||
2234 | * Get offsets to the reference element | ||
2235 | * @method | ||
2236 | * @memberof Popper.Utils | ||
2237 | * @param {Object} state | ||
2238 | * @param {Element} popper - the popper element | ||
2239 | * @param {Element} reference - the reference element (the popper will be relative to this) | ||
2240 | * @param {Element} fixedPosition - is in fixed position mode | ||
2241 | * @returns {Object} An object containing the offsets which will be applied to the popper | ||
2242 | */ | ||
2243 | function getReferenceOffsets(state, popper, reference) { | ||
2244 | var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; | ||
2245 | |||
2246 | var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference); | ||
2247 | return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition); | ||
2248 | } | ||
2249 | |||
2250 | /** | ||
2251 | * Get the outer sizes of the given element (offset size + margins) | ||
2252 | * @method | ||
2253 | * @memberof Popper.Utils | ||
2254 | * @argument {Element} element | ||
2255 | * @returns {Object} object containing width and height properties | ||
2256 | */ | ||
2257 | function getOuterSizes(element) { | ||
2258 | var window = element.ownerDocument.defaultView; | ||
2259 | var styles = window.getComputedStyle(element); | ||
2260 | var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0); | ||
2261 | var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0); | ||
2262 | var result = { | ||
2263 | width: element.offsetWidth + y, | ||
2264 | height: element.offsetHeight + x | ||
2265 | }; | ||
2266 | return result; | ||
2267 | } | ||
2268 | |||
2269 | /** | ||
2270 | * Get the opposite placement of the given one | ||
2271 | * @method | ||
2272 | * @memberof Popper.Utils | ||
2273 | * @argument {String} placement | ||
2274 | * @returns {String} flipped placement | ||
2275 | */ | ||
2276 | function getOppositePlacement(placement) { | ||
2277 | var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' }; | ||
2278 | return placement.replace(/left|right|bottom|top/g, function (matched) { | ||
2279 | return hash[matched]; | ||
2280 | }); | ||
2281 | } | ||
2282 | |||
2283 | /** | ||
2284 | * Get offsets to the popper | ||
2285 | * @method | ||
2286 | * @memberof Popper.Utils | ||
2287 | * @param {Object} position - CSS position the Popper will get applied | ||
2288 | * @param {HTMLElement} popper - the popper element | ||
2289 | * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this) | ||
2290 | * @param {String} placement - one of the valid placement options | ||
2291 | * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper | ||
2292 | */ | ||
2293 | function getPopperOffsets(popper, referenceOffsets, placement) { | ||
2294 | placement = placement.split('-')[0]; | ||
2295 | |||
2296 | // Get popper node sizes | ||
2297 | var popperRect = getOuterSizes(popper); | ||
2298 | |||
2299 | // Add position, width and height to our offsets object | ||
2300 | var popperOffsets = { | ||
2301 | width: popperRect.width, | ||
2302 | height: popperRect.height | ||
2303 | }; | ||
2304 | |||
2305 | // depending by the popper placement we have to compute its offsets slightly differently | ||
2306 | var isHoriz = ['right', 'left'].indexOf(placement) !== -1; | ||
2307 | var mainSide = isHoriz ? 'top' : 'left'; | ||
2308 | var secondarySide = isHoriz ? 'left' : 'top'; | ||
2309 | var measurement = isHoriz ? 'height' : 'width'; | ||
2310 | var secondaryMeasurement = !isHoriz ? 'height' : 'width'; | ||
2311 | |||
2312 | popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2; | ||
2313 | if (placement === secondarySide) { | ||
2314 | popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement]; | ||
2315 | } else { | ||
2316 | popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)]; | ||
2317 | } | ||
2318 | |||
2319 | return popperOffsets; | ||
2320 | } | ||
2321 | |||
2322 | /** | ||
2323 | * Mimics the `find` method of Array | ||
2324 | * @method | ||
2325 | * @memberof Popper.Utils | ||
2326 | * @argument {Array} arr | ||
2327 | * @argument prop | ||
2328 | * @argument value | ||
2329 | * @returns index or -1 | ||
2330 | */ | ||
2331 | function find(arr, check) { | ||
2332 | // use native find if supported | ||
2333 | if (Array.prototype.find) { | ||
2334 | return arr.find(check); | ||
2335 | } | ||
2336 | |||
2337 | // use `filter` to obtain the same behavior of `find` | ||
2338 | return arr.filter(check)[0]; | ||
2339 | } | ||
2340 | |||
2341 | /** | ||
2342 | * Return the index of the matching object | ||
2343 | * @method | ||
2344 | * @memberof Popper.Utils | ||
2345 | * @argument {Array} arr | ||
2346 | * @argument prop | ||
2347 | * @argument value | ||
2348 | * @returns index or -1 | ||
2349 | */ | ||
2350 | function findIndex(arr, prop, value) { | ||
2351 | // use native findIndex if supported | ||
2352 | if (Array.prototype.findIndex) { | ||
2353 | return arr.findIndex(function (cur) { | ||
2354 | return cur[prop] === value; | ||
2355 | }); | ||
2356 | } | ||
2357 | |||
2358 | // use `find` + `indexOf` if `findIndex` isn't supported | ||
2359 | var match = find(arr, function (obj) { | ||
2360 | return obj[prop] === value; | ||
2361 | }); | ||
2362 | return arr.indexOf(match); | ||
2363 | } | ||
2364 | |||
2365 | /** | ||
2366 | * Loop trough the list of modifiers and run them in order, | ||
2367 | * each of them will then edit the data object. | ||
2368 | * @method | ||
2369 | * @memberof Popper.Utils | ||
2370 | * @param {dataObject} data | ||
2371 | * @param {Array} modifiers | ||
2372 | * @param {String} ends - Optional modifier name used as stopper | ||
2373 | * @returns {dataObject} | ||
2374 | */ | ||
2375 | function runModifiers(modifiers, data, ends) { | ||
2376 | var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends)); | ||
2377 | |||
2378 | modifiersToRun.forEach(function (modifier) { | ||
2379 | if (modifier['function']) { | ||
2380 | // eslint-disable-line dot-notation | ||
2381 | console.warn('`modifier.function` is deprecated, use `modifier.fn`!'); | ||
2382 | } | ||
2383 | var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation | ||
2384 | if (modifier.enabled && isFunction(fn)) { | ||
2385 | // Add properties to offsets to make them a complete clientRect object | ||
2386 | // we do this before each modifier to make sure the previous one doesn't | ||
2387 | // mess with these values | ||
2388 | data.offsets.popper = getClientRect(data.offsets.popper); | ||
2389 | data.offsets.reference = getClientRect(data.offsets.reference); | ||
2390 | |||
2391 | data = fn(data, modifier); | ||
2392 | } | ||
2393 | }); | ||
2394 | |||
2395 | return data; | ||
2396 | } | ||
2397 | |||
2398 | /** | ||
2399 | * Updates the position of the popper, computing the new offsets and applying | ||
2400 | * the new style.<br /> | ||
2401 | * Prefer `scheduleUpdate` over `update` because of performance reasons. | ||
2402 | * @method | ||
2403 | * @memberof Popper | ||
2404 | */ | ||
2405 | function update() { | ||
2406 | // if popper is destroyed, don't perform any further update | ||
2407 | if (this.state.isDestroyed) { | ||
2408 | return; | ||
2409 | } | ||
2410 | |||
2411 | var data = { | ||
2412 | instance: this, | ||
2413 | styles: {}, | ||
2414 | arrowStyles: {}, | ||
2415 | attributes: {}, | ||
2416 | flipped: false, | ||
2417 | offsets: {} | ||
2418 | }; | ||
2419 | |||
2420 | // compute reference element offsets | ||
2421 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); | ||
2422 | |||
2423 | // compute auto placement, store placement inside the data object, | ||
2424 | // modifiers will be able to edit `placement` if needed | ||
2425 | // and refer to originalPlacement to know the original value | ||
2426 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); | ||
2427 | |||
2428 | // store the computed placement inside `originalPlacement` | ||
2429 | data.originalPlacement = data.placement; | ||
2430 | |||
2431 | data.positionFixed = this.options.positionFixed; | ||
2432 | |||
2433 | // compute the popper offsets | ||
2434 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); | ||
2435 | |||
2436 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; | ||
2437 | |||
2438 | // run the modifiers | ||
2439 | data = runModifiers(this.modifiers, data); | ||
2440 | |||
2441 | // the first `update` will call `onCreate` callback | ||
2442 | // the other ones will call `onUpdate` callback | ||
2443 | if (!this.state.isCreated) { | ||
2444 | this.state.isCreated = true; | ||
2445 | this.options.onCreate(data); | ||
2446 | } else { | ||
2447 | this.options.onUpdate(data); | ||
2448 | } | ||
2449 | } | ||
2450 | |||
2451 | /** | ||
2452 | * Helper used to know if the given modifier is enabled. | ||
2453 | * @method | ||
2454 | * @memberof Popper.Utils | ||
2455 | * @returns {Boolean} | ||
2456 | */ | ||
2457 | function isModifierEnabled(modifiers, modifierName) { | ||
2458 | return modifiers.some(function (_ref) { | ||
2459 | var name = _ref.name, | ||
2460 | enabled = _ref.enabled; | ||
2461 | return enabled && name === modifierName; | ||
2462 | }); | ||
2463 | } | ||
2464 | |||
2465 | /** | ||
2466 | * Get the prefixed supported property name | ||
2467 | * @method | ||
2468 | * @memberof Popper.Utils | ||
2469 | * @argument {String} property (camelCase) | ||
2470 | * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix) | ||
2471 | */ | ||
2472 | function getSupportedPropertyName(property) { | ||
2473 | var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O']; | ||
2474 | var upperProp = property.charAt(0).toUpperCase() + property.slice(1); | ||
2475 | |||
2476 | for (var i = 0; i < prefixes.length; i++) { | ||
2477 | var prefix = prefixes[i]; | ||
2478 | var toCheck = prefix ? '' + prefix + upperProp : property; | ||
2479 | if (typeof document.body.style[toCheck] !== 'undefined') { | ||
2480 | return toCheck; | ||
2481 | } | ||
2482 | } | ||
2483 | return null; | ||
2484 | } | ||
2485 | |||
2486 | /** | ||
2487 | * Destroys the popper. | ||
2488 | * @method | ||
2489 | * @memberof Popper | ||
2490 | */ | ||
2491 | function destroy() { | ||
2492 | this.state.isDestroyed = true; | ||
2493 | |||
2494 | // touch DOM only if `applyStyle` modifier is enabled | ||
2495 | if (isModifierEnabled(this.modifiers, 'applyStyle')) { | ||
2496 | this.popper.removeAttribute('x-placement'); | ||
2497 | this.popper.style.position = ''; | ||
2498 | this.popper.style.top = ''; | ||
2499 | this.popper.style.left = ''; | ||
2500 | this.popper.style.right = ''; | ||
2501 | this.popper.style.bottom = ''; | ||
2502 | this.popper.style.willChange = ''; | ||
2503 | this.popper.style[getSupportedPropertyName('transform')] = ''; | ||
2504 | } | ||
2505 | |||
2506 | this.disableEventListeners(); | ||
2507 | |||
2508 | // remove the popper if user explicity asked for the deletion on destroy | ||
2509 | // do not use `remove` because IE11 doesn't support it | ||
2510 | if (this.options.removeOnDestroy) { | ||
2511 | this.popper.parentNode.removeChild(this.popper); | ||
2512 | } | ||
2513 | return this; | ||
2514 | } | ||
2515 | |||
2516 | /** | ||
2517 | * Get the window associated with the element | ||
2518 | * @argument {Element} element | ||
2519 | * @returns {Window} | ||
2520 | */ | ||
2521 | function getWindow(element) { | ||
2522 | var ownerDocument = element.ownerDocument; | ||
2523 | return ownerDocument ? ownerDocument.defaultView : window; | ||
2524 | } | ||
2525 | |||
2526 | function attachToScrollParents(scrollParent, event, callback, scrollParents) { | ||
2527 | var isBody = scrollParent.nodeName === 'BODY'; | ||
2528 | var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent; | ||
2529 | target.addEventListener(event, callback, { passive: true }); | ||
2530 | |||
2531 | if (!isBody) { | ||
2532 | attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents); | ||
2533 | } | ||
2534 | scrollParents.push(target); | ||
2535 | } | ||
2536 | |||
2537 | /** | ||
2538 | * Setup needed event listeners used to update the popper position | ||
2539 | * @method | ||
2540 | * @memberof Popper.Utils | ||
2541 | * @private | ||
2542 | */ | ||
2543 | function setupEventListeners(reference, options, state, updateBound) { | ||
2544 | // Resize event listener on window | ||
2545 | state.updateBound = updateBound; | ||
2546 | getWindow(reference).addEventListener('resize', state.updateBound, { passive: true }); | ||
2547 | |||
2548 | // Scroll event listener on scroll parents | ||
2549 | var scrollElement = getScrollParent(reference); | ||
2550 | attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents); | ||
2551 | state.scrollElement = scrollElement; | ||
2552 | state.eventsEnabled = true; | ||
2553 | |||
2554 | return state; | ||
2555 | } | ||
2556 | |||
2557 | /** | ||
2558 | * It will add resize/scroll events and start recalculating | ||
2559 | * position of the popper element when they are triggered. | ||
2560 | * @method | ||
2561 | * @memberof Popper | ||
2562 | */ | ||
2563 | function enableEventListeners() { | ||
2564 | if (!this.state.eventsEnabled) { | ||
2565 | this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate); | ||
2566 | } | ||
2567 | } | ||
2568 | |||
2569 | /** | ||
2570 | * Remove event listeners used to update the popper position | ||
2571 | * @method | ||
2572 | * @memberof Popper.Utils | ||
2573 | * @private | ||
2574 | */ | ||
2575 | function removeEventListeners(reference, state) { | ||
2576 | // Remove resize event listener on window | ||
2577 | getWindow(reference).removeEventListener('resize', state.updateBound); | ||
2578 | |||
2579 | // Remove scroll event listener on scroll parents | ||
2580 | state.scrollParents.forEach(function (target) { | ||
2581 | target.removeEventListener('scroll', state.updateBound); | ||
2582 | }); | ||
2583 | |||
2584 | // Reset state | ||
2585 | state.updateBound = null; | ||
2586 | state.scrollParents = []; | ||
2587 | state.scrollElement = null; | ||
2588 | state.eventsEnabled = false; | ||
2589 | return state; | ||
2590 | } | ||
2591 | |||
2592 | /** | ||
2593 | * It will remove resize/scroll events and won't recalculate popper position | ||
2594 | * when they are triggered. It also won't trigger `onUpdate` callback anymore, | ||
2595 | * unless you call `update` method manually. | ||
2596 | * @method | ||
2597 | * @memberof Popper | ||
2598 | */ | ||
2599 | function disableEventListeners() { | ||
2600 | if (this.state.eventsEnabled) { | ||
2601 | cancelAnimationFrame(this.scheduleUpdate); | ||
2602 | this.state = removeEventListeners(this.reference, this.state); | ||
2603 | } | ||
2604 | } | ||
2605 | |||
2606 | /** | ||
2607 | * Tells if a given input is a number | ||
2608 | * @method | ||
2609 | * @memberof Popper.Utils | ||
2610 | * @param {*} input to check | ||
2611 | * @return {Boolean} | ||
2612 | */ | ||
2613 | function isNumeric(n) { | ||
2614 | return n !== '' && !isNaN(parseFloat(n)) && isFinite(n); | ||
2615 | } | ||
2616 | |||
2617 | /** | ||
2618 | * Set the style to the given popper | ||
2619 | * @method | ||
2620 | * @memberof Popper.Utils | ||
2621 | * @argument {Element} element - Element to apply the style to | ||
2622 | * @argument {Object} styles | ||
2623 | * Object with a list of properties and values which will be applied to the element | ||
2624 | */ | ||
2625 | function setStyles(element, styles) { | ||
2626 | Object.keys(styles).forEach(function (prop) { | ||
2627 | var unit = ''; | ||
2628 | // add unit if the value is numeric and is one of the following | ||
2629 | if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) { | ||
2630 | unit = 'px'; | ||
2631 | } | ||
2632 | element.style[prop] = styles[prop] + unit; | ||
2633 | }); | ||
2634 | } | ||
2635 | |||
2636 | /** | ||
2637 | * Set the attributes to the given popper | ||
2638 | * @method | ||
2639 | * @memberof Popper.Utils | ||
2640 | * @argument {Element} element - Element to apply the attributes to | ||
2641 | * @argument {Object} styles | ||
2642 | * Object with a list of properties and values which will be applied to the element | ||
2643 | */ | ||
2644 | function setAttributes(element, attributes) { | ||
2645 | Object.keys(attributes).forEach(function (prop) { | ||
2646 | var value = attributes[prop]; | ||
2647 | if (value !== false) { | ||
2648 | element.setAttribute(prop, attributes[prop]); | ||
2649 | } else { | ||
2650 | element.removeAttribute(prop); | ||
2651 | } | ||
2652 | }); | ||
2653 | } | ||
2654 | |||
2655 | /** | ||
2656 | * @function | ||
2657 | * @memberof Modifiers | ||
2658 | * @argument {Object} data - The data object generated by `update` method | ||
2659 | * @argument {Object} data.styles - List of style properties - values to apply to popper element | ||
2660 | * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element | ||
2661 | * @argument {Object} options - Modifiers configuration and options | ||
2662 | * @returns {Object} The same data object | ||
2663 | */ | ||
2664 | function applyStyle(data) { | ||
2665 | // any property present in `data.styles` will be applied to the popper, | ||
2666 | // in this way we can make the 3rd party modifiers add custom styles to it | ||
2667 | // Be aware, modifiers could override the properties defined in the previous | ||
2668 | // lines of this modifier! | ||
2669 | setStyles(data.instance.popper, data.styles); | ||
2670 | |||
2671 | // any property present in `data.attributes` will be applied to the popper, | ||
2672 | // they will be set as HTML attributes of the element | ||
2673 | setAttributes(data.instance.popper, data.attributes); | ||
2674 | |||
2675 | // if arrowElement is defined and arrowStyles has some properties | ||
2676 | if (data.arrowElement && Object.keys(data.arrowStyles).length) { | ||
2677 | setStyles(data.arrowElement, data.arrowStyles); | ||
2678 | } | ||
2679 | |||
2680 | return data; | ||
2681 | } | ||
2682 | |||
2683 | /** | ||
2684 | * Set the x-placement attribute before everything else because it could be used | ||
2685 | * to add margins to the popper margins needs to be calculated to get the | ||
2686 | * correct popper offsets. | ||
2687 | * @method | ||
2688 | * @memberof Popper.modifiers | ||
2689 | * @param {HTMLElement} reference - The reference element used to position the popper | ||
2690 | * @param {HTMLElement} popper - The HTML element used as popper | ||
2691 | * @param {Object} options - Popper.js options | ||
2692 | */ | ||
2693 | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) { | ||
2694 | // compute reference element offsets | ||
2695 | var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed); | ||
2696 | |||
2697 | // compute auto placement, store placement inside the data object, | ||
2698 | // modifiers will be able to edit `placement` if needed | ||
2699 | // and refer to originalPlacement to know the original value | ||
2700 | var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding); | ||
2701 | |||
2702 | popper.setAttribute('x-placement', placement); | ||
2703 | |||
2704 | // Apply `position` to popper before anything else because | ||
2705 | // without the position applied we can't guarantee correct computations | ||
2706 | setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' }); | ||
2707 | |||
2708 | return options; | ||
2709 | } | ||
2710 | |||
2711 | /** | ||
2712 | * @function | ||
2713 | * @memberof Popper.Utils | ||
2714 | * @argument {Object} data - The data object generated by `update` method | ||
2715 | * @argument {Boolean} shouldRound - If the offsets should be rounded at all | ||
2716 | * @returns {Object} The popper's position offsets rounded | ||
2717 | * | ||
2718 | * The tale of pixel-perfect positioning. It's still not 100% perfect, but as | ||
2719 | * good as it can be within reason. | ||
2720 | * Discussion here: https://github.com/FezVrasta/popper.js/pull/715 | ||
2721 | * | ||
2722 | * Low DPI screens cause a popper to be blurry if not using full pixels (Safari | ||
2723 | * as well on High DPI screens). | ||
2724 | * | ||
2725 | * Firefox prefers no rounding for positioning and does not have blurriness on | ||
2726 | * high DPI screens. | ||
2727 | * | ||
2728 | * Only horizontal placement and left/right values need to be considered. | ||
2729 | */ | ||
2730 | function getRoundedOffsets(data, shouldRound) { | ||
2731 | var _data$offsets = data.offsets, | ||
2732 | popper = _data$offsets.popper, | ||
2733 | reference = _data$offsets.reference; | ||
2734 | var round = Math.round, | ||
2735 | floor = Math.floor; | ||
2736 | |||
2737 | var noRound = function noRound(v) { | ||
2738 | return v; | ||
2739 | }; | ||
2740 | |||
2741 | var referenceWidth = round(reference.width); | ||
2742 | var popperWidth = round(popper.width); | ||
2743 | |||
2744 | var isVertical = ['left', 'right'].indexOf(data.placement) !== -1; | ||
2745 | var isVariation = data.placement.indexOf('-') !== -1; | ||
2746 | var sameWidthParity = referenceWidth % 2 === popperWidth % 2; | ||
2747 | var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1; | ||
2748 | |||
2749 | var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor; | ||
2750 | var verticalToInteger = !shouldRound ? noRound : round; | ||
2751 | |||
2752 | return { | ||
2753 | left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left), | ||
2754 | top: verticalToInteger(popper.top), | ||
2755 | bottom: verticalToInteger(popper.bottom), | ||
2756 | right: horizontalToInteger(popper.right) | ||
2757 | }; | ||
2758 | } | ||
2759 | |||
2760 | var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent); | ||
2761 | |||
2762 | /** | ||
2763 | * @function | ||
2764 | * @memberof Modifiers | ||
2765 | * @argument {Object} data - The data object generated by `update` method | ||
2766 | * @argument {Object} options - Modifiers configuration and options | ||
2767 | * @returns {Object} The data object, properly modified | ||
2768 | */ | ||
2769 | function computeStyle(data, options) { | ||
2770 | var x = options.x, | ||
2771 | y = options.y; | ||
2772 | var popper = data.offsets.popper; | ||
2773 | |||
2774 | // Remove this legacy support in Popper.js v2 | ||
2775 | |||
2776 | var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) { | ||
2777 | return modifier.name === 'applyStyle'; | ||
2778 | }).gpuAcceleration; | ||
2779 | if (legacyGpuAccelerationOption !== undefined) { | ||
2780 | console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!'); | ||
2781 | } | ||
2782 | var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration; | ||
2783 | |||
2784 | var offsetParent = getOffsetParent(data.instance.popper); | ||
2785 | var offsetParentRect = getBoundingClientRect(offsetParent); | ||
2786 | |||
2787 | // Styles | ||
2788 | var styles = { | ||
2789 | position: popper.position | ||
2790 | }; | ||
2791 | |||
2792 | var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox); | ||
2793 | |||
2794 | var sideA = x === 'bottom' ? 'top' : 'bottom'; | ||
2795 | var sideB = y === 'right' ? 'left' : 'right'; | ||
2796 | |||
2797 | // if gpuAcceleration is set to `true` and transform is supported, | ||
2798 | // we use `translate3d` to apply the position to the popper we | ||
2799 | // automatically use the supported prefixed version if needed | ||
2800 | var prefixedProperty = getSupportedPropertyName('transform'); | ||
2801 | |||
2802 | // now, let's make a step back and look at this code closely (wtf?) | ||
2803 | // If the content of the popper grows once it's been positioned, it | ||
2804 | // may happen that the popper gets misplaced because of the new content | ||
2805 | // overflowing its reference element | ||
2806 | // To avoid this problem, we provide two options (x and y), which allow | ||
2807 | // the consumer to define the offset origin. | ||
2808 | // If we position a popper on top of a reference element, we can set | ||
2809 | // `x` to `top` to make the popper grow towards its top instead of | ||
2810 | // its bottom. | ||
2811 | var left = void 0, | ||
2812 | top = void 0; | ||
2813 | if (sideA === 'bottom') { | ||
2814 | // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar) | ||
2815 | // and not the bottom of the html element | ||
2816 | if (offsetParent.nodeName === 'HTML') { | ||
2817 | top = -offsetParent.clientHeight + offsets.bottom; | ||
2818 | } else { | ||
2819 | top = -offsetParentRect.height + offsets.bottom; | ||
2820 | } | ||
2821 | } else { | ||
2822 | top = offsets.top; | ||
2823 | } | ||
2824 | if (sideB === 'right') { | ||
2825 | if (offsetParent.nodeName === 'HTML') { | ||
2826 | left = -offsetParent.clientWidth + offsets.right; | ||
2827 | } else { | ||
2828 | left = -offsetParentRect.width + offsets.right; | ||
2829 | } | ||
2830 | } else { | ||
2831 | left = offsets.left; | ||
2832 | } | ||
2833 | if (gpuAcceleration && prefixedProperty) { | ||
2834 | styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)'; | ||
2835 | styles[sideA] = 0; | ||
2836 | styles[sideB] = 0; | ||
2837 | styles.willChange = 'transform'; | ||
2838 | } else { | ||
2839 | // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties | ||
2840 | var invertTop = sideA === 'bottom' ? -1 : 1; | ||
2841 | var invertLeft = sideB === 'right' ? -1 : 1; | ||
2842 | styles[sideA] = top * invertTop; | ||
2843 | styles[sideB] = left * invertLeft; | ||
2844 | styles.willChange = sideA + ', ' + sideB; | ||
2845 | } | ||
2846 | |||
2847 | // Attributes | ||
2848 | var attributes = { | ||
2849 | 'x-placement': data.placement | ||
2850 | }; | ||
2851 | |||
2852 | // Update `data` attributes, styles and arrowStyles | ||
2853 | data.attributes = _extends({}, attributes, data.attributes); | ||
2854 | data.styles = _extends({}, styles, data.styles); | ||
2855 | data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles); | ||
2856 | |||
2857 | return data; | ||
2858 | } | ||
2859 | |||
2860 | /** | ||
2861 | * Helper used to know if the given modifier depends from another one.<br /> | ||
2862 | * It checks if the needed modifier is listed and enabled. | ||
2863 | * @method | ||
2864 | * @memberof Popper.Utils | ||
2865 | * @param {Array} modifiers - list of modifiers | ||
2866 | * @param {String} requestingName - name of requesting modifier | ||
2867 | * @param {String} requestedName - name of requested modifier | ||
2868 | * @returns {Boolean} | ||
2869 | */ | ||
2870 | function isModifierRequired(modifiers, requestingName, requestedName) { | ||
2871 | var requesting = find(modifiers, function (_ref) { | ||
2872 | var name = _ref.name; | ||
2873 | return name === requestingName; | ||
2874 | }); | ||
2875 | |||
2876 | var isRequired = !!requesting && modifiers.some(function (modifier) { | ||
2877 | return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order; | ||
2878 | }); | ||
2879 | |||
2880 | if (!isRequired) { | ||
2881 | var _requesting = '`' + requestingName + '`'; | ||
2882 | var requested = '`' + requestedName + '`'; | ||
2883 | console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!'); | ||
2884 | } | ||
2885 | return isRequired; | ||
2886 | } | ||
2887 | |||
2888 | /** | ||
2889 | * @function | ||
2890 | * @memberof Modifiers | ||
2891 | * @argument {Object} data - The data object generated by update method | ||
2892 | * @argument {Object} options - Modifiers configuration and options | ||
2893 | * @returns {Object} The data object, properly modified | ||
2894 | */ | ||
2895 | function arrow(data, options) { | ||
2896 | var _data$offsets$arrow; | ||
2897 | |||
2898 | // arrow depends on keepTogether in order to work | ||
2899 | if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) { | ||
2900 | return data; | ||
2901 | } | ||
2902 | |||
2903 | var arrowElement = options.element; | ||
2904 | |||
2905 | // if arrowElement is a string, suppose it's a CSS selector | ||
2906 | if (typeof arrowElement === 'string') { | ||
2907 | arrowElement = data.instance.popper.querySelector(arrowElement); | ||
2908 | |||
2909 | // if arrowElement is not found, don't run the modifier | ||
2910 | if (!arrowElement) { | ||
2911 | return data; | ||
2912 | } | ||
2913 | } else { | ||
2914 | // if the arrowElement isn't a query selector we must check that the | ||
2915 | // provided DOM node is child of its popper node | ||
2916 | if (!data.instance.popper.contains(arrowElement)) { | ||
2917 | console.warn('WARNING: `arrow.element` must be child of its popper element!'); | ||
2918 | return data; | ||
2919 | } | ||
2920 | } | ||
2921 | |||
2922 | var placement = data.placement.split('-')[0]; | ||
2923 | var _data$offsets = data.offsets, | ||
2924 | popper = _data$offsets.popper, | ||
2925 | reference = _data$offsets.reference; | ||
2926 | |||
2927 | var isVertical = ['left', 'right'].indexOf(placement) !== -1; | ||
2928 | |||
2929 | var len = isVertical ? 'height' : 'width'; | ||
2930 | var sideCapitalized = isVertical ? 'Top' : 'Left'; | ||
2931 | var side = sideCapitalized.toLowerCase(); | ||
2932 | var altSide = isVertical ? 'left' : 'top'; | ||
2933 | var opSide = isVertical ? 'bottom' : 'right'; | ||
2934 | var arrowElementSize = getOuterSizes(arrowElement)[len]; | ||
2935 | |||
2936 | // | ||
2937 | // extends keepTogether behavior making sure the popper and its | ||
2938 | // reference have enough pixels in conjunction | ||
2939 | // | ||
2940 | |||
2941 | // top/left side | ||
2942 | if (reference[opSide] - arrowElementSize < popper[side]) { | ||
2943 | data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize); | ||
2944 | } | ||
2945 | // bottom/right side | ||
2946 | if (reference[side] + arrowElementSize > popper[opSide]) { | ||
2947 | data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide]; | ||
2948 | } | ||
2949 | data.offsets.popper = getClientRect(data.offsets.popper); | ||
2950 | |||
2951 | // compute center of the popper | ||
2952 | var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; | ||
2953 | |||
2954 | // Compute the sideValue using the updated popper offsets | ||
2955 | // take popper margin in account because we don't have this info available | ||
2956 | var css = getStyleComputedProperty(data.instance.popper); | ||
2957 | var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10); | ||
2958 | var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10); | ||
2959 | var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; | ||
2960 | |||
2961 | // prevent arrowElement from being placed not contiguously to its popper | ||
2962 | sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0); | ||
2963 | |||
2964 | data.arrowElement = arrowElement; | ||
2965 | data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow); | ||
2966 | |||
2967 | return data; | ||
2968 | } | ||
2969 | |||
2970 | /** | ||
2971 | * Get the opposite placement variation of the given one | ||
2972 | * @method | ||
2973 | * @memberof Popper.Utils | ||
2974 | * @argument {String} placement variation | ||
2975 | * @returns {String} flipped placement variation | ||
2976 | */ | ||
2977 | function getOppositeVariation(variation) { | ||
2978 | if (variation === 'end') { | ||
2979 | return 'start'; | ||
2980 | } else if (variation === 'start') { | ||
2981 | return 'end'; | ||
2982 | } | ||
2983 | return variation; | ||
2984 | } | ||
2985 | |||
2986 | /** | ||
2987 | * List of accepted placements to use as values of the `placement` option.<br /> | ||
2988 | * Valid placements are: | ||
2989 | * - `auto` | ||
2990 | * - `top` | ||
2991 | * - `right` | ||
2992 | * - `bottom` | ||
2993 | * - `left` | ||
2994 | * | ||
2995 | * Each placement can have a variation from this list: | ||
2996 | * - `-start` | ||
2997 | * - `-end` | ||
2998 | * | ||
2999 | * Variations are interpreted easily if you think of them as the left to right | ||
3000 | * written languages. Horizontally (`top` and `bottom`), `start` is left and `end` | ||
3001 | * is right.<br /> | ||
3002 | * Vertically (`left` and `right`), `start` is top and `end` is bottom. | ||
3003 | * | ||
3004 | * Some valid examples are: | ||
3005 | * - `top-end` (on top of reference, right aligned) | ||
3006 | * - `right-start` (on right of reference, top aligned) | ||
3007 | * - `bottom` (on bottom, centered) | ||
3008 | * - `auto-end` (on the side with more space available, alignment depends by placement) | ||
3009 | * | ||
3010 | * @static | ||
3011 | * @type {Array} | ||
3012 | * @enum {String} | ||
3013 | * @readonly | ||
3014 | * @method placements | ||
3015 | * @memberof Popper | ||
3016 | */ | ||
3017 | var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']; | ||
3018 | |||
3019 | // Get rid of `auto` `auto-start` and `auto-end` | ||
3020 | var validPlacements = placements.slice(3); | ||
3021 | |||
3022 | /** | ||
3023 | * Given an initial placement, returns all the subsequent placements | ||
3024 | * clockwise (or counter-clockwise). | ||
3025 | * | ||
3026 | * @method | ||
3027 | * @memberof Popper.Utils | ||
3028 | * @argument {String} placement - A valid placement (it accepts variations) | ||
3029 | * @argument {Boolean} counter - Set to true to walk the placements counterclockwise | ||
3030 | * @returns {Array} placements including their variations | ||
3031 | */ | ||
3032 | function clockwise(placement) { | ||
3033 | var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
3034 | |||
3035 | var index = validPlacements.indexOf(placement); | ||
3036 | var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index)); | ||
3037 | return counter ? arr.reverse() : arr; | ||
3038 | } | ||
3039 | |||
3040 | var BEHAVIORS = { | ||
3041 | FLIP: 'flip', | ||
3042 | CLOCKWISE: 'clockwise', | ||
3043 | COUNTERCLOCKWISE: 'counterclockwise' | ||
3044 | }; | ||
3045 | |||
3046 | /** | ||
3047 | * @function | ||
3048 | * @memberof Modifiers | ||
3049 | * @argument {Object} data - The data object generated by update method | ||
3050 | * @argument {Object} options - Modifiers configuration and options | ||
3051 | * @returns {Object} The data object, properly modified | ||
3052 | */ | ||
3053 | function flip(data, options) { | ||
3054 | // if `inner` modifier is enabled, we can't use the `flip` modifier | ||
3055 | if (isModifierEnabled(data.instance.modifiers, 'inner')) { | ||
3056 | return data; | ||
3057 | } | ||
3058 | |||
3059 | if (data.flipped && data.placement === data.originalPlacement) { | ||
3060 | // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides | ||
3061 | return data; | ||
3062 | } | ||
3063 | |||
3064 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed); | ||
3065 | |||
3066 | var placement = data.placement.split('-')[0]; | ||
3067 | var placementOpposite = getOppositePlacement(placement); | ||
3068 | var variation = data.placement.split('-')[1] || ''; | ||
3069 | |||
3070 | var flipOrder = []; | ||
3071 | |||
3072 | switch (options.behavior) { | ||
3073 | case BEHAVIORS.FLIP: | ||
3074 | flipOrder = [placement, placementOpposite]; | ||
3075 | break; | ||
3076 | case BEHAVIORS.CLOCKWISE: | ||
3077 | flipOrder = clockwise(placement); | ||
3078 | break; | ||
3079 | case BEHAVIORS.COUNTERCLOCKWISE: | ||
3080 | flipOrder = clockwise(placement, true); | ||
3081 | break; | ||
3082 | default: | ||
3083 | flipOrder = options.behavior; | ||
3084 | } | ||
3085 | |||
3086 | flipOrder.forEach(function (step, index) { | ||
3087 | if (placement !== step || flipOrder.length === index + 1) { | ||
3088 | return data; | ||
3089 | } | ||
3090 | |||
3091 | placement = data.placement.split('-')[0]; | ||
3092 | placementOpposite = getOppositePlacement(placement); | ||
3093 | |||
3094 | var popperOffsets = data.offsets.popper; | ||
3095 | var refOffsets = data.offsets.reference; | ||
3096 | |||
3097 | // using floor because the reference offsets may contain decimals we are not going to consider here | ||
3098 | var floor = Math.floor; | ||
3099 | var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom); | ||
3100 | |||
3101 | var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left); | ||
3102 | var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right); | ||
3103 | var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top); | ||
3104 | var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom); | ||
3105 | |||
3106 | var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom; | ||
3107 | |||
3108 | // flip the variation if required | ||
3109 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; | ||
3110 | var flippedVariation = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); | ||
3111 | |||
3112 | if (overlapsRef || overflowsBoundaries || flippedVariation) { | ||
3113 | // this boolean to detect any flip loop | ||
3114 | data.flipped = true; | ||
3115 | |||
3116 | if (overlapsRef || overflowsBoundaries) { | ||
3117 | placement = flipOrder[index + 1]; | ||
3118 | } | ||
3119 | |||
3120 | if (flippedVariation) { | ||
3121 | variation = getOppositeVariation(variation); | ||
3122 | } | ||
3123 | |||
3124 | data.placement = placement + (variation ? '-' + variation : ''); | ||
3125 | |||
3126 | // this object contains `position`, we want to preserve it along with | ||
3127 | // any additional property we may add in the future | ||
3128 | data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); | ||
3129 | |||
3130 | data = runModifiers(data.instance.modifiers, data, 'flip'); | ||
3131 | } | ||
3132 | }); | ||
3133 | return data; | ||
3134 | } | ||
3135 | |||
3136 | /** | ||
3137 | * @function | ||
3138 | * @memberof Modifiers | ||
3139 | * @argument {Object} data - The data object generated by update method | ||
3140 | * @argument {Object} options - Modifiers configuration and options | ||
3141 | * @returns {Object} The data object, properly modified | ||
3142 | */ | ||
3143 | function keepTogether(data) { | ||
3144 | var _data$offsets = data.offsets, | ||
3145 | popper = _data$offsets.popper, | ||
3146 | reference = _data$offsets.reference; | ||
3147 | |||
3148 | var placement = data.placement.split('-')[0]; | ||
3149 | var floor = Math.floor; | ||
3150 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; | ||
3151 | var side = isVertical ? 'right' : 'bottom'; | ||
3152 | var opSide = isVertical ? 'left' : 'top'; | ||
3153 | var measurement = isVertical ? 'width' : 'height'; | ||
3154 | |||
3155 | if (popper[side] < floor(reference[opSide])) { | ||
3156 | data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement]; | ||
3157 | } | ||
3158 | if (popper[opSide] > floor(reference[side])) { | ||
3159 | data.offsets.popper[opSide] = floor(reference[side]); | ||
3160 | } | ||
3161 | |||
3162 | return data; | ||
3163 | } | ||
3164 | |||
3165 | /** | ||
3166 | * Converts a string containing value + unit into a px value number | ||
3167 | * @function | ||
3168 | * @memberof {modifiers~offset} | ||
3169 | * @private | ||
3170 | * @argument {String} str - Value + unit string | ||
3171 | * @argument {String} measurement - `height` or `width` | ||
3172 | * @argument {Object} popperOffsets | ||
3173 | * @argument {Object} referenceOffsets | ||
3174 | * @returns {Number|String} | ||
3175 | * Value in pixels, or original string if no values were extracted | ||
3176 | */ | ||
3177 | function toValue(str, measurement, popperOffsets, referenceOffsets) { | ||
3178 | // separate value from unit | ||
3179 | var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/); | ||
3180 | var value = +split[1]; | ||
3181 | var unit = split[2]; | ||
3182 | |||
3183 | // If it's not a number it's an operator, I guess | ||
3184 | if (!value) { | ||
3185 | return str; | ||
3186 | } | ||
3187 | |||
3188 | if (unit.indexOf('%') === 0) { | ||
3189 | var element = void 0; | ||
3190 | switch (unit) { | ||
3191 | case '%p': | ||
3192 | element = popperOffsets; | ||
3193 | break; | ||
3194 | case '%': | ||
3195 | case '%r': | ||
3196 | default: | ||
3197 | element = referenceOffsets; | ||
3198 | } | ||
3199 | |||
3200 | var rect = getClientRect(element); | ||
3201 | return rect[measurement] / 100 * value; | ||
3202 | } else if (unit === 'vh' || unit === 'vw') { | ||
3203 | // if is a vh or vw, we calculate the size based on the viewport | ||
3204 | var size = void 0; | ||
3205 | if (unit === 'vh') { | ||
3206 | size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); | ||
3207 | } else { | ||
3208 | size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); | ||
3209 | } | ||
3210 | return size / 100 * value; | ||
3211 | } else { | ||
3212 | // if is an explicit pixel unit, we get rid of the unit and keep the value | ||
3213 | // if is an implicit unit, it's px, and we return just the value | ||
3214 | return value; | ||
3215 | } | ||
3216 | } | ||
3217 | |||
3218 | /** | ||
3219 | * Parse an `offset` string to extrapolate `x` and `y` numeric offsets. | ||
3220 | * @function | ||
3221 | * @memberof {modifiers~offset} | ||
3222 | * @private | ||
3223 | * @argument {String} offset | ||
3224 | * @argument {Object} popperOffsets | ||
3225 | * @argument {Object} referenceOffsets | ||
3226 | * @argument {String} basePlacement | ||
3227 | * @returns {Array} a two cells array with x and y offsets in numbers | ||
3228 | */ | ||
3229 | function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) { | ||
3230 | var offsets = [0, 0]; | ||
3231 | |||
3232 | // Use height if placement is left or right and index is 0 otherwise use width | ||
3233 | // in this way the first offset will use an axis and the second one | ||
3234 | // will use the other one | ||
3235 | var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1; | ||
3236 | |||
3237 | // Split the offset string to obtain a list of values and operands | ||
3238 | // The regex addresses values with the plus or minus sign in front (+10, -20, etc) | ||
3239 | var fragments = offset.split(/(\+|\-)/).map(function (frag) { | ||
3240 | return frag.trim(); | ||
3241 | }); | ||
3242 | |||
3243 | // Detect if the offset string contains a pair of values or a single one | ||
3244 | // they could be separated by comma or space | ||
3245 | var divider = fragments.indexOf(find(fragments, function (frag) { | ||
3246 | return frag.search(/,|\s/) !== -1; | ||
3247 | })); | ||
3248 | |||
3249 | if (fragments[divider] && fragments[divider].indexOf(',') === -1) { | ||
3250 | console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.'); | ||
3251 | } | ||
3252 | |||
3253 | // If divider is found, we divide the list of values and operands to divide | ||
3254 | // them by ofset X and Y. | ||
3255 | var splitRegex = /\s*,\s*|\s+/; | ||
3256 | var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments]; | ||
3257 | |||
3258 | // Convert the values with units to absolute pixels to allow our computations | ||
3259 | ops = ops.map(function (op, index) { | ||
3260 | // Most of the units rely on the orientation of the popper | ||
3261 | var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width'; | ||
3262 | var mergeWithPrevious = false; | ||
3263 | return op | ||
3264 | // This aggregates any `+` or `-` sign that aren't considered operators | ||
3265 | // e.g.: 10 + +5 => [10, +, +5] | ||
3266 | .reduce(function (a, b) { | ||
3267 | if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) { | ||
3268 | a[a.length - 1] = b; | ||
3269 | mergeWithPrevious = true; | ||
3270 | return a; | ||
3271 | } else if (mergeWithPrevious) { | ||
3272 | a[a.length - 1] += b; | ||
3273 | mergeWithPrevious = false; | ||
3274 | return a; | ||
3275 | } else { | ||
3276 | return a.concat(b); | ||
3277 | } | ||
3278 | }, []) | ||
3279 | // Here we convert the string values into number values (in px) | ||
3280 | .map(function (str) { | ||
3281 | return toValue(str, measurement, popperOffsets, referenceOffsets); | ||
3282 | }); | ||
3283 | }); | ||
3284 | |||
3285 | // Loop trough the offsets arrays and execute the operations | ||
3286 | ops.forEach(function (op, index) { | ||
3287 | op.forEach(function (frag, index2) { | ||
3288 | if (isNumeric(frag)) { | ||
3289 | offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1); | ||
3290 | } | ||
3291 | }); | ||
3292 | }); | ||
3293 | return offsets; | ||
3294 | } | ||
3295 | |||
3296 | /** | ||
3297 | * @function | ||
3298 | * @memberof Modifiers | ||
3299 | * @argument {Object} data - The data object generated by update method | ||
3300 | * @argument {Object} options - Modifiers configuration and options | ||
3301 | * @argument {Number|String} options.offset=0 | ||
3302 | * The offset value as described in the modifier description | ||
3303 | * @returns {Object} The data object, properly modified | ||
3304 | */ | ||
3305 | function offset(data, _ref) { | ||
3306 | var offset = _ref.offset; | ||
3307 | var placement = data.placement, | ||
3308 | _data$offsets = data.offsets, | ||
3309 | popper = _data$offsets.popper, | ||
3310 | reference = _data$offsets.reference; | ||
3311 | |||
3312 | var basePlacement = placement.split('-')[0]; | ||
3313 | |||
3314 | var offsets = void 0; | ||
3315 | if (isNumeric(+offset)) { | ||
3316 | offsets = [+offset, 0]; | ||
3317 | } else { | ||
3318 | offsets = parseOffset(offset, popper, reference, basePlacement); | ||
3319 | } | ||
3320 | |||
3321 | if (basePlacement === 'left') { | ||
3322 | popper.top += offsets[0]; | ||
3323 | popper.left -= offsets[1]; | ||
3324 | } else if (basePlacement === 'right') { | ||
3325 | popper.top += offsets[0]; | ||
3326 | popper.left += offsets[1]; | ||
3327 | } else if (basePlacement === 'top') { | ||
3328 | popper.left += offsets[0]; | ||
3329 | popper.top -= offsets[1]; | ||
3330 | } else if (basePlacement === 'bottom') { | ||
3331 | popper.left += offsets[0]; | ||
3332 | popper.top += offsets[1]; | ||
3333 | } | ||
3334 | |||
3335 | data.popper = popper; | ||
3336 | return data; | ||
3337 | } | ||
3338 | |||
3339 | /** | ||
3340 | * @function | ||
3341 | * @memberof Modifiers | ||
3342 | * @argument {Object} data - The data object generated by `update` method | ||
3343 | * @argument {Object} options - Modifiers configuration and options | ||
3344 | * @returns {Object} The data object, properly modified | ||
3345 | */ | ||
3346 | function preventOverflow(data, options) { | ||
3347 | var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper); | ||
3348 | |||
3349 | // If offsetParent is the reference element, we really want to | ||
3350 | // go one step up and use the next offsetParent as reference to | ||
3351 | // avoid to make this modifier completely useless and look like broken | ||
3352 | if (data.instance.reference === boundariesElement) { | ||
3353 | boundariesElement = getOffsetParent(boundariesElement); | ||
3354 | } | ||
3355 | |||
3356 | // NOTE: DOM access here | ||
3357 | // resets the popper's position so that the document size can be calculated excluding | ||
3358 | // the size of the popper element itself | ||
3359 | var transformProp = getSupportedPropertyName('transform'); | ||
3360 | var popperStyles = data.instance.popper.style; // assignment to help minification | ||
3361 | var top = popperStyles.top, | ||
3362 | left = popperStyles.left, | ||
3363 | transform = popperStyles[transformProp]; | ||
3364 | |||
3365 | popperStyles.top = ''; | ||
3366 | popperStyles.left = ''; | ||
3367 | popperStyles[transformProp] = ''; | ||
3368 | |||
3369 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed); | ||
3370 | |||
3371 | // NOTE: DOM access here | ||
3372 | // restores the original style properties after the offsets have been computed | ||
3373 | popperStyles.top = top; | ||
3374 | popperStyles.left = left; | ||
3375 | popperStyles[transformProp] = transform; | ||
3376 | |||
3377 | options.boundaries = boundaries; | ||
3378 | |||
3379 | var order = options.priority; | ||
3380 | var popper = data.offsets.popper; | ||
3381 | |||
3382 | var check = { | ||
3383 | primary: function primary(placement) { | ||
3384 | var value = popper[placement]; | ||
3385 | if (popper[placement] < boundaries[placement] && !options.escapeWithReference) { | ||
3386 | value = Math.max(popper[placement], boundaries[placement]); | ||
3387 | } | ||
3388 | return defineProperty({}, placement, value); | ||
3389 | }, | ||
3390 | secondary: function secondary(placement) { | ||
3391 | var mainSide = placement === 'right' ? 'left' : 'top'; | ||
3392 | var value = popper[mainSide]; | ||
3393 | if (popper[placement] > boundaries[placement] && !options.escapeWithReference) { | ||
3394 | value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height)); | ||
3395 | } | ||
3396 | return defineProperty({}, mainSide, value); | ||
3397 | } | ||
3398 | }; | ||
3399 | |||
3400 | order.forEach(function (placement) { | ||
3401 | var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary'; | ||
3402 | popper = _extends({}, popper, check[side](placement)); | ||
3403 | }); | ||
3404 | |||
3405 | data.offsets.popper = popper; | ||
3406 | |||
3407 | return data; | ||
3408 | } | ||
3409 | |||
3410 | /** | ||
3411 | * @function | ||
3412 | * @memberof Modifiers | ||
3413 | * @argument {Object} data - The data object generated by `update` method | ||
3414 | * @argument {Object} options - Modifiers configuration and options | ||
3415 | * @returns {Object} The data object, properly modified | ||
3416 | */ | ||
3417 | function shift(data) { | ||
3418 | var placement = data.placement; | ||
3419 | var basePlacement = placement.split('-')[0]; | ||
3420 | var shiftvariation = placement.split('-')[1]; | ||
3421 | |||
3422 | // if shift shiftvariation is specified, run the modifier | ||
3423 | if (shiftvariation) { | ||
3424 | var _data$offsets = data.offsets, | ||
3425 | reference = _data$offsets.reference, | ||
3426 | popper = _data$offsets.popper; | ||
3427 | |||
3428 | var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1; | ||
3429 | var side = isVertical ? 'left' : 'top'; | ||
3430 | var measurement = isVertical ? 'width' : 'height'; | ||
3431 | |||
3432 | var shiftOffsets = { | ||
3433 | start: defineProperty({}, side, reference[side]), | ||
3434 | end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement]) | ||
3435 | }; | ||
3436 | |||
3437 | data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]); | ||
3438 | } | ||
3439 | |||
3440 | return data; | ||
3441 | } | ||
3442 | |||
3443 | /** | ||
3444 | * @function | ||
3445 | * @memberof Modifiers | ||
3446 | * @argument {Object} data - The data object generated by update method | ||
3447 | * @argument {Object} options - Modifiers configuration and options | ||
3448 | * @returns {Object} The data object, properly modified | ||
3449 | */ | ||
3450 | function hide(data) { | ||
3451 | if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) { | ||
3452 | return data; | ||
3453 | } | ||
3454 | |||
3455 | var refRect = data.offsets.reference; | ||
3456 | var bound = find(data.instance.modifiers, function (modifier) { | ||
3457 | return modifier.name === 'preventOverflow'; | ||
3458 | }).boundaries; | ||
3459 | |||
3460 | if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) { | ||
3461 | // Avoid unnecessary DOM access if visibility hasn't changed | ||
3462 | if (data.hide === true) { | ||
3463 | return data; | ||
3464 | } | ||
3465 | |||
3466 | data.hide = true; | ||
3467 | data.attributes['x-out-of-boundaries'] = ''; | ||
3468 | } else { | ||
3469 | // Avoid unnecessary DOM access if visibility hasn't changed | ||
3470 | if (data.hide === false) { | ||
3471 | return data; | ||
3472 | } | ||
3473 | |||
3474 | data.hide = false; | ||
3475 | data.attributes['x-out-of-boundaries'] = false; | ||
3476 | } | ||
3477 | |||
3478 | return data; | ||
3479 | } | ||
3480 | |||
3481 | /** | ||
3482 | * @function | ||
3483 | * @memberof Modifiers | ||
3484 | * @argument {Object} data - The data object generated by `update` method | ||
3485 | * @argument {Object} options - Modifiers configuration and options | ||
3486 | * @returns {Object} The data object, properly modified | ||
3487 | */ | ||
3488 | function inner(data) { | ||
3489 | var placement = data.placement; | ||
3490 | var basePlacement = placement.split('-')[0]; | ||
3491 | var _data$offsets = data.offsets, | ||
3492 | popper = _data$offsets.popper, | ||
3493 | reference = _data$offsets.reference; | ||
3494 | |||
3495 | var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1; | ||
3496 | |||
3497 | var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1; | ||
3498 | |||
3499 | popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0); | ||
3500 | |||
3501 | data.placement = getOppositePlacement(placement); | ||
3502 | data.offsets.popper = getClientRect(popper); | ||
3503 | |||
3504 | return data; | ||
3505 | } | ||
3506 | |||
3507 | /** | ||
3508 | * Modifier function, each modifier can have a function of this type assigned | ||
3509 | * to its `fn` property.<br /> | ||
3510 | * These functions will be called on each update, this means that you must | ||
3511 | * make sure they are performant enough to avoid performance bottlenecks. | ||
3512 | * | ||
3513 | * @function ModifierFn | ||
3514 | * @argument {dataObject} data - The data object generated by `update` method | ||
3515 | * @argument {Object} options - Modifiers configuration and options | ||
3516 | * @returns {dataObject} The data object, properly modified | ||
3517 | */ | ||
3518 | |||
3519 | /** | ||
3520 | * Modifiers are plugins used to alter the behavior of your poppers.<br /> | ||
3521 | * Popper.js uses a set of 9 modifiers to provide all the basic functionalities | ||
3522 | * needed by the library. | ||
3523 | * | ||
3524 | * Usually you don't want to override the `order`, `fn` and `onLoad` props. | ||
3525 | * All the other properties are configurations that could be tweaked. | ||
3526 | * @namespace modifiers | ||
3527 | */ | ||
3528 | var modifiers = { | ||
3529 | /** | ||
3530 | * Modifier used to shift the popper on the start or end of its reference | ||
3531 | * element.<br /> | ||
3532 | * It will read the variation of the `placement` property.<br /> | ||
3533 | * It can be one either `-end` or `-start`. | ||
3534 | * @memberof modifiers | ||
3535 | * @inner | ||
3536 | */ | ||
3537 | shift: { | ||
3538 | /** @prop {number} order=100 - Index used to define the order of execution */ | ||
3539 | order: 100, | ||
3540 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3541 | enabled: true, | ||
3542 | /** @prop {ModifierFn} */ | ||
3543 | fn: shift | ||
3544 | }, | ||
3545 | |||
3546 | /** | ||
3547 | * The `offset` modifier can shift your popper on both its axis. | ||
3548 | * | ||
3549 | * It accepts the following units: | ||
3550 | * - `px` or unit-less, interpreted as pixels | ||
3551 | * - `%` or `%r`, percentage relative to the length of the reference element | ||
3552 | * - `%p`, percentage relative to the length of the popper element | ||
3553 | * - `vw`, CSS viewport width unit | ||
3554 | * - `vh`, CSS viewport height unit | ||
3555 | * | ||
3556 | * For length is intended the main axis relative to the placement of the popper.<br /> | ||
3557 | * This means that if the placement is `top` or `bottom`, the length will be the | ||
3558 | * `width`. In case of `left` or `right`, it will be the `height`. | ||
3559 | * | ||
3560 | * You can provide a single value (as `Number` or `String`), or a pair of values | ||
3561 | * as `String` divided by a comma or one (or more) white spaces.<br /> | ||
3562 | * The latter is a deprecated method because it leads to confusion and will be | ||
3563 | * removed in v2.<br /> | ||
3564 | * Additionally, it accepts additions and subtractions between different units. | ||
3565 | * Note that multiplications and divisions aren't supported. | ||
3566 | * | ||
3567 | * Valid examples are: | ||
3568 | * ``` | ||
3569 | * 10 | ||
3570 | * '10%' | ||
3571 | * '10, 10' | ||
3572 | * '10%, 10' | ||
3573 | * '10 + 10%' | ||
3574 | * '10 - 5vh + 3%' | ||
3575 | * '-10px + 5vh, 5px - 6%' | ||
3576 | * ``` | ||
3577 | * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap | ||
3578 | * > with their reference element, unfortunately, you will have to disable the `flip` modifier. | ||
3579 | * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373). | ||
3580 | * | ||
3581 | * @memberof modifiers | ||
3582 | * @inner | ||
3583 | */ | ||
3584 | offset: { | ||
3585 | /** @prop {number} order=200 - Index used to define the order of execution */ | ||
3586 | order: 200, | ||
3587 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3588 | enabled: true, | ||
3589 | /** @prop {ModifierFn} */ | ||
3590 | fn: offset, | ||
3591 | /** @prop {Number|String} offset=0 | ||
3592 | * The offset value as described in the modifier description | ||
3593 | */ | ||
3594 | offset: 0 | ||
3595 | }, | ||
3596 | |||
3597 | /** | ||
3598 | * Modifier used to prevent the popper from being positioned outside the boundary. | ||
3599 | * | ||
3600 | * A scenario exists where the reference itself is not within the boundaries.<br /> | ||
3601 | * We can say it has "escaped the boundaries" — or just "escaped".<br /> | ||
3602 | * In this case we need to decide whether the popper should either: | ||
3603 | * | ||
3604 | * - detach from the reference and remain "trapped" in the boundaries, or | ||
3605 | * - if it should ignore the boundary and "escape with its reference" | ||
3606 | * | ||
3607 | * When `escapeWithReference` is set to`true` and reference is completely | ||
3608 | * outside its boundaries, the popper will overflow (or completely leave) | ||
3609 | * the boundaries in order to remain attached to the edge of the reference. | ||
3610 | * | ||
3611 | * @memberof modifiers | ||
3612 | * @inner | ||
3613 | */ | ||
3614 | preventOverflow: { | ||
3615 | /** @prop {number} order=300 - Index used to define the order of execution */ | ||
3616 | order: 300, | ||
3617 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3618 | enabled: true, | ||
3619 | /** @prop {ModifierFn} */ | ||
3620 | fn: preventOverflow, | ||
3621 | /** | ||
3622 | * @prop {Array} [priority=['left','right','top','bottom']] | ||
3623 | * Popper will try to prevent overflow following these priorities by default, | ||
3624 | * then, it could overflow on the left and on top of the `boundariesElement` | ||
3625 | */ | ||
3626 | priority: ['left', 'right', 'top', 'bottom'], | ||
3627 | /** | ||
3628 | * @prop {number} padding=5 | ||
3629 | * Amount of pixel used to define a minimum distance between the boundaries | ||
3630 | * and the popper. This makes sure the popper always has a little padding | ||
3631 | * between the edges of its container | ||
3632 | */ | ||
3633 | padding: 5, | ||
3634 | /** | ||
3635 | * @prop {String|HTMLElement} boundariesElement='scrollParent' | ||
3636 | * Boundaries used by the modifier. Can be `scrollParent`, `window`, | ||
3637 | * `viewport` or any DOM element. | ||
3638 | */ | ||
3639 | boundariesElement: 'scrollParent' | ||
3640 | }, | ||
3641 | |||
3642 | /** | ||
3643 | * Modifier used to make sure the reference and its popper stay near each other | ||
3644 | * without leaving any gap between the two. Especially useful when the arrow is | ||
3645 | * enabled and you want to ensure that it points to its reference element. | ||
3646 | * It cares only about the first axis. You can still have poppers with margin | ||
3647 | * between the popper and its reference element. | ||
3648 | * @memberof modifiers | ||
3649 | * @inner | ||
3650 | */ | ||
3651 | keepTogether: { | ||
3652 | /** @prop {number} order=400 - Index used to define the order of execution */ | ||
3653 | order: 400, | ||
3654 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3655 | enabled: true, | ||
3656 | /** @prop {ModifierFn} */ | ||
3657 | fn: keepTogether | ||
3658 | }, | ||
3659 | |||
3660 | /** | ||
3661 | * This modifier is used to move the `arrowElement` of the popper to make | ||
3662 | * sure it is positioned between the reference element and its popper element. | ||
3663 | * It will read the outer size of the `arrowElement` node to detect how many | ||
3664 | * pixels of conjunction are needed. | ||
3665 | * | ||
3666 | * It has no effect if no `arrowElement` is provided. | ||
3667 | * @memberof modifiers | ||
3668 | * @inner | ||
3669 | */ | ||
3670 | arrow: { | ||
3671 | /** @prop {number} order=500 - Index used to define the order of execution */ | ||
3672 | order: 500, | ||
3673 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3674 | enabled: true, | ||
3675 | /** @prop {ModifierFn} */ | ||
3676 | fn: arrow, | ||
3677 | /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */ | ||
3678 | element: '[x-arrow]' | ||
3679 | }, | ||
3680 | |||
3681 | /** | ||
3682 | * Modifier used to flip the popper's placement when it starts to overlap its | ||
3683 | * reference element. | ||
3684 | * | ||
3685 | * Requires the `preventOverflow` modifier before it in order to work. | ||
3686 | * | ||
3687 | * **NOTE:** this modifier will interrupt the current update cycle and will | ||
3688 | * restart it if it detects the need to flip the placement. | ||
3689 | * @memberof modifiers | ||
3690 | * @inner | ||
3691 | */ | ||
3692 | flip: { | ||
3693 | /** @prop {number} order=600 - Index used to define the order of execution */ | ||
3694 | order: 600, | ||
3695 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3696 | enabled: true, | ||
3697 | /** @prop {ModifierFn} */ | ||
3698 | fn: flip, | ||
3699 | /** | ||
3700 | * @prop {String|Array} behavior='flip' | ||
3701 | * The behavior used to change the popper's placement. It can be one of | ||
3702 | * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid | ||
3703 | * placements (with optional variations) | ||
3704 | */ | ||
3705 | behavior: 'flip', | ||
3706 | /** | ||
3707 | * @prop {number} padding=5 | ||
3708 | * The popper will flip if it hits the edges of the `boundariesElement` | ||
3709 | */ | ||
3710 | padding: 5, | ||
3711 | /** | ||
3712 | * @prop {String|HTMLElement} boundariesElement='viewport' | ||
3713 | * The element which will define the boundaries of the popper position. | ||
3714 | * The popper will never be placed outside of the defined boundaries | ||
3715 | * (except if `keepTogether` is enabled) | ||
3716 | */ | ||
3717 | boundariesElement: 'viewport' | ||
3718 | }, | ||
3719 | |||
3720 | /** | ||
3721 | * Modifier used to make the popper flow toward the inner of the reference element. | ||
3722 | * By default, when this modifier is disabled, the popper will be placed outside | ||
3723 | * the reference element. | ||
3724 | * @memberof modifiers | ||
3725 | * @inner | ||
3726 | */ | ||
3727 | inner: { | ||
3728 | /** @prop {number} order=700 - Index used to define the order of execution */ | ||
3729 | order: 700, | ||
3730 | /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */ | ||
3731 | enabled: false, | ||
3732 | /** @prop {ModifierFn} */ | ||
3733 | fn: inner | ||
3734 | }, | ||
3735 | |||
3736 | /** | ||
3737 | * Modifier used to hide the popper when its reference element is outside of the | ||
3738 | * popper boundaries. It will set a `x-out-of-boundaries` attribute which can | ||
3739 | * be used to hide with a CSS selector the popper when its reference is | ||
3740 | * out of boundaries. | ||
3741 | * | ||
3742 | * Requires the `preventOverflow` modifier before it in order to work. | ||
3743 | * @memberof modifiers | ||
3744 | * @inner | ||
3745 | */ | ||
3746 | hide: { | ||
3747 | /** @prop {number} order=800 - Index used to define the order of execution */ | ||
3748 | order: 800, | ||
3749 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3750 | enabled: true, | ||
3751 | /** @prop {ModifierFn} */ | ||
3752 | fn: hide | ||
3753 | }, | ||
3754 | |||
3755 | /** | ||
3756 | * Computes the style that will be applied to the popper element to gets | ||
3757 | * properly positioned. | ||
3758 | * | ||
3759 | * Note that this modifier will not touch the DOM, it just prepares the styles | ||
3760 | * so that `applyStyle` modifier can apply it. This separation is useful | ||
3761 | * in case you need to replace `applyStyle` with a custom implementation. | ||
3762 | * | ||
3763 | * This modifier has `850` as `order` value to maintain backward compatibility | ||
3764 | * with previous versions of Popper.js. Expect the modifiers ordering method | ||
3765 | * to change in future major versions of the library. | ||
3766 | * | ||
3767 | * @memberof modifiers | ||
3768 | * @inner | ||
3769 | */ | ||
3770 | computeStyle: { | ||
3771 | /** @prop {number} order=850 - Index used to define the order of execution */ | ||
3772 | order: 850, | ||
3773 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3774 | enabled: true, | ||
3775 | /** @prop {ModifierFn} */ | ||
3776 | fn: computeStyle, | ||
3777 | /** | ||
3778 | * @prop {Boolean} gpuAcceleration=true | ||
3779 | * If true, it uses the CSS 3D transformation to position the popper. | ||
3780 | * Otherwise, it will use the `top` and `left` properties | ||
3781 | */ | ||
3782 | gpuAcceleration: true, | ||
3783 | /** | ||
3784 | * @prop {string} [x='bottom'] | ||
3785 | * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin. | ||
3786 | * Change this if your popper should grow in a direction different from `bottom` | ||
3787 | */ | ||
3788 | x: 'bottom', | ||
3789 | /** | ||
3790 | * @prop {string} [x='left'] | ||
3791 | * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin. | ||
3792 | * Change this if your popper should grow in a direction different from `right` | ||
3793 | */ | ||
3794 | y: 'right' | ||
3795 | }, | ||
3796 | |||
3797 | /** | ||
3798 | * Applies the computed styles to the popper element. | ||
3799 | * | ||
3800 | * All the DOM manipulations are limited to this modifier. This is useful in case | ||
3801 | * you want to integrate Popper.js inside a framework or view library and you | ||
3802 | * want to delegate all the DOM manipulations to it. | ||
3803 | * | ||
3804 | * Note that if you disable this modifier, you must make sure the popper element | ||
3805 | * has its position set to `absolute` before Popper.js can do its work! | ||
3806 | * | ||
3807 | * Just disable this modifier and define your own to achieve the desired effect. | ||
3808 | * | ||
3809 | * @memberof modifiers | ||
3810 | * @inner | ||
3811 | */ | ||
3812 | applyStyle: { | ||
3813 | /** @prop {number} order=900 - Index used to define the order of execution */ | ||
3814 | order: 900, | ||
3815 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ | ||
3816 | enabled: true, | ||
3817 | /** @prop {ModifierFn} */ | ||
3818 | fn: applyStyle, | ||
3819 | /** @prop {Function} */ | ||
3820 | onLoad: applyStyleOnLoad, | ||
3821 | /** | ||
3822 | * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier | ||
3823 | * @prop {Boolean} gpuAcceleration=true | ||
3824 | * If true, it uses the CSS 3D transformation to position the popper. | ||
3825 | * Otherwise, it will use the `top` and `left` properties | ||
3826 | */ | ||
3827 | gpuAcceleration: undefined | ||
3828 | } | ||
3829 | }; | ||
3830 | |||
3831 | /** | ||
3832 | * The `dataObject` is an object containing all the information used by Popper.js. | ||
3833 | * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks. | ||
3834 | * @name dataObject | ||
3835 | * @property {Object} data.instance The Popper.js instance | ||
3836 | * @property {String} data.placement Placement applied to popper | ||
3837 | * @property {String} data.originalPlacement Placement originally defined on init | ||
3838 | * @property {Boolean} data.flipped True if popper has been flipped by flip modifier | ||
3839 | * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper | ||
3840 | * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier | ||
3841 | * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`) | ||
3842 | * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`) | ||
3843 | * @property {Object} data.boundaries Offsets of the popper boundaries | ||
3844 | * @property {Object} data.offsets The measurements of popper, reference and arrow elements | ||
3845 | * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values | ||
3846 | * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values | ||
3847 | * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0 | ||
3848 | */ | ||
3849 | |||
3850 | /** | ||
3851 | * Default options provided to Popper.js constructor.<br /> | ||
3852 | * These can be overridden using the `options` argument of Popper.js.<br /> | ||
3853 | * To override an option, simply pass an object with the same | ||
3854 | * structure of the `options` object, as the 3rd argument. For example: | ||
3855 | * ``` | ||
3856 | * new Popper(ref, pop, { | ||
3857 | * modifiers: { | ||
3858 | * preventOverflow: { enabled: false } | ||
3859 | * } | ||
3860 | * }) | ||
3861 | * ``` | ||
3862 | * @type {Object} | ||
3863 | * @static | ||
3864 | * @memberof Popper | ||
3865 | */ | ||
3866 | var Defaults = { | ||
3867 | /** | ||
3868 | * Popper's placement. | ||
3869 | * @prop {Popper.placements} placement='bottom' | ||
3870 | */ | ||
3871 | placement: 'bottom', | ||
3872 | |||
3873 | /** | ||
3874 | * Set this to true if you want popper to position it self in 'fixed' mode | ||
3875 | * @prop {Boolean} positionFixed=false | ||
3876 | */ | ||
3877 | positionFixed: false, | ||
3878 | |||
3879 | /** | ||
3880 | * Whether events (resize, scroll) are initially enabled. | ||
3881 | * @prop {Boolean} eventsEnabled=true | ||
3882 | */ | ||
3883 | eventsEnabled: true, | ||
3884 | |||
3885 | /** | ||
3886 | * Set to true if you want to automatically remove the popper when | ||
3887 | * you call the `destroy` method. | ||
3888 | * @prop {Boolean} removeOnDestroy=false | ||
3889 | */ | ||
3890 | removeOnDestroy: false, | ||
3891 | |||
3892 | /** | ||
3893 | * Callback called when the popper is created.<br /> | ||
3894 | * By default, it is set to no-op.<br /> | ||
3895 | * Access Popper.js instance with `data.instance`. | ||
3896 | * @prop {onCreate} | ||
3897 | */ | ||
3898 | onCreate: function onCreate() {}, | ||
3899 | |||
3900 | /** | ||
3901 | * Callback called when the popper is updated. This callback is not called | ||
3902 | * on the initialization/creation of the popper, but only on subsequent | ||
3903 | * updates.<br /> | ||
3904 | * By default, it is set to no-op.<br /> | ||
3905 | * Access Popper.js instance with `data.instance`. | ||
3906 | * @prop {onUpdate} | ||
3907 | */ | ||
3908 | onUpdate: function onUpdate() {}, | ||
3909 | |||
3910 | /** | ||
3911 | * List of modifiers used to modify the offsets before they are applied to the popper. | ||
3912 | * They provide most of the functionalities of Popper.js. | ||
3913 | * @prop {modifiers} | ||
3914 | */ | ||
3915 | modifiers: modifiers | ||
3916 | }; | ||
3917 | |||
3918 | /** | ||
3919 | * @callback onCreate | ||
3920 | * @param {dataObject} data | ||
3921 | */ | ||
3922 | |||
3923 | /** | ||
3924 | * @callback onUpdate | ||
3925 | * @param {dataObject} data | ||
3926 | */ | ||
3927 | |||
3928 | // Utils | ||
3929 | // Methods | ||
3930 | var Popper = function () { | ||
3931 | /** | ||
3932 | * Creates a new Popper.js instance. | ||
3933 | * @class Popper | ||
3934 | * @param {HTMLElement|referenceObject} reference - The reference element used to position the popper | ||
3935 | * @param {HTMLElement} popper - The HTML element used as the popper | ||
3936 | * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults) | ||
3937 | * @return {Object} instance - The generated Popper.js instance | ||
3938 | */ | ||
3939 | function Popper(reference, popper) { | ||
3940 | var _this = this; | ||
3941 | |||
3942 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
3943 | classCallCheck(this, Popper); | ||
3944 | |||
3945 | this.scheduleUpdate = function () { | ||
3946 | return requestAnimationFrame(_this.update); | ||
3947 | }; | ||
3948 | |||
3949 | // make update() debounced, so that it only runs at most once-per-tick | ||
3950 | this.update = debounce(this.update.bind(this)); | ||
3951 | |||
3952 | // with {} we create a new object with the options inside it | ||
3953 | this.options = _extends({}, Popper.Defaults, options); | ||
3954 | |||
3955 | // init state | ||
3956 | this.state = { | ||
3957 | isDestroyed: false, | ||
3958 | isCreated: false, | ||
3959 | scrollParents: [] | ||
3960 | }; | ||
3961 | |||
3962 | // get reference and popper elements (allow jQuery wrappers) | ||
3963 | this.reference = reference && reference.jquery ? reference[0] : reference; | ||
3964 | this.popper = popper && popper.jquery ? popper[0] : popper; | ||
3965 | |||
3966 | // Deep merge modifiers options | ||
3967 | this.options.modifiers = {}; | ||
3968 | Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { | ||
3969 | _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); | ||
3970 | }); | ||
3971 | |||
3972 | // Refactoring modifiers' list (Object => Array) | ||
3973 | this.modifiers = Object.keys(this.options.modifiers).map(function (name) { | ||
3974 | return _extends({ | ||
3975 | name: name | ||
3976 | }, _this.options.modifiers[name]); | ||
3977 | }) | ||
3978 | // sort the modifiers by order | ||
3979 | .sort(function (a, b) { | ||
3980 | return a.order - b.order; | ||
3981 | }); | ||
3982 | |||
3983 | // modifiers have the ability to execute arbitrary code when Popper.js get inited | ||
3984 | // such code is executed in the same order of its modifier | ||
3985 | // they could add new properties to their options configuration | ||
3986 | // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`! | ||
3987 | this.modifiers.forEach(function (modifierOptions) { | ||
3988 | if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) { | ||
3989 | modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state); | ||
3990 | } | ||
3991 | }); | ||
3992 | |||
3993 | // fire the first update to position the popper in the right place | ||
3994 | this.update(); | ||
3995 | |||
3996 | var eventsEnabled = this.options.eventsEnabled; | ||
3997 | if (eventsEnabled) { | ||
3998 | // setup event listeners, they will take care of update the position in specific situations | ||
3999 | this.enableEventListeners(); | ||
4000 | } | ||
4001 | |||
4002 | this.state.eventsEnabled = eventsEnabled; | ||
4003 | } | ||
4004 | |||
4005 | // We can't use class properties because they don't get listed in the | ||
4006 | // class prototype and break stuff like Sinon stubs | ||
4007 | |||
4008 | |||
4009 | createClass(Popper, [{ | ||
4010 | key: 'update', | ||
4011 | value: function update$$1() { | ||
4012 | return update.call(this); | ||
4013 | } | ||
4014 | }, { | ||
4015 | key: 'destroy', | ||
4016 | value: function destroy$$1() { | ||
4017 | return destroy.call(this); | ||
4018 | } | ||
4019 | }, { | ||
4020 | key: 'enableEventListeners', | ||
4021 | value: function enableEventListeners$$1() { | ||
4022 | return enableEventListeners.call(this); | ||
4023 | } | ||
4024 | }, { | ||
4025 | key: 'disableEventListeners', | ||
4026 | value: function disableEventListeners$$1() { | ||
4027 | return disableEventListeners.call(this); | ||
4028 | } | ||
4029 | |||
4030 | /** | ||
4031 | * Schedules an update. It will run on the next UI update available. | ||
4032 | * @method scheduleUpdate | ||
4033 | * @memberof Popper | ||
4034 | */ | ||
4035 | |||
4036 | |||
4037 | /** | ||
4038 | * Collection of utilities useful when writing custom modifiers. | ||
4039 | * Starting from version 1.7, this method is available only if you | ||
4040 | * include `popper-utils.js` before `popper.js`. | ||
4041 | * | ||
4042 | * **DEPRECATION**: This way to access PopperUtils is deprecated | ||
4043 | * and will be removed in v2! Use the PopperUtils module directly instead. | ||
4044 | * Due to the high instability of the methods contained in Utils, we can't | ||
4045 | * guarantee them to follow semver. Use them at your own risk! | ||
4046 | * @static | ||
4047 | * @private | ||
4048 | * @type {Object} | ||
4049 | * @deprecated since version 1.8 | ||
4050 | * @member Utils | ||
4051 | * @memberof Popper | ||
4052 | */ | ||
4053 | |||
4054 | }]); | ||
4055 | return Popper; | ||
4056 | }(); | ||
4057 | |||
4058 | /** | ||
4059 | * The `referenceObject` is an object that provides an interface compatible with Popper.js | ||
4060 | * and lets you use it as replacement of a real DOM node.<br /> | ||
4061 | * You can use this method to position a popper relatively to a set of coordinates | ||
4062 | * in case you don't have a DOM node to use as reference. | ||
4063 | * | ||
4064 | * ``` | ||
4065 | * new Popper(referenceObject, popperNode); | ||
4066 | * ``` | ||
4067 | * | ||
4068 | * NB: This feature isn't supported in Internet Explorer 10. | ||
4069 | * @name referenceObject | ||
4070 | * @property {Function} data.getBoundingClientRect | ||
4071 | * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method. | ||
4072 | * @property {number} data.clientWidth | ||
4073 | * An ES6 getter that will return the width of the virtual reference element. | ||
4074 | * @property {number} data.clientHeight | ||
4075 | * An ES6 getter that will return the height of the virtual reference element. | ||
4076 | */ | ||
4077 | |||
4078 | |||
4079 | Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils; | ||
4080 | Popper.placements = placements; | ||
4081 | Popper.Defaults = Defaults; | ||
4082 | |||
4083 | /** | ||
4084 | * ------------------------------------------------------------------------ | ||
4085 | * Constants | ||
4086 | * ------------------------------------------------------------------------ | ||
4087 | */ | ||
4088 | |||
4089 | var NAME$4 = 'dropdown'; | ||
4090 | var VERSION$4 = '4.3.1'; | ||
4091 | var DATA_KEY$4 = 'bs.dropdown'; | ||
4092 | var EVENT_KEY$4 = "." + DATA_KEY$4; | ||
4093 | var DATA_API_KEY$4 = '.data-api'; | ||
4094 | var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4]; | ||
4095 | var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key | ||
4096 | |||
4097 | var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key | ||
4098 | |||
4099 | var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key | ||
4100 | |||
4101 | var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key | ||
4102 | |||
4103 | var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key | ||
4104 | |||
4105 | var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) | ||
4106 | |||
4107 | var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); | ||
4108 | var Event$4 = { | ||
4109 | HIDE: "hide" + EVENT_KEY$4, | ||
4110 | HIDDEN: "hidden" + EVENT_KEY$4, | ||
4111 | SHOW: "show" + EVENT_KEY$4, | ||
4112 | SHOWN: "shown" + EVENT_KEY$4, | ||
4113 | CLICK: "click" + EVENT_KEY$4, | ||
4114 | CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4, | ||
4115 | KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4, | ||
4116 | KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4 | ||
4117 | }; | ||
4118 | var ClassName$4 = { | ||
4119 | DISABLED: 'disabled', | ||
4120 | SHOW: 'show', | ||
4121 | DROPUP: 'dropup', | ||
4122 | DROPRIGHT: 'dropright', | ||
4123 | DROPLEFT: 'dropleft', | ||
4124 | MENURIGHT: 'dropdown-menu-right', | ||
4125 | MENULEFT: 'dropdown-menu-left', | ||
4126 | POSITION_STATIC: 'position-static' | ||
4127 | }; | ||
4128 | var Selector$4 = { | ||
4129 | DATA_TOGGLE: '[data-toggle="dropdown"]', | ||
4130 | FORM_CHILD: '.dropdown form', | ||
4131 | MENU: '.dropdown-menu', | ||
4132 | NAVBAR_NAV: '.navbar-nav', | ||
4133 | VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)' | ||
4134 | }; | ||
4135 | var AttachmentMap = { | ||
4136 | TOP: 'top-start', | ||
4137 | TOPEND: 'top-end', | ||
4138 | BOTTOM: 'bottom-start', | ||
4139 | BOTTOMEND: 'bottom-end', | ||
4140 | RIGHT: 'right-start', | ||
4141 | RIGHTEND: 'right-end', | ||
4142 | LEFT: 'left-start', | ||
4143 | LEFTEND: 'left-end' | ||
4144 | }; | ||
4145 | var Default$2 = { | ||
4146 | offset: 0, | ||
4147 | flip: true, | ||
4148 | boundary: 'scrollParent', | ||
4149 | reference: 'toggle', | ||
4150 | display: 'dynamic' | ||
4151 | }; | ||
4152 | var DefaultType$2 = { | ||
4153 | offset: '(number|string|function)', | ||
4154 | flip: 'boolean', | ||
4155 | boundary: '(string|element)', | ||
4156 | reference: '(string|element)', | ||
4157 | display: 'string' | ||
4158 | /** | ||
4159 | * ------------------------------------------------------------------------ | ||
4160 | * Class Definition | ||
4161 | * ------------------------------------------------------------------------ | ||
4162 | */ | ||
4163 | |||
4164 | }; | ||
4165 | |||
4166 | var Dropdown = | ||
4167 | /*#__PURE__*/ | ||
4168 | function () { | ||
4169 | function Dropdown(element, config) { | ||
4170 | this._element = element; | ||
4171 | this._popper = null; | ||
4172 | this._config = this._getConfig(config); | ||
4173 | this._menu = this._getMenuElement(); | ||
4174 | this._inNavbar = this._detectNavbar(); | ||
4175 | |||
4176 | this._addEventListeners(); | ||
4177 | } // Getters | ||
4178 | |||
4179 | |||
4180 | var _proto = Dropdown.prototype; | ||
4181 | |||
4182 | // Public | ||
4183 | _proto.toggle = function toggle() { | ||
4184 | if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) { | ||
4185 | return; | ||
4186 | } | ||
4187 | |||
4188 | var parent = Dropdown._getParentFromElement(this._element); | ||
4189 | |||
4190 | var isActive = $(this._menu).hasClass(ClassName$4.SHOW); | ||
4191 | |||
4192 | Dropdown._clearMenus(); | ||
4193 | |||
4194 | if (isActive) { | ||
4195 | return; | ||
4196 | } | ||
4197 | |||
4198 | var relatedTarget = { | ||
4199 | relatedTarget: this._element | ||
4200 | }; | ||
4201 | var showEvent = $.Event(Event$4.SHOW, relatedTarget); | ||
4202 | $(parent).trigger(showEvent); | ||
4203 | |||
4204 | if (showEvent.isDefaultPrevented()) { | ||
4205 | return; | ||
4206 | } // Disable totally Popper.js for Dropdown in Navbar | ||
4207 | |||
4208 | |||
4209 | if (!this._inNavbar) { | ||
4210 | /** | ||
4211 | * Check for Popper dependency | ||
4212 | * Popper - https://popper.js.org | ||
4213 | */ | ||
4214 | if (typeof Popper === 'undefined') { | ||
4215 | throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)'); | ||
4216 | } | ||
4217 | |||
4218 | var referenceElement = this._element; | ||
4219 | |||
4220 | if (this._config.reference === 'parent') { | ||
4221 | referenceElement = parent; | ||
4222 | } else if (Util.isElement(this._config.reference)) { | ||
4223 | referenceElement = this._config.reference; // Check if it's jQuery element | ||
4224 | |||
4225 | if (typeof this._config.reference.jquery !== 'undefined') { | ||
4226 | referenceElement = this._config.reference[0]; | ||
4227 | } | ||
4228 | } // If boundary is not `scrollParent`, then set position to `static` | ||
4229 | // to allow the menu to "escape" the scroll parent's boundaries | ||
4230 | // https://github.com/twbs/bootstrap/issues/24251 | ||
4231 | |||
4232 | |||
4233 | if (this._config.boundary !== 'scrollParent') { | ||
4234 | $(parent).addClass(ClassName$4.POSITION_STATIC); | ||
4235 | } | ||
4236 | |||
4237 | this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); | ||
4238 | } // If this is a touch-enabled device we add extra | ||
4239 | // empty mouseover listeners to the body's immediate children; | ||
4240 | // only needed because of broken event delegation on iOS | ||
4241 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html | ||
4242 | |||
4243 | |||
4244 | if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) { | ||
4245 | $(document.body).children().on('mouseover', null, $.noop); | ||
4246 | } | ||
4247 | |||
4248 | this._element.focus(); | ||
4249 | |||
4250 | this._element.setAttribute('aria-expanded', true); | ||
4251 | |||
4252 | $(this._menu).toggleClass(ClassName$4.SHOW); | ||
4253 | $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget)); | ||
4254 | }; | ||
4255 | |||
4256 | _proto.show = function show() { | ||
4257 | if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) { | ||
4258 | return; | ||
4259 | } | ||
4260 | |||
4261 | var relatedTarget = { | ||
4262 | relatedTarget: this._element | ||
4263 | }; | ||
4264 | var showEvent = $.Event(Event$4.SHOW, relatedTarget); | ||
4265 | |||
4266 | var parent = Dropdown._getParentFromElement(this._element); | ||
4267 | |||
4268 | $(parent).trigger(showEvent); | ||
4269 | |||
4270 | if (showEvent.isDefaultPrevented()) { | ||
4271 | return; | ||
4272 | } | ||
4273 | |||
4274 | $(this._menu).toggleClass(ClassName$4.SHOW); | ||
4275 | $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget)); | ||
4276 | }; | ||
4277 | |||
4278 | _proto.hide = function hide() { | ||
4279 | if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) { | ||
4280 | return; | ||
4281 | } | ||
4282 | |||
4283 | var relatedTarget = { | ||
4284 | relatedTarget: this._element | ||
4285 | }; | ||
4286 | var hideEvent = $.Event(Event$4.HIDE, relatedTarget); | ||
4287 | |||
4288 | var parent = Dropdown._getParentFromElement(this._element); | ||
4289 | |||
4290 | $(parent).trigger(hideEvent); | ||
4291 | |||
4292 | if (hideEvent.isDefaultPrevented()) { | ||
4293 | return; | ||
4294 | } | ||
4295 | |||
4296 | $(this._menu).toggleClass(ClassName$4.SHOW); | ||
4297 | $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget)); | ||
4298 | }; | ||
4299 | |||
4300 | _proto.dispose = function dispose() { | ||
4301 | $.removeData(this._element, DATA_KEY$4); | ||
4302 | $(this._element).off(EVENT_KEY$4); | ||
4303 | this._element = null; | ||
4304 | this._menu = null; | ||
4305 | |||
4306 | if (this._popper !== null) { | ||
4307 | this._popper.destroy(); | ||
4308 | |||
4309 | this._popper = null; | ||
4310 | } | ||
4311 | }; | ||
4312 | |||
4313 | _proto.update = function update() { | ||
4314 | this._inNavbar = this._detectNavbar(); | ||
4315 | |||
4316 | if (this._popper !== null) { | ||
4317 | this._popper.scheduleUpdate(); | ||
4318 | } | ||
4319 | } // Private | ||
4320 | ; | ||
4321 | |||
4322 | _proto._addEventListeners = function _addEventListeners() { | ||
4323 | var _this = this; | ||
4324 | |||
4325 | $(this._element).on(Event$4.CLICK, function (event) { | ||
4326 | event.preventDefault(); | ||
4327 | event.stopPropagation(); | ||
4328 | |||
4329 | _this.toggle(); | ||
4330 | }); | ||
4331 | }; | ||
4332 | |||
4333 | _proto._getConfig = function _getConfig(config) { | ||
4334 | config = _objectSpread({}, this.constructor.Default, $(this._element).data(), config); | ||
4335 | Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType); | ||
4336 | return config; | ||
4337 | }; | ||
4338 | |||
4339 | _proto._getMenuElement = function _getMenuElement() { | ||
4340 | if (!this._menu) { | ||
4341 | var parent = Dropdown._getParentFromElement(this._element); | ||
4342 | |||
4343 | if (parent) { | ||
4344 | this._menu = parent.querySelector(Selector$4.MENU); | ||
4345 | } | ||
4346 | } | ||
4347 | |||
4348 | return this._menu; | ||
4349 | }; | ||
4350 | |||
4351 | _proto._getPlacement = function _getPlacement() { | ||
4352 | var $parentDropdown = $(this._element.parentNode); | ||
4353 | var placement = AttachmentMap.BOTTOM; // Handle dropup | ||
4354 | |||
4355 | if ($parentDropdown.hasClass(ClassName$4.DROPUP)) { | ||
4356 | placement = AttachmentMap.TOP; | ||
4357 | |||
4358 | if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) { | ||
4359 | placement = AttachmentMap.TOPEND; | ||
4360 | } | ||
4361 | } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) { | ||
4362 | placement = AttachmentMap.RIGHT; | ||
4363 | } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) { | ||
4364 | placement = AttachmentMap.LEFT; | ||
4365 | } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) { | ||
4366 | placement = AttachmentMap.BOTTOMEND; | ||
4367 | } | ||
4368 | |||
4369 | return placement; | ||
4370 | }; | ||
4371 | |||
4372 | _proto._detectNavbar = function _detectNavbar() { | ||
4373 | return $(this._element).closest('.navbar').length > 0; | ||
4374 | }; | ||
4375 | |||
4376 | _proto._getOffset = function _getOffset() { | ||
4377 | var _this2 = this; | ||
4378 | |||
4379 | var offset = {}; | ||
4380 | |||
4381 | if (typeof this._config.offset === 'function') { | ||
4382 | offset.fn = function (data) { | ||
4383 | data.offsets = _objectSpread({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); | ||
4384 | return data; | ||
4385 | }; | ||
4386 | } else { | ||
4387 | offset.offset = this._config.offset; | ||
4388 | } | ||
4389 | |||
4390 | return offset; | ||
4391 | }; | ||
4392 | |||
4393 | _proto._getPopperConfig = function _getPopperConfig() { | ||
4394 | var popperConfig = { | ||
4395 | placement: this._getPlacement(), | ||
4396 | modifiers: { | ||
4397 | offset: this._getOffset(), | ||
4398 | flip: { | ||
4399 | enabled: this._config.flip | ||
4400 | }, | ||
4401 | preventOverflow: { | ||
4402 | boundariesElement: this._config.boundary | ||
4403 | } | ||
4404 | } // Disable Popper.js if we have a static display | ||
4405 | |||
4406 | }; | ||
4407 | |||
4408 | if (this._config.display === 'static') { | ||
4409 | popperConfig.modifiers.applyStyle = { | ||
4410 | enabled: false | ||
4411 | }; | ||
4412 | } | ||
4413 | |||
4414 | return popperConfig; | ||
4415 | } // Static | ||
4416 | ; | ||
4417 | |||
4418 | Dropdown._jQueryInterface = function _jQueryInterface(config) { | ||
4419 | return this.each(function () { | ||
4420 | var data = $(this).data(DATA_KEY$4); | ||
4421 | |||
4422 | var _config = typeof config === 'object' ? config : null; | ||
4423 | |||
4424 | if (!data) { | ||
4425 | data = new Dropdown(this, _config); | ||
4426 | $(this).data(DATA_KEY$4, data); | ||
4427 | } | ||
4428 | |||
4429 | if (typeof config === 'string') { | ||
4430 | if (typeof data[config] === 'undefined') { | ||
4431 | throw new TypeError("No method named \"" + config + "\""); | ||
4432 | } | ||
4433 | |||
4434 | data[config](); | ||
4435 | } | ||
4436 | }); | ||
4437 | }; | ||
4438 | |||
4439 | Dropdown._clearMenus = function _clearMenus(event) { | ||
4440 | if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { | ||
4441 | return; | ||
4442 | } | ||
4443 | |||
4444 | var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE)); | ||
4445 | |||
4446 | for (var i = 0, len = toggles.length; i < len; i++) { | ||
4447 | var parent = Dropdown._getParentFromElement(toggles[i]); | ||
4448 | |||
4449 | var context = $(toggles[i]).data(DATA_KEY$4); | ||
4450 | var relatedTarget = { | ||
4451 | relatedTarget: toggles[i] | ||
4452 | }; | ||
4453 | |||
4454 | if (event && event.type === 'click') { | ||
4455 | relatedTarget.clickEvent = event; | ||
4456 | } | ||
4457 | |||
4458 | if (!context) { | ||
4459 | continue; | ||
4460 | } | ||
4461 | |||
4462 | var dropdownMenu = context._menu; | ||
4463 | |||
4464 | if (!$(parent).hasClass(ClassName$4.SHOW)) { | ||
4465 | continue; | ||
4466 | } | ||
4467 | |||
4468 | if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) { | ||
4469 | continue; | ||
4470 | } | ||
4471 | |||
4472 | var hideEvent = $.Event(Event$4.HIDE, relatedTarget); | ||
4473 | $(parent).trigger(hideEvent); | ||
4474 | |||
4475 | if (hideEvent.isDefaultPrevented()) { | ||
4476 | continue; | ||
4477 | } // If this is a touch-enabled device we remove the extra | ||
4478 | // empty mouseover listeners we added for iOS support | ||
4479 | |||
4480 | |||
4481 | if ('ontouchstart' in document.documentElement) { | ||
4482 | $(document.body).children().off('mouseover', null, $.noop); | ||
4483 | } | ||
4484 | |||
4485 | toggles[i].setAttribute('aria-expanded', 'false'); | ||
4486 | $(dropdownMenu).removeClass(ClassName$4.SHOW); | ||
4487 | $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget)); | ||
4488 | } | ||
4489 | }; | ||
4490 | |||
4491 | Dropdown._getParentFromElement = function _getParentFromElement(element) { | ||
4492 | var parent; | ||
4493 | var selector = Util.getSelectorFromElement(element); | ||
4494 | |||
4495 | if (selector) { | ||
4496 | parent = document.querySelector(selector); | ||
4497 | } | ||
4498 | |||
4499 | return parent || element.parentNode; | ||
4500 | } // eslint-disable-next-line complexity | ||
4501 | ; | ||
4502 | |||
4503 | Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { | ||
4504 | // If not input/textarea: | ||
4505 | // - And not a key in REGEXP_KEYDOWN => not a dropdown command | ||
4506 | // If input/textarea: | ||
4507 | // - If space key => not a dropdown command | ||
4508 | // - If key is other than escape | ||
4509 | // - If key is not up or down => not a dropdown command | ||
4510 | // - If trigger inside the menu => not a dropdown command | ||
4511 | if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(Selector$4.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { | ||
4512 | return; | ||
4513 | } | ||
4514 | |||
4515 | event.preventDefault(); | ||
4516 | event.stopPropagation(); | ||
4517 | |||
4518 | if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) { | ||
4519 | return; | ||
4520 | } | ||
4521 | |||
4522 | var parent = Dropdown._getParentFromElement(this); | ||
4523 | |||
4524 | var isActive = $(parent).hasClass(ClassName$4.SHOW); | ||
4525 | |||
4526 | if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { | ||
4527 | if (event.which === ESCAPE_KEYCODE) { | ||
4528 | var toggle = parent.querySelector(Selector$4.DATA_TOGGLE); | ||
4529 | $(toggle).trigger('focus'); | ||
4530 | } | ||
4531 | |||
4532 | $(this).trigger('click'); | ||
4533 | return; | ||
4534 | } | ||
4535 | |||
4536 | var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)); | ||
4537 | |||
4538 | if (items.length === 0) { | ||
4539 | return; | ||
4540 | } | ||
4541 | |||
4542 | var index = items.indexOf(event.target); | ||
4543 | |||
4544 | if (event.which === ARROW_UP_KEYCODE && index > 0) { | ||
4545 | // Up | ||
4546 | index--; | ||
4547 | } | ||
4548 | |||
4549 | if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { | ||
4550 | // Down | ||
4551 | index++; | ||
4552 | } | ||
4553 | |||
4554 | if (index < 0) { | ||
4555 | index = 0; | ||
4556 | } | ||
4557 | |||
4558 | items[index].focus(); | ||
4559 | }; | ||
4560 | |||
4561 | _createClass(Dropdown, null, [{ | ||
4562 | key: "VERSION", | ||
4563 | get: function get() { | ||
4564 | return VERSION$4; | ||
4565 | } | ||
4566 | }, { | ||
4567 | key: "Default", | ||
4568 | get: function get() { | ||
4569 | return Default$2; | ||
4570 | } | ||
4571 | }, { | ||
4572 | key: "DefaultType", | ||
4573 | get: function get() { | ||
4574 | return DefaultType$2; | ||
4575 | } | ||
4576 | }]); | ||
4577 | |||
4578 | return Dropdown; | ||
4579 | }(); | ||
4580 | /** | ||
4581 | * ------------------------------------------------------------------------ | ||
4582 | * Data Api implementation | ||
4583 | * ------------------------------------------------------------------------ | ||
4584 | */ | ||
4585 | |||
4586 | |||
4587 | $(document).on(Event$4.KEYDOWN_DATA_API, Selector$4.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event$4.KEYDOWN_DATA_API, Selector$4.MENU, Dropdown._dataApiKeydownHandler).on(Event$4.CLICK_DATA_API + " " + Event$4.KEYUP_DATA_API, Dropdown._clearMenus).on(Event$4.CLICK_DATA_API, Selector$4.DATA_TOGGLE, function (event) { | ||
4588 | event.preventDefault(); | ||
4589 | event.stopPropagation(); | ||
4590 | |||
4591 | Dropdown._jQueryInterface.call($(this), 'toggle'); | ||
4592 | }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) { | ||
4593 | e.stopPropagation(); | ||
4594 | }); | ||
4595 | /** | ||
4596 | * ------------------------------------------------------------------------ | ||
4597 | * jQuery | ||
4598 | * ------------------------------------------------------------------------ | ||
4599 | */ | ||
4600 | |||
4601 | $.fn[NAME$4] = Dropdown._jQueryInterface; | ||
4602 | $.fn[NAME$4].Constructor = Dropdown; | ||
4603 | |||
4604 | $.fn[NAME$4].noConflict = function () { | ||
4605 | $.fn[NAME$4] = JQUERY_NO_CONFLICT$4; | ||
4606 | return Dropdown._jQueryInterface; | ||
4607 | }; | ||
4608 | |||
4609 | /** | ||
4610 | * ------------------------------------------------------------------------ | ||
4611 | * Constants | ||
4612 | * ------------------------------------------------------------------------ | ||
4613 | */ | ||
4614 | |||
4615 | var NAME$5 = 'modal'; | ||
4616 | var VERSION$5 = '4.3.1'; | ||
4617 | var DATA_KEY$5 = 'bs.modal'; | ||
4618 | var EVENT_KEY$5 = "." + DATA_KEY$5; | ||
4619 | var DATA_API_KEY$5 = '.data-api'; | ||
4620 | var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5]; | ||
4621 | var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key | ||
4622 | |||
4623 | var Default$3 = { | ||
4624 | backdrop: true, | ||
4625 | keyboard: true, | ||
4626 | focus: true, | ||
4627 | show: true | ||
4628 | }; | ||
4629 | var DefaultType$3 = { | ||
4630 | backdrop: '(boolean|string)', | ||
4631 | keyboard: 'boolean', | ||
4632 | focus: 'boolean', | ||
4633 | show: 'boolean' | ||
4634 | }; | ||
4635 | var Event$5 = { | ||
4636 | HIDE: "hide" + EVENT_KEY$5, | ||
4637 | HIDDEN: "hidden" + EVENT_KEY$5, | ||
4638 | SHOW: "show" + EVENT_KEY$5, | ||
4639 | SHOWN: "shown" + EVENT_KEY$5, | ||
4640 | FOCUSIN: "focusin" + EVENT_KEY$5, | ||
4641 | RESIZE: "resize" + EVENT_KEY$5, | ||
4642 | CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5, | ||
4643 | KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5, | ||
4644 | MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5, | ||
4645 | MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5, | ||
4646 | CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5 | ||
4647 | }; | ||
4648 | var ClassName$5 = { | ||
4649 | SCROLLABLE: 'modal-dialog-scrollable', | ||
4650 | SCROLLBAR_MEASURER: 'modal-scrollbar-measure', | ||
4651 | BACKDROP: 'modal-backdrop', | ||
4652 | OPEN: 'modal-open', | ||
4653 | FADE: 'fade', | ||
4654 | SHOW: 'show' | ||
4655 | }; | ||
4656 | var Selector$5 = { | ||
4657 | DIALOG: '.modal-dialog', | ||
4658 | MODAL_BODY: '.modal-body', | ||
4659 | DATA_TOGGLE: '[data-toggle="modal"]', | ||
4660 | DATA_DISMISS: '[data-dismiss="modal"]', | ||
4661 | FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', | ||
4662 | STICKY_CONTENT: '.sticky-top' | ||
4663 | /** | ||
4664 | * ------------------------------------------------------------------------ | ||
4665 | * Class Definition | ||
4666 | * ------------------------------------------------------------------------ | ||
4667 | */ | ||
4668 | |||
4669 | }; | ||
4670 | |||
4671 | var Modal = | ||
4672 | /*#__PURE__*/ | ||
4673 | function () { | ||
4674 | function Modal(element, config) { | ||
4675 | this._config = this._getConfig(config); | ||
4676 | this._element = element; | ||
4677 | this._dialog = element.querySelector(Selector$5.DIALOG); | ||
4678 | this._backdrop = null; | ||
4679 | this._isShown = false; | ||
4680 | this._isBodyOverflowing = false; | ||
4681 | this._ignoreBackdropClick = false; | ||
4682 | this._isTransitioning = false; | ||
4683 | this._scrollbarWidth = 0; | ||
4684 | } // Getters | ||
4685 | |||
4686 | |||
4687 | var _proto = Modal.prototype; | ||
4688 | |||
4689 | // Public | ||
4690 | _proto.toggle = function toggle(relatedTarget) { | ||
4691 | return this._isShown ? this.hide() : this.show(relatedTarget); | ||
4692 | }; | ||
4693 | |||
4694 | _proto.show = function show(relatedTarget) { | ||
4695 | var _this = this; | ||
4696 | |||
4697 | if (this._isShown || this._isTransitioning) { | ||
4698 | return; | ||
4699 | } | ||
4700 | |||
4701 | if ($(this._element).hasClass(ClassName$5.FADE)) { | ||
4702 | this._isTransitioning = true; | ||
4703 | } | ||
4704 | |||
4705 | var showEvent = $.Event(Event$5.SHOW, { | ||
4706 | relatedTarget: relatedTarget | ||
4707 | }); | ||
4708 | $(this._element).trigger(showEvent); | ||
4709 | |||
4710 | if (this._isShown || showEvent.isDefaultPrevented()) { | ||
4711 | return; | ||
4712 | } | ||
4713 | |||
4714 | this._isShown = true; | ||
4715 | |||
4716 | this._checkScrollbar(); | ||
4717 | |||
4718 | this._setScrollbar(); | ||
4719 | |||
4720 | this._adjustDialog(); | ||
4721 | |||
4722 | this._setEscapeEvent(); | ||
4723 | |||
4724 | this._setResizeEvent(); | ||
4725 | |||
4726 | $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) { | ||
4727 | return _this.hide(event); | ||
4728 | }); | ||
4729 | $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () { | ||
4730 | $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) { | ||
4731 | if ($(event.target).is(_this._element)) { | ||
4732 | _this._ignoreBackdropClick = true; | ||
4733 | } | ||
4734 | }); | ||
4735 | }); | ||
4736 | |||
4737 | this._showBackdrop(function () { | ||
4738 | return _this._showElement(relatedTarget); | ||
4739 | }); | ||
4740 | }; | ||
4741 | |||
4742 | _proto.hide = function hide(event) { | ||
4743 | var _this2 = this; | ||
4744 | |||
4745 | if (event) { | ||
4746 | event.preventDefault(); | ||
4747 | } | ||
4748 | |||
4749 | if (!this._isShown || this._isTransitioning) { | ||
4750 | return; | ||
4751 | } | ||
4752 | |||
4753 | var hideEvent = $.Event(Event$5.HIDE); | ||
4754 | $(this._element).trigger(hideEvent); | ||
4755 | |||
4756 | if (!this._isShown || hideEvent.isDefaultPrevented()) { | ||
4757 | return; | ||
4758 | } | ||
4759 | |||
4760 | this._isShown = false; | ||
4761 | var transition = $(this._element).hasClass(ClassName$5.FADE); | ||
4762 | |||
4763 | if (transition) { | ||
4764 | this._isTransitioning = true; | ||
4765 | } | ||
4766 | |||
4767 | this._setEscapeEvent(); | ||
4768 | |||
4769 | this._setResizeEvent(); | ||
4770 | |||
4771 | $(document).off(Event$5.FOCUSIN); | ||
4772 | $(this._element).removeClass(ClassName$5.SHOW); | ||
4773 | $(this._element).off(Event$5.CLICK_DISMISS); | ||
4774 | $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS); | ||
4775 | |||
4776 | if (transition) { | ||
4777 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); | ||
4778 | $(this._element).one(Util.TRANSITION_END, function (event) { | ||
4779 | return _this2._hideModal(event); | ||
4780 | }).emulateTransitionEnd(transitionDuration); | ||
4781 | } else { | ||
4782 | this._hideModal(); | ||
4783 | } | ||
4784 | }; | ||
4785 | |||
4786 | _proto.dispose = function dispose() { | ||
4787 | [window, this._element, this._dialog].forEach(function (htmlElement) { | ||
4788 | return $(htmlElement).off(EVENT_KEY$5); | ||
4789 | }); | ||
4790 | /** | ||
4791 | * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API` | ||
4792 | * Do not move `document` in `htmlElements` array | ||
4793 | * It will remove `Event.CLICK_DATA_API` event that should remain | ||
4794 | */ | ||
4795 | |||
4796 | $(document).off(Event$5.FOCUSIN); | ||
4797 | $.removeData(this._element, DATA_KEY$5); | ||
4798 | this._config = null; | ||
4799 | this._element = null; | ||
4800 | this._dialog = null; | ||
4801 | this._backdrop = null; | ||
4802 | this._isShown = null; | ||
4803 | this._isBodyOverflowing = null; | ||
4804 | this._ignoreBackdropClick = null; | ||
4805 | this._isTransitioning = null; | ||
4806 | this._scrollbarWidth = null; | ||
4807 | }; | ||
4808 | |||
4809 | _proto.handleUpdate = function handleUpdate() { | ||
4810 | this._adjustDialog(); | ||
4811 | } // Private | ||
4812 | ; | ||
4813 | |||
4814 | _proto._getConfig = function _getConfig(config) { | ||
4815 | config = _objectSpread({}, Default$3, config); | ||
4816 | Util.typeCheckConfig(NAME$5, config, DefaultType$3); | ||
4817 | return config; | ||
4818 | }; | ||
4819 | |||
4820 | _proto._showElement = function _showElement(relatedTarget) { | ||
4821 | var _this3 = this; | ||
4822 | |||
4823 | var transition = $(this._element).hasClass(ClassName$5.FADE); | ||
4824 | |||
4825 | if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { | ||
4826 | // Don't move modal's DOM position | ||
4827 | document.body.appendChild(this._element); | ||
4828 | } | ||
4829 | |||
4830 | this._element.style.display = 'block'; | ||
4831 | |||
4832 | this._element.removeAttribute('aria-hidden'); | ||
4833 | |||
4834 | this._element.setAttribute('aria-modal', true); | ||
4835 | |||
4836 | if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE)) { | ||
4837 | this._dialog.querySelector(Selector$5.MODAL_BODY).scrollTop = 0; | ||
4838 | } else { | ||
4839 | this._element.scrollTop = 0; | ||
4840 | } | ||
4841 | |||
4842 | if (transition) { | ||
4843 | Util.reflow(this._element); | ||
4844 | } | ||
4845 | |||
4846 | $(this._element).addClass(ClassName$5.SHOW); | ||
4847 | |||
4848 | if (this._config.focus) { | ||
4849 | this._enforceFocus(); | ||
4850 | } | ||
4851 | |||
4852 | var shownEvent = $.Event(Event$5.SHOWN, { | ||
4853 | relatedTarget: relatedTarget | ||
4854 | }); | ||
4855 | |||
4856 | var transitionComplete = function transitionComplete() { | ||
4857 | if (_this3._config.focus) { | ||
4858 | _this3._element.focus(); | ||
4859 | } | ||
4860 | |||
4861 | _this3._isTransitioning = false; | ||
4862 | $(_this3._element).trigger(shownEvent); | ||
4863 | }; | ||
4864 | |||
4865 | if (transition) { | ||
4866 | var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); | ||
4867 | $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); | ||
4868 | } else { | ||
4869 | transitionComplete(); | ||
4870 | } | ||
4871 | }; | ||
4872 | |||
4873 | _proto._enforceFocus = function _enforceFocus() { | ||
4874 | var _this4 = this; | ||
4875 | |||
4876 | $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop | ||
4877 | .on(Event$5.FOCUSIN, function (event) { | ||
4878 | if (document !== event.target && _this4._element !== event.target && $(_this4._element).has(event.target).length === 0) { | ||
4879 | _this4._element.focus(); | ||
4880 | } | ||
4881 | }); | ||
4882 | }; | ||
4883 | |||
4884 | _proto._setEscapeEvent = function _setEscapeEvent() { | ||
4885 | var _this5 = this; | ||
4886 | |||
4887 | if (this._isShown && this._config.keyboard) { | ||
4888 | $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) { | ||
4889 | if (event.which === ESCAPE_KEYCODE$1) { | ||
4890 | event.preventDefault(); | ||
4891 | |||
4892 | _this5.hide(); | ||
4893 | } | ||
4894 | }); | ||
4895 | } else if (!this._isShown) { | ||
4896 | $(this._element).off(Event$5.KEYDOWN_DISMISS); | ||
4897 | } | ||
4898 | }; | ||
4899 | |||
4900 | _proto._setResizeEvent = function _setResizeEvent() { | ||
4901 | var _this6 = this; | ||
4902 | |||
4903 | if (this._isShown) { | ||
4904 | $(window).on(Event$5.RESIZE, function (event) { | ||
4905 | return _this6.handleUpdate(event); | ||
4906 | }); | ||
4907 | } else { | ||
4908 | $(window).off(Event$5.RESIZE); | ||
4909 | } | ||
4910 | }; | ||
4911 | |||
4912 | _proto._hideModal = function _hideModal() { | ||
4913 | var _this7 = this; | ||
4914 | |||
4915 | this._element.style.display = 'none'; | ||
4916 | |||
4917 | this._element.setAttribute('aria-hidden', true); | ||
4918 | |||
4919 | this._element.removeAttribute('aria-modal'); | ||
4920 | |||
4921 | this._isTransitioning = false; | ||
4922 | |||
4923 | this._showBackdrop(function () { | ||
4924 | $(document.body).removeClass(ClassName$5.OPEN); | ||
4925 | |||
4926 | _this7._resetAdjustments(); | ||
4927 | |||
4928 | _this7._resetScrollbar(); | ||
4929 | |||
4930 | $(_this7._element).trigger(Event$5.HIDDEN); | ||
4931 | }); | ||
4932 | }; | ||
4933 | |||
4934 | _proto._removeBackdrop = function _removeBackdrop() { | ||
4935 | if (this._backdrop) { | ||
4936 | $(this._backdrop).remove(); | ||
4937 | this._backdrop = null; | ||
4938 | } | ||
4939 | }; | ||
4940 | |||
4941 | _proto._showBackdrop = function _showBackdrop(callback) { | ||
4942 | var _this8 = this; | ||
4943 | |||
4944 | var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : ''; | ||
4945 | |||
4946 | if (this._isShown && this._config.backdrop) { | ||
4947 | this._backdrop = document.createElement('div'); | ||
4948 | this._backdrop.className = ClassName$5.BACKDROP; | ||
4949 | |||
4950 | if (animate) { | ||
4951 | this._backdrop.classList.add(animate); | ||
4952 | } | ||
4953 | |||
4954 | $(this._backdrop).appendTo(document.body); | ||
4955 | $(this._element).on(Event$5.CLICK_DISMISS, function (event) { | ||
4956 | if (_this8._ignoreBackdropClick) { | ||
4957 | _this8._ignoreBackdropClick = false; | ||
4958 | return; | ||
4959 | } | ||
4960 | |||
4961 | if (event.target !== event.currentTarget) { | ||
4962 | return; | ||
4963 | } | ||
4964 | |||
4965 | if (_this8._config.backdrop === 'static') { | ||
4966 | _this8._element.focus(); | ||
4967 | } else { | ||
4968 | _this8.hide(); | ||
4969 | } | ||
4970 | }); | ||
4971 | |||
4972 | if (animate) { | ||
4973 | Util.reflow(this._backdrop); | ||
4974 | } | ||
4975 | |||
4976 | $(this._backdrop).addClass(ClassName$5.SHOW); | ||
4977 | |||
4978 | if (!callback) { | ||
4979 | return; | ||
4980 | } | ||
4981 | |||
4982 | if (!animate) { | ||
4983 | callback(); | ||
4984 | return; | ||
4985 | } | ||
4986 | |||
4987 | var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); | ||
4988 | $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); | ||
4989 | } else if (!this._isShown && this._backdrop) { | ||
4990 | $(this._backdrop).removeClass(ClassName$5.SHOW); | ||
4991 | |||
4992 | var callbackRemove = function callbackRemove() { | ||
4993 | _this8._removeBackdrop(); | ||
4994 | |||
4995 | if (callback) { | ||
4996 | callback(); | ||
4997 | } | ||
4998 | }; | ||
4999 | |||
5000 | if ($(this._element).hasClass(ClassName$5.FADE)) { | ||
5001 | var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); | ||
5002 | |||
5003 | $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); | ||
5004 | } else { | ||
5005 | callbackRemove(); | ||
5006 | } | ||
5007 | } else if (callback) { | ||
5008 | callback(); | ||
5009 | } | ||
5010 | } // ---------------------------------------------------------------------- | ||
5011 | // the following methods are used to handle overflowing modals | ||
5012 | // todo (fat): these should probably be refactored out of modal.js | ||
5013 | // ---------------------------------------------------------------------- | ||
5014 | ; | ||
5015 | |||
5016 | _proto._adjustDialog = function _adjustDialog() { | ||
5017 | var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; | ||
5018 | |||
5019 | if (!this._isBodyOverflowing && isModalOverflowing) { | ||
5020 | this._element.style.paddingLeft = this._scrollbarWidth + "px"; | ||
5021 | } | ||
5022 | |||
5023 | if (this._isBodyOverflowing && !isModalOverflowing) { | ||
5024 | this._element.style.paddingRight = this._scrollbarWidth + "px"; | ||
5025 | } | ||
5026 | }; | ||
5027 | |||
5028 | _proto._resetAdjustments = function _resetAdjustments() { | ||
5029 | this._element.style.paddingLeft = ''; | ||
5030 | this._element.style.paddingRight = ''; | ||
5031 | }; | ||
5032 | |||
5033 | _proto._checkScrollbar = function _checkScrollbar() { | ||
5034 | var rect = document.body.getBoundingClientRect(); | ||
5035 | this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; | ||
5036 | this._scrollbarWidth = this._getScrollbarWidth(); | ||
5037 | }; | ||
5038 | |||
5039 | _proto._setScrollbar = function _setScrollbar() { | ||
5040 | var _this9 = this; | ||
5041 | |||
5042 | if (this._isBodyOverflowing) { | ||
5043 | // Note: DOMNode.style.paddingRight returns the actual value or '' if not set | ||
5044 | // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set | ||
5045 | var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); | ||
5046 | var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding | ||
5047 | |||
5048 | $(fixedContent).each(function (index, element) { | ||
5049 | var actualPadding = element.style.paddingRight; | ||
5050 | var calculatedPadding = $(element).css('padding-right'); | ||
5051 | $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + "px"); | ||
5052 | }); // Adjust sticky content margin | ||
5053 | |||
5054 | $(stickyContent).each(function (index, element) { | ||
5055 | var actualMargin = element.style.marginRight; | ||
5056 | var calculatedMargin = $(element).css('margin-right'); | ||
5057 | $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + "px"); | ||
5058 | }); // Adjust body padding | ||
5059 | |||
5060 | var actualPadding = document.body.style.paddingRight; | ||
5061 | var calculatedPadding = $(document.body).css('padding-right'); | ||
5062 | $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); | ||
5063 | } | ||
5064 | |||
5065 | $(document.body).addClass(ClassName$5.OPEN); | ||
5066 | }; | ||
5067 | |||
5068 | _proto._resetScrollbar = function _resetScrollbar() { | ||
5069 | // Restore fixed content padding | ||
5070 | var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT)); | ||
5071 | $(fixedContent).each(function (index, element) { | ||
5072 | var padding = $(element).data('padding-right'); | ||
5073 | $(element).removeData('padding-right'); | ||
5074 | element.style.paddingRight = padding ? padding : ''; | ||
5075 | }); // Restore sticky content | ||
5076 | |||
5077 | var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT)); | ||
5078 | $(elements).each(function (index, element) { | ||
5079 | var margin = $(element).data('margin-right'); | ||
5080 | |||
5081 | if (typeof margin !== 'undefined') { | ||
5082 | $(element).css('margin-right', margin).removeData('margin-right'); | ||
5083 | } | ||
5084 | }); // Restore body padding | ||
5085 | |||
5086 | var padding = $(document.body).data('padding-right'); | ||
5087 | $(document.body).removeData('padding-right'); | ||
5088 | document.body.style.paddingRight = padding ? padding : ''; | ||
5089 | }; | ||
5090 | |||
5091 | _proto._getScrollbarWidth = function _getScrollbarWidth() { | ||
5092 | // thx d.walsh | ||
5093 | var scrollDiv = document.createElement('div'); | ||
5094 | scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER; | ||
5095 | document.body.appendChild(scrollDiv); | ||
5096 | var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; | ||
5097 | document.body.removeChild(scrollDiv); | ||
5098 | return scrollbarWidth; | ||
5099 | } // Static | ||
5100 | ; | ||
5101 | |||
5102 | Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { | ||
5103 | return this.each(function () { | ||
5104 | var data = $(this).data(DATA_KEY$5); | ||
5105 | |||
5106 | var _config = _objectSpread({}, Default$3, $(this).data(), typeof config === 'object' && config ? config : {}); | ||
5107 | |||
5108 | if (!data) { | ||
5109 | data = new Modal(this, _config); | ||
5110 | $(this).data(DATA_KEY$5, data); | ||
5111 | } | ||
5112 | |||
5113 | if (typeof config === 'string') { | ||
5114 | if (typeof data[config] === 'undefined') { | ||
5115 | throw new TypeError("No method named \"" + config + "\""); | ||
5116 | } | ||
5117 | |||
5118 | data[config](relatedTarget); | ||
5119 | } else if (_config.show) { | ||
5120 | data.show(relatedTarget); | ||
5121 | } | ||
5122 | }); | ||
5123 | }; | ||
5124 | |||
5125 | _createClass(Modal, null, [{ | ||
5126 | key: "VERSION", | ||
5127 | get: function get() { | ||
5128 | return VERSION$5; | ||
5129 | } | ||
5130 | }, { | ||
5131 | key: "Default", | ||
5132 | get: function get() { | ||
5133 | return Default$3; | ||
5134 | } | ||
5135 | }]); | ||
5136 | |||
5137 | return Modal; | ||
5138 | }(); | ||
5139 | /** | ||
5140 | * ------------------------------------------------------------------------ | ||
5141 | * Data Api implementation | ||
5142 | * ------------------------------------------------------------------------ | ||
5143 | */ | ||
5144 | |||
5145 | |||
5146 | $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) { | ||
5147 | var _this10 = this; | ||
5148 | |||
5149 | var target; | ||
5150 | var selector = Util.getSelectorFromElement(this); | ||
5151 | |||
5152 | if (selector) { | ||
5153 | target = document.querySelector(selector); | ||
5154 | } | ||
5155 | |||
5156 | var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread({}, $(target).data(), $(this).data()); | ||
5157 | |||
5158 | if (this.tagName === 'A' || this.tagName === 'AREA') { | ||
5159 | event.preventDefault(); | ||
5160 | } | ||
5161 | |||
5162 | var $target = $(target).one(Event$5.SHOW, function (showEvent) { | ||
5163 | if (showEvent.isDefaultPrevented()) { | ||
5164 | // Only register focus restorer if modal will actually get shown | ||
5165 | return; | ||
5166 | } | ||
5167 | |||
5168 | $target.one(Event$5.HIDDEN, function () { | ||
5169 | if ($(_this10).is(':visible')) { | ||
5170 | _this10.focus(); | ||
5171 | } | ||
5172 | }); | ||
5173 | }); | ||
5174 | |||
5175 | Modal._jQueryInterface.call($(target), config, this); | ||
5176 | }); | ||
5177 | /** | ||
5178 | * ------------------------------------------------------------------------ | ||
5179 | * jQuery | ||
5180 | * ------------------------------------------------------------------------ | ||
5181 | */ | ||
5182 | |||
5183 | $.fn[NAME$5] = Modal._jQueryInterface; | ||
5184 | $.fn[NAME$5].Constructor = Modal; | ||
5185 | |||
5186 | $.fn[NAME$5].noConflict = function () { | ||
5187 | $.fn[NAME$5] = JQUERY_NO_CONFLICT$5; | ||
5188 | return Modal._jQueryInterface; | ||
5189 | }; | ||
5190 | |||
5191 | /** | ||
5192 | * -------------------------------------------------------------------------- | ||
5193 | * Bootstrap (v4.3.1): tools/sanitizer.js | ||
5194 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
5195 | * -------------------------------------------------------------------------- | ||
5196 | */ | ||
5197 | var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; | ||
5198 | var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; | ||
5199 | var DefaultWhitelist = { | ||
5200 | // Global attributes allowed on any supplied element below. | ||
5201 | '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], | ||
5202 | a: ['target', 'href', 'title', 'rel'], | ||
5203 | area: [], | ||
5204 | b: [], | ||
5205 | br: [], | ||
5206 | col: [], | ||
5207 | code: [], | ||
5208 | div: [], | ||
5209 | em: [], | ||
5210 | hr: [], | ||
5211 | h1: [], | ||
5212 | h2: [], | ||
5213 | h3: [], | ||
5214 | h4: [], | ||
5215 | h5: [], | ||
5216 | h6: [], | ||
5217 | i: [], | ||
5218 | img: ['src', 'alt', 'title', 'width', 'height'], | ||
5219 | li: [], | ||
5220 | ol: [], | ||
5221 | p: [], | ||
5222 | pre: [], | ||
5223 | s: [], | ||
5224 | small: [], | ||
5225 | span: [], | ||
5226 | sub: [], | ||
5227 | sup: [], | ||
5228 | strong: [], | ||
5229 | u: [], | ||
5230 | ul: [] | ||
5231 | /** | ||
5232 | * A pattern that recognizes a commonly useful subset of URLs that are safe. | ||
5233 | * | ||
5234 | * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts | ||
5235 | */ | ||
5236 | |||
5237 | }; | ||
5238 | var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi; | ||
5239 | /** | ||
5240 | * A pattern that matches safe data URLs. Only matches image, video and audio types. | ||
5241 | * | ||
5242 | * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts | ||
5243 | */ | ||
5244 | |||
5245 | var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i; | ||
5246 | |||
5247 | function allowedAttribute(attr, allowedAttributeList) { | ||
5248 | var attrName = attr.nodeName.toLowerCase(); | ||
5249 | |||
5250 | if (allowedAttributeList.indexOf(attrName) !== -1) { | ||
5251 | if (uriAttrs.indexOf(attrName) !== -1) { | ||
5252 | return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); | ||
5253 | } | ||
5254 | |||
5255 | return true; | ||
5256 | } | ||
5257 | |||
5258 | var regExp = allowedAttributeList.filter(function (attrRegex) { | ||
5259 | return attrRegex instanceof RegExp; | ||
5260 | }); // Check if a regular expression validates the attribute. | ||
5261 | |||
5262 | for (var i = 0, l = regExp.length; i < l; i++) { | ||
5263 | if (attrName.match(regExp[i])) { | ||
5264 | return true; | ||
5265 | } | ||
5266 | } | ||
5267 | |||
5268 | return false; | ||
5269 | } | ||
5270 | |||
5271 | function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { | ||
5272 | if (unsafeHtml.length === 0) { | ||
5273 | return unsafeHtml; | ||
5274 | } | ||
5275 | |||
5276 | if (sanitizeFn && typeof sanitizeFn === 'function') { | ||
5277 | return sanitizeFn(unsafeHtml); | ||
5278 | } | ||
5279 | |||
5280 | var domParser = new window.DOMParser(); | ||
5281 | var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); | ||
5282 | var whitelistKeys = Object.keys(whiteList); | ||
5283 | var elements = [].slice.call(createdDocument.body.querySelectorAll('*')); | ||
5284 | |||
5285 | var _loop = function _loop(i, len) { | ||
5286 | var el = elements[i]; | ||
5287 | var elName = el.nodeName.toLowerCase(); | ||
5288 | |||
5289 | if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) { | ||
5290 | el.parentNode.removeChild(el); | ||
5291 | return "continue"; | ||
5292 | } | ||
5293 | |||
5294 | var attributeList = [].slice.call(el.attributes); | ||
5295 | var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); | ||
5296 | attributeList.forEach(function (attr) { | ||
5297 | if (!allowedAttribute(attr, whitelistedAttributes)) { | ||
5298 | el.removeAttribute(attr.nodeName); | ||
5299 | } | ||
5300 | }); | ||
5301 | }; | ||
5302 | |||
5303 | for (var i = 0, len = elements.length; i < len; i++) { | ||
5304 | var _ret = _loop(i, len); | ||
5305 | |||
5306 | if (_ret === "continue") continue; | ||
5307 | } | ||
5308 | |||
5309 | return createdDocument.body.innerHTML; | ||
5310 | } | ||
5311 | |||
5312 | /** | ||
5313 | * ------------------------------------------------------------------------ | ||
5314 | * Constants | ||
5315 | * ------------------------------------------------------------------------ | ||
5316 | */ | ||
5317 | |||
5318 | var NAME$6 = 'tooltip'; | ||
5319 | var VERSION$6 = '4.3.1'; | ||
5320 | var DATA_KEY$6 = 'bs.tooltip'; | ||
5321 | var EVENT_KEY$6 = "." + DATA_KEY$6; | ||
5322 | var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6]; | ||
5323 | var CLASS_PREFIX = 'bs-tooltip'; | ||
5324 | var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g'); | ||
5325 | var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; | ||
5326 | var DefaultType$4 = { | ||
5327 | animation: 'boolean', | ||
5328 | template: 'string', | ||
5329 | title: '(string|element|function)', | ||
5330 | trigger: 'string', | ||
5331 | delay: '(number|object)', | ||
5332 | html: 'boolean', | ||
5333 | selector: '(string|boolean)', | ||
5334 | placement: '(string|function)', | ||
5335 | offset: '(number|string|function)', | ||
5336 | container: '(string|element|boolean)', | ||
5337 | fallbackPlacement: '(string|array)', | ||
5338 | boundary: '(string|element)', | ||
5339 | sanitize: 'boolean', | ||
5340 | sanitizeFn: '(null|function)', | ||
5341 | whiteList: 'object' | ||
5342 | }; | ||
5343 | var AttachmentMap$1 = { | ||
5344 | AUTO: 'auto', | ||
5345 | TOP: 'top', | ||
5346 | RIGHT: 'right', | ||
5347 | BOTTOM: 'bottom', | ||
5348 | LEFT: 'left' | ||
5349 | }; | ||
5350 | var Default$4 = { | ||
5351 | animation: true, | ||
5352 | template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>', | ||
5353 | trigger: 'hover focus', | ||
5354 | title: '', | ||
5355 | delay: 0, | ||
5356 | html: false, | ||
5357 | selector: false, | ||
5358 | placement: 'top', | ||
5359 | offset: 0, | ||
5360 | container: false, | ||
5361 | fallbackPlacement: 'flip', | ||
5362 | boundary: 'scrollParent', | ||
5363 | sanitize: true, | ||
5364 | sanitizeFn: null, | ||
5365 | whiteList: DefaultWhitelist | ||
5366 | }; | ||
5367 | var HoverState = { | ||
5368 | SHOW: 'show', | ||
5369 | OUT: 'out' | ||
5370 | }; | ||
5371 | var Event$6 = { | ||
5372 | HIDE: "hide" + EVENT_KEY$6, | ||
5373 | HIDDEN: "hidden" + EVENT_KEY$6, | ||
5374 | SHOW: "show" + EVENT_KEY$6, | ||
5375 | SHOWN: "shown" + EVENT_KEY$6, | ||
5376 | INSERTED: "inserted" + EVENT_KEY$6, | ||
5377 | CLICK: "click" + EVENT_KEY$6, | ||
5378 | FOCUSIN: "focusin" + EVENT_KEY$6, | ||
5379 | FOCUSOUT: "focusout" + EVENT_KEY$6, | ||
5380 | MOUSEENTER: "mouseenter" + EVENT_KEY$6, | ||
5381 | MOUSELEAVE: "mouseleave" + EVENT_KEY$6 | ||
5382 | }; | ||
5383 | var ClassName$6 = { | ||
5384 | FADE: 'fade', | ||
5385 | SHOW: 'show' | ||
5386 | }; | ||
5387 | var Selector$6 = { | ||
5388 | TOOLTIP: '.tooltip', | ||
5389 | TOOLTIP_INNER: '.tooltip-inner', | ||
5390 | ARROW: '.arrow' | ||
5391 | }; | ||
5392 | var Trigger = { | ||
5393 | HOVER: 'hover', | ||
5394 | FOCUS: 'focus', | ||
5395 | CLICK: 'click', | ||
5396 | MANUAL: 'manual' | ||
5397 | /** | ||
5398 | * ------------------------------------------------------------------------ | ||
5399 | * Class Definition | ||
5400 | * ------------------------------------------------------------------------ | ||
5401 | */ | ||
5402 | |||
5403 | }; | ||
5404 | |||
5405 | var Tooltip = | ||
5406 | /*#__PURE__*/ | ||
5407 | function () { | ||
5408 | function Tooltip(element, config) { | ||
5409 | /** | ||
5410 | * Check for Popper dependency | ||
5411 | * Popper - https://popper.js.org | ||
5412 | */ | ||
5413 | if (typeof Popper === 'undefined') { | ||
5414 | throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)'); | ||
5415 | } // private | ||
5416 | |||
5417 | |||
5418 | this._isEnabled = true; | ||
5419 | this._timeout = 0; | ||
5420 | this._hoverState = ''; | ||
5421 | this._activeTrigger = {}; | ||
5422 | this._popper = null; // Protected | ||
5423 | |||
5424 | this.element = element; | ||
5425 | this.config = this._getConfig(config); | ||
5426 | this.tip = null; | ||
5427 | |||
5428 | this._setListeners(); | ||
5429 | } // Getters | ||
5430 | |||
5431 | |||
5432 | var _proto = Tooltip.prototype; | ||
5433 | |||
5434 | // Public | ||
5435 | _proto.enable = function enable() { | ||
5436 | this._isEnabled = true; | ||
5437 | }; | ||
5438 | |||
5439 | _proto.disable = function disable() { | ||
5440 | this._isEnabled = false; | ||
5441 | }; | ||
5442 | |||
5443 | _proto.toggleEnabled = function toggleEnabled() { | ||
5444 | this._isEnabled = !this._isEnabled; | ||
5445 | }; | ||
5446 | |||
5447 | _proto.toggle = function toggle(event) { | ||
5448 | if (!this._isEnabled) { | ||
5449 | return; | ||
5450 | } | ||
5451 | |||
5452 | if (event) { | ||
5453 | var dataKey = this.constructor.DATA_KEY; | ||
5454 | var context = $(event.currentTarget).data(dataKey); | ||
5455 | |||
5456 | if (!context) { | ||
5457 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); | ||
5458 | $(event.currentTarget).data(dataKey, context); | ||
5459 | } | ||
5460 | |||
5461 | context._activeTrigger.click = !context._activeTrigger.click; | ||
5462 | |||
5463 | if (context._isWithActiveTrigger()) { | ||
5464 | context._enter(null, context); | ||
5465 | } else { | ||
5466 | context._leave(null, context); | ||
5467 | } | ||
5468 | } else { | ||
5469 | if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) { | ||
5470 | this._leave(null, this); | ||
5471 | |||
5472 | return; | ||
5473 | } | ||
5474 | |||
5475 | this._enter(null, this); | ||
5476 | } | ||
5477 | }; | ||
5478 | |||
5479 | _proto.dispose = function dispose() { | ||
5480 | clearTimeout(this._timeout); | ||
5481 | $.removeData(this.element, this.constructor.DATA_KEY); | ||
5482 | $(this.element).off(this.constructor.EVENT_KEY); | ||
5483 | $(this.element).closest('.modal').off('hide.bs.modal'); | ||
5484 | |||
5485 | if (this.tip) { | ||
5486 | $(this.tip).remove(); | ||
5487 | } | ||
5488 | |||
5489 | this._isEnabled = null; | ||
5490 | this._timeout = null; | ||
5491 | this._hoverState = null; | ||
5492 | this._activeTrigger = null; | ||
5493 | |||
5494 | if (this._popper !== null) { | ||
5495 | this._popper.destroy(); | ||
5496 | } | ||
5497 | |||
5498 | this._popper = null; | ||
5499 | this.element = null; | ||
5500 | this.config = null; | ||
5501 | this.tip = null; | ||
5502 | }; | ||
5503 | |||
5504 | _proto.show = function show() { | ||
5505 | var _this = this; | ||
5506 | |||
5507 | if ($(this.element).css('display') === 'none') { | ||
5508 | throw new Error('Please use show on visible elements'); | ||
5509 | } | ||
5510 | |||
5511 | var showEvent = $.Event(this.constructor.Event.SHOW); | ||
5512 | |||
5513 | if (this.isWithContent() && this._isEnabled) { | ||
5514 | $(this.element).trigger(showEvent); | ||
5515 | var shadowRoot = Util.findShadowRoot(this.element); | ||
5516 | var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element); | ||
5517 | |||
5518 | if (showEvent.isDefaultPrevented() || !isInTheDom) { | ||
5519 | return; | ||
5520 | } | ||
5521 | |||
5522 | var tip = this.getTipElement(); | ||
5523 | var tipId = Util.getUID(this.constructor.NAME); | ||
5524 | tip.setAttribute('id', tipId); | ||
5525 | this.element.setAttribute('aria-describedby', tipId); | ||
5526 | this.setContent(); | ||
5527 | |||
5528 | if (this.config.animation) { | ||
5529 | $(tip).addClass(ClassName$6.FADE); | ||
5530 | } | ||
5531 | |||
5532 | var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; | ||
5533 | |||
5534 | var attachment = this._getAttachment(placement); | ||
5535 | |||
5536 | this.addAttachmentClass(attachment); | ||
5537 | |||
5538 | var container = this._getContainer(); | ||
5539 | |||
5540 | $(tip).data(this.constructor.DATA_KEY, this); | ||
5541 | |||
5542 | if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) { | ||
5543 | $(tip).appendTo(container); | ||
5544 | } | ||
5545 | |||
5546 | $(this.element).trigger(this.constructor.Event.INSERTED); | ||
5547 | this._popper = new Popper(this.element, tip, { | ||
5548 | placement: attachment, | ||
5549 | modifiers: { | ||
5550 | offset: this._getOffset(), | ||
5551 | flip: { | ||
5552 | behavior: this.config.fallbackPlacement | ||
5553 | }, | ||
5554 | arrow: { | ||
5555 | element: Selector$6.ARROW | ||
5556 | }, | ||
5557 | preventOverflow: { | ||
5558 | boundariesElement: this.config.boundary | ||
5559 | } | ||
5560 | }, | ||
5561 | onCreate: function onCreate(data) { | ||
5562 | if (data.originalPlacement !== data.placement) { | ||
5563 | _this._handlePopperPlacementChange(data); | ||
5564 | } | ||
5565 | }, | ||
5566 | onUpdate: function onUpdate(data) { | ||
5567 | return _this._handlePopperPlacementChange(data); | ||
5568 | } | ||
5569 | }); | ||
5570 | $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra | ||
5571 | // empty mouseover listeners to the body's immediate children; | ||
5572 | // only needed because of broken event delegation on iOS | ||
5573 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html | ||
5574 | |||
5575 | if ('ontouchstart' in document.documentElement) { | ||
5576 | $(document.body).children().on('mouseover', null, $.noop); | ||
5577 | } | ||
5578 | |||
5579 | var complete = function complete() { | ||
5580 | if (_this.config.animation) { | ||
5581 | _this._fixTransition(); | ||
5582 | } | ||
5583 | |||
5584 | var prevHoverState = _this._hoverState; | ||
5585 | _this._hoverState = null; | ||
5586 | $(_this.element).trigger(_this.constructor.Event.SHOWN); | ||
5587 | |||
5588 | if (prevHoverState === HoverState.OUT) { | ||
5589 | _this._leave(null, _this); | ||
5590 | } | ||
5591 | }; | ||
5592 | |||
5593 | if ($(this.tip).hasClass(ClassName$6.FADE)) { | ||
5594 | var transitionDuration = Util.getTransitionDurationFromElement(this.tip); | ||
5595 | $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
5596 | } else { | ||
5597 | complete(); | ||
5598 | } | ||
5599 | } | ||
5600 | }; | ||
5601 | |||
5602 | _proto.hide = function hide(callback) { | ||
5603 | var _this2 = this; | ||
5604 | |||
5605 | var tip = this.getTipElement(); | ||
5606 | var hideEvent = $.Event(this.constructor.Event.HIDE); | ||
5607 | |||
5608 | var complete = function complete() { | ||
5609 | if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) { | ||
5610 | tip.parentNode.removeChild(tip); | ||
5611 | } | ||
5612 | |||
5613 | _this2._cleanTipClass(); | ||
5614 | |||
5615 | _this2.element.removeAttribute('aria-describedby'); | ||
5616 | |||
5617 | $(_this2.element).trigger(_this2.constructor.Event.HIDDEN); | ||
5618 | |||
5619 | if (_this2._popper !== null) { | ||
5620 | _this2._popper.destroy(); | ||
5621 | } | ||
5622 | |||
5623 | if (callback) { | ||
5624 | callback(); | ||
5625 | } | ||
5626 | }; | ||
5627 | |||
5628 | $(this.element).trigger(hideEvent); | ||
5629 | |||
5630 | if (hideEvent.isDefaultPrevented()) { | ||
5631 | return; | ||
5632 | } | ||
5633 | |||
5634 | $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra | ||
5635 | // empty mouseover listeners we added for iOS support | ||
5636 | |||
5637 | if ('ontouchstart' in document.documentElement) { | ||
5638 | $(document.body).children().off('mouseover', null, $.noop); | ||
5639 | } | ||
5640 | |||
5641 | this._activeTrigger[Trigger.CLICK] = false; | ||
5642 | this._activeTrigger[Trigger.FOCUS] = false; | ||
5643 | this._activeTrigger[Trigger.HOVER] = false; | ||
5644 | |||
5645 | if ($(this.tip).hasClass(ClassName$6.FADE)) { | ||
5646 | var transitionDuration = Util.getTransitionDurationFromElement(tip); | ||
5647 | $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
5648 | } else { | ||
5649 | complete(); | ||
5650 | } | ||
5651 | |||
5652 | this._hoverState = ''; | ||
5653 | }; | ||
5654 | |||
5655 | _proto.update = function update() { | ||
5656 | if (this._popper !== null) { | ||
5657 | this._popper.scheduleUpdate(); | ||
5658 | } | ||
5659 | } // Protected | ||
5660 | ; | ||
5661 | |||
5662 | _proto.isWithContent = function isWithContent() { | ||
5663 | return Boolean(this.getTitle()); | ||
5664 | }; | ||
5665 | |||
5666 | _proto.addAttachmentClass = function addAttachmentClass(attachment) { | ||
5667 | $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment); | ||
5668 | }; | ||
5669 | |||
5670 | _proto.getTipElement = function getTipElement() { | ||
5671 | this.tip = this.tip || $(this.config.template)[0]; | ||
5672 | return this.tip; | ||
5673 | }; | ||
5674 | |||
5675 | _proto.setContent = function setContent() { | ||
5676 | var tip = this.getTipElement(); | ||
5677 | this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle()); | ||
5678 | $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW); | ||
5679 | }; | ||
5680 | |||
5681 | _proto.setElementContent = function setElementContent($element, content) { | ||
5682 | if (typeof content === 'object' && (content.nodeType || content.jquery)) { | ||
5683 | // Content is a DOM node or a jQuery | ||
5684 | if (this.config.html) { | ||
5685 | if (!$(content).parent().is($element)) { | ||
5686 | $element.empty().append(content); | ||
5687 | } | ||
5688 | } else { | ||
5689 | $element.text($(content).text()); | ||
5690 | } | ||
5691 | |||
5692 | return; | ||
5693 | } | ||
5694 | |||
5695 | if (this.config.html) { | ||
5696 | if (this.config.sanitize) { | ||
5697 | content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn); | ||
5698 | } | ||
5699 | |||
5700 | $element.html(content); | ||
5701 | } else { | ||
5702 | $element.text(content); | ||
5703 | } | ||
5704 | }; | ||
5705 | |||
5706 | _proto.getTitle = function getTitle() { | ||
5707 | var title = this.element.getAttribute('data-original-title'); | ||
5708 | |||
5709 | if (!title) { | ||
5710 | title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; | ||
5711 | } | ||
5712 | |||
5713 | return title; | ||
5714 | } // Private | ||
5715 | ; | ||
5716 | |||
5717 | _proto._getOffset = function _getOffset() { | ||
5718 | var _this3 = this; | ||
5719 | |||
5720 | var offset = {}; | ||
5721 | |||
5722 | if (typeof this.config.offset === 'function') { | ||
5723 | offset.fn = function (data) { | ||
5724 | data.offsets = _objectSpread({}, data.offsets, _this3.config.offset(data.offsets, _this3.element) || {}); | ||
5725 | return data; | ||
5726 | }; | ||
5727 | } else { | ||
5728 | offset.offset = this.config.offset; | ||
5729 | } | ||
5730 | |||
5731 | return offset; | ||
5732 | }; | ||
5733 | |||
5734 | _proto._getContainer = function _getContainer() { | ||
5735 | if (this.config.container === false) { | ||
5736 | return document.body; | ||
5737 | } | ||
5738 | |||
5739 | if (Util.isElement(this.config.container)) { | ||
5740 | return $(this.config.container); | ||
5741 | } | ||
5742 | |||
5743 | return $(document).find(this.config.container); | ||
5744 | }; | ||
5745 | |||
5746 | _proto._getAttachment = function _getAttachment(placement) { | ||
5747 | return AttachmentMap$1[placement.toUpperCase()]; | ||
5748 | }; | ||
5749 | |||
5750 | _proto._setListeners = function _setListeners() { | ||
5751 | var _this4 = this; | ||
5752 | |||
5753 | var triggers = this.config.trigger.split(' '); | ||
5754 | triggers.forEach(function (trigger) { | ||
5755 | if (trigger === 'click') { | ||
5756 | $(_this4.element).on(_this4.constructor.Event.CLICK, _this4.config.selector, function (event) { | ||
5757 | return _this4.toggle(event); | ||
5758 | }); | ||
5759 | } else if (trigger !== Trigger.MANUAL) { | ||
5760 | var eventIn = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSEENTER : _this4.constructor.Event.FOCUSIN; | ||
5761 | var eventOut = trigger === Trigger.HOVER ? _this4.constructor.Event.MOUSELEAVE : _this4.constructor.Event.FOCUSOUT; | ||
5762 | $(_this4.element).on(eventIn, _this4.config.selector, function (event) { | ||
5763 | return _this4._enter(event); | ||
5764 | }).on(eventOut, _this4.config.selector, function (event) { | ||
5765 | return _this4._leave(event); | ||
5766 | }); | ||
5767 | } | ||
5768 | }); | ||
5769 | $(this.element).closest('.modal').on('hide.bs.modal', function () { | ||
5770 | if (_this4.element) { | ||
5771 | _this4.hide(); | ||
5772 | } | ||
5773 | }); | ||
5774 | |||
5775 | if (this.config.selector) { | ||
5776 | this.config = _objectSpread({}, this.config, { | ||
5777 | trigger: 'manual', | ||
5778 | selector: '' | ||
5779 | }); | ||
5780 | } else { | ||
5781 | this._fixTitle(); | ||
5782 | } | ||
5783 | }; | ||
5784 | |||
5785 | _proto._fixTitle = function _fixTitle() { | ||
5786 | var titleType = typeof this.element.getAttribute('data-original-title'); | ||
5787 | |||
5788 | if (this.element.getAttribute('title') || titleType !== 'string') { | ||
5789 | this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); | ||
5790 | this.element.setAttribute('title', ''); | ||
5791 | } | ||
5792 | }; | ||
5793 | |||
5794 | _proto._enter = function _enter(event, context) { | ||
5795 | var dataKey = this.constructor.DATA_KEY; | ||
5796 | context = context || $(event.currentTarget).data(dataKey); | ||
5797 | |||
5798 | if (!context) { | ||
5799 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); | ||
5800 | $(event.currentTarget).data(dataKey, context); | ||
5801 | } | ||
5802 | |||
5803 | if (event) { | ||
5804 | context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true; | ||
5805 | } | ||
5806 | |||
5807 | if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) { | ||
5808 | context._hoverState = HoverState.SHOW; | ||
5809 | return; | ||
5810 | } | ||
5811 | |||
5812 | clearTimeout(context._timeout); | ||
5813 | context._hoverState = HoverState.SHOW; | ||
5814 | |||
5815 | if (!context.config.delay || !context.config.delay.show) { | ||
5816 | context.show(); | ||
5817 | return; | ||
5818 | } | ||
5819 | |||
5820 | context._timeout = setTimeout(function () { | ||
5821 | if (context._hoverState === HoverState.SHOW) { | ||
5822 | context.show(); | ||
5823 | } | ||
5824 | }, context.config.delay.show); | ||
5825 | }; | ||
5826 | |||
5827 | _proto._leave = function _leave(event, context) { | ||
5828 | var dataKey = this.constructor.DATA_KEY; | ||
5829 | context = context || $(event.currentTarget).data(dataKey); | ||
5830 | |||
5831 | if (!context) { | ||
5832 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); | ||
5833 | $(event.currentTarget).data(dataKey, context); | ||
5834 | } | ||
5835 | |||
5836 | if (event) { | ||
5837 | context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false; | ||
5838 | } | ||
5839 | |||
5840 | if (context._isWithActiveTrigger()) { | ||
5841 | return; | ||
5842 | } | ||
5843 | |||
5844 | clearTimeout(context._timeout); | ||
5845 | context._hoverState = HoverState.OUT; | ||
5846 | |||
5847 | if (!context.config.delay || !context.config.delay.hide) { | ||
5848 | context.hide(); | ||
5849 | return; | ||
5850 | } | ||
5851 | |||
5852 | context._timeout = setTimeout(function () { | ||
5853 | if (context._hoverState === HoverState.OUT) { | ||
5854 | context.hide(); | ||
5855 | } | ||
5856 | }, context.config.delay.hide); | ||
5857 | }; | ||
5858 | |||
5859 | _proto._isWithActiveTrigger = function _isWithActiveTrigger() { | ||
5860 | for (var trigger in this._activeTrigger) { | ||
5861 | if (this._activeTrigger[trigger]) { | ||
5862 | return true; | ||
5863 | } | ||
5864 | } | ||
5865 | |||
5866 | return false; | ||
5867 | }; | ||
5868 | |||
5869 | _proto._getConfig = function _getConfig(config) { | ||
5870 | var dataAttributes = $(this.element).data(); | ||
5871 | Object.keys(dataAttributes).forEach(function (dataAttr) { | ||
5872 | if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { | ||
5873 | delete dataAttributes[dataAttr]; | ||
5874 | } | ||
5875 | }); | ||
5876 | config = _objectSpread({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); | ||
5877 | |||
5878 | if (typeof config.delay === 'number') { | ||
5879 | config.delay = { | ||
5880 | show: config.delay, | ||
5881 | hide: config.delay | ||
5882 | }; | ||
5883 | } | ||
5884 | |||
5885 | if (typeof config.title === 'number') { | ||
5886 | config.title = config.title.toString(); | ||
5887 | } | ||
5888 | |||
5889 | if (typeof config.content === 'number') { | ||
5890 | config.content = config.content.toString(); | ||
5891 | } | ||
5892 | |||
5893 | Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType); | ||
5894 | |||
5895 | if (config.sanitize) { | ||
5896 | config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn); | ||
5897 | } | ||
5898 | |||
5899 | return config; | ||
5900 | }; | ||
5901 | |||
5902 | _proto._getDelegateConfig = function _getDelegateConfig() { | ||
5903 | var config = {}; | ||
5904 | |||
5905 | if (this.config) { | ||
5906 | for (var key in this.config) { | ||
5907 | if (this.constructor.Default[key] !== this.config[key]) { | ||
5908 | config[key] = this.config[key]; | ||
5909 | } | ||
5910 | } | ||
5911 | } | ||
5912 | |||
5913 | return config; | ||
5914 | }; | ||
5915 | |||
5916 | _proto._cleanTipClass = function _cleanTipClass() { | ||
5917 | var $tip = $(this.getTipElement()); | ||
5918 | var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); | ||
5919 | |||
5920 | if (tabClass !== null && tabClass.length) { | ||
5921 | $tip.removeClass(tabClass.join('')); | ||
5922 | } | ||
5923 | }; | ||
5924 | |||
5925 | _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { | ||
5926 | var popperInstance = popperData.instance; | ||
5927 | this.tip = popperInstance.popper; | ||
5928 | |||
5929 | this._cleanTipClass(); | ||
5930 | |||
5931 | this.addAttachmentClass(this._getAttachment(popperData.placement)); | ||
5932 | }; | ||
5933 | |||
5934 | _proto._fixTransition = function _fixTransition() { | ||
5935 | var tip = this.getTipElement(); | ||
5936 | var initConfigAnimation = this.config.animation; | ||
5937 | |||
5938 | if (tip.getAttribute('x-placement') !== null) { | ||
5939 | return; | ||
5940 | } | ||
5941 | |||
5942 | $(tip).removeClass(ClassName$6.FADE); | ||
5943 | this.config.animation = false; | ||
5944 | this.hide(); | ||
5945 | this.show(); | ||
5946 | this.config.animation = initConfigAnimation; | ||
5947 | } // Static | ||
5948 | ; | ||
5949 | |||
5950 | Tooltip._jQueryInterface = function _jQueryInterface(config) { | ||
5951 | return this.each(function () { | ||
5952 | var data = $(this).data(DATA_KEY$6); | ||
5953 | |||
5954 | var _config = typeof config === 'object' && config; | ||
5955 | |||
5956 | if (!data && /dispose|hide/.test(config)) { | ||
5957 | return; | ||
5958 | } | ||
5959 | |||
5960 | if (!data) { | ||
5961 | data = new Tooltip(this, _config); | ||
5962 | $(this).data(DATA_KEY$6, data); | ||
5963 | } | ||
5964 | |||
5965 | if (typeof config === 'string') { | ||
5966 | if (typeof data[config] === 'undefined') { | ||
5967 | throw new TypeError("No method named \"" + config + "\""); | ||
5968 | } | ||
5969 | |||
5970 | data[config](); | ||
5971 | } | ||
5972 | }); | ||
5973 | }; | ||
5974 | |||
5975 | _createClass(Tooltip, null, [{ | ||
5976 | key: "VERSION", | ||
5977 | get: function get() { | ||
5978 | return VERSION$6; | ||
5979 | } | ||
5980 | }, { | ||
5981 | key: "Default", | ||
5982 | get: function get() { | ||
5983 | return Default$4; | ||
5984 | } | ||
5985 | }, { | ||
5986 | key: "NAME", | ||
5987 | get: function get() { | ||
5988 | return NAME$6; | ||
5989 | } | ||
5990 | }, { | ||
5991 | key: "DATA_KEY", | ||
5992 | get: function get() { | ||
5993 | return DATA_KEY$6; | ||
5994 | } | ||
5995 | }, { | ||
5996 | key: "Event", | ||
5997 | get: function get() { | ||
5998 | return Event$6; | ||
5999 | } | ||
6000 | }, { | ||
6001 | key: "EVENT_KEY", | ||
6002 | get: function get() { | ||
6003 | return EVENT_KEY$6; | ||
6004 | } | ||
6005 | }, { | ||
6006 | key: "DefaultType", | ||
6007 | get: function get() { | ||
6008 | return DefaultType$4; | ||
6009 | } | ||
6010 | }]); | ||
6011 | |||
6012 | return Tooltip; | ||
6013 | }(); | ||
6014 | /** | ||
6015 | * ------------------------------------------------------------------------ | ||
6016 | * jQuery | ||
6017 | * ------------------------------------------------------------------------ | ||
6018 | */ | ||
6019 | |||
6020 | |||
6021 | $.fn[NAME$6] = Tooltip._jQueryInterface; | ||
6022 | $.fn[NAME$6].Constructor = Tooltip; | ||
6023 | |||
6024 | $.fn[NAME$6].noConflict = function () { | ||
6025 | $.fn[NAME$6] = JQUERY_NO_CONFLICT$6; | ||
6026 | return Tooltip._jQueryInterface; | ||
6027 | }; | ||
6028 | |||
6029 | /** | ||
6030 | * ------------------------------------------------------------------------ | ||
6031 | * Constants | ||
6032 | * ------------------------------------------------------------------------ | ||
6033 | */ | ||
6034 | |||
6035 | var NAME$7 = 'popover'; | ||
6036 | var VERSION$7 = '4.3.1'; | ||
6037 | var DATA_KEY$7 = 'bs.popover'; | ||
6038 | var EVENT_KEY$7 = "." + DATA_KEY$7; | ||
6039 | var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7]; | ||
6040 | var CLASS_PREFIX$1 = 'bs-popover'; | ||
6041 | var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g'); | ||
6042 | |||
6043 | var Default$5 = _objectSpread({}, Tooltip.Default, { | ||
6044 | placement: 'right', | ||
6045 | trigger: 'click', | ||
6046 | content: '', | ||
6047 | template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>' | ||
6048 | }); | ||
6049 | |||
6050 | var DefaultType$5 = _objectSpread({}, Tooltip.DefaultType, { | ||
6051 | content: '(string|element|function)' | ||
6052 | }); | ||
6053 | |||
6054 | var ClassName$7 = { | ||
6055 | FADE: 'fade', | ||
6056 | SHOW: 'show' | ||
6057 | }; | ||
6058 | var Selector$7 = { | ||
6059 | TITLE: '.popover-header', | ||
6060 | CONTENT: '.popover-body' | ||
6061 | }; | ||
6062 | var Event$7 = { | ||
6063 | HIDE: "hide" + EVENT_KEY$7, | ||
6064 | HIDDEN: "hidden" + EVENT_KEY$7, | ||
6065 | SHOW: "show" + EVENT_KEY$7, | ||
6066 | SHOWN: "shown" + EVENT_KEY$7, | ||
6067 | INSERTED: "inserted" + EVENT_KEY$7, | ||
6068 | CLICK: "click" + EVENT_KEY$7, | ||
6069 | FOCUSIN: "focusin" + EVENT_KEY$7, | ||
6070 | FOCUSOUT: "focusout" + EVENT_KEY$7, | ||
6071 | MOUSEENTER: "mouseenter" + EVENT_KEY$7, | ||
6072 | MOUSELEAVE: "mouseleave" + EVENT_KEY$7 | ||
6073 | /** | ||
6074 | * ------------------------------------------------------------------------ | ||
6075 | * Class Definition | ||
6076 | * ------------------------------------------------------------------------ | ||
6077 | */ | ||
6078 | |||
6079 | }; | ||
6080 | |||
6081 | var Popover = | ||
6082 | /*#__PURE__*/ | ||
6083 | function (_Tooltip) { | ||
6084 | _inheritsLoose(Popover, _Tooltip); | ||
6085 | |||
6086 | function Popover() { | ||
6087 | return _Tooltip.apply(this, arguments) || this; | ||
6088 | } | ||
6089 | |||
6090 | var _proto = Popover.prototype; | ||
6091 | |||
6092 | // Overrides | ||
6093 | _proto.isWithContent = function isWithContent() { | ||
6094 | return this.getTitle() || this._getContent(); | ||
6095 | }; | ||
6096 | |||
6097 | _proto.addAttachmentClass = function addAttachmentClass(attachment) { | ||
6098 | $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment); | ||
6099 | }; | ||
6100 | |||
6101 | _proto.getTipElement = function getTipElement() { | ||
6102 | this.tip = this.tip || $(this.config.template)[0]; | ||
6103 | return this.tip; | ||
6104 | }; | ||
6105 | |||
6106 | _proto.setContent = function setContent() { | ||
6107 | var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events | ||
6108 | |||
6109 | this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle()); | ||
6110 | |||
6111 | var content = this._getContent(); | ||
6112 | |||
6113 | if (typeof content === 'function') { | ||
6114 | content = content.call(this.element); | ||
6115 | } | ||
6116 | |||
6117 | this.setElementContent($tip.find(Selector$7.CONTENT), content); | ||
6118 | $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW); | ||
6119 | } // Private | ||
6120 | ; | ||
6121 | |||
6122 | _proto._getContent = function _getContent() { | ||
6123 | return this.element.getAttribute('data-content') || this.config.content; | ||
6124 | }; | ||
6125 | |||
6126 | _proto._cleanTipClass = function _cleanTipClass() { | ||
6127 | var $tip = $(this.getTipElement()); | ||
6128 | var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1); | ||
6129 | |||
6130 | if (tabClass !== null && tabClass.length > 0) { | ||
6131 | $tip.removeClass(tabClass.join('')); | ||
6132 | } | ||
6133 | } // Static | ||
6134 | ; | ||
6135 | |||
6136 | Popover._jQueryInterface = function _jQueryInterface(config) { | ||
6137 | return this.each(function () { | ||
6138 | var data = $(this).data(DATA_KEY$7); | ||
6139 | |||
6140 | var _config = typeof config === 'object' ? config : null; | ||
6141 | |||
6142 | if (!data && /dispose|hide/.test(config)) { | ||
6143 | return; | ||
6144 | } | ||
6145 | |||
6146 | if (!data) { | ||
6147 | data = new Popover(this, _config); | ||
6148 | $(this).data(DATA_KEY$7, data); | ||
6149 | } | ||
6150 | |||
6151 | if (typeof config === 'string') { | ||
6152 | if (typeof data[config] === 'undefined') { | ||
6153 | throw new TypeError("No method named \"" + config + "\""); | ||
6154 | } | ||
6155 | |||
6156 | data[config](); | ||
6157 | } | ||
6158 | }); | ||
6159 | }; | ||
6160 | |||
6161 | _createClass(Popover, null, [{ | ||
6162 | key: "VERSION", | ||
6163 | // Getters | ||
6164 | get: function get() { | ||
6165 | return VERSION$7; | ||
6166 | } | ||
6167 | }, { | ||
6168 | key: "Default", | ||
6169 | get: function get() { | ||
6170 | return Default$5; | ||
6171 | } | ||
6172 | }, { | ||
6173 | key: "NAME", | ||
6174 | get: function get() { | ||
6175 | return NAME$7; | ||
6176 | } | ||
6177 | }, { | ||
6178 | key: "DATA_KEY", | ||
6179 | get: function get() { | ||
6180 | return DATA_KEY$7; | ||
6181 | } | ||
6182 | }, { | ||
6183 | key: "Event", | ||
6184 | get: function get() { | ||
6185 | return Event$7; | ||
6186 | } | ||
6187 | }, { | ||
6188 | key: "EVENT_KEY", | ||
6189 | get: function get() { | ||
6190 | return EVENT_KEY$7; | ||
6191 | } | ||
6192 | }, { | ||
6193 | key: "DefaultType", | ||
6194 | get: function get() { | ||
6195 | return DefaultType$5; | ||
6196 | } | ||
6197 | }]); | ||
6198 | |||
6199 | return Popover; | ||
6200 | }(Tooltip); | ||
6201 | /** | ||
6202 | * ------------------------------------------------------------------------ | ||
6203 | * jQuery | ||
6204 | * ------------------------------------------------------------------------ | ||
6205 | */ | ||
6206 | |||
6207 | |||
6208 | $.fn[NAME$7] = Popover._jQueryInterface; | ||
6209 | $.fn[NAME$7].Constructor = Popover; | ||
6210 | |||
6211 | $.fn[NAME$7].noConflict = function () { | ||
6212 | $.fn[NAME$7] = JQUERY_NO_CONFLICT$7; | ||
6213 | return Popover._jQueryInterface; | ||
6214 | }; | ||
6215 | |||
6216 | /** | ||
6217 | * ------------------------------------------------------------------------ | ||
6218 | * Constants | ||
6219 | * ------------------------------------------------------------------------ | ||
6220 | */ | ||
6221 | |||
6222 | var NAME$8 = 'scrollspy'; | ||
6223 | var VERSION$8 = '4.3.1'; | ||
6224 | var DATA_KEY$8 = 'bs.scrollspy'; | ||
6225 | var EVENT_KEY$8 = "." + DATA_KEY$8; | ||
6226 | var DATA_API_KEY$6 = '.data-api'; | ||
6227 | var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8]; | ||
6228 | var Default$6 = { | ||
6229 | offset: 10, | ||
6230 | method: 'auto', | ||
6231 | target: '' | ||
6232 | }; | ||
6233 | var DefaultType$6 = { | ||
6234 | offset: 'number', | ||
6235 | method: 'string', | ||
6236 | target: '(string|element)' | ||
6237 | }; | ||
6238 | var Event$8 = { | ||
6239 | ACTIVATE: "activate" + EVENT_KEY$8, | ||
6240 | SCROLL: "scroll" + EVENT_KEY$8, | ||
6241 | LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6 | ||
6242 | }; | ||
6243 | var ClassName$8 = { | ||
6244 | DROPDOWN_ITEM: 'dropdown-item', | ||
6245 | DROPDOWN_MENU: 'dropdown-menu', | ||
6246 | ACTIVE: 'active' | ||
6247 | }; | ||
6248 | var Selector$8 = { | ||
6249 | DATA_SPY: '[data-spy="scroll"]', | ||
6250 | ACTIVE: '.active', | ||
6251 | NAV_LIST_GROUP: '.nav, .list-group', | ||
6252 | NAV_LINKS: '.nav-link', | ||
6253 | NAV_ITEMS: '.nav-item', | ||
6254 | LIST_ITEMS: '.list-group-item', | ||
6255 | DROPDOWN: '.dropdown', | ||
6256 | DROPDOWN_ITEMS: '.dropdown-item', | ||
6257 | DROPDOWN_TOGGLE: '.dropdown-toggle' | ||
6258 | }; | ||
6259 | var OffsetMethod = { | ||
6260 | OFFSET: 'offset', | ||
6261 | POSITION: 'position' | ||
6262 | /** | ||
6263 | * ------------------------------------------------------------------------ | ||
6264 | * Class Definition | ||
6265 | * ------------------------------------------------------------------------ | ||
6266 | */ | ||
6267 | |||
6268 | }; | ||
6269 | |||
6270 | var ScrollSpy = | ||
6271 | /*#__PURE__*/ | ||
6272 | function () { | ||
6273 | function ScrollSpy(element, config) { | ||
6274 | var _this = this; | ||
6275 | |||
6276 | this._element = element; | ||
6277 | this._scrollElement = element.tagName === 'BODY' ? window : element; | ||
6278 | this._config = this._getConfig(config); | ||
6279 | this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS); | ||
6280 | this._offsets = []; | ||
6281 | this._targets = []; | ||
6282 | this._activeTarget = null; | ||
6283 | this._scrollHeight = 0; | ||
6284 | $(this._scrollElement).on(Event$8.SCROLL, function (event) { | ||
6285 | return _this._process(event); | ||
6286 | }); | ||
6287 | this.refresh(); | ||
6288 | |||
6289 | this._process(); | ||
6290 | } // Getters | ||
6291 | |||
6292 | |||
6293 | var _proto = ScrollSpy.prototype; | ||
6294 | |||
6295 | // Public | ||
6296 | _proto.refresh = function refresh() { | ||
6297 | var _this2 = this; | ||
6298 | |||
6299 | var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION; | ||
6300 | var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; | ||
6301 | var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; | ||
6302 | this._offsets = []; | ||
6303 | this._targets = []; | ||
6304 | this._scrollHeight = this._getScrollHeight(); | ||
6305 | var targets = [].slice.call(document.querySelectorAll(this._selector)); | ||
6306 | targets.map(function (element) { | ||
6307 | var target; | ||
6308 | var targetSelector = Util.getSelectorFromElement(element); | ||
6309 | |||
6310 | if (targetSelector) { | ||
6311 | target = document.querySelector(targetSelector); | ||
6312 | } | ||
6313 | |||
6314 | if (target) { | ||
6315 | var targetBCR = target.getBoundingClientRect(); | ||
6316 | |||
6317 | if (targetBCR.width || targetBCR.height) { | ||
6318 | // TODO (fat): remove sketch reliance on jQuery position/offset | ||
6319 | return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; | ||
6320 | } | ||
6321 | } | ||
6322 | |||
6323 | return null; | ||
6324 | }).filter(function (item) { | ||
6325 | return item; | ||
6326 | }).sort(function (a, b) { | ||
6327 | return a[0] - b[0]; | ||
6328 | }).forEach(function (item) { | ||
6329 | _this2._offsets.push(item[0]); | ||
6330 | |||
6331 | _this2._targets.push(item[1]); | ||
6332 | }); | ||
6333 | }; | ||
6334 | |||
6335 | _proto.dispose = function dispose() { | ||
6336 | $.removeData(this._element, DATA_KEY$8); | ||
6337 | $(this._scrollElement).off(EVENT_KEY$8); | ||
6338 | this._element = null; | ||
6339 | this._scrollElement = null; | ||
6340 | this._config = null; | ||
6341 | this._selector = null; | ||
6342 | this._offsets = null; | ||
6343 | this._targets = null; | ||
6344 | this._activeTarget = null; | ||
6345 | this._scrollHeight = null; | ||
6346 | } // Private | ||
6347 | ; | ||
6348 | |||
6349 | _proto._getConfig = function _getConfig(config) { | ||
6350 | config = _objectSpread({}, Default$6, typeof config === 'object' && config ? config : {}); | ||
6351 | |||
6352 | if (typeof config.target !== 'string') { | ||
6353 | var id = $(config.target).attr('id'); | ||
6354 | |||
6355 | if (!id) { | ||
6356 | id = Util.getUID(NAME$8); | ||
6357 | $(config.target).attr('id', id); | ||
6358 | } | ||
6359 | |||
6360 | config.target = "#" + id; | ||
6361 | } | ||
6362 | |||
6363 | Util.typeCheckConfig(NAME$8, config, DefaultType$6); | ||
6364 | return config; | ||
6365 | }; | ||
6366 | |||
6367 | _proto._getScrollTop = function _getScrollTop() { | ||
6368 | return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; | ||
6369 | }; | ||
6370 | |||
6371 | _proto._getScrollHeight = function _getScrollHeight() { | ||
6372 | return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); | ||
6373 | }; | ||
6374 | |||
6375 | _proto._getOffsetHeight = function _getOffsetHeight() { | ||
6376 | return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; | ||
6377 | }; | ||
6378 | |||
6379 | _proto._process = function _process() { | ||
6380 | var scrollTop = this._getScrollTop() + this._config.offset; | ||
6381 | |||
6382 | var scrollHeight = this._getScrollHeight(); | ||
6383 | |||
6384 | var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); | ||
6385 | |||
6386 | if (this._scrollHeight !== scrollHeight) { | ||
6387 | this.refresh(); | ||
6388 | } | ||
6389 | |||
6390 | if (scrollTop >= maxScroll) { | ||
6391 | var target = this._targets[this._targets.length - 1]; | ||
6392 | |||
6393 | if (this._activeTarget !== target) { | ||
6394 | this._activate(target); | ||
6395 | } | ||
6396 | |||
6397 | return; | ||
6398 | } | ||
6399 | |||
6400 | if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { | ||
6401 | this._activeTarget = null; | ||
6402 | |||
6403 | this._clear(); | ||
6404 | |||
6405 | return; | ||
6406 | } | ||
6407 | |||
6408 | var offsetLength = this._offsets.length; | ||
6409 | |||
6410 | for (var i = offsetLength; i--;) { | ||
6411 | var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); | ||
6412 | |||
6413 | if (isActiveTarget) { | ||
6414 | this._activate(this._targets[i]); | ||
6415 | } | ||
6416 | } | ||
6417 | }; | ||
6418 | |||
6419 | _proto._activate = function _activate(target) { | ||
6420 | this._activeTarget = target; | ||
6421 | |||
6422 | this._clear(); | ||
6423 | |||
6424 | var queries = this._selector.split(',').map(function (selector) { | ||
6425 | return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; | ||
6426 | }); | ||
6427 | |||
6428 | var $link = $([].slice.call(document.querySelectorAll(queries.join(',')))); | ||
6429 | |||
6430 | if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) { | ||
6431 | $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE); | ||
6432 | $link.addClass(ClassName$8.ACTIVE); | ||
6433 | } else { | ||
6434 | // Set triggered link as active | ||
6435 | $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active | ||
6436 | // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor | ||
6437 | |||
6438 | $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_LINKS + ", " + Selector$8.LIST_ITEMS).addClass(ClassName$8.ACTIVE); // Handle special case when .nav-link is inside .nav-item | ||
6439 | |||
6440 | $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE); | ||
6441 | } | ||
6442 | |||
6443 | $(this._scrollElement).trigger(Event$8.ACTIVATE, { | ||
6444 | relatedTarget: target | ||
6445 | }); | ||
6446 | }; | ||
6447 | |||
6448 | _proto._clear = function _clear() { | ||
6449 | [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) { | ||
6450 | return node.classList.contains(ClassName$8.ACTIVE); | ||
6451 | }).forEach(function (node) { | ||
6452 | return node.classList.remove(ClassName$8.ACTIVE); | ||
6453 | }); | ||
6454 | } // Static | ||
6455 | ; | ||
6456 | |||
6457 | ScrollSpy._jQueryInterface = function _jQueryInterface(config) { | ||
6458 | return this.each(function () { | ||
6459 | var data = $(this).data(DATA_KEY$8); | ||
6460 | |||
6461 | var _config = typeof config === 'object' && config; | ||
6462 | |||
6463 | if (!data) { | ||
6464 | data = new ScrollSpy(this, _config); | ||
6465 | $(this).data(DATA_KEY$8, data); | ||
6466 | } | ||
6467 | |||
6468 | if (typeof config === 'string') { | ||
6469 | if (typeof data[config] === 'undefined') { | ||
6470 | throw new TypeError("No method named \"" + config + "\""); | ||
6471 | } | ||
6472 | |||
6473 | data[config](); | ||
6474 | } | ||
6475 | }); | ||
6476 | }; | ||
6477 | |||
6478 | _createClass(ScrollSpy, null, [{ | ||
6479 | key: "VERSION", | ||
6480 | get: function get() { | ||
6481 | return VERSION$8; | ||
6482 | } | ||
6483 | }, { | ||
6484 | key: "Default", | ||
6485 | get: function get() { | ||
6486 | return Default$6; | ||
6487 | } | ||
6488 | }]); | ||
6489 | |||
6490 | return ScrollSpy; | ||
6491 | }(); | ||
6492 | /** | ||
6493 | * ------------------------------------------------------------------------ | ||
6494 | * Data Api implementation | ||
6495 | * ------------------------------------------------------------------------ | ||
6496 | */ | ||
6497 | |||
6498 | |||
6499 | $(window).on(Event$8.LOAD_DATA_API, function () { | ||
6500 | var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY)); | ||
6501 | var scrollSpysLength = scrollSpys.length; | ||
6502 | |||
6503 | for (var i = scrollSpysLength; i--;) { | ||
6504 | var $spy = $(scrollSpys[i]); | ||
6505 | |||
6506 | ScrollSpy._jQueryInterface.call($spy, $spy.data()); | ||
6507 | } | ||
6508 | }); | ||
6509 | /** | ||
6510 | * ------------------------------------------------------------------------ | ||
6511 | * jQuery | ||
6512 | * ------------------------------------------------------------------------ | ||
6513 | */ | ||
6514 | |||
6515 | $.fn[NAME$8] = ScrollSpy._jQueryInterface; | ||
6516 | $.fn[NAME$8].Constructor = ScrollSpy; | ||
6517 | |||
6518 | $.fn[NAME$8].noConflict = function () { | ||
6519 | $.fn[NAME$8] = JQUERY_NO_CONFLICT$8; | ||
6520 | return ScrollSpy._jQueryInterface; | ||
6521 | }; | ||
6522 | |||
6523 | /** | ||
6524 | * ------------------------------------------------------------------------ | ||
6525 | * Constants | ||
6526 | * ------------------------------------------------------------------------ | ||
6527 | */ | ||
6528 | |||
6529 | var NAME$9 = 'tab'; | ||
6530 | var VERSION$9 = '4.3.1'; | ||
6531 | var DATA_KEY$9 = 'bs.tab'; | ||
6532 | var EVENT_KEY$9 = "." + DATA_KEY$9; | ||
6533 | var DATA_API_KEY$7 = '.data-api'; | ||
6534 | var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9]; | ||
6535 | var Event$9 = { | ||
6536 | HIDE: "hide" + EVENT_KEY$9, | ||
6537 | HIDDEN: "hidden" + EVENT_KEY$9, | ||
6538 | SHOW: "show" + EVENT_KEY$9, | ||
6539 | SHOWN: "shown" + EVENT_KEY$9, | ||
6540 | CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7 | ||
6541 | }; | ||
6542 | var ClassName$9 = { | ||
6543 | DROPDOWN_MENU: 'dropdown-menu', | ||
6544 | ACTIVE: 'active', | ||
6545 | DISABLED: 'disabled', | ||
6546 | FADE: 'fade', | ||
6547 | SHOW: 'show' | ||
6548 | }; | ||
6549 | var Selector$9 = { | ||
6550 | DROPDOWN: '.dropdown', | ||
6551 | NAV_LIST_GROUP: '.nav, .list-group', | ||
6552 | ACTIVE: '.active', | ||
6553 | ACTIVE_UL: '> li > .active', | ||
6554 | DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]', | ||
6555 | DROPDOWN_TOGGLE: '.dropdown-toggle', | ||
6556 | DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active' | ||
6557 | /** | ||
6558 | * ------------------------------------------------------------------------ | ||
6559 | * Class Definition | ||
6560 | * ------------------------------------------------------------------------ | ||
6561 | */ | ||
6562 | |||
6563 | }; | ||
6564 | |||
6565 | var Tab = | ||
6566 | /*#__PURE__*/ | ||
6567 | function () { | ||
6568 | function Tab(element) { | ||
6569 | this._element = element; | ||
6570 | } // Getters | ||
6571 | |||
6572 | |||
6573 | var _proto = Tab.prototype; | ||
6574 | |||
6575 | // Public | ||
6576 | _proto.show = function show() { | ||
6577 | var _this = this; | ||
6578 | |||
6579 | if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) { | ||
6580 | return; | ||
6581 | } | ||
6582 | |||
6583 | var target; | ||
6584 | var previous; | ||
6585 | var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0]; | ||
6586 | var selector = Util.getSelectorFromElement(this._element); | ||
6587 | |||
6588 | if (listElement) { | ||
6589 | var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE; | ||
6590 | previous = $.makeArray($(listElement).find(itemSelector)); | ||
6591 | previous = previous[previous.length - 1]; | ||
6592 | } | ||
6593 | |||
6594 | var hideEvent = $.Event(Event$9.HIDE, { | ||
6595 | relatedTarget: this._element | ||
6596 | }); | ||
6597 | var showEvent = $.Event(Event$9.SHOW, { | ||
6598 | relatedTarget: previous | ||
6599 | }); | ||
6600 | |||
6601 | if (previous) { | ||
6602 | $(previous).trigger(hideEvent); | ||
6603 | } | ||
6604 | |||
6605 | $(this._element).trigger(showEvent); | ||
6606 | |||
6607 | if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { | ||
6608 | return; | ||
6609 | } | ||
6610 | |||
6611 | if (selector) { | ||
6612 | target = document.querySelector(selector); | ||
6613 | } | ||
6614 | |||
6615 | this._activate(this._element, listElement); | ||
6616 | |||
6617 | var complete = function complete() { | ||
6618 | var hiddenEvent = $.Event(Event$9.HIDDEN, { | ||
6619 | relatedTarget: _this._element | ||
6620 | }); | ||
6621 | var shownEvent = $.Event(Event$9.SHOWN, { | ||
6622 | relatedTarget: previous | ||
6623 | }); | ||
6624 | $(previous).trigger(hiddenEvent); | ||
6625 | $(_this._element).trigger(shownEvent); | ||
6626 | }; | ||
6627 | |||
6628 | if (target) { | ||
6629 | this._activate(target, target.parentNode, complete); | ||
6630 | } else { | ||
6631 | complete(); | ||
6632 | } | ||
6633 | }; | ||
6634 | |||
6635 | _proto.dispose = function dispose() { | ||
6636 | $.removeData(this._element, DATA_KEY$9); | ||
6637 | this._element = null; | ||
6638 | } // Private | ||
6639 | ; | ||
6640 | |||
6641 | _proto._activate = function _activate(element, container, callback) { | ||
6642 | var _this2 = this; | ||
6643 | |||
6644 | var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE); | ||
6645 | var active = activeElements[0]; | ||
6646 | var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE); | ||
6647 | |||
6648 | var complete = function complete() { | ||
6649 | return _this2._transitionComplete(element, active, callback); | ||
6650 | }; | ||
6651 | |||
6652 | if (active && isTransitioning) { | ||
6653 | var transitionDuration = Util.getTransitionDurationFromElement(active); | ||
6654 | $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
6655 | } else { | ||
6656 | complete(); | ||
6657 | } | ||
6658 | }; | ||
6659 | |||
6660 | _proto._transitionComplete = function _transitionComplete(element, active, callback) { | ||
6661 | if (active) { | ||
6662 | $(active).removeClass(ClassName$9.ACTIVE); | ||
6663 | var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0]; | ||
6664 | |||
6665 | if (dropdownChild) { | ||
6666 | $(dropdownChild).removeClass(ClassName$9.ACTIVE); | ||
6667 | } | ||
6668 | |||
6669 | if (active.getAttribute('role') === 'tab') { | ||
6670 | active.setAttribute('aria-selected', false); | ||
6671 | } | ||
6672 | } | ||
6673 | |||
6674 | $(element).addClass(ClassName$9.ACTIVE); | ||
6675 | |||
6676 | if (element.getAttribute('role') === 'tab') { | ||
6677 | element.setAttribute('aria-selected', true); | ||
6678 | } | ||
6679 | |||
6680 | Util.reflow(element); | ||
6681 | |||
6682 | if (element.classList.contains(ClassName$9.FADE)) { | ||
6683 | element.classList.add(ClassName$9.SHOW); | ||
6684 | } | ||
6685 | |||
6686 | if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) { | ||
6687 | var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0]; | ||
6688 | |||
6689 | if (dropdownElement) { | ||
6690 | var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE)); | ||
6691 | $(dropdownToggleList).addClass(ClassName$9.ACTIVE); | ||
6692 | } | ||
6693 | |||
6694 | element.setAttribute('aria-expanded', true); | ||
6695 | } | ||
6696 | |||
6697 | if (callback) { | ||
6698 | callback(); | ||
6699 | } | ||
6700 | } // Static | ||
6701 | ; | ||
6702 | |||
6703 | Tab._jQueryInterface = function _jQueryInterface(config) { | ||
6704 | return this.each(function () { | ||
6705 | var $this = $(this); | ||
6706 | var data = $this.data(DATA_KEY$9); | ||
6707 | |||
6708 | if (!data) { | ||
6709 | data = new Tab(this); | ||
6710 | $this.data(DATA_KEY$9, data); | ||
6711 | } | ||
6712 | |||
6713 | if (typeof config === 'string') { | ||
6714 | if (typeof data[config] === 'undefined') { | ||
6715 | throw new TypeError("No method named \"" + config + "\""); | ||
6716 | } | ||
6717 | |||
6718 | data[config](); | ||
6719 | } | ||
6720 | }); | ||
6721 | }; | ||
6722 | |||
6723 | _createClass(Tab, null, [{ | ||
6724 | key: "VERSION", | ||
6725 | get: function get() { | ||
6726 | return VERSION$9; | ||
6727 | } | ||
6728 | }]); | ||
6729 | |||
6730 | return Tab; | ||
6731 | }(); | ||
6732 | /** | ||
6733 | * ------------------------------------------------------------------------ | ||
6734 | * Data Api implementation | ||
6735 | * ------------------------------------------------------------------------ | ||
6736 | */ | ||
6737 | |||
6738 | |||
6739 | $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) { | ||
6740 | event.preventDefault(); | ||
6741 | |||
6742 | Tab._jQueryInterface.call($(this), 'show'); | ||
6743 | }); | ||
6744 | /** | ||
6745 | * ------------------------------------------------------------------------ | ||
6746 | * jQuery | ||
6747 | * ------------------------------------------------------------------------ | ||
6748 | */ | ||
6749 | |||
6750 | $.fn[NAME$9] = Tab._jQueryInterface; | ||
6751 | $.fn[NAME$9].Constructor = Tab; | ||
6752 | |||
6753 | $.fn[NAME$9].noConflict = function () { | ||
6754 | $.fn[NAME$9] = JQUERY_NO_CONFLICT$9; | ||
6755 | return Tab._jQueryInterface; | ||
6756 | }; | ||
6757 | |||
6758 | /** | ||
6759 | * ------------------------------------------------------------------------ | ||
6760 | * Constants | ||
6761 | * ------------------------------------------------------------------------ | ||
6762 | */ | ||
6763 | |||
6764 | var NAME$a = 'toast'; | ||
6765 | var VERSION$a = '4.3.1'; | ||
6766 | var DATA_KEY$a = 'bs.toast'; | ||
6767 | var EVENT_KEY$a = "." + DATA_KEY$a; | ||
6768 | var JQUERY_NO_CONFLICT$a = $.fn[NAME$a]; | ||
6769 | var Event$a = { | ||
6770 | CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a, | ||
6771 | HIDE: "hide" + EVENT_KEY$a, | ||
6772 | HIDDEN: "hidden" + EVENT_KEY$a, | ||
6773 | SHOW: "show" + EVENT_KEY$a, | ||
6774 | SHOWN: "shown" + EVENT_KEY$a | ||
6775 | }; | ||
6776 | var ClassName$a = { | ||
6777 | FADE: 'fade', | ||
6778 | HIDE: 'hide', | ||
6779 | SHOW: 'show', | ||
6780 | SHOWING: 'showing' | ||
6781 | }; | ||
6782 | var DefaultType$7 = { | ||
6783 | animation: 'boolean', | ||
6784 | autohide: 'boolean', | ||
6785 | delay: 'number' | ||
6786 | }; | ||
6787 | var Default$7 = { | ||
6788 | animation: true, | ||
6789 | autohide: true, | ||
6790 | delay: 500 | ||
6791 | }; | ||
6792 | var Selector$a = { | ||
6793 | DATA_DISMISS: '[data-dismiss="toast"]' | ||
6794 | /** | ||
6795 | * ------------------------------------------------------------------------ | ||
6796 | * Class Definition | ||
6797 | * ------------------------------------------------------------------------ | ||
6798 | */ | ||
6799 | |||
6800 | }; | ||
6801 | |||
6802 | var Toast = | ||
6803 | /*#__PURE__*/ | ||
6804 | function () { | ||
6805 | function Toast(element, config) { | ||
6806 | this._element = element; | ||
6807 | this._config = this._getConfig(config); | ||
6808 | this._timeout = null; | ||
6809 | |||
6810 | this._setListeners(); | ||
6811 | } // Getters | ||
6812 | |||
6813 | |||
6814 | var _proto = Toast.prototype; | ||
6815 | |||
6816 | // Public | ||
6817 | _proto.show = function show() { | ||
6818 | var _this = this; | ||
6819 | |||
6820 | $(this._element).trigger(Event$a.SHOW); | ||
6821 | |||
6822 | if (this._config.animation) { | ||
6823 | this._element.classList.add(ClassName$a.FADE); | ||
6824 | } | ||
6825 | |||
6826 | var complete = function complete() { | ||
6827 | _this._element.classList.remove(ClassName$a.SHOWING); | ||
6828 | |||
6829 | _this._element.classList.add(ClassName$a.SHOW); | ||
6830 | |||
6831 | $(_this._element).trigger(Event$a.SHOWN); | ||
6832 | |||
6833 | if (_this._config.autohide) { | ||
6834 | _this.hide(); | ||
6835 | } | ||
6836 | }; | ||
6837 | |||
6838 | this._element.classList.remove(ClassName$a.HIDE); | ||
6839 | |||
6840 | this._element.classList.add(ClassName$a.SHOWING); | ||
6841 | |||
6842 | if (this._config.animation) { | ||
6843 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); | ||
6844 | $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
6845 | } else { | ||
6846 | complete(); | ||
6847 | } | ||
6848 | }; | ||
6849 | |||
6850 | _proto.hide = function hide(withoutTimeout) { | ||
6851 | var _this2 = this; | ||
6852 | |||
6853 | if (!this._element.classList.contains(ClassName$a.SHOW)) { | ||
6854 | return; | ||
6855 | } | ||
6856 | |||
6857 | $(this._element).trigger(Event$a.HIDE); | ||
6858 | |||
6859 | if (withoutTimeout) { | ||
6860 | this._close(); | ||
6861 | } else { | ||
6862 | this._timeout = setTimeout(function () { | ||
6863 | _this2._close(); | ||
6864 | }, this._config.delay); | ||
6865 | } | ||
6866 | }; | ||
6867 | |||
6868 | _proto.dispose = function dispose() { | ||
6869 | clearTimeout(this._timeout); | ||
6870 | this._timeout = null; | ||
6871 | |||
6872 | if (this._element.classList.contains(ClassName$a.SHOW)) { | ||
6873 | this._element.classList.remove(ClassName$a.SHOW); | ||
6874 | } | ||
6875 | |||
6876 | $(this._element).off(Event$a.CLICK_DISMISS); | ||
6877 | $.removeData(this._element, DATA_KEY$a); | ||
6878 | this._element = null; | ||
6879 | this._config = null; | ||
6880 | } // Private | ||
6881 | ; | ||
6882 | |||
6883 | _proto._getConfig = function _getConfig(config) { | ||
6884 | config = _objectSpread({}, Default$7, $(this._element).data(), typeof config === 'object' && config ? config : {}); | ||
6885 | Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType); | ||
6886 | return config; | ||
6887 | }; | ||
6888 | |||
6889 | _proto._setListeners = function _setListeners() { | ||
6890 | var _this3 = this; | ||
6891 | |||
6892 | $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () { | ||
6893 | return _this3.hide(true); | ||
6894 | }); | ||
6895 | }; | ||
6896 | |||
6897 | _proto._close = function _close() { | ||
6898 | var _this4 = this; | ||
6899 | |||
6900 | var complete = function complete() { | ||
6901 | _this4._element.classList.add(ClassName$a.HIDE); | ||
6902 | |||
6903 | $(_this4._element).trigger(Event$a.HIDDEN); | ||
6904 | }; | ||
6905 | |||
6906 | this._element.classList.remove(ClassName$a.SHOW); | ||
6907 | |||
6908 | if (this._config.animation) { | ||
6909 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); | ||
6910 | $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); | ||
6911 | } else { | ||
6912 | complete(); | ||
6913 | } | ||
6914 | } // Static | ||
6915 | ; | ||
6916 | |||
6917 | Toast._jQueryInterface = function _jQueryInterface(config) { | ||
6918 | return this.each(function () { | ||
6919 | var $element = $(this); | ||
6920 | var data = $element.data(DATA_KEY$a); | ||
6921 | |||
6922 | var _config = typeof config === 'object' && config; | ||
6923 | |||
6924 | if (!data) { | ||
6925 | data = new Toast(this, _config); | ||
6926 | $element.data(DATA_KEY$a, data); | ||
6927 | } | ||
6928 | |||
6929 | if (typeof config === 'string') { | ||
6930 | if (typeof data[config] === 'undefined') { | ||
6931 | throw new TypeError("No method named \"" + config + "\""); | ||
6932 | } | ||
6933 | |||
6934 | data[config](this); | ||
6935 | } | ||
6936 | }); | ||
6937 | }; | ||
6938 | |||
6939 | _createClass(Toast, null, [{ | ||
6940 | key: "VERSION", | ||
6941 | get: function get() { | ||
6942 | return VERSION$a; | ||
6943 | } | ||
6944 | }, { | ||
6945 | key: "DefaultType", | ||
6946 | get: function get() { | ||
6947 | return DefaultType$7; | ||
6948 | } | ||
6949 | }, { | ||
6950 | key: "Default", | ||
6951 | get: function get() { | ||
6952 | return Default$7; | ||
6953 | } | ||
6954 | }]); | ||
6955 | |||
6956 | return Toast; | ||
6957 | }(); | ||
6958 | /** | ||
6959 | * ------------------------------------------------------------------------ | ||
6960 | * jQuery | ||
6961 | * ------------------------------------------------------------------------ | ||
6962 | */ | ||
6963 | |||
6964 | |||
6965 | $.fn[NAME$a] = Toast._jQueryInterface; | ||
6966 | $.fn[NAME$a].Constructor = Toast; | ||
6967 | |||
6968 | $.fn[NAME$a].noConflict = function () { | ||
6969 | $.fn[NAME$a] = JQUERY_NO_CONFLICT$a; | ||
6970 | return Toast._jQueryInterface; | ||
6971 | }; | ||
6972 | |||
6973 | /** | ||
6974 | * -------------------------------------------------------------------------- | ||
6975 | * Bootstrap (v4.3.1): index.js | ||
6976 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) | ||
6977 | * -------------------------------------------------------------------------- | ||
6978 | */ | ||
6979 | |||
6980 | (function () { | ||
6981 | if (typeof $ === 'undefined') { | ||
6982 | throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.'); | ||
6983 | } | ||
6984 | |||
6985 | var version = $.fn.jquery.split(' ')[0].split('.'); | ||
6986 | var minMajor = 1; | ||
6987 | var ltMajor = 2; | ||
6988 | var minMinor = 9; | ||
6989 | var minPatch = 1; | ||
6990 | var maxMajor = 4; | ||
6991 | |||
6992 | if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) { | ||
6993 | throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0'); | ||
6994 | } | ||
6995 | })(); | ||
6996 | |||
6997 | exports.Util = Util; | ||
6998 | exports.Alert = Alert; | ||
6999 | exports.Button = Button; | ||
7000 | exports.Carousel = Carousel; | ||
7001 | exports.Collapse = Collapse; | ||
7002 | exports.Dropdown = Dropdown; | ||
7003 | exports.Modal = Modal; | ||
7004 | exports.Popover = Popover; | ||
7005 | exports.Scrollspy = ScrollSpy; | ||
7006 | exports.Tab = Tab; | ||
7007 | exports.Toast = Toast; | ||
7008 | exports.Tooltip = Tooltip; | ||
7009 | |||
7010 | Object.defineProperty(exports, '__esModule', { value: true }); | ||
7011 | |||
7012 | })); | ||
7013 | //# sourceMappingURL=bootstrap.bundle.js.map | ||