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