Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 760 | blopes | 1 | /*! |
| 2 | * Bootstrap v4.5.3 (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/main/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 = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bootstrap = {}, global.jQuery)); |
||
| 10 | }(this, (function (exports, $) { 'use strict'; |
||
| 11 | |||
| 12 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } |
||
| 13 | |||
| 14 | var $__default = /*#__PURE__*/_interopDefaultLegacy($); |
||
| 15 | |||
| 16 | function _defineProperties(target, props) { |
||
| 17 | for (var i = 0; i < props.length; i++) { |
||
| 18 | var descriptor = props[i]; |
||
| 19 | descriptor.enumerable = descriptor.enumerable || false; |
||
| 20 | descriptor.configurable = true; |
||
| 21 | if ("value" in descriptor) descriptor.writable = true; |
||
| 22 | Object.defineProperty(target, descriptor.key, descriptor); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | function _createClass(Constructor, protoProps, staticProps) { |
||
| 27 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
||
| 28 | if (staticProps) _defineProperties(Constructor, staticProps); |
||
| 29 | return Constructor; |
||
| 30 | } |
||
| 31 | |||
| 32 | function _extends() { |
||
| 33 | _extends = Object.assign || function (target) { |
||
| 34 | for (var i = 1; i < arguments.length; i++) { |
||
| 35 | var source = arguments[i]; |
||
| 36 | |||
| 37 | for (var key in source) { |
||
| 38 | if (Object.prototype.hasOwnProperty.call(source, key)) { |
||
| 39 | target[key] = source[key]; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return target; |
||
| 45 | }; |
||
| 46 | |||
| 47 | return _extends.apply(this, arguments); |
||
| 48 | } |
||
| 49 | |||
| 50 | function _inheritsLoose(subClass, superClass) { |
||
| 51 | subClass.prototype = Object.create(superClass.prototype); |
||
| 52 | subClass.prototype.constructor = subClass; |
||
| 53 | subClass.__proto__ = superClass; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * -------------------------------------------------------------------------- |
||
| 58 | * Bootstrap (v4.5.3): util.js |
||
| 59 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
||
| 60 | * -------------------------------------------------------------------------- |
||
| 61 | */ |
||
| 62 | /** |
||
| 63 | * ------------------------------------------------------------------------ |
||
| 64 | * Private TransitionEnd Helpers |
||
| 65 | * ------------------------------------------------------------------------ |
||
| 66 | */ |
||
| 67 | |||
| 68 | var TRANSITION_END = 'transitionend'; |
||
| 69 | var MAX_UID = 1000000; |
||
| 70 | var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp) |
||
| 71 | |||
| 72 | function toType(obj) { |
||
| 73 | if (obj === null || typeof obj === 'undefined') { |
||
| 74 | return "" + obj; |
||
| 75 | } |
||
| 76 | |||
| 77 | return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); |
||
| 78 | } |
||
| 79 | |||
| 80 | function getSpecialTransitionEndEvent() { |
||
| 81 | return { |
||
| 82 | bindType: TRANSITION_END, |
||
| 83 | delegateType: TRANSITION_END, |
||
| 84 | handle: function handle(event) { |
||
| 85 | if ($__default['default'](event.target).is(this)) { |
||
| 86 | return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params |
||
| 87 | } |
||
| 88 | |||
| 89 | return undefined; |
||
| 90 | } |
||
| 91 | }; |
||
| 92 | } |
||
| 93 | |||
| 94 | function transitionEndEmulator(duration) { |
||
| 95 | var _this = this; |
||
| 96 | |||
| 97 | var called = false; |
||
| 98 | $__default['default'](this).one(Util.TRANSITION_END, function () { |
||
| 99 | called = true; |
||
| 100 | }); |
||
| 101 | setTimeout(function () { |
||
| 102 | if (!called) { |
||
| 103 | Util.triggerTransitionEnd(_this); |
||
| 104 | } |
||
| 105 | }, duration); |
||
| 106 | return this; |
||
| 107 | } |
||
| 108 | |||
| 109 | function setTransitionEndSupport() { |
||
| 110 | $__default['default'].fn.emulateTransitionEnd = transitionEndEmulator; |
||
| 111 | $__default['default'].event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); |
||
| 112 | } |
||
| 113 | /** |
||
| 114 | * -------------------------------------------------------------------------- |
||
| 115 | * Public Util Api |
||
| 116 | * -------------------------------------------------------------------------- |
||
| 117 | */ |
||
| 118 | |||
| 119 | |||
| 120 | var Util = { |
||
| 121 | TRANSITION_END: 'bsTransitionEnd', |
||
| 122 | getUID: function getUID(prefix) { |
||
| 123 | do { |
||
| 124 | prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here |
||
| 125 | } while (document.getElementById(prefix)); |
||
| 126 | |||
| 127 | return prefix; |
||
| 128 | }, |
||
| 129 | getSelectorFromElement: function getSelectorFromElement(element) { |
||
| 130 | var selector = element.getAttribute('data-target'); |
||
| 131 | |||
| 132 | if (!selector || selector === '#') { |
||
| 133 | var hrefAttr = element.getAttribute('href'); |
||
| 134 | selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : ''; |
||
| 135 | } |
||
| 136 | |||
| 137 | try { |
||
| 138 | return document.querySelector(selector) ? selector : null; |
||
| 139 | } catch (_) { |
||
| 140 | return null; |
||
| 141 | } |
||
| 142 | }, |
||
| 143 | getTransitionDurationFromElement: function getTransitionDurationFromElement(element) { |
||
| 144 | if (!element) { |
||
| 145 | return 0; |
||
| 146 | } // Get transition-duration of the element |
||
| 147 | |||
| 148 | |||
| 149 | var transitionDuration = $__default['default'](element).css('transition-duration'); |
||
| 150 | var transitionDelay = $__default['default'](element).css('transition-delay'); |
||
| 151 | var floatTransitionDuration = parseFloat(transitionDuration); |
||
| 152 | var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found |
||
| 153 | |||
| 154 | if (!floatTransitionDuration && !floatTransitionDelay) { |
||
| 155 | return 0; |
||
| 156 | } // If multiple durations are defined, take the first |
||
| 157 | |||
| 158 | |||
| 159 | transitionDuration = transitionDuration.split(',')[0]; |
||
| 160 | transitionDelay = transitionDelay.split(',')[0]; |
||
| 161 | return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; |
||
| 162 | }, |
||
| 163 | reflow: function reflow(element) { |
||
| 164 | return element.offsetHeight; |
||
| 165 | }, |
||
| 166 | triggerTransitionEnd: function triggerTransitionEnd(element) { |
||
| 167 | $__default['default'](element).trigger(TRANSITION_END); |
||
| 168 | }, |
||
| 169 | supportsTransitionEnd: function supportsTransitionEnd() { |
||
| 170 | return Boolean(TRANSITION_END); |
||
| 171 | }, |
||
| 172 | isElement: function isElement(obj) { |
||
| 173 | return (obj[0] || obj).nodeType; |
||
| 174 | }, |
||
| 175 | typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { |
||
| 176 | for (var property in configTypes) { |
||
| 177 | if (Object.prototype.hasOwnProperty.call(configTypes, property)) { |
||
| 178 | var expectedTypes = configTypes[property]; |
||
| 179 | var value = config[property]; |
||
| 180 | var valueType = value && Util.isElement(value) ? 'element' : toType(value); |
||
| 181 | |||
| 182 | if (!new RegExp(expectedTypes).test(valueType)) { |
||
| 183 | throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\".")); |
||
| 184 | } |
||
| 185 | } |
||
| 186 | } |
||
| 187 | }, |
||
| 188 | findShadowRoot: function findShadowRoot(element) { |
||
| 189 | if (!document.documentElement.attachShadow) { |
||
| 190 | return null; |
||
| 191 | } // Can find the shadow root otherwise it'll return the document |
||
| 192 | |||
| 193 | |||
| 194 | if (typeof element.getRootNode === 'function') { |
||
| 195 | var root = element.getRootNode(); |
||
| 196 | return root instanceof ShadowRoot ? root : null; |
||
| 197 | } |
||
| 198 | |||
| 199 | if (element instanceof ShadowRoot) { |
||
| 200 | return element; |
||
| 201 | } // when we don't find a shadow root |
||
| 202 | |||
| 203 | |||
| 204 | if (!element.parentNode) { |
||
| 205 | return null; |
||
| 206 | } |
||
| 207 | |||
| 208 | return Util.findShadowRoot(element.parentNode); |
||
| 209 | }, |
||
| 210 | jQueryDetection: function jQueryDetection() { |
||
| 211 | if (typeof $__default['default'] === 'undefined') { |
||
| 212 | throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.'); |
||
| 213 | } |
||
| 214 | |||
| 215 | var version = $__default['default'].fn.jquery.split(' ')[0].split('.'); |
||
| 216 | var minMajor = 1; |
||
| 217 | var ltMajor = 2; |
||
| 218 | var minMinor = 9; |
||
| 219 | var minPatch = 1; |
||
| 220 | var maxMajor = 4; |
||
| 221 | |||
| 222 | if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) { |
||
| 223 | throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0'); |
||
| 224 | } |
||
| 225 | } |
||
| 226 | }; |
||
| 227 | Util.jQueryDetection(); |
||
| 228 | setTransitionEndSupport(); |
||
| 229 | |||
| 230 | /** |
||
| 231 | * ------------------------------------------------------------------------ |
||
| 232 | * Constants |
||
| 233 | * ------------------------------------------------------------------------ |
||
| 234 | */ |
||
| 235 | |||
| 236 | var NAME = 'alert'; |
||
| 237 | var VERSION = '4.5.3'; |
||
| 238 | var DATA_KEY = 'bs.alert'; |
||
| 239 | var EVENT_KEY = "." + DATA_KEY; |
||
| 240 | var DATA_API_KEY = '.data-api'; |
||
| 241 | var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME]; |
||
| 242 | var SELECTOR_DISMISS = '[data-dismiss="alert"]'; |
||
| 243 | var EVENT_CLOSE = "close" + EVENT_KEY; |
||
| 244 | var EVENT_CLOSED = "closed" + EVENT_KEY; |
||
| 245 | var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; |
||
| 246 | var CLASS_NAME_ALERT = 'alert'; |
||
| 247 | var CLASS_NAME_FADE = 'fade'; |
||
| 248 | var CLASS_NAME_SHOW = 'show'; |
||
| 249 | /** |
||
| 250 | * ------------------------------------------------------------------------ |
||
| 251 | * Class Definition |
||
| 252 | * ------------------------------------------------------------------------ |
||
| 253 | */ |
||
| 254 | |||
| 255 | var Alert = /*#__PURE__*/function () { |
||
| 256 | function Alert(element) { |
||
| 257 | this._element = element; |
||
| 258 | } // Getters |
||
| 259 | |||
| 260 | |||
| 261 | var _proto = Alert.prototype; |
||
| 262 | |||
| 263 | // Public |
||
| 264 | _proto.close = function close(element) { |
||
| 265 | var rootElement = this._element; |
||
| 266 | |||
| 267 | if (element) { |
||
| 268 | rootElement = this._getRootElement(element); |
||
| 269 | } |
||
| 270 | |||
| 271 | var customEvent = this._triggerCloseEvent(rootElement); |
||
| 272 | |||
| 273 | if (customEvent.isDefaultPrevented()) { |
||
| 274 | return; |
||
| 275 | } |
||
| 276 | |||
| 277 | this._removeElement(rootElement); |
||
| 278 | }; |
||
| 279 | |||
| 280 | _proto.dispose = function dispose() { |
||
| 281 | $__default['default'].removeData(this._element, DATA_KEY); |
||
| 282 | this._element = null; |
||
| 283 | } // Private |
||
| 284 | ; |
||
| 285 | |||
| 286 | _proto._getRootElement = function _getRootElement(element) { |
||
| 287 | var selector = Util.getSelectorFromElement(element); |
||
| 288 | var parent = false; |
||
| 289 | |||
| 290 | if (selector) { |
||
| 291 | parent = document.querySelector(selector); |
||
| 292 | } |
||
| 293 | |||
| 294 | if (!parent) { |
||
| 295 | parent = $__default['default'](element).closest("." + CLASS_NAME_ALERT)[0]; |
||
| 296 | } |
||
| 297 | |||
| 298 | return parent; |
||
| 299 | }; |
||
| 300 | |||
| 301 | _proto._triggerCloseEvent = function _triggerCloseEvent(element) { |
||
| 302 | var closeEvent = $__default['default'].Event(EVENT_CLOSE); |
||
| 303 | $__default['default'](element).trigger(closeEvent); |
||
| 304 | return closeEvent; |
||
| 305 | }; |
||
| 306 | |||
| 307 | _proto._removeElement = function _removeElement(element) { |
||
| 308 | var _this = this; |
||
| 309 | |||
| 310 | $__default['default'](element).removeClass(CLASS_NAME_SHOW); |
||
| 311 | |||
| 312 | if (!$__default['default'](element).hasClass(CLASS_NAME_FADE)) { |
||
| 313 | this._destroyElement(element); |
||
| 314 | |||
| 315 | return; |
||
| 316 | } |
||
| 317 | |||
| 318 | var transitionDuration = Util.getTransitionDurationFromElement(element); |
||
| 319 | $__default['default'](element).one(Util.TRANSITION_END, function (event) { |
||
| 320 | return _this._destroyElement(element, event); |
||
| 321 | }).emulateTransitionEnd(transitionDuration); |
||
| 322 | }; |
||
| 323 | |||
| 324 | _proto._destroyElement = function _destroyElement(element) { |
||
| 325 | $__default['default'](element).detach().trigger(EVENT_CLOSED).remove(); |
||
| 326 | } // Static |
||
| 327 | ; |
||
| 328 | |||
| 329 | Alert._jQueryInterface = function _jQueryInterface(config) { |
||
| 330 | return this.each(function () { |
||
| 331 | var $element = $__default['default'](this); |
||
| 332 | var data = $element.data(DATA_KEY); |
||
| 333 | |||
| 334 | if (!data) { |
||
| 335 | data = new Alert(this); |
||
| 336 | $element.data(DATA_KEY, data); |
||
| 337 | } |
||
| 338 | |||
| 339 | if (config === 'close') { |
||
| 340 | data[config](this); |
||
| 341 | } |
||
| 342 | }); |
||
| 343 | }; |
||
| 344 | |||
| 345 | Alert._handleDismiss = function _handleDismiss(alertInstance) { |
||
| 346 | return function (event) { |
||
| 347 | if (event) { |
||
| 348 | event.preventDefault(); |
||
| 349 | } |
||
| 350 | |||
| 351 | alertInstance.close(this); |
||
| 352 | }; |
||
| 353 | }; |
||
| 354 | |||
| 355 | _createClass(Alert, null, [{ |
||
| 356 | key: "VERSION", |
||
| 357 | get: function get() { |
||
| 358 | return VERSION; |
||
| 359 | } |
||
| 360 | }]); |
||
| 361 | |||
| 362 | return Alert; |
||
| 363 | }(); |
||
| 364 | /** |
||
| 365 | * ------------------------------------------------------------------------ |
||
| 366 | * Data Api implementation |
||
| 367 | * ------------------------------------------------------------------------ |
||
| 368 | */ |
||
| 369 | |||
| 370 | |||
| 371 | $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert._handleDismiss(new Alert())); |
||
| 372 | /** |
||
| 373 | * ------------------------------------------------------------------------ |
||
| 374 | * jQuery |
||
| 375 | * ------------------------------------------------------------------------ |
||
| 376 | */ |
||
| 377 | |||
| 378 | $__default['default'].fn[NAME] = Alert._jQueryInterface; |
||
| 379 | $__default['default'].fn[NAME].Constructor = Alert; |
||
| 380 | |||
| 381 | $__default['default'].fn[NAME].noConflict = function () { |
||
| 382 | $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT; |
||
| 383 | return Alert._jQueryInterface; |
||
| 384 | }; |
||
| 385 | |||
| 386 | /** |
||
| 387 | * ------------------------------------------------------------------------ |
||
| 388 | * Constants |
||
| 389 | * ------------------------------------------------------------------------ |
||
| 390 | */ |
||
| 391 | |||
| 392 | var NAME$1 = 'button'; |
||
| 393 | var VERSION$1 = '4.5.3'; |
||
| 394 | var DATA_KEY$1 = 'bs.button'; |
||
| 395 | var EVENT_KEY$1 = "." + DATA_KEY$1; |
||
| 396 | var DATA_API_KEY$1 = '.data-api'; |
||
| 397 | var JQUERY_NO_CONFLICT$1 = $__default['default'].fn[NAME$1]; |
||
| 398 | var CLASS_NAME_ACTIVE = 'active'; |
||
| 399 | var CLASS_NAME_BUTTON = 'btn'; |
||
| 400 | var CLASS_NAME_FOCUS = 'focus'; |
||
| 401 | var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]'; |
||
| 402 | var SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]'; |
||
| 403 | var SELECTOR_DATA_TOGGLE = '[data-toggle="button"]'; |
||
| 404 | var SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn'; |
||
| 405 | var SELECTOR_INPUT = 'input:not([type="hidden"])'; |
||
| 406 | var SELECTOR_ACTIVE = '.active'; |
||
| 407 | var SELECTOR_BUTTON = '.btn'; |
||
| 408 | var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1; |
||
| 409 | var EVENT_FOCUS_BLUR_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1); |
||
| 410 | var EVENT_LOAD_DATA_API = "load" + EVENT_KEY$1 + DATA_API_KEY$1; |
||
| 411 | /** |
||
| 412 | * ------------------------------------------------------------------------ |
||
| 413 | * Class Definition |
||
| 414 | * ------------------------------------------------------------------------ |
||
| 415 | */ |
||
| 416 | |||
| 417 | var Button = /*#__PURE__*/function () { |
||
| 418 | function Button(element) { |
||
| 419 | this._element = element; |
||
| 420 | this.shouldAvoidTriggerChange = false; |
||
| 421 | } // Getters |
||
| 422 | |||
| 423 | |||
| 424 | var _proto = Button.prototype; |
||
| 425 | |||
| 426 | // Public |
||
| 427 | _proto.toggle = function toggle() { |
||
| 428 | var triggerChangeEvent = true; |
||
| 429 | var addAriaPressed = true; |
||
| 430 | var rootElement = $__default['default'](this._element).closest(SELECTOR_DATA_TOGGLES)[0]; |
||
| 431 | |||
| 432 | if (rootElement) { |
||
| 433 | var input = this._element.querySelector(SELECTOR_INPUT); |
||
| 434 | |||
| 435 | if (input) { |
||
| 436 | if (input.type === 'radio') { |
||
| 437 | if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) { |
||
| 438 | triggerChangeEvent = false; |
||
| 439 | } else { |
||
| 440 | var activeElement = rootElement.querySelector(SELECTOR_ACTIVE); |
||
| 441 | |||
| 442 | if (activeElement) { |
||
| 443 | $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE); |
||
| 444 | } |
||
| 445 | } |
||
| 446 | } |
||
| 447 | |||
| 448 | if (triggerChangeEvent) { |
||
| 449 | // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input |
||
| 450 | if (input.type === 'checkbox' || input.type === 'radio') { |
||
| 451 | input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE); |
||
| 452 | } |
||
| 453 | |||
| 454 | if (!this.shouldAvoidTriggerChange) { |
||
| 455 | $__default['default'](input).trigger('change'); |
||
| 456 | } |
||
| 457 | } |
||
| 458 | |||
| 459 | input.focus(); |
||
| 460 | addAriaPressed = false; |
||
| 461 | } |
||
| 462 | } |
||
| 463 | |||
| 464 | if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) { |
||
| 465 | if (addAriaPressed) { |
||
| 466 | this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE)); |
||
| 467 | } |
||
| 468 | |||
| 469 | if (triggerChangeEvent) { |
||
| 470 | $__default['default'](this._element).toggleClass(CLASS_NAME_ACTIVE); |
||
| 471 | } |
||
| 472 | } |
||
| 473 | }; |
||
| 474 | |||
| 475 | _proto.dispose = function dispose() { |
||
| 476 | $__default['default'].removeData(this._element, DATA_KEY$1); |
||
| 477 | this._element = null; |
||
| 478 | } // Static |
||
| 479 | ; |
||
| 480 | |||
| 481 | Button._jQueryInterface = function _jQueryInterface(config, avoidTriggerChange) { |
||
| 482 | return this.each(function () { |
||
| 483 | var $element = $__default['default'](this); |
||
| 484 | var data = $element.data(DATA_KEY$1); |
||
| 485 | |||
| 486 | if (!data) { |
||
| 487 | data = new Button(this); |
||
| 488 | $element.data(DATA_KEY$1, data); |
||
| 489 | } |
||
| 490 | |||
| 491 | data.shouldAvoidTriggerChange = avoidTriggerChange; |
||
| 492 | |||
| 493 | if (config === 'toggle') { |
||
| 494 | data[config](); |
||
| 495 | } |
||
| 496 | }); |
||
| 497 | }; |
||
| 498 | |||
| 499 | _createClass(Button, null, [{ |
||
| 500 | key: "VERSION", |
||
| 501 | get: function get() { |
||
| 502 | return VERSION$1; |
||
| 503 | } |
||
| 504 | }]); |
||
| 505 | |||
| 506 | return Button; |
||
| 507 | }(); |
||
| 508 | /** |
||
| 509 | * ------------------------------------------------------------------------ |
||
| 510 | * Data Api implementation |
||
| 511 | * ------------------------------------------------------------------------ |
||
| 512 | */ |
||
| 513 | |||
| 514 | |||
| 515 | $__default['default'](document).on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, function (event) { |
||
| 516 | var button = event.target; |
||
| 517 | var initialButton = button; |
||
| 518 | |||
| 519 | if (!$__default['default'](button).hasClass(CLASS_NAME_BUTTON)) { |
||
| 520 | button = $__default['default'](button).closest(SELECTOR_BUTTON)[0]; |
||
| 521 | } |
||
| 522 | |||
| 523 | if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) { |
||
| 524 | event.preventDefault(); // work around Firefox bug #1540995 |
||
| 525 | } else { |
||
| 526 | var inputBtn = button.querySelector(SELECTOR_INPUT); |
||
| 527 | |||
| 528 | if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) { |
||
| 529 | event.preventDefault(); // work around Firefox bug #1540995 |
||
| 530 | |||
| 531 | return; |
||
| 532 | } |
||
| 533 | |||
| 534 | if (initialButton.tagName === 'INPUT' || button.tagName !== 'LABEL') { |
||
| 535 | Button._jQueryInterface.call($__default['default'](button), 'toggle', initialButton.tagName === 'INPUT'); |
||
| 536 | } |
||
| 537 | } |
||
| 538 | }).on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, function (event) { |
||
| 539 | var button = $__default['default'](event.target).closest(SELECTOR_BUTTON)[0]; |
||
| 540 | $__default['default'](button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type)); |
||
| 541 | }); |
||
| 542 | $__default['default'](window).on(EVENT_LOAD_DATA_API, function () { |
||
| 543 | // ensure correct active class is set to match the controls' actual values/states |
||
| 544 | // find all checkboxes/readio buttons inside data-toggle groups |
||
| 545 | var buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS)); |
||
| 546 | |||
| 547 | for (var i = 0, len = buttons.length; i < len; i++) { |
||
| 548 | var button = buttons[i]; |
||
| 549 | var input = button.querySelector(SELECTOR_INPUT); |
||
| 550 | |||
| 551 | if (input.checked || input.hasAttribute('checked')) { |
||
| 552 | button.classList.add(CLASS_NAME_ACTIVE); |
||
| 553 | } else { |
||
| 554 | button.classList.remove(CLASS_NAME_ACTIVE); |
||
| 555 | } |
||
| 556 | } // find all button toggles |
||
| 557 | |||
| 558 | |||
| 559 | buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE)); |
||
| 560 | |||
| 561 | for (var _i = 0, _len = buttons.length; _i < _len; _i++) { |
||
| 562 | var _button = buttons[_i]; |
||
| 563 | |||
| 564 | if (_button.getAttribute('aria-pressed') === 'true') { |
||
| 565 | _button.classList.add(CLASS_NAME_ACTIVE); |
||
| 566 | } else { |
||
| 567 | _button.classList.remove(CLASS_NAME_ACTIVE); |
||
| 568 | } |
||
| 569 | } |
||
| 570 | }); |
||
| 571 | /** |
||
| 572 | * ------------------------------------------------------------------------ |
||
| 573 | * jQuery |
||
| 574 | * ------------------------------------------------------------------------ |
||
| 575 | */ |
||
| 576 | |||
| 577 | $__default['default'].fn[NAME$1] = Button._jQueryInterface; |
||
| 578 | $__default['default'].fn[NAME$1].Constructor = Button; |
||
| 579 | |||
| 580 | $__default['default'].fn[NAME$1].noConflict = function () { |
||
| 581 | $__default['default'].fn[NAME$1] = JQUERY_NO_CONFLICT$1; |
||
| 582 | return Button._jQueryInterface; |
||
| 583 | }; |
||
| 584 | |||
| 585 | /** |
||
| 586 | * ------------------------------------------------------------------------ |
||
| 587 | * Constants |
||
| 588 | * ------------------------------------------------------------------------ |
||
| 589 | */ |
||
| 590 | |||
| 591 | var NAME$2 = 'carousel'; |
||
| 592 | var VERSION$2 = '4.5.3'; |
||
| 593 | var DATA_KEY$2 = 'bs.carousel'; |
||
| 594 | var EVENT_KEY$2 = "." + DATA_KEY$2; |
||
| 595 | var DATA_API_KEY$2 = '.data-api'; |
||
| 596 | var JQUERY_NO_CONFLICT$2 = $__default['default'].fn[NAME$2]; |
||
| 597 | var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key |
||
| 598 | |||
| 599 | var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key |
||
| 600 | |||
| 601 | var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch |
||
| 602 | |||
| 603 | var SWIPE_THRESHOLD = 40; |
||
| 604 | var Default = { |
||
| 605 | interval: 5000, |
||
| 606 | keyboard: true, |
||
| 607 | slide: false, |
||
| 608 | pause: 'hover', |
||
| 609 | wrap: true, |
||
| 610 | touch: true |
||
| 611 | }; |
||
| 612 | var DefaultType = { |
||
| 613 | interval: '(number|boolean)', |
||
| 614 | keyboard: 'boolean', |
||
| 615 | slide: '(boolean|string)', |
||
| 616 | pause: '(string|boolean)', |
||
| 617 | wrap: 'boolean', |
||
| 618 | touch: 'boolean' |
||
| 619 | }; |
||
| 620 | var DIRECTION_NEXT = 'next'; |
||
| 621 | var DIRECTION_PREV = 'prev'; |
||
| 622 | var DIRECTION_LEFT = 'left'; |
||
| 623 | var DIRECTION_RIGHT = 'right'; |
||
| 624 | var EVENT_SLIDE = "slide" + EVENT_KEY$2; |
||
| 625 | var EVENT_SLID = "slid" + EVENT_KEY$2; |
||
| 626 | var EVENT_KEYDOWN = "keydown" + EVENT_KEY$2; |
||
| 627 | var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY$2; |
||
| 628 | var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY$2; |
||
| 629 | var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY$2; |
||
| 630 | var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY$2; |
||
| 631 | var EVENT_TOUCHEND = "touchend" + EVENT_KEY$2; |
||
| 632 | var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY$2; |
||
| 633 | var EVENT_POINTERUP = "pointerup" + EVENT_KEY$2; |
||
| 634 | var EVENT_DRAG_START = "dragstart" + EVENT_KEY$2; |
||
| 635 | var EVENT_LOAD_DATA_API$1 = "load" + EVENT_KEY$2 + DATA_API_KEY$2; |
||
| 636 | var EVENT_CLICK_DATA_API$2 = "click" + EVENT_KEY$2 + DATA_API_KEY$2; |
||
| 637 | var CLASS_NAME_CAROUSEL = 'carousel'; |
||
| 638 | var CLASS_NAME_ACTIVE$1 = 'active'; |
||
| 639 | var CLASS_NAME_SLIDE = 'slide'; |
||
| 640 | var CLASS_NAME_RIGHT = 'carousel-item-right'; |
||
| 641 | var CLASS_NAME_LEFT = 'carousel-item-left'; |
||
| 642 | var CLASS_NAME_NEXT = 'carousel-item-next'; |
||
| 643 | var CLASS_NAME_PREV = 'carousel-item-prev'; |
||
| 644 | var CLASS_NAME_POINTER_EVENT = 'pointer-event'; |
||
| 645 | var SELECTOR_ACTIVE$1 = '.active'; |
||
| 646 | var SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; |
||
| 647 | var SELECTOR_ITEM = '.carousel-item'; |
||
| 648 | var SELECTOR_ITEM_IMG = '.carousel-item img'; |
||
| 649 | var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; |
||
| 650 | var SELECTOR_INDICATORS = '.carousel-indicators'; |
||
| 651 | var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]'; |
||
| 652 | var SELECTOR_DATA_RIDE = '[data-ride="carousel"]'; |
||
| 653 | var PointerType = { |
||
| 654 | TOUCH: 'touch', |
||
| 655 | PEN: 'pen' |
||
| 656 | }; |
||
| 657 | /** |
||
| 658 | * ------------------------------------------------------------------------ |
||
| 659 | * Class Definition |
||
| 660 | * ------------------------------------------------------------------------ |
||
| 661 | */ |
||
| 662 | |||
| 663 | var Carousel = /*#__PURE__*/function () { |
||
| 664 | function Carousel(element, config) { |
||
| 665 | this._items = null; |
||
| 666 | this._interval = null; |
||
| 667 | this._activeElement = null; |
||
| 668 | this._isPaused = false; |
||
| 669 | this._isSliding = false; |
||
| 670 | this.touchTimeout = null; |
||
| 671 | this.touchStartX = 0; |
||
| 672 | this.touchDeltaX = 0; |
||
| 673 | this._config = this._getConfig(config); |
||
| 674 | this._element = element; |
||
| 675 | this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS); |
||
| 676 | this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; |
||
| 677 | this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent); |
||
| 678 | |||
| 679 | this._addEventListeners(); |
||
| 680 | } // Getters |
||
| 681 | |||
| 682 | |||
| 683 | var _proto = Carousel.prototype; |
||
| 684 | |||
| 685 | // Public |
||
| 686 | _proto.next = function next() { |
||
| 687 | if (!this._isSliding) { |
||
| 688 | this._slide(DIRECTION_NEXT); |
||
| 689 | } |
||
| 690 | }; |
||
| 691 | |||
| 692 | _proto.nextWhenVisible = function nextWhenVisible() { |
||
| 693 | var $element = $__default['default'](this._element); // Don't call next when the page isn't visible |
||
| 694 | // or the carousel or its parent isn't visible |
||
| 695 | |||
| 696 | if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') { |
||
| 697 | this.next(); |
||
| 698 | } |
||
| 699 | }; |
||
| 700 | |||
| 701 | _proto.prev = function prev() { |
||
| 702 | if (!this._isSliding) { |
||
| 703 | this._slide(DIRECTION_PREV); |
||
| 704 | } |
||
| 705 | }; |
||
| 706 | |||
| 707 | _proto.pause = function pause(event) { |
||
| 708 | if (!event) { |
||
| 709 | this._isPaused = true; |
||
| 710 | } |
||
| 711 | |||
| 712 | if (this._element.querySelector(SELECTOR_NEXT_PREV)) { |
||
| 713 | Util.triggerTransitionEnd(this._element); |
||
| 714 | this.cycle(true); |
||
| 715 | } |
||
| 716 | |||
| 717 | clearInterval(this._interval); |
||
| 718 | this._interval = null; |
||
| 719 | }; |
||
| 720 | |||
| 721 | _proto.cycle = function cycle(event) { |
||
| 722 | if (!event) { |
||
| 723 | this._isPaused = false; |
||
| 724 | } |
||
| 725 | |||
| 726 | if (this._interval) { |
||
| 727 | clearInterval(this._interval); |
||
| 728 | this._interval = null; |
||
| 729 | } |
||
| 730 | |||
| 731 | if (this._config.interval && !this._isPaused) { |
||
| 732 | this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); |
||
| 733 | } |
||
| 734 | }; |
||
| 735 | |||
| 736 | _proto.to = function to(index) { |
||
| 737 | var _this = this; |
||
| 738 | |||
| 739 | this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM); |
||
| 740 | |||
| 741 | var activeIndex = this._getItemIndex(this._activeElement); |
||
| 742 | |||
| 743 | if (index > this._items.length - 1 || index < 0) { |
||
| 744 | return; |
||
| 745 | } |
||
| 746 | |||
| 747 | if (this._isSliding) { |
||
| 748 | $__default['default'](this._element).one(EVENT_SLID, function () { |
||
| 749 | return _this.to(index); |
||
| 750 | }); |
||
| 751 | return; |
||
| 752 | } |
||
| 753 | |||
| 754 | if (activeIndex === index) { |
||
| 755 | this.pause(); |
||
| 756 | this.cycle(); |
||
| 757 | return; |
||
| 758 | } |
||
| 759 | |||
| 760 | var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV; |
||
| 761 | |||
| 762 | this._slide(direction, this._items[index]); |
||
| 763 | }; |
||
| 764 | |||
| 765 | _proto.dispose = function dispose() { |
||
| 766 | $__default['default'](this._element).off(EVENT_KEY$2); |
||
| 767 | $__default['default'].removeData(this._element, DATA_KEY$2); |
||
| 768 | this._items = null; |
||
| 769 | this._config = null; |
||
| 770 | this._element = null; |
||
| 771 | this._interval = null; |
||
| 772 | this._isPaused = null; |
||
| 773 | this._isSliding = null; |
||
| 774 | this._activeElement = null; |
||
| 775 | this._indicatorsElement = null; |
||
| 776 | } // Private |
||
| 777 | ; |
||
| 778 | |||
| 779 | _proto._getConfig = function _getConfig(config) { |
||
| 780 | config = _extends({}, Default, config); |
||
| 781 | Util.typeCheckConfig(NAME$2, config, DefaultType); |
||
| 782 | return config; |
||
| 783 | }; |
||
| 784 | |||
| 785 | _proto._handleSwipe = function _handleSwipe() { |
||
| 786 | var absDeltax = Math.abs(this.touchDeltaX); |
||
| 787 | |||
| 788 | if (absDeltax <= SWIPE_THRESHOLD) { |
||
| 789 | return; |
||
| 790 | } |
||
| 791 | |||
| 792 | var direction = absDeltax / this.touchDeltaX; |
||
| 793 | this.touchDeltaX = 0; // swipe left |
||
| 794 | |||
| 795 | if (direction > 0) { |
||
| 796 | this.prev(); |
||
| 797 | } // swipe right |
||
| 798 | |||
| 799 | |||
| 800 | if (direction < 0) { |
||
| 801 | this.next(); |
||
| 802 | } |
||
| 803 | }; |
||
| 804 | |||
| 805 | _proto._addEventListeners = function _addEventListeners() { |
||
| 806 | var _this2 = this; |
||
| 807 | |||
| 808 | if (this._config.keyboard) { |
||
| 809 | $__default['default'](this._element).on(EVENT_KEYDOWN, function (event) { |
||
| 810 | return _this2._keydown(event); |
||
| 811 | }); |
||
| 812 | } |
||
| 813 | |||
| 814 | if (this._config.pause === 'hover') { |
||
| 815 | $__default['default'](this._element).on(EVENT_MOUSEENTER, function (event) { |
||
| 816 | return _this2.pause(event); |
||
| 817 | }).on(EVENT_MOUSELEAVE, function (event) { |
||
| 818 | return _this2.cycle(event); |
||
| 819 | }); |
||
| 820 | } |
||
| 821 | |||
| 822 | if (this._config.touch) { |
||
| 823 | this._addTouchEventListeners(); |
||
| 824 | } |
||
| 825 | }; |
||
| 826 | |||
| 827 | _proto._addTouchEventListeners = function _addTouchEventListeners() { |
||
| 828 | var _this3 = this; |
||
| 829 | |||
| 830 | if (!this._touchSupported) { |
||
| 831 | return; |
||
| 832 | } |
||
| 833 | |||
| 834 | var start = function start(event) { |
||
| 835 | if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { |
||
| 836 | _this3.touchStartX = event.originalEvent.clientX; |
||
| 837 | } else if (!_this3._pointerEvent) { |
||
| 838 | _this3.touchStartX = event.originalEvent.touches[0].clientX; |
||
| 839 | } |
||
| 840 | }; |
||
| 841 | |||
| 842 | var move = function move(event) { |
||
| 843 | // ensure swiping with one touch and not pinching |
||
| 844 | if (event.originalEvent.touches && event.originalEvent.touches.length > 1) { |
||
| 845 | _this3.touchDeltaX = 0; |
||
| 846 | } else { |
||
| 847 | _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX; |
||
| 848 | } |
||
| 849 | }; |
||
| 850 | |||
| 851 | var end = function end(event) { |
||
| 852 | if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) { |
||
| 853 | _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX; |
||
| 854 | } |
||
| 855 | |||
| 856 | _this3._handleSwipe(); |
||
| 857 | |||
| 858 | if (_this3._config.pause === 'hover') { |
||
| 859 | // If it's a touch-enabled device, mouseenter/leave are fired as |
||
| 860 | // part of the mouse compatibility events on first tap - the carousel |
||
| 861 | // would stop cycling until user tapped out of it; |
||
| 862 | // here, we listen for touchend, explicitly pause the carousel |
||
| 863 | // (as if it's the second time we tap on it, mouseenter compat event |
||
| 864 | // is NOT fired) and after a timeout (to allow for mouse compatibility |
||
| 865 | // events to fire) we explicitly restart cycling |
||
| 866 | _this3.pause(); |
||
| 867 | |||
| 868 | if (_this3.touchTimeout) { |
||
| 869 | clearTimeout(_this3.touchTimeout); |
||
| 870 | } |
||
| 871 | |||
| 872 | _this3.touchTimeout = setTimeout(function (event) { |
||
| 873 | return _this3.cycle(event); |
||
| 874 | }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval); |
||
| 875 | } |
||
| 876 | }; |
||
| 877 | |||
| 878 | $__default['default'](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) { |
||
| 879 | return e.preventDefault(); |
||
| 880 | }); |
||
| 881 | |||
| 882 | if (this._pointerEvent) { |
||
| 883 | $__default['default'](this._element).on(EVENT_POINTERDOWN, function (event) { |
||
| 884 | return start(event); |
||
| 885 | }); |
||
| 886 | $__default['default'](this._element).on(EVENT_POINTERUP, function (event) { |
||
| 887 | return end(event); |
||
| 888 | }); |
||
| 889 | |||
| 890 | this._element.classList.add(CLASS_NAME_POINTER_EVENT); |
||
| 891 | } else { |
||
| 892 | $__default['default'](this._element).on(EVENT_TOUCHSTART, function (event) { |
||
| 893 | return start(event); |
||
| 894 | }); |
||
| 895 | $__default['default'](this._element).on(EVENT_TOUCHMOVE, function (event) { |
||
| 896 | return move(event); |
||
| 897 | }); |
||
| 898 | $__default['default'](this._element).on(EVENT_TOUCHEND, function (event) { |
||
| 899 | return end(event); |
||
| 900 | }); |
||
| 901 | } |
||
| 902 | }; |
||
| 903 | |||
| 904 | _proto._keydown = function _keydown(event) { |
||
| 905 | if (/input|textarea/i.test(event.target.tagName)) { |
||
| 906 | return; |
||
| 907 | } |
||
| 908 | |||
| 909 | switch (event.which) { |
||
| 910 | case ARROW_LEFT_KEYCODE: |
||
| 911 | event.preventDefault(); |
||
| 912 | this.prev(); |
||
| 913 | break; |
||
| 914 | |||
| 915 | case ARROW_RIGHT_KEYCODE: |
||
| 916 | event.preventDefault(); |
||
| 917 | this.next(); |
||
| 918 | break; |
||
| 919 | } |
||
| 920 | }; |
||
| 921 | |||
| 922 | _proto._getItemIndex = function _getItemIndex(element) { |
||
| 923 | this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : []; |
||
| 924 | return this._items.indexOf(element); |
||
| 925 | }; |
||
| 926 | |||
| 927 | _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) { |
||
| 928 | var isNextDirection = direction === DIRECTION_NEXT; |
||
| 929 | var isPrevDirection = direction === DIRECTION_PREV; |
||
| 930 | |||
| 931 | var activeIndex = this._getItemIndex(activeElement); |
||
| 932 | |||
| 933 | var lastItemIndex = this._items.length - 1; |
||
| 934 | var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; |
||
| 935 | |||
| 936 | if (isGoingToWrap && !this._config.wrap) { |
||
| 937 | return activeElement; |
||
| 938 | } |
||
| 939 | |||
| 940 | var delta = direction === DIRECTION_PREV ? -1 : 1; |
||
| 941 | var itemIndex = (activeIndex + delta) % this._items.length; |
||
| 942 | return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; |
||
| 943 | }; |
||
| 944 | |||
| 945 | _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { |
||
| 946 | var targetIndex = this._getItemIndex(relatedTarget); |
||
| 947 | |||
| 948 | var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM)); |
||
| 949 | |||
| 950 | var slideEvent = $__default['default'].Event(EVENT_SLIDE, { |
||
| 951 | relatedTarget: relatedTarget, |
||
| 952 | direction: eventDirectionName, |
||
| 953 | from: fromIndex, |
||
| 954 | to: targetIndex |
||
| 955 | }); |
||
| 956 | $__default['default'](this._element).trigger(slideEvent); |
||
| 957 | return slideEvent; |
||
| 958 | }; |
||
| 959 | |||
| 960 | _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { |
||
| 961 | if (this._indicatorsElement) { |
||
| 962 | var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE$1)); |
||
| 963 | $__default['default'](indicators).removeClass(CLASS_NAME_ACTIVE$1); |
||
| 964 | |||
| 965 | var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; |
||
| 966 | |||
| 967 | if (nextIndicator) { |
||
| 968 | $__default['default'](nextIndicator).addClass(CLASS_NAME_ACTIVE$1); |
||
| 969 | } |
||
| 970 | } |
||
| 971 | }; |
||
| 972 | |||
| 973 | _proto._slide = function _slide(direction, element) { |
||
| 974 | var _this4 = this; |
||
| 975 | |||
| 976 | var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM); |
||
| 977 | |||
| 978 | var activeElementIndex = this._getItemIndex(activeElement); |
||
| 979 | |||
| 980 | var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); |
||
| 981 | |||
| 982 | var nextElementIndex = this._getItemIndex(nextElement); |
||
| 983 | |||
| 984 | var isCycling = Boolean(this._interval); |
||
| 985 | var directionalClassName; |
||
| 986 | var orderClassName; |
||
| 987 | var eventDirectionName; |
||
| 988 | |||
| 989 | if (direction === DIRECTION_NEXT) { |
||
| 990 | directionalClassName = CLASS_NAME_LEFT; |
||
| 991 | orderClassName = CLASS_NAME_NEXT; |
||
| 992 | eventDirectionName = DIRECTION_LEFT; |
||
| 993 | } else { |
||
| 994 | directionalClassName = CLASS_NAME_RIGHT; |
||
| 995 | orderClassName = CLASS_NAME_PREV; |
||
| 996 | eventDirectionName = DIRECTION_RIGHT; |
||
| 997 | } |
||
| 998 | |||
| 999 | if (nextElement && $__default['default'](nextElement).hasClass(CLASS_NAME_ACTIVE$1)) { |
||
| 1000 | this._isSliding = false; |
||
| 1001 | return; |
||
| 1002 | } |
||
| 1003 | |||
| 1004 | var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); |
||
| 1005 | |||
| 1006 | if (slideEvent.isDefaultPrevented()) { |
||
| 1007 | return; |
||
| 1008 | } |
||
| 1009 | |||
| 1010 | if (!activeElement || !nextElement) { |
||
| 1011 | // Some weirdness is happening, so we bail |
||
| 1012 | return; |
||
| 1013 | } |
||
| 1014 | |||
| 1015 | this._isSliding = true; |
||
| 1016 | |||
| 1017 | if (isCycling) { |
||
| 1018 | this.pause(); |
||
| 1019 | } |
||
| 1020 | |||
| 1021 | this._setActiveIndicatorElement(nextElement); |
||
| 1022 | |||
| 1023 | var slidEvent = $__default['default'].Event(EVENT_SLID, { |
||
| 1024 | relatedTarget: nextElement, |
||
| 1025 | direction: eventDirectionName, |
||
| 1026 | from: activeElementIndex, |
||
| 1027 | to: nextElementIndex |
||
| 1028 | }); |
||
| 1029 | |||
| 1030 | if ($__default['default'](this._element).hasClass(CLASS_NAME_SLIDE)) { |
||
| 1031 | $__default['default'](nextElement).addClass(orderClassName); |
||
| 1032 | Util.reflow(nextElement); |
||
| 1033 | $__default['default'](activeElement).addClass(directionalClassName); |
||
| 1034 | $__default['default'](nextElement).addClass(directionalClassName); |
||
| 1035 | var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10); |
||
| 1036 | |||
| 1037 | if (nextElementInterval) { |
||
| 1038 | this._config.defaultInterval = this._config.defaultInterval || this._config.interval; |
||
| 1039 | this._config.interval = nextElementInterval; |
||
| 1040 | } else { |
||
| 1041 | this._config.interval = this._config.defaultInterval || this._config.interval; |
||
| 1042 | } |
||
| 1043 | |||
| 1044 | var transitionDuration = Util.getTransitionDurationFromElement(activeElement); |
||
| 1045 | $__default['default'](activeElement).one(Util.TRANSITION_END, function () { |
||
| 1046 | $__default['default'](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE$1); |
||
| 1047 | $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1 + " " + orderClassName + " " + directionalClassName); |
||
| 1048 | _this4._isSliding = false; |
||
| 1049 | setTimeout(function () { |
||
| 1050 | return $__default['default'](_this4._element).trigger(slidEvent); |
||
| 1051 | }, 0); |
||
| 1052 | }).emulateTransitionEnd(transitionDuration); |
||
| 1053 | } else { |
||
| 1054 | $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE$1); |
||
| 1055 | $__default['default'](nextElement).addClass(CLASS_NAME_ACTIVE$1); |
||
| 1056 | this._isSliding = false; |
||
| 1057 | $__default['default'](this._element).trigger(slidEvent); |
||
| 1058 | } |
||
| 1059 | |||
| 1060 | if (isCycling) { |
||
| 1061 | this.cycle(); |
||
| 1062 | } |
||
| 1063 | } // Static |
||
| 1064 | ; |
||
| 1065 | |||
| 1066 | Carousel._jQueryInterface = function _jQueryInterface(config) { |
||
| 1067 | return this.each(function () { |
||
| 1068 | var data = $__default['default'](this).data(DATA_KEY$2); |
||
| 1069 | |||
| 1070 | var _config = _extends({}, Default, $__default['default'](this).data()); |
||
| 1071 | |||
| 1072 | if (typeof config === 'object') { |
||
| 1073 | _config = _extends({}, _config, config); |
||
| 1074 | } |
||
| 1075 | |||
| 1076 | var action = typeof config === 'string' ? config : _config.slide; |
||
| 1077 | |||
| 1078 | if (!data) { |
||
| 1079 | data = new Carousel(this, _config); |
||
| 1080 | $__default['default'](this).data(DATA_KEY$2, data); |
||
| 1081 | } |
||
| 1082 | |||
| 1083 | if (typeof config === 'number') { |
||
| 1084 | data.to(config); |
||
| 1085 | } else if (typeof action === 'string') { |
||
| 1086 | if (typeof data[action] === 'undefined') { |
||
| 1087 | throw new TypeError("No method named \"" + action + "\""); |
||
| 1088 | } |
||
| 1089 | |||
| 1090 | data[action](); |
||
| 1091 | } else if (_config.interval && _config.ride) { |
||
| 1092 | data.pause(); |
||
| 1093 | data.cycle(); |
||
| 1094 | } |
||
| 1095 | }); |
||
| 1096 | }; |
||
| 1097 | |||
| 1098 | Carousel._dataApiClickHandler = function _dataApiClickHandler(event) { |
||
| 1099 | var selector = Util.getSelectorFromElement(this); |
||
| 1100 | |||
| 1101 | if (!selector) { |
||
| 1102 | return; |
||
| 1103 | } |
||
| 1104 | |||
| 1105 | var target = $__default['default'](selector)[0]; |
||
| 1106 | |||
| 1107 | if (!target || !$__default['default'](target).hasClass(CLASS_NAME_CAROUSEL)) { |
||
| 1108 | return; |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | var config = _extends({}, $__default['default'](target).data(), $__default['default'](this).data()); |
||
| 1112 | |||
| 1113 | var slideIndex = this.getAttribute('data-slide-to'); |
||
| 1114 | |||
| 1115 | if (slideIndex) { |
||
| 1116 | config.interval = false; |
||
| 1117 | } |
||
| 1118 | |||
| 1119 | Carousel._jQueryInterface.call($__default['default'](target), config); |
||
| 1120 | |||
| 1121 | if (slideIndex) { |
||
| 1122 | $__default['default'](target).data(DATA_KEY$2).to(slideIndex); |
||
| 1123 | } |
||
| 1124 | |||
| 1125 | event.preventDefault(); |
||
| 1126 | }; |
||
| 1127 | |||
| 1128 | _createClass(Carousel, null, [{ |
||
| 1129 | key: "VERSION", |
||
| 1130 | get: function get() { |
||
| 1131 | return VERSION$2; |
||
| 1132 | } |
||
| 1133 | }, { |
||
| 1134 | key: "Default", |
||
| 1135 | get: function get() { |
||
| 1136 | return Default; |
||
| 1137 | } |
||
| 1138 | }]); |
||
| 1139 | |||
| 1140 | return Carousel; |
||
| 1141 | }(); |
||
| 1142 | /** |
||
| 1143 | * ------------------------------------------------------------------------ |
||
| 1144 | * Data Api implementation |
||
| 1145 | * ------------------------------------------------------------------------ |
||
| 1146 | */ |
||
| 1147 | |||
| 1148 | |||
| 1149 | $__default['default'](document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler); |
||
| 1150 | $__default['default'](window).on(EVENT_LOAD_DATA_API$1, function () { |
||
| 1151 | var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE)); |
||
| 1152 | |||
| 1153 | for (var i = 0, len = carousels.length; i < len; i++) { |
||
| 1154 | var $carousel = $__default['default'](carousels[i]); |
||
| 1155 | |||
| 1156 | Carousel._jQueryInterface.call($carousel, $carousel.data()); |
||
| 1157 | } |
||
| 1158 | }); |
||
| 1159 | /** |
||
| 1160 | * ------------------------------------------------------------------------ |
||
| 1161 | * jQuery |
||
| 1162 | * ------------------------------------------------------------------------ |
||
| 1163 | */ |
||
| 1164 | |||
| 1165 | $__default['default'].fn[NAME$2] = Carousel._jQueryInterface; |
||
| 1166 | $__default['default'].fn[NAME$2].Constructor = Carousel; |
||
| 1167 | |||
| 1168 | $__default['default'].fn[NAME$2].noConflict = function () { |
||
| 1169 | $__default['default'].fn[NAME$2] = JQUERY_NO_CONFLICT$2; |
||
| 1170 | return Carousel._jQueryInterface; |
||
| 1171 | }; |
||
| 1172 | |||
| 1173 | /** |
||
| 1174 | * ------------------------------------------------------------------------ |
||
| 1175 | * Constants |
||
| 1176 | * ------------------------------------------------------------------------ |
||
| 1177 | */ |
||
| 1178 | |||
| 1179 | var NAME$3 = 'collapse'; |
||
| 1180 | var VERSION$3 = '4.5.3'; |
||
| 1181 | var DATA_KEY$3 = 'bs.collapse'; |
||
| 1182 | var EVENT_KEY$3 = "." + DATA_KEY$3; |
||
| 1183 | var DATA_API_KEY$3 = '.data-api'; |
||
| 1184 | var JQUERY_NO_CONFLICT$3 = $__default['default'].fn[NAME$3]; |
||
| 1185 | var Default$1 = { |
||
| 1186 | toggle: true, |
||
| 1187 | parent: '' |
||
| 1188 | }; |
||
| 1189 | var DefaultType$1 = { |
||
| 1190 | toggle: 'boolean', |
||
| 1191 | parent: '(string|element)' |
||
| 1192 | }; |
||
| 1193 | var EVENT_SHOW = "show" + EVENT_KEY$3; |
||
| 1194 | var EVENT_SHOWN = "shown" + EVENT_KEY$3; |
||
| 1195 | var EVENT_HIDE = "hide" + EVENT_KEY$3; |
||
| 1196 | var EVENT_HIDDEN = "hidden" + EVENT_KEY$3; |
||
| 1197 | var EVENT_CLICK_DATA_API$3 = "click" + EVENT_KEY$3 + DATA_API_KEY$3; |
||
| 1198 | var CLASS_NAME_SHOW$1 = 'show'; |
||
| 1199 | var CLASS_NAME_COLLAPSE = 'collapse'; |
||
| 1200 | var CLASS_NAME_COLLAPSING = 'collapsing'; |
||
| 1201 | var CLASS_NAME_COLLAPSED = 'collapsed'; |
||
| 1202 | var DIMENSION_WIDTH = 'width'; |
||
| 1203 | var DIMENSION_HEIGHT = 'height'; |
||
| 1204 | var SELECTOR_ACTIVES = '.show, .collapsing'; |
||
| 1205 | var SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]'; |
||
| 1206 | /** |
||
| 1207 | * ------------------------------------------------------------------------ |
||
| 1208 | * Class Definition |
||
| 1209 | * ------------------------------------------------------------------------ |
||
| 1210 | */ |
||
| 1211 | |||
| 1212 | var Collapse = /*#__PURE__*/function () { |
||
| 1213 | function Collapse(element, config) { |
||
| 1214 | this._isTransitioning = false; |
||
| 1215 | this._element = element; |
||
| 1216 | this._config = this._getConfig(config); |
||
| 1217 | this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); |
||
| 1218 | var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1)); |
||
| 1219 | |||
| 1220 | for (var i = 0, len = toggleList.length; i < len; i++) { |
||
| 1221 | var elem = toggleList[i]; |
||
| 1222 | var selector = Util.getSelectorFromElement(elem); |
||
| 1223 | var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) { |
||
| 1224 | return foundElem === element; |
||
| 1225 | }); |
||
| 1226 | |||
| 1227 | if (selector !== null && filterElement.length > 0) { |
||
| 1228 | this._selector = selector; |
||
| 1229 | |||
| 1230 | this._triggerArray.push(elem); |
||
| 1231 | } |
||
| 1232 | } |
||
| 1233 | |||
| 1234 | this._parent = this._config.parent ? this._getParent() : null; |
||
| 1235 | |||
| 1236 | if (!this._config.parent) { |
||
| 1237 | this._addAriaAndCollapsedClass(this._element, this._triggerArray); |
||
| 1238 | } |
||
| 1239 | |||
| 1240 | if (this._config.toggle) { |
||
| 1241 | this.toggle(); |
||
| 1242 | } |
||
| 1243 | } // Getters |
||
| 1244 | |||
| 1245 | |||
| 1246 | var _proto = Collapse.prototype; |
||
| 1247 | |||
| 1248 | // Public |
||
| 1249 | _proto.toggle = function toggle() { |
||
| 1250 | if ($__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { |
||
| 1251 | this.hide(); |
||
| 1252 | } else { |
||
| 1253 | this.show(); |
||
| 1254 | } |
||
| 1255 | }; |
||
| 1256 | |||
| 1257 | _proto.show = function show() { |
||
| 1258 | var _this = this; |
||
| 1259 | |||
| 1260 | if (this._isTransitioning || $__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { |
||
| 1261 | return; |
||
| 1262 | } |
||
| 1263 | |||
| 1264 | var actives; |
||
| 1265 | var activesData; |
||
| 1266 | |||
| 1267 | if (this._parent) { |
||
| 1268 | actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) { |
||
| 1269 | if (typeof _this._config.parent === 'string') { |
||
| 1270 | return elem.getAttribute('data-parent') === _this._config.parent; |
||
| 1271 | } |
||
| 1272 | |||
| 1273 | return elem.classList.contains(CLASS_NAME_COLLAPSE); |
||
| 1274 | }); |
||
| 1275 | |||
| 1276 | if (actives.length === 0) { |
||
| 1277 | actives = null; |
||
| 1278 | } |
||
| 1279 | } |
||
| 1280 | |||
| 1281 | if (actives) { |
||
| 1282 | activesData = $__default['default'](actives).not(this._selector).data(DATA_KEY$3); |
||
| 1283 | |||
| 1284 | if (activesData && activesData._isTransitioning) { |
||
| 1285 | return; |
||
| 1286 | } |
||
| 1287 | } |
||
| 1288 | |||
| 1289 | var startEvent = $__default['default'].Event(EVENT_SHOW); |
||
| 1290 | $__default['default'](this._element).trigger(startEvent); |
||
| 1291 | |||
| 1292 | if (startEvent.isDefaultPrevented()) { |
||
| 1293 | return; |
||
| 1294 | } |
||
| 1295 | |||
| 1296 | if (actives) { |
||
| 1297 | Collapse._jQueryInterface.call($__default['default'](actives).not(this._selector), 'hide'); |
||
| 1298 | |||
| 1299 | if (!activesData) { |
||
| 1300 | $__default['default'](actives).data(DATA_KEY$3, null); |
||
| 1301 | } |
||
| 1302 | } |
||
| 1303 | |||
| 1304 | var dimension = this._getDimension(); |
||
| 1305 | |||
| 1306 | $__default['default'](this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING); |
||
| 1307 | this._element.style[dimension] = 0; |
||
| 1308 | |||
| 1309 | if (this._triggerArray.length) { |
||
| 1310 | $__default['default'](this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true); |
||
| 1311 | } |
||
| 1312 | |||
| 1313 | this.setTransitioning(true); |
||
| 1314 | |||
| 1315 | var complete = function complete() { |
||
| 1316 | $__default['default'](_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1); |
||
| 1317 | _this._element.style[dimension] = ''; |
||
| 1318 | |||
| 1319 | _this.setTransitioning(false); |
||
| 1320 | |||
| 1321 | $__default['default'](_this._element).trigger(EVENT_SHOWN); |
||
| 1322 | }; |
||
| 1323 | |||
| 1324 | var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); |
||
| 1325 | var scrollSize = "scroll" + capitalizedDimension; |
||
| 1326 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); |
||
| 1327 | $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 1328 | this._element.style[dimension] = this._element[scrollSize] + "px"; |
||
| 1329 | }; |
||
| 1330 | |||
| 1331 | _proto.hide = function hide() { |
||
| 1332 | var _this2 = this; |
||
| 1333 | |||
| 1334 | if (this._isTransitioning || !$__default['default'](this._element).hasClass(CLASS_NAME_SHOW$1)) { |
||
| 1335 | return; |
||
| 1336 | } |
||
| 1337 | |||
| 1338 | var startEvent = $__default['default'].Event(EVENT_HIDE); |
||
| 1339 | $__default['default'](this._element).trigger(startEvent); |
||
| 1340 | |||
| 1341 | if (startEvent.isDefaultPrevented()) { |
||
| 1342 | return; |
||
| 1343 | } |
||
| 1344 | |||
| 1345 | var dimension = this._getDimension(); |
||
| 1346 | |||
| 1347 | this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; |
||
| 1348 | Util.reflow(this._element); |
||
| 1349 | $__default['default'](this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW$1); |
||
| 1350 | var triggerArrayLength = this._triggerArray.length; |
||
| 1351 | |||
| 1352 | if (triggerArrayLength > 0) { |
||
| 1353 | for (var i = 0; i < triggerArrayLength; i++) { |
||
| 1354 | var trigger = this._triggerArray[i]; |
||
| 1355 | var selector = Util.getSelectorFromElement(trigger); |
||
| 1356 | |||
| 1357 | if (selector !== null) { |
||
| 1358 | var $elem = $__default['default']([].slice.call(document.querySelectorAll(selector))); |
||
| 1359 | |||
| 1360 | if (!$elem.hasClass(CLASS_NAME_SHOW$1)) { |
||
| 1361 | $__default['default'](trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false); |
||
| 1362 | } |
||
| 1363 | } |
||
| 1364 | } |
||
| 1365 | } |
||
| 1366 | |||
| 1367 | this.setTransitioning(true); |
||
| 1368 | |||
| 1369 | var complete = function complete() { |
||
| 1370 | _this2.setTransitioning(false); |
||
| 1371 | |||
| 1372 | $__default['default'](_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN); |
||
| 1373 | }; |
||
| 1374 | |||
| 1375 | this._element.style[dimension] = ''; |
||
| 1376 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); |
||
| 1377 | $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 1378 | }; |
||
| 1379 | |||
| 1380 | _proto.setTransitioning = function setTransitioning(isTransitioning) { |
||
| 1381 | this._isTransitioning = isTransitioning; |
||
| 1382 | }; |
||
| 1383 | |||
| 1384 | _proto.dispose = function dispose() { |
||
| 1385 | $__default['default'].removeData(this._element, DATA_KEY$3); |
||
| 1386 | this._config = null; |
||
| 1387 | this._parent = null; |
||
| 1388 | this._element = null; |
||
| 1389 | this._triggerArray = null; |
||
| 1390 | this._isTransitioning = null; |
||
| 1391 | } // Private |
||
| 1392 | ; |
||
| 1393 | |||
| 1394 | _proto._getConfig = function _getConfig(config) { |
||
| 1395 | config = _extends({}, Default$1, config); |
||
| 1396 | config.toggle = Boolean(config.toggle); // Coerce string values |
||
| 1397 | |||
| 1398 | Util.typeCheckConfig(NAME$3, config, DefaultType$1); |
||
| 1399 | return config; |
||
| 1400 | }; |
||
| 1401 | |||
| 1402 | _proto._getDimension = function _getDimension() { |
||
| 1403 | var hasWidth = $__default['default'](this._element).hasClass(DIMENSION_WIDTH); |
||
| 1404 | return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT; |
||
| 1405 | }; |
||
| 1406 | |||
| 1407 | _proto._getParent = function _getParent() { |
||
| 1408 | var _this3 = this; |
||
| 1409 | |||
| 1410 | var parent; |
||
| 1411 | |||
| 1412 | if (Util.isElement(this._config.parent)) { |
||
| 1413 | parent = this._config.parent; // It's a jQuery object |
||
| 1414 | |||
| 1415 | if (typeof this._config.parent.jquery !== 'undefined') { |
||
| 1416 | parent = this._config.parent[0]; |
||
| 1417 | } |
||
| 1418 | } else { |
||
| 1419 | parent = document.querySelector(this._config.parent); |
||
| 1420 | } |
||
| 1421 | |||
| 1422 | var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]"; |
||
| 1423 | var children = [].slice.call(parent.querySelectorAll(selector)); |
||
| 1424 | $__default['default'](children).each(function (i, element) { |
||
| 1425 | _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); |
||
| 1426 | }); |
||
| 1427 | return parent; |
||
| 1428 | }; |
||
| 1429 | |||
| 1430 | _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { |
||
| 1431 | var isOpen = $__default['default'](element).hasClass(CLASS_NAME_SHOW$1); |
||
| 1432 | |||
| 1433 | if (triggerArray.length) { |
||
| 1434 | $__default['default'](triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen); |
||
| 1435 | } |
||
| 1436 | } // Static |
||
| 1437 | ; |
||
| 1438 | |||
| 1439 | Collapse._getTargetFromElement = function _getTargetFromElement(element) { |
||
| 1440 | var selector = Util.getSelectorFromElement(element); |
||
| 1441 | return selector ? document.querySelector(selector) : null; |
||
| 1442 | }; |
||
| 1443 | |||
| 1444 | Collapse._jQueryInterface = function _jQueryInterface(config) { |
||
| 1445 | return this.each(function () { |
||
| 1446 | var $element = $__default['default'](this); |
||
| 1447 | var data = $element.data(DATA_KEY$3); |
||
| 1448 | |||
| 1449 | var _config = _extends({}, Default$1, $element.data(), typeof config === 'object' && config ? config : {}); |
||
| 1450 | |||
| 1451 | if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { |
||
| 1452 | _config.toggle = false; |
||
| 1453 | } |
||
| 1454 | |||
| 1455 | if (!data) { |
||
| 1456 | data = new Collapse(this, _config); |
||
| 1457 | $element.data(DATA_KEY$3, data); |
||
| 1458 | } |
||
| 1459 | |||
| 1460 | if (typeof config === 'string') { |
||
| 1461 | if (typeof data[config] === 'undefined') { |
||
| 1462 | throw new TypeError("No method named \"" + config + "\""); |
||
| 1463 | } |
||
| 1464 | |||
| 1465 | data[config](); |
||
| 1466 | } |
||
| 1467 | }); |
||
| 1468 | }; |
||
| 1469 | |||
| 1470 | _createClass(Collapse, null, [{ |
||
| 1471 | key: "VERSION", |
||
| 1472 | get: function get() { |
||
| 1473 | return VERSION$3; |
||
| 1474 | } |
||
| 1475 | }, { |
||
| 1476 | key: "Default", |
||
| 1477 | get: function get() { |
||
| 1478 | return Default$1; |
||
| 1479 | } |
||
| 1480 | }]); |
||
| 1481 | |||
| 1482 | return Collapse; |
||
| 1483 | }(); |
||
| 1484 | /** |
||
| 1485 | * ------------------------------------------------------------------------ |
||
| 1486 | * Data Api implementation |
||
| 1487 | * ------------------------------------------------------------------------ |
||
| 1488 | */ |
||
| 1489 | |||
| 1490 | |||
| 1491 | $__default['default'](document).on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$1, function (event) { |
||
| 1492 | // preventDefault only for <a> elements (which change the URL) not inside the collapsible element |
||
| 1493 | if (event.currentTarget.tagName === 'A') { |
||
| 1494 | event.preventDefault(); |
||
| 1495 | } |
||
| 1496 | |||
| 1497 | var $trigger = $__default['default'](this); |
||
| 1498 | var selector = Util.getSelectorFromElement(this); |
||
| 1499 | var selectors = [].slice.call(document.querySelectorAll(selector)); |
||
| 1500 | $__default['default'](selectors).each(function () { |
||
| 1501 | var $target = $__default['default'](this); |
||
| 1502 | var data = $target.data(DATA_KEY$3); |
||
| 1503 | var config = data ? 'toggle' : $trigger.data(); |
||
| 1504 | |||
| 1505 | Collapse._jQueryInterface.call($target, config); |
||
| 1506 | }); |
||
| 1507 | }); |
||
| 1508 | /** |
||
| 1509 | * ------------------------------------------------------------------------ |
||
| 1510 | * jQuery |
||
| 1511 | * ------------------------------------------------------------------------ |
||
| 1512 | */ |
||
| 1513 | |||
| 1514 | $__default['default'].fn[NAME$3] = Collapse._jQueryInterface; |
||
| 1515 | $__default['default'].fn[NAME$3].Constructor = Collapse; |
||
| 1516 | |||
| 1517 | $__default['default'].fn[NAME$3].noConflict = function () { |
||
| 1518 | $__default['default'].fn[NAME$3] = JQUERY_NO_CONFLICT$3; |
||
| 1519 | return Collapse._jQueryInterface; |
||
| 1520 | }; |
||
| 1521 | |||
| 1522 | /**! |
||
| 1523 | * @fileOverview Kickass library to create and place poppers near their reference elements. |
||
| 1524 | * @version 1.16.1 |
||
| 1525 | * @license |
||
| 1526 | * Copyright (c) 2016 Federico Zivolo and contributors |
||
| 1527 | * |
||
| 1528 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
||
| 1529 | * of this software and associated documentation files (the "Software"), to deal |
||
| 1530 | * in the Software without restriction, including without limitation the rights |
||
| 1531 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||
| 1532 | * copies of the Software, and to permit persons to whom the Software is |
||
| 1533 | * furnished to do so, subject to the following conditions: |
||
| 1534 | * |
||
| 1535 | * The above copyright notice and this permission notice shall be included in all |
||
| 1536 | * copies or substantial portions of the Software. |
||
| 1537 | * |
||
| 1538 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||
| 1539 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
| 1540 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||
| 1541 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||
| 1542 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||
| 1543 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||
| 1544 | * SOFTWARE. |
||
| 1545 | */ |
||
| 1546 | var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined'; |
||
| 1547 | |||
| 1548 | var timeoutDuration = function () { |
||
| 1549 | var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; |
||
| 1550 | for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { |
||
| 1551 | if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) { |
||
| 1552 | return 1; |
||
| 1553 | } |
||
| 1554 | } |
||
| 1555 | return 0; |
||
| 1556 | }(); |
||
| 1557 | |||
| 1558 | function microtaskDebounce(fn) { |
||
| 1559 | var called = false; |
||
| 1560 | return function () { |
||
| 1561 | if (called) { |
||
| 1562 | return; |
||
| 1563 | } |
||
| 1564 | called = true; |
||
| 1565 | window.Promise.resolve().then(function () { |
||
| 1566 | called = false; |
||
| 1567 | fn(); |
||
| 1568 | }); |
||
| 1569 | }; |
||
| 1570 | } |
||
| 1571 | |||
| 1572 | function taskDebounce(fn) { |
||
| 1573 | var scheduled = false; |
||
| 1574 | return function () { |
||
| 1575 | if (!scheduled) { |
||
| 1576 | scheduled = true; |
||
| 1577 | setTimeout(function () { |
||
| 1578 | scheduled = false; |
||
| 1579 | fn(); |
||
| 1580 | }, timeoutDuration); |
||
| 1581 | } |
||
| 1582 | }; |
||
| 1583 | } |
||
| 1584 | |||
| 1585 | var supportsMicroTasks = isBrowser && window.Promise; |
||
| 1586 | |||
| 1587 | /** |
||
| 1588 | * Create a debounced version of a method, that's asynchronously deferred |
||
| 1589 | * but called in the minimum time possible. |
||
| 1590 | * |
||
| 1591 | * @method |
||
| 1592 | * @memberof Popper.Utils |
||
| 1593 | * @argument {Function} fn |
||
| 1594 | * @returns {Function} |
||
| 1595 | */ |
||
| 1596 | var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce; |
||
| 1597 | |||
| 1598 | /** |
||
| 1599 | * Check if the given variable is a function |
||
| 1600 | * @method |
||
| 1601 | * @memberof Popper.Utils |
||
| 1602 | * @argument {Any} functionToCheck - variable to check |
||
| 1603 | * @returns {Boolean} answer to: is a function? |
||
| 1604 | */ |
||
| 1605 | function isFunction(functionToCheck) { |
||
| 1606 | var getType = {}; |
||
| 1607 | return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; |
||
| 1608 | } |
||
| 1609 | |||
| 1610 | /** |
||
| 1611 | * Get CSS computed property of the given element |
||
| 1612 | * @method |
||
| 1613 | * @memberof Popper.Utils |
||
| 1614 | * @argument {Eement} element |
||
| 1615 | * @argument {String} property |
||
| 1616 | */ |
||
| 1617 | function getStyleComputedProperty(element, property) { |
||
| 1618 | if (element.nodeType !== 1) { |
||
| 1619 | return []; |
||
| 1620 | } |
||
| 1621 | // NOTE: 1 DOM access here |
||
| 1622 | var window = element.ownerDocument.defaultView; |
||
| 1623 | var css = window.getComputedStyle(element, null); |
||
| 1624 | return property ? css[property] : css; |
||
| 1625 | } |
||
| 1626 | |||
| 1627 | /** |
||
| 1628 | * Returns the parentNode or the host of the element |
||
| 1629 | * @method |
||
| 1630 | * @memberof Popper.Utils |
||
| 1631 | * @argument {Element} element |
||
| 1632 | * @returns {Element} parent |
||
| 1633 | */ |
||
| 1634 | function getParentNode(element) { |
||
| 1635 | if (element.nodeName === 'HTML') { |
||
| 1636 | return element; |
||
| 1637 | } |
||
| 1638 | return element.parentNode || element.host; |
||
| 1639 | } |
||
| 1640 | |||
| 1641 | /** |
||
| 1642 | * Returns the scrolling parent of the given element |
||
| 1643 | * @method |
||
| 1644 | * @memberof Popper.Utils |
||
| 1645 | * @argument {Element} element |
||
| 1646 | * @returns {Element} scroll parent |
||
| 1647 | */ |
||
| 1648 | function getScrollParent(element) { |
||
| 1649 | // Return body, `getScroll` will take care to get the correct `scrollTop` from it |
||
| 1650 | if (!element) { |
||
| 1651 | return document.body; |
||
| 1652 | } |
||
| 1653 | |||
| 1654 | switch (element.nodeName) { |
||
| 1655 | case 'HTML': |
||
| 1656 | case 'BODY': |
||
| 1657 | return element.ownerDocument.body; |
||
| 1658 | case '#document': |
||
| 1659 | return element.body; |
||
| 1660 | } |
||
| 1661 | |||
| 1662 | // Firefox want us to check `-x` and `-y` variations as well |
||
| 1663 | |||
| 1664 | var _getStyleComputedProp = getStyleComputedProperty(element), |
||
| 1665 | overflow = _getStyleComputedProp.overflow, |
||
| 1666 | overflowX = _getStyleComputedProp.overflowX, |
||
| 1667 | overflowY = _getStyleComputedProp.overflowY; |
||
| 1668 | |||
| 1669 | if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) { |
||
| 1670 | return element; |
||
| 1671 | } |
||
| 1672 | |||
| 1673 | return getScrollParent(getParentNode(element)); |
||
| 1674 | } |
||
| 1675 | |||
| 1676 | /** |
||
| 1677 | * Returns the reference node of the reference object, or the reference object itself. |
||
| 1678 | * @method |
||
| 1679 | * @memberof Popper.Utils |
||
| 1680 | * @param {Element|Object} reference - the reference element (the popper will be relative to this) |
||
| 1681 | * @returns {Element} parent |
||
| 1682 | */ |
||
| 1683 | function getReferenceNode(reference) { |
||
| 1684 | return reference && reference.referenceNode ? reference.referenceNode : reference; |
||
| 1685 | } |
||
| 1686 | |||
| 1687 | var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode); |
||
| 1688 | var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent); |
||
| 1689 | |||
| 1690 | /** |
||
| 1691 | * Determines if the browser is Internet Explorer |
||
| 1692 | * @method |
||
| 1693 | * @memberof Popper.Utils |
||
| 1694 | * @param {Number} version to check |
||
| 1695 | * @returns {Boolean} isIE |
||
| 1696 | */ |
||
| 1697 | function isIE(version) { |
||
| 1698 | if (version === 11) { |
||
| 1699 | return isIE11; |
||
| 1700 | } |
||
| 1701 | if (version === 10) { |
||
| 1702 | return isIE10; |
||
| 1703 | } |
||
| 1704 | return isIE11 || isIE10; |
||
| 1705 | } |
||
| 1706 | |||
| 1707 | /** |
||
| 1708 | * Returns the offset parent of the given element |
||
| 1709 | * @method |
||
| 1710 | * @memberof Popper.Utils |
||
| 1711 | * @argument {Element} element |
||
| 1712 | * @returns {Element} offset parent |
||
| 1713 | */ |
||
| 1714 | function getOffsetParent(element) { |
||
| 1715 | if (!element) { |
||
| 1716 | return document.documentElement; |
||
| 1717 | } |
||
| 1718 | |||
| 1719 | var noOffsetParent = isIE(10) ? document.body : null; |
||
| 1720 | |||
| 1721 | // NOTE: 1 DOM access here |
||
| 1722 | var offsetParent = element.offsetParent || null; |
||
| 1723 | // Skip hidden elements which don't have an offsetParent |
||
| 1724 | while (offsetParent === noOffsetParent && element.nextElementSibling) { |
||
| 1725 | offsetParent = (element = element.nextElementSibling).offsetParent; |
||
| 1726 | } |
||
| 1727 | |||
| 1728 | var nodeName = offsetParent && offsetParent.nodeName; |
||
| 1729 | |||
| 1730 | if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') { |
||
| 1731 | return element ? element.ownerDocument.documentElement : document.documentElement; |
||
| 1732 | } |
||
| 1733 | |||
| 1734 | // .offsetParent will return the closest TH, TD or TABLE in case |
||
| 1735 | // no offsetParent is present, I hate this job... |
||
| 1736 | if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') { |
||
| 1737 | return getOffsetParent(offsetParent); |
||
| 1738 | } |
||
| 1739 | |||
| 1740 | return offsetParent; |
||
| 1741 | } |
||
| 1742 | |||
| 1743 | function isOffsetContainer(element) { |
||
| 1744 | var nodeName = element.nodeName; |
||
| 1745 | |||
| 1746 | if (nodeName === 'BODY') { |
||
| 1747 | return false; |
||
| 1748 | } |
||
| 1749 | return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element; |
||
| 1750 | } |
||
| 1751 | |||
| 1752 | /** |
||
| 1753 | * Finds the root node (document, shadowDOM root) of the given element |
||
| 1754 | * @method |
||
| 1755 | * @memberof Popper.Utils |
||
| 1756 | * @argument {Element} node |
||
| 1757 | * @returns {Element} root node |
||
| 1758 | */ |
||
| 1759 | function getRoot(node) { |
||
| 1760 | if (node.parentNode !== null) { |
||
| 1761 | return getRoot(node.parentNode); |
||
| 1762 | } |
||
| 1763 | |||
| 1764 | return node; |
||
| 1765 | } |
||
| 1766 | |||
| 1767 | /** |
||
| 1768 | * Finds the offset parent common to the two provided nodes |
||
| 1769 | * @method |
||
| 1770 | * @memberof Popper.Utils |
||
| 1771 | * @argument {Element} element1 |
||
| 1772 | * @argument {Element} element2 |
||
| 1773 | * @returns {Element} common offset parent |
||
| 1774 | */ |
||
| 1775 | function findCommonOffsetParent(element1, element2) { |
||
| 1776 | // This check is needed to avoid errors in case one of the elements isn't defined for any reason |
||
| 1777 | if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) { |
||
| 1778 | return document.documentElement; |
||
| 1779 | } |
||
| 1780 | |||
| 1781 | // Here we make sure to give as "start" the element that comes first in the DOM |
||
| 1782 | var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING; |
||
| 1783 | var start = order ? element1 : element2; |
||
| 1784 | var end = order ? element2 : element1; |
||
| 1785 | |||
| 1786 | // Get common ancestor container |
||
| 1787 | var range = document.createRange(); |
||
| 1788 | range.setStart(start, 0); |
||
| 1789 | range.setEnd(end, 0); |
||
| 1790 | var commonAncestorContainer = range.commonAncestorContainer; |
||
| 1791 | |||
| 1792 | // Both nodes are inside #document |
||
| 1793 | |||
| 1794 | if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) { |
||
| 1795 | if (isOffsetContainer(commonAncestorContainer)) { |
||
| 1796 | return commonAncestorContainer; |
||
| 1797 | } |
||
| 1798 | |||
| 1799 | return getOffsetParent(commonAncestorContainer); |
||
| 1800 | } |
||
| 1801 | |||
| 1802 | // one of the nodes is inside shadowDOM, find which one |
||
| 1803 | var element1root = getRoot(element1); |
||
| 1804 | if (element1root.host) { |
||
| 1805 | return findCommonOffsetParent(element1root.host, element2); |
||
| 1806 | } else { |
||
| 1807 | return findCommonOffsetParent(element1, getRoot(element2).host); |
||
| 1808 | } |
||
| 1809 | } |
||
| 1810 | |||
| 1811 | /** |
||
| 1812 | * Gets the scroll value of the given element in the given side (top and left) |
||
| 1813 | * @method |
||
| 1814 | * @memberof Popper.Utils |
||
| 1815 | * @argument {Element} element |
||
| 1816 | * @argument {String} side `top` or `left` |
||
| 1817 | * @returns {number} amount of scrolled pixels |
||
| 1818 | */ |
||
| 1819 | function getScroll(element) { |
||
| 1820 | var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top'; |
||
| 1821 | |||
| 1822 | var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft'; |
||
| 1823 | var nodeName = element.nodeName; |
||
| 1824 | |||
| 1825 | if (nodeName === 'BODY' || nodeName === 'HTML') { |
||
| 1826 | var html = element.ownerDocument.documentElement; |
||
| 1827 | var scrollingElement = element.ownerDocument.scrollingElement || html; |
||
| 1828 | return scrollingElement[upperSide]; |
||
| 1829 | } |
||
| 1830 | |||
| 1831 | return element[upperSide]; |
||
| 1832 | } |
||
| 1833 | |||
| 1834 | /* |
||
| 1835 | * Sum or subtract the element scroll values (left and top) from a given rect object |
||
| 1836 | * @method |
||
| 1837 | * @memberof Popper.Utils |
||
| 1838 | * @param {Object} rect - Rect object you want to change |
||
| 1839 | * @param {HTMLElement} element - The element from the function reads the scroll values |
||
| 1840 | * @param {Boolean} subtract - set to true if you want to subtract the scroll values |
||
| 1841 | * @return {Object} rect - The modifier rect object |
||
| 1842 | */ |
||
| 1843 | function includeScroll(rect, element) { |
||
| 1844 | var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
||
| 1845 | |||
| 1846 | var scrollTop = getScroll(element, 'top'); |
||
| 1847 | var scrollLeft = getScroll(element, 'left'); |
||
| 1848 | var modifier = subtract ? -1 : 1; |
||
| 1849 | rect.top += scrollTop * modifier; |
||
| 1850 | rect.bottom += scrollTop * modifier; |
||
| 1851 | rect.left += scrollLeft * modifier; |
||
| 1852 | rect.right += scrollLeft * modifier; |
||
| 1853 | return rect; |
||
| 1854 | } |
||
| 1855 | |||
| 1856 | /* |
||
| 1857 | * Helper to detect borders of a given element |
||
| 1858 | * @method |
||
| 1859 | * @memberof Popper.Utils |
||
| 1860 | * @param {CSSStyleDeclaration} styles |
||
| 1861 | * Result of `getStyleComputedProperty` on the given element |
||
| 1862 | * @param {String} axis - `x` or `y` |
||
| 1863 | * @return {number} borders - The borders size of the given axis |
||
| 1864 | */ |
||
| 1865 | |||
| 1866 | function getBordersSize(styles, axis) { |
||
| 1867 | var sideA = axis === 'x' ? 'Left' : 'Top'; |
||
| 1868 | var sideB = sideA === 'Left' ? 'Right' : 'Bottom'; |
||
| 1869 | |||
| 1870 | return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']); |
||
| 1871 | } |
||
| 1872 | |||
| 1873 | function getSize(axis, body, html, computedStyle) { |
||
| 1874 | 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); |
||
| 1875 | } |
||
| 1876 | |||
| 1877 | function getWindowSizes(document) { |
||
| 1878 | var body = document.body; |
||
| 1879 | var html = document.documentElement; |
||
| 1880 | var computedStyle = isIE(10) && getComputedStyle(html); |
||
| 1881 | |||
| 1882 | return { |
||
| 1883 | height: getSize('Height', body, html, computedStyle), |
||
| 1884 | width: getSize('Width', body, html, computedStyle) |
||
| 1885 | }; |
||
| 1886 | } |
||
| 1887 | |||
| 1888 | var classCallCheck = function (instance, Constructor) { |
||
| 1889 | if (!(instance instanceof Constructor)) { |
||
| 1890 | throw new TypeError("Cannot call a class as a function"); |
||
| 1891 | } |
||
| 1892 | }; |
||
| 1893 | |||
| 1894 | var createClass = function () { |
||
| 1895 | function defineProperties(target, props) { |
||
| 1896 | for (var i = 0; i < props.length; i++) { |
||
| 1897 | var descriptor = props[i]; |
||
| 1898 | descriptor.enumerable = descriptor.enumerable || false; |
||
| 1899 | descriptor.configurable = true; |
||
| 1900 | if ("value" in descriptor) descriptor.writable = true; |
||
| 1901 | Object.defineProperty(target, descriptor.key, descriptor); |
||
| 1902 | } |
||
| 1903 | } |
||
| 1904 | |||
| 1905 | return function (Constructor, protoProps, staticProps) { |
||
| 1906 | if (protoProps) defineProperties(Constructor.prototype, protoProps); |
||
| 1907 | if (staticProps) defineProperties(Constructor, staticProps); |
||
| 1908 | return Constructor; |
||
| 1909 | }; |
||
| 1910 | }(); |
||
| 1911 | |||
| 1912 | |||
| 1913 | |||
| 1914 | |||
| 1915 | |||
| 1916 | var defineProperty = function (obj, key, value) { |
||
| 1917 | if (key in obj) { |
||
| 1918 | Object.defineProperty(obj, key, { |
||
| 1919 | value: value, |
||
| 1920 | enumerable: true, |
||
| 1921 | configurable: true, |
||
| 1922 | writable: true |
||
| 1923 | }); |
||
| 1924 | } else { |
||
| 1925 | obj[key] = value; |
||
| 1926 | } |
||
| 1927 | |||
| 1928 | return obj; |
||
| 1929 | }; |
||
| 1930 | |||
| 1931 | var _extends$1 = Object.assign || function (target) { |
||
| 1932 | for (var i = 1; i < arguments.length; i++) { |
||
| 1933 | var source = arguments[i]; |
||
| 1934 | |||
| 1935 | for (var key in source) { |
||
| 1936 | if (Object.prototype.hasOwnProperty.call(source, key)) { |
||
| 1937 | target[key] = source[key]; |
||
| 1938 | } |
||
| 1939 | } |
||
| 1940 | } |
||
| 1941 | |||
| 1942 | return target; |
||
| 1943 | }; |
||
| 1944 | |||
| 1945 | /** |
||
| 1946 | * Given element offsets, generate an output similar to getBoundingClientRect |
||
| 1947 | * @method |
||
| 1948 | * @memberof Popper.Utils |
||
| 1949 | * @argument {Object} offsets |
||
| 1950 | * @returns {Object} ClientRect like output |
||
| 1951 | */ |
||
| 1952 | function getClientRect(offsets) { |
||
| 1953 | return _extends$1({}, offsets, { |
||
| 1954 | right: offsets.left + offsets.width, |
||
| 1955 | bottom: offsets.top + offsets.height |
||
| 1956 | }); |
||
| 1957 | } |
||
| 1958 | |||
| 1959 | /** |
||
| 1960 | * Get bounding client rect of given element |
||
| 1961 | * @method |
||
| 1962 | * @memberof Popper.Utils |
||
| 1963 | * @param {HTMLElement} element |
||
| 1964 | * @return {Object} client rect |
||
| 1965 | */ |
||
| 1966 | function getBoundingClientRect(element) { |
||
| 1967 | var rect = {}; |
||
| 1968 | |||
| 1969 | // IE10 10 FIX: Please, don't ask, the element isn't |
||
| 1970 | // considered in DOM in some circumstances... |
||
| 1971 | // This isn't reproducible in IE10 compatibility mode of IE11 |
||
| 1972 | try { |
||
| 1973 | if (isIE(10)) { |
||
| 1974 | rect = element.getBoundingClientRect(); |
||
| 1975 | var scrollTop = getScroll(element, 'top'); |
||
| 1976 | var scrollLeft = getScroll(element, 'left'); |
||
| 1977 | rect.top += scrollTop; |
||
| 1978 | rect.left += scrollLeft; |
||
| 1979 | rect.bottom += scrollTop; |
||
| 1980 | rect.right += scrollLeft; |
||
| 1981 | } else { |
||
| 1982 | rect = element.getBoundingClientRect(); |
||
| 1983 | } |
||
| 1984 | } catch (e) {} |
||
| 1985 | |||
| 1986 | var result = { |
||
| 1987 | left: rect.left, |
||
| 1988 | top: rect.top, |
||
| 1989 | width: rect.right - rect.left, |
||
| 1990 | height: rect.bottom - rect.top |
||
| 1991 | }; |
||
| 1992 | |||
| 1993 | // subtract scrollbar size from sizes |
||
| 1994 | var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {}; |
||
| 1995 | var width = sizes.width || element.clientWidth || result.width; |
||
| 1996 | var height = sizes.height || element.clientHeight || result.height; |
||
| 1997 | |||
| 1998 | var horizScrollbar = element.offsetWidth - width; |
||
| 1999 | var vertScrollbar = element.offsetHeight - height; |
||
| 2000 | |||
| 2001 | // if an hypothetical scrollbar is detected, we must be sure it's not a `border` |
||
| 2002 | // we make this check conditional for performance reasons |
||
| 2003 | if (horizScrollbar || vertScrollbar) { |
||
| 2004 | var styles = getStyleComputedProperty(element); |
||
| 2005 | horizScrollbar -= getBordersSize(styles, 'x'); |
||
| 2006 | vertScrollbar -= getBordersSize(styles, 'y'); |
||
| 2007 | |||
| 2008 | result.width -= horizScrollbar; |
||
| 2009 | result.height -= vertScrollbar; |
||
| 2010 | } |
||
| 2011 | |||
| 2012 | return getClientRect(result); |
||
| 2013 | } |
||
| 2014 | |||
| 2015 | function getOffsetRectRelativeToArbitraryNode(children, parent) { |
||
| 2016 | var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
||
| 2017 | |||
| 2018 | var isIE10 = isIE(10); |
||
| 2019 | var isHTML = parent.nodeName === 'HTML'; |
||
| 2020 | var childrenRect = getBoundingClientRect(children); |
||
| 2021 | var parentRect = getBoundingClientRect(parent); |
||
| 2022 | var scrollParent = getScrollParent(children); |
||
| 2023 | |||
| 2024 | var styles = getStyleComputedProperty(parent); |
||
| 2025 | var borderTopWidth = parseFloat(styles.borderTopWidth); |
||
| 2026 | var borderLeftWidth = parseFloat(styles.borderLeftWidth); |
||
| 2027 | |||
| 2028 | // In cases where the parent is fixed, we must ignore negative scroll in offset calc |
||
| 2029 | if (fixedPosition && isHTML) { |
||
| 2030 | parentRect.top = Math.max(parentRect.top, 0); |
||
| 2031 | parentRect.left = Math.max(parentRect.left, 0); |
||
| 2032 | } |
||
| 2033 | var offsets = getClientRect({ |
||
| 2034 | top: childrenRect.top - parentRect.top - borderTopWidth, |
||
| 2035 | left: childrenRect.left - parentRect.left - borderLeftWidth, |
||
| 2036 | width: childrenRect.width, |
||
| 2037 | height: childrenRect.height |
||
| 2038 | }); |
||
| 2039 | offsets.marginTop = 0; |
||
| 2040 | offsets.marginLeft = 0; |
||
| 2041 | |||
| 2042 | // Subtract margins of documentElement in case it's being used as parent |
||
| 2043 | // we do this only on HTML because it's the only element that behaves |
||
| 2044 | // differently when margins are applied to it. The margins are included in |
||
| 2045 | // the box of the documentElement, in the other cases not. |
||
| 2046 | if (!isIE10 && isHTML) { |
||
| 2047 | var marginTop = parseFloat(styles.marginTop); |
||
| 2048 | var marginLeft = parseFloat(styles.marginLeft); |
||
| 2049 | |||
| 2050 | offsets.top -= borderTopWidth - marginTop; |
||
| 2051 | offsets.bottom -= borderTopWidth - marginTop; |
||
| 2052 | offsets.left -= borderLeftWidth - marginLeft; |
||
| 2053 | offsets.right -= borderLeftWidth - marginLeft; |
||
| 2054 | |||
| 2055 | // Attach marginTop and marginLeft because in some circumstances we may need them |
||
| 2056 | offsets.marginTop = marginTop; |
||
| 2057 | offsets.marginLeft = marginLeft; |
||
| 2058 | } |
||
| 2059 | |||
| 2060 | if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') { |
||
| 2061 | offsets = includeScroll(offsets, parent); |
||
| 2062 | } |
||
| 2063 | |||
| 2064 | return offsets; |
||
| 2065 | } |
||
| 2066 | |||
| 2067 | function getViewportOffsetRectRelativeToArtbitraryNode(element) { |
||
| 2068 | var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
||
| 2069 | |||
| 2070 | var html = element.ownerDocument.documentElement; |
||
| 2071 | var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); |
||
| 2072 | var width = Math.max(html.clientWidth, window.innerWidth || 0); |
||
| 2073 | var height = Math.max(html.clientHeight, window.innerHeight || 0); |
||
| 2074 | |||
| 2075 | var scrollTop = !excludeScroll ? getScroll(html) : 0; |
||
| 2076 | var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0; |
||
| 2077 | |||
| 2078 | var offset = { |
||
| 2079 | top: scrollTop - relativeOffset.top + relativeOffset.marginTop, |
||
| 2080 | left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft, |
||
| 2081 | width: width, |
||
| 2082 | height: height |
||
| 2083 | }; |
||
| 2084 | |||
| 2085 | return getClientRect(offset); |
||
| 2086 | } |
||
| 2087 | |||
| 2088 | /** |
||
| 2089 | * Check if the given element is fixed or is inside a fixed parent |
||
| 2090 | * @method |
||
| 2091 | * @memberof Popper.Utils |
||
| 2092 | * @argument {Element} element |
||
| 2093 | * @argument {Element} customContainer |
||
| 2094 | * @returns {Boolean} answer to "isFixed?" |
||
| 2095 | */ |
||
| 2096 | function isFixed(element) { |
||
| 2097 | var nodeName = element.nodeName; |
||
| 2098 | if (nodeName === 'BODY' || nodeName === 'HTML') { |
||
| 2099 | return false; |
||
| 2100 | } |
||
| 2101 | if (getStyleComputedProperty(element, 'position') === 'fixed') { |
||
| 2102 | return true; |
||
| 2103 | } |
||
| 2104 | var parentNode = getParentNode(element); |
||
| 2105 | if (!parentNode) { |
||
| 2106 | return false; |
||
| 2107 | } |
||
| 2108 | return isFixed(parentNode); |
||
| 2109 | } |
||
| 2110 | |||
| 2111 | /** |
||
| 2112 | * Finds the first parent of an element that has a transformed property defined |
||
| 2113 | * @method |
||
| 2114 | * @memberof Popper.Utils |
||
| 2115 | * @argument {Element} element |
||
| 2116 | * @returns {Element} first transformed parent or documentElement |
||
| 2117 | */ |
||
| 2118 | |||
| 2119 | function getFixedPositionOffsetParent(element) { |
||
| 2120 | // This check is needed to avoid errors in case one of the elements isn't defined for any reason |
||
| 2121 | if (!element || !element.parentElement || isIE()) { |
||
| 2122 | return document.documentElement; |
||
| 2123 | } |
||
| 2124 | var el = element.parentElement; |
||
| 2125 | while (el && getStyleComputedProperty(el, 'transform') === 'none') { |
||
| 2126 | el = el.parentElement; |
||
| 2127 | } |
||
| 2128 | return el || document.documentElement; |
||
| 2129 | } |
||
| 2130 | |||
| 2131 | /** |
||
| 2132 | * Computed the boundaries limits and return them |
||
| 2133 | * @method |
||
| 2134 | * @memberof Popper.Utils |
||
| 2135 | * @param {HTMLElement} popper |
||
| 2136 | * @param {HTMLElement} reference |
||
| 2137 | * @param {number} padding |
||
| 2138 | * @param {HTMLElement} boundariesElement - Element used to define the boundaries |
||
| 2139 | * @param {Boolean} fixedPosition - Is in fixed position mode |
||
| 2140 | * @returns {Object} Coordinates of the boundaries |
||
| 2141 | */ |
||
| 2142 | function getBoundaries(popper, reference, padding, boundariesElement) { |
||
| 2143 | var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; |
||
| 2144 | |||
| 2145 | // NOTE: 1 DOM access here |
||
| 2146 | |||
| 2147 | var boundaries = { top: 0, left: 0 }; |
||
| 2148 | var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); |
||
| 2149 | |||
| 2150 | // Handle viewport case |
||
| 2151 | if (boundariesElement === 'viewport') { |
||
| 2152 | boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition); |
||
| 2153 | } else { |
||
| 2154 | // Handle other cases based on DOM element used as boundaries |
||
| 2155 | var boundariesNode = void 0; |
||
| 2156 | if (boundariesElement === 'scrollParent') { |
||
| 2157 | boundariesNode = getScrollParent(getParentNode(reference)); |
||
| 2158 | if (boundariesNode.nodeName === 'BODY') { |
||
| 2159 | boundariesNode = popper.ownerDocument.documentElement; |
||
| 2160 | } |
||
| 2161 | } else if (boundariesElement === 'window') { |
||
| 2162 | boundariesNode = popper.ownerDocument.documentElement; |
||
| 2163 | } else { |
||
| 2164 | boundariesNode = boundariesElement; |
||
| 2165 | } |
||
| 2166 | |||
| 2167 | var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition); |
||
| 2168 | |||
| 2169 | // In case of HTML, we need a different computation |
||
| 2170 | if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) { |
||
| 2171 | var _getWindowSizes = getWindowSizes(popper.ownerDocument), |
||
| 2172 | height = _getWindowSizes.height, |
||
| 2173 | width = _getWindowSizes.width; |
||
| 2174 | |||
| 2175 | boundaries.top += offsets.top - offsets.marginTop; |
||
| 2176 | boundaries.bottom = height + offsets.top; |
||
| 2177 | boundaries.left += offsets.left - offsets.marginLeft; |
||
| 2178 | boundaries.right = width + offsets.left; |
||
| 2179 | } else { |
||
| 2180 | // for all the other DOM elements, this one is good |
||
| 2181 | boundaries = offsets; |
||
| 2182 | } |
||
| 2183 | } |
||
| 2184 | |||
| 2185 | // Add paddings |
||
| 2186 | padding = padding || 0; |
||
| 2187 | var isPaddingNumber = typeof padding === 'number'; |
||
| 2188 | boundaries.left += isPaddingNumber ? padding : padding.left || 0; |
||
| 2189 | boundaries.top += isPaddingNumber ? padding : padding.top || 0; |
||
| 2190 | boundaries.right -= isPaddingNumber ? padding : padding.right || 0; |
||
| 2191 | boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0; |
||
| 2192 | |||
| 2193 | return boundaries; |
||
| 2194 | } |
||
| 2195 | |||
| 2196 | function getArea(_ref) { |
||
| 2197 | var width = _ref.width, |
||
| 2198 | height = _ref.height; |
||
| 2199 | |||
| 2200 | return width * height; |
||
| 2201 | } |
||
| 2202 | |||
| 2203 | /** |
||
| 2204 | * Utility used to transform the `auto` placement to the placement with more |
||
| 2205 | * available space. |
||
| 2206 | * @method |
||
| 2207 | * @memberof Popper.Utils |
||
| 2208 | * @argument {Object} data - The data object generated by update method |
||
| 2209 | * @argument {Object} options - Modifiers configuration and options |
||
| 2210 | * @returns {Object} The data object, properly modified |
||
| 2211 | */ |
||
| 2212 | function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) { |
||
| 2213 | var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0; |
||
| 2214 | |||
| 2215 | if (placement.indexOf('auto') === -1) { |
||
| 2216 | return placement; |
||
| 2217 | } |
||
| 2218 | |||
| 2219 | var boundaries = getBoundaries(popper, reference, padding, boundariesElement); |
||
| 2220 | |||
| 2221 | var rects = { |
||
| 2222 | top: { |
||
| 2223 | width: boundaries.width, |
||
| 2224 | height: refRect.top - boundaries.top |
||
| 2225 | }, |
||
| 2226 | right: { |
||
| 2227 | width: boundaries.right - refRect.right, |
||
| 2228 | height: boundaries.height |
||
| 2229 | }, |
||
| 2230 | bottom: { |
||
| 2231 | width: boundaries.width, |
||
| 2232 | height: boundaries.bottom - refRect.bottom |
||
| 2233 | }, |
||
| 2234 | left: { |
||
| 2235 | width: refRect.left - boundaries.left, |
||
| 2236 | height: boundaries.height |
||
| 2237 | } |
||
| 2238 | }; |
||
| 2239 | |||
| 2240 | var sortedAreas = Object.keys(rects).map(function (key) { |
||
| 2241 | return _extends$1({ |
||
| 2242 | key: key |
||
| 2243 | }, rects[key], { |
||
| 2244 | area: getArea(rects[key]) |
||
| 2245 | }); |
||
| 2246 | }).sort(function (a, b) { |
||
| 2247 | return b.area - a.area; |
||
| 2248 | }); |
||
| 2249 | |||
| 2250 | var filteredAreas = sortedAreas.filter(function (_ref2) { |
||
| 2251 | var width = _ref2.width, |
||
| 2252 | height = _ref2.height; |
||
| 2253 | return width >= popper.clientWidth && height >= popper.clientHeight; |
||
| 2254 | }); |
||
| 2255 | |||
| 2256 | var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key; |
||
| 2257 | |||
| 2258 | var variation = placement.split('-')[1]; |
||
| 2259 | |||
| 2260 | return computedPlacement + (variation ? '-' + variation : ''); |
||
| 2261 | } |
||
| 2262 | |||
| 2263 | /** |
||
| 2264 | * Get offsets to the reference element |
||
| 2265 | * @method |
||
| 2266 | * @memberof Popper.Utils |
||
| 2267 | * @param {Object} state |
||
| 2268 | * @param {Element} popper - the popper element |
||
| 2269 | * @param {Element} reference - the reference element (the popper will be relative to this) |
||
| 2270 | * @param {Element} fixedPosition - is in fixed position mode |
||
| 2271 | * @returns {Object} An object containing the offsets which will be applied to the popper |
||
| 2272 | */ |
||
| 2273 | function getReferenceOffsets(state, popper, reference) { |
||
| 2274 | var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; |
||
| 2275 | |||
| 2276 | var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference)); |
||
| 2277 | return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition); |
||
| 2278 | } |
||
| 2279 | |||
| 2280 | /** |
||
| 2281 | * Get the outer sizes of the given element (offset size + margins) |
||
| 2282 | * @method |
||
| 2283 | * @memberof Popper.Utils |
||
| 2284 | * @argument {Element} element |
||
| 2285 | * @returns {Object} object containing width and height properties |
||
| 2286 | */ |
||
| 2287 | function getOuterSizes(element) { |
||
| 2288 | var window = element.ownerDocument.defaultView; |
||
| 2289 | var styles = window.getComputedStyle(element); |
||
| 2290 | var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0); |
||
| 2291 | var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0); |
||
| 2292 | var result = { |
||
| 2293 | width: element.offsetWidth + y, |
||
| 2294 | height: element.offsetHeight + x |
||
| 2295 | }; |
||
| 2296 | return result; |
||
| 2297 | } |
||
| 2298 | |||
| 2299 | /** |
||
| 2300 | * Get the opposite placement of the given one |
||
| 2301 | * @method |
||
| 2302 | * @memberof Popper.Utils |
||
| 2303 | * @argument {String} placement |
||
| 2304 | * @returns {String} flipped placement |
||
| 2305 | */ |
||
| 2306 | function getOppositePlacement(placement) { |
||
| 2307 | var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' }; |
||
| 2308 | return placement.replace(/left|right|bottom|top/g, function (matched) { |
||
| 2309 | return hash[matched]; |
||
| 2310 | }); |
||
| 2311 | } |
||
| 2312 | |||
| 2313 | /** |
||
| 2314 | * Get offsets to the popper |
||
| 2315 | * @method |
||
| 2316 | * @memberof Popper.Utils |
||
| 2317 | * @param {Object} position - CSS position the Popper will get applied |
||
| 2318 | * @param {HTMLElement} popper - the popper element |
||
| 2319 | * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this) |
||
| 2320 | * @param {String} placement - one of the valid placement options |
||
| 2321 | * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper |
||
| 2322 | */ |
||
| 2323 | function getPopperOffsets(popper, referenceOffsets, placement) { |
||
| 2324 | placement = placement.split('-')[0]; |
||
| 2325 | |||
| 2326 | // Get popper node sizes |
||
| 2327 | var popperRect = getOuterSizes(popper); |
||
| 2328 | |||
| 2329 | // Add position, width and height to our offsets object |
||
| 2330 | var popperOffsets = { |
||
| 2331 | width: popperRect.width, |
||
| 2332 | height: popperRect.height |
||
| 2333 | }; |
||
| 2334 | |||
| 2335 | // depending by the popper placement we have to compute its offsets slightly differently |
||
| 2336 | var isHoriz = ['right', 'left'].indexOf(placement) !== -1; |
||
| 2337 | var mainSide = isHoriz ? 'top' : 'left'; |
||
| 2338 | var secondarySide = isHoriz ? 'left' : 'top'; |
||
| 2339 | var measurement = isHoriz ? 'height' : 'width'; |
||
| 2340 | var secondaryMeasurement = !isHoriz ? 'height' : 'width'; |
||
| 2341 | |||
| 2342 | popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2; |
||
| 2343 | if (placement === secondarySide) { |
||
| 2344 | popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement]; |
||
| 2345 | } else { |
||
| 2346 | popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)]; |
||
| 2347 | } |
||
| 2348 | |||
| 2349 | return popperOffsets; |
||
| 2350 | } |
||
| 2351 | |||
| 2352 | /** |
||
| 2353 | * Mimics the `find` method of Array |
||
| 2354 | * @method |
||
| 2355 | * @memberof Popper.Utils |
||
| 2356 | * @argument {Array} arr |
||
| 2357 | * @argument prop |
||
| 2358 | * @argument value |
||
| 2359 | * @returns index or -1 |
||
| 2360 | */ |
||
| 2361 | function find(arr, check) { |
||
| 2362 | // use native find if supported |
||
| 2363 | if (Array.prototype.find) { |
||
| 2364 | return arr.find(check); |
||
| 2365 | } |
||
| 2366 | |||
| 2367 | // use `filter` to obtain the same behavior of `find` |
||
| 2368 | return arr.filter(check)[0]; |
||
| 2369 | } |
||
| 2370 | |||
| 2371 | /** |
||
| 2372 | * Return the index of the matching object |
||
| 2373 | * @method |
||
| 2374 | * @memberof Popper.Utils |
||
| 2375 | * @argument {Array} arr |
||
| 2376 | * @argument prop |
||
| 2377 | * @argument value |
||
| 2378 | * @returns index or -1 |
||
| 2379 | */ |
||
| 2380 | function findIndex(arr, prop, value) { |
||
| 2381 | // use native findIndex if supported |
||
| 2382 | if (Array.prototype.findIndex) { |
||
| 2383 | return arr.findIndex(function (cur) { |
||
| 2384 | return cur[prop] === value; |
||
| 2385 | }); |
||
| 2386 | } |
||
| 2387 | |||
| 2388 | // use `find` + `indexOf` if `findIndex` isn't supported |
||
| 2389 | var match = find(arr, function (obj) { |
||
| 2390 | return obj[prop] === value; |
||
| 2391 | }); |
||
| 2392 | return arr.indexOf(match); |
||
| 2393 | } |
||
| 2394 | |||
| 2395 | /** |
||
| 2396 | * Loop trough the list of modifiers and run them in order, |
||
| 2397 | * each of them will then edit the data object. |
||
| 2398 | * @method |
||
| 2399 | * @memberof Popper.Utils |
||
| 2400 | * @param {dataObject} data |
||
| 2401 | * @param {Array} modifiers |
||
| 2402 | * @param {String} ends - Optional modifier name used as stopper |
||
| 2403 | * @returns {dataObject} |
||
| 2404 | */ |
||
| 2405 | function runModifiers(modifiers, data, ends) { |
||
| 2406 | var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends)); |
||
| 2407 | |||
| 2408 | modifiersToRun.forEach(function (modifier) { |
||
| 2409 | if (modifier['function']) { |
||
| 2410 | // eslint-disable-line dot-notation |
||
| 2411 | console.warn('`modifier.function` is deprecated, use `modifier.fn`!'); |
||
| 2412 | } |
||
| 2413 | var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation |
||
| 2414 | if (modifier.enabled && isFunction(fn)) { |
||
| 2415 | // Add properties to offsets to make them a complete clientRect object |
||
| 2416 | // we do this before each modifier to make sure the previous one doesn't |
||
| 2417 | // mess with these values |
||
| 2418 | data.offsets.popper = getClientRect(data.offsets.popper); |
||
| 2419 | data.offsets.reference = getClientRect(data.offsets.reference); |
||
| 2420 | |||
| 2421 | data = fn(data, modifier); |
||
| 2422 | } |
||
| 2423 | }); |
||
| 2424 | |||
| 2425 | return data; |
||
| 2426 | } |
||
| 2427 | |||
| 2428 | /** |
||
| 2429 | * Updates the position of the popper, computing the new offsets and applying |
||
| 2430 | * the new style.<br /> |
||
| 2431 | * Prefer `scheduleUpdate` over `update` because of performance reasons. |
||
| 2432 | * @method |
||
| 2433 | * @memberof Popper |
||
| 2434 | */ |
||
| 2435 | function update() { |
||
| 2436 | // if popper is destroyed, don't perform any further update |
||
| 2437 | if (this.state.isDestroyed) { |
||
| 2438 | return; |
||
| 2439 | } |
||
| 2440 | |||
| 2441 | var data = { |
||
| 2442 | instance: this, |
||
| 2443 | styles: {}, |
||
| 2444 | arrowStyles: {}, |
||
| 2445 | attributes: {}, |
||
| 2446 | flipped: false, |
||
| 2447 | offsets: {} |
||
| 2448 | }; |
||
| 2449 | |||
| 2450 | // compute reference element offsets |
||
| 2451 | data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed); |
||
| 2452 | |||
| 2453 | // compute auto placement, store placement inside the data object, |
||
| 2454 | // modifiers will be able to edit `placement` if needed |
||
| 2455 | // and refer to originalPlacement to know the original value |
||
| 2456 | data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding); |
||
| 2457 | |||
| 2458 | // store the computed placement inside `originalPlacement` |
||
| 2459 | data.originalPlacement = data.placement; |
||
| 2460 | |||
| 2461 | data.positionFixed = this.options.positionFixed; |
||
| 2462 | |||
| 2463 | // compute the popper offsets |
||
| 2464 | data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement); |
||
| 2465 | |||
| 2466 | data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute'; |
||
| 2467 | |||
| 2468 | // run the modifiers |
||
| 2469 | data = runModifiers(this.modifiers, data); |
||
| 2470 | |||
| 2471 | // the first `update` will call `onCreate` callback |
||
| 2472 | // the other ones will call `onUpdate` callback |
||
| 2473 | if (!this.state.isCreated) { |
||
| 2474 | this.state.isCreated = true; |
||
| 2475 | this.options.onCreate(data); |
||
| 2476 | } else { |
||
| 2477 | this.options.onUpdate(data); |
||
| 2478 | } |
||
| 2479 | } |
||
| 2480 | |||
| 2481 | /** |
||
| 2482 | * Helper used to know if the given modifier is enabled. |
||
| 2483 | * @method |
||
| 2484 | * @memberof Popper.Utils |
||
| 2485 | * @returns {Boolean} |
||
| 2486 | */ |
||
| 2487 | function isModifierEnabled(modifiers, modifierName) { |
||
| 2488 | return modifiers.some(function (_ref) { |
||
| 2489 | var name = _ref.name, |
||
| 2490 | enabled = _ref.enabled; |
||
| 2491 | return enabled && name === modifierName; |
||
| 2492 | }); |
||
| 2493 | } |
||
| 2494 | |||
| 2495 | /** |
||
| 2496 | * Get the prefixed supported property name |
||
| 2497 | * @method |
||
| 2498 | * @memberof Popper.Utils |
||
| 2499 | * @argument {String} property (camelCase) |
||
| 2500 | * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix) |
||
| 2501 | */ |
||
| 2502 | function getSupportedPropertyName(property) { |
||
| 2503 | var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O']; |
||
| 2504 | var upperProp = property.charAt(0).toUpperCase() + property.slice(1); |
||
| 2505 | |||
| 2506 | for (var i = 0; i < prefixes.length; i++) { |
||
| 2507 | var prefix = prefixes[i]; |
||
| 2508 | var toCheck = prefix ? '' + prefix + upperProp : property; |
||
| 2509 | if (typeof document.body.style[toCheck] !== 'undefined') { |
||
| 2510 | return toCheck; |
||
| 2511 | } |
||
| 2512 | } |
||
| 2513 | return null; |
||
| 2514 | } |
||
| 2515 | |||
| 2516 | /** |
||
| 2517 | * Destroys the popper. |
||
| 2518 | * @method |
||
| 2519 | * @memberof Popper |
||
| 2520 | */ |
||
| 2521 | function destroy() { |
||
| 2522 | this.state.isDestroyed = true; |
||
| 2523 | |||
| 2524 | // touch DOM only if `applyStyle` modifier is enabled |
||
| 2525 | if (isModifierEnabled(this.modifiers, 'applyStyle')) { |
||
| 2526 | this.popper.removeAttribute('x-placement'); |
||
| 2527 | this.popper.style.position = ''; |
||
| 2528 | this.popper.style.top = ''; |
||
| 2529 | this.popper.style.left = ''; |
||
| 2530 | this.popper.style.right = ''; |
||
| 2531 | this.popper.style.bottom = ''; |
||
| 2532 | this.popper.style.willChange = ''; |
||
| 2533 | this.popper.style[getSupportedPropertyName('transform')] = ''; |
||
| 2534 | } |
||
| 2535 | |||
| 2536 | this.disableEventListeners(); |
||
| 2537 | |||
| 2538 | // remove the popper if user explicitly asked for the deletion on destroy |
||
| 2539 | // do not use `remove` because IE11 doesn't support it |
||
| 2540 | if (this.options.removeOnDestroy) { |
||
| 2541 | this.popper.parentNode.removeChild(this.popper); |
||
| 2542 | } |
||
| 2543 | return this; |
||
| 2544 | } |
||
| 2545 | |||
| 2546 | /** |
||
| 2547 | * Get the window associated with the element |
||
| 2548 | * @argument {Element} element |
||
| 2549 | * @returns {Window} |
||
| 2550 | */ |
||
| 2551 | function getWindow(element) { |
||
| 2552 | var ownerDocument = element.ownerDocument; |
||
| 2553 | return ownerDocument ? ownerDocument.defaultView : window; |
||
| 2554 | } |
||
| 2555 | |||
| 2556 | function attachToScrollParents(scrollParent, event, callback, scrollParents) { |
||
| 2557 | var isBody = scrollParent.nodeName === 'BODY'; |
||
| 2558 | var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent; |
||
| 2559 | target.addEventListener(event, callback, { passive: true }); |
||
| 2560 | |||
| 2561 | if (!isBody) { |
||
| 2562 | attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents); |
||
| 2563 | } |
||
| 2564 | scrollParents.push(target); |
||
| 2565 | } |
||
| 2566 | |||
| 2567 | /** |
||
| 2568 | * Setup needed event listeners used to update the popper position |
||
| 2569 | * @method |
||
| 2570 | * @memberof Popper.Utils |
||
| 2571 | * @private |
||
| 2572 | */ |
||
| 2573 | function setupEventListeners(reference, options, state, updateBound) { |
||
| 2574 | // Resize event listener on window |
||
| 2575 | state.updateBound = updateBound; |
||
| 2576 | getWindow(reference).addEventListener('resize', state.updateBound, { passive: true }); |
||
| 2577 | |||
| 2578 | // Scroll event listener on scroll parents |
||
| 2579 | var scrollElement = getScrollParent(reference); |
||
| 2580 | attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents); |
||
| 2581 | state.scrollElement = scrollElement; |
||
| 2582 | state.eventsEnabled = true; |
||
| 2583 | |||
| 2584 | return state; |
||
| 2585 | } |
||
| 2586 | |||
| 2587 | /** |
||
| 2588 | * It will add resize/scroll events and start recalculating |
||
| 2589 | * position of the popper element when they are triggered. |
||
| 2590 | * @method |
||
| 2591 | * @memberof Popper |
||
| 2592 | */ |
||
| 2593 | function enableEventListeners() { |
||
| 2594 | if (!this.state.eventsEnabled) { |
||
| 2595 | this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate); |
||
| 2596 | } |
||
| 2597 | } |
||
| 2598 | |||
| 2599 | /** |
||
| 2600 | * Remove event listeners used to update the popper position |
||
| 2601 | * @method |
||
| 2602 | * @memberof Popper.Utils |
||
| 2603 | * @private |
||
| 2604 | */ |
||
| 2605 | function removeEventListeners(reference, state) { |
||
| 2606 | // Remove resize event listener on window |
||
| 2607 | getWindow(reference).removeEventListener('resize', state.updateBound); |
||
| 2608 | |||
| 2609 | // Remove scroll event listener on scroll parents |
||
| 2610 | state.scrollParents.forEach(function (target) { |
||
| 2611 | target.removeEventListener('scroll', state.updateBound); |
||
| 2612 | }); |
||
| 2613 | |||
| 2614 | // Reset state |
||
| 2615 | state.updateBound = null; |
||
| 2616 | state.scrollParents = []; |
||
| 2617 | state.scrollElement = null; |
||
| 2618 | state.eventsEnabled = false; |
||
| 2619 | return state; |
||
| 2620 | } |
||
| 2621 | |||
| 2622 | /** |
||
| 2623 | * It will remove resize/scroll events and won't recalculate popper position |
||
| 2624 | * when they are triggered. It also won't trigger `onUpdate` callback anymore, |
||
| 2625 | * unless you call `update` method manually. |
||
| 2626 | * @method |
||
| 2627 | * @memberof Popper |
||
| 2628 | */ |
||
| 2629 | function disableEventListeners() { |
||
| 2630 | if (this.state.eventsEnabled) { |
||
| 2631 | cancelAnimationFrame(this.scheduleUpdate); |
||
| 2632 | this.state = removeEventListeners(this.reference, this.state); |
||
| 2633 | } |
||
| 2634 | } |
||
| 2635 | |||
| 2636 | /** |
||
| 2637 | * Tells if a given input is a number |
||
| 2638 | * @method |
||
| 2639 | * @memberof Popper.Utils |
||
| 2640 | * @param {*} input to check |
||
| 2641 | * @return {Boolean} |
||
| 2642 | */ |
||
| 2643 | function isNumeric(n) { |
||
| 2644 | return n !== '' && !isNaN(parseFloat(n)) && isFinite(n); |
||
| 2645 | } |
||
| 2646 | |||
| 2647 | /** |
||
| 2648 | * Set the style to the given popper |
||
| 2649 | * @method |
||
| 2650 | * @memberof Popper.Utils |
||
| 2651 | * @argument {Element} element - Element to apply the style to |
||
| 2652 | * @argument {Object} styles |
||
| 2653 | * Object with a list of properties and values which will be applied to the element |
||
| 2654 | */ |
||
| 2655 | function setStyles(element, styles) { |
||
| 2656 | Object.keys(styles).forEach(function (prop) { |
||
| 2657 | var unit = ''; |
||
| 2658 | // add unit if the value is numeric and is one of the following |
||
| 2659 | if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) { |
||
| 2660 | unit = 'px'; |
||
| 2661 | } |
||
| 2662 | element.style[prop] = styles[prop] + unit; |
||
| 2663 | }); |
||
| 2664 | } |
||
| 2665 | |||
| 2666 | /** |
||
| 2667 | * Set the attributes to the given popper |
||
| 2668 | * @method |
||
| 2669 | * @memberof Popper.Utils |
||
| 2670 | * @argument {Element} element - Element to apply the attributes to |
||
| 2671 | * @argument {Object} styles |
||
| 2672 | * Object with a list of properties and values which will be applied to the element |
||
| 2673 | */ |
||
| 2674 | function setAttributes(element, attributes) { |
||
| 2675 | Object.keys(attributes).forEach(function (prop) { |
||
| 2676 | var value = attributes[prop]; |
||
| 2677 | if (value !== false) { |
||
| 2678 | element.setAttribute(prop, attributes[prop]); |
||
| 2679 | } else { |
||
| 2680 | element.removeAttribute(prop); |
||
| 2681 | } |
||
| 2682 | }); |
||
| 2683 | } |
||
| 2684 | |||
| 2685 | /** |
||
| 2686 | * @function |
||
| 2687 | * @memberof Modifiers |
||
| 2688 | * @argument {Object} data - The data object generated by `update` method |
||
| 2689 | * @argument {Object} data.styles - List of style properties - values to apply to popper element |
||
| 2690 | * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element |
||
| 2691 | * @argument {Object} options - Modifiers configuration and options |
||
| 2692 | * @returns {Object} The same data object |
||
| 2693 | */ |
||
| 2694 | function applyStyle(data) { |
||
| 2695 | // any property present in `data.styles` will be applied to the popper, |
||
| 2696 | // in this way we can make the 3rd party modifiers add custom styles to it |
||
| 2697 | // Be aware, modifiers could override the properties defined in the previous |
||
| 2698 | // lines of this modifier! |
||
| 2699 | setStyles(data.instance.popper, data.styles); |
||
| 2700 | |||
| 2701 | // any property present in `data.attributes` will be applied to the popper, |
||
| 2702 | // they will be set as HTML attributes of the element |
||
| 2703 | setAttributes(data.instance.popper, data.attributes); |
||
| 2704 | |||
| 2705 | // if arrowElement is defined and arrowStyles has some properties |
||
| 2706 | if (data.arrowElement && Object.keys(data.arrowStyles).length) { |
||
| 2707 | setStyles(data.arrowElement, data.arrowStyles); |
||
| 2708 | } |
||
| 2709 | |||
| 2710 | return data; |
||
| 2711 | } |
||
| 2712 | |||
| 2713 | /** |
||
| 2714 | * Set the x-placement attribute before everything else because it could be used |
||
| 2715 | * to add margins to the popper margins needs to be calculated to get the |
||
| 2716 | * correct popper offsets. |
||
| 2717 | * @method |
||
| 2718 | * @memberof Popper.modifiers |
||
| 2719 | * @param {HTMLElement} reference - The reference element used to position the popper |
||
| 2720 | * @param {HTMLElement} popper - The HTML element used as popper |
||
| 2721 | * @param {Object} options - Popper.js options |
||
| 2722 | */ |
||
| 2723 | function applyStyleOnLoad(reference, popper, options, modifierOptions, state) { |
||
| 2724 | // compute reference element offsets |
||
| 2725 | var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed); |
||
| 2726 | |||
| 2727 | // compute auto placement, store placement inside the data object, |
||
| 2728 | // modifiers will be able to edit `placement` if needed |
||
| 2729 | // and refer to originalPlacement to know the original value |
||
| 2730 | var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding); |
||
| 2731 | |||
| 2732 | popper.setAttribute('x-placement', placement); |
||
| 2733 | |||
| 2734 | // Apply `position` to popper before anything else because |
||
| 2735 | // without the position applied we can't guarantee correct computations |
||
| 2736 | setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' }); |
||
| 2737 | |||
| 2738 | return options; |
||
| 2739 | } |
||
| 2740 | |||
| 2741 | /** |
||
| 2742 | * @function |
||
| 2743 | * @memberof Popper.Utils |
||
| 2744 | * @argument {Object} data - The data object generated by `update` method |
||
| 2745 | * @argument {Boolean} shouldRound - If the offsets should be rounded at all |
||
| 2746 | * @returns {Object} The popper's position offsets rounded |
||
| 2747 | * |
||
| 2748 | * The tale of pixel-perfect positioning. It's still not 100% perfect, but as |
||
| 2749 | * good as it can be within reason. |
||
| 2750 | * Discussion here: https://github.com/FezVrasta/popper.js/pull/715 |
||
| 2751 | * |
||
| 2752 | * Low DPI screens cause a popper to be blurry if not using full pixels (Safari |
||
| 2753 | * as well on High DPI screens). |
||
| 2754 | * |
||
| 2755 | * Firefox prefers no rounding for positioning and does not have blurriness on |
||
| 2756 | * high DPI screens. |
||
| 2757 | * |
||
| 2758 | * Only horizontal placement and left/right values need to be considered. |
||
| 2759 | */ |
||
| 2760 | function getRoundedOffsets(data, shouldRound) { |
||
| 2761 | var _data$offsets = data.offsets, |
||
| 2762 | popper = _data$offsets.popper, |
||
| 2763 | reference = _data$offsets.reference; |
||
| 2764 | var round = Math.round, |
||
| 2765 | floor = Math.floor; |
||
| 2766 | |||
| 2767 | var noRound = function noRound(v) { |
||
| 2768 | return v; |
||
| 2769 | }; |
||
| 2770 | |||
| 2771 | var referenceWidth = round(reference.width); |
||
| 2772 | var popperWidth = round(popper.width); |
||
| 2773 | |||
| 2774 | var isVertical = ['left', 'right'].indexOf(data.placement) !== -1; |
||
| 2775 | var isVariation = data.placement.indexOf('-') !== -1; |
||
| 2776 | var sameWidthParity = referenceWidth % 2 === popperWidth % 2; |
||
| 2777 | var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1; |
||
| 2778 | |||
| 2779 | var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor; |
||
| 2780 | var verticalToInteger = !shouldRound ? noRound : round; |
||
| 2781 | |||
| 2782 | return { |
||
| 2783 | left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left), |
||
| 2784 | top: verticalToInteger(popper.top), |
||
| 2785 | bottom: verticalToInteger(popper.bottom), |
||
| 2786 | right: horizontalToInteger(popper.right) |
||
| 2787 | }; |
||
| 2788 | } |
||
| 2789 | |||
| 2790 | var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent); |
||
| 2791 | |||
| 2792 | /** |
||
| 2793 | * @function |
||
| 2794 | * @memberof Modifiers |
||
| 2795 | * @argument {Object} data - The data object generated by `update` method |
||
| 2796 | * @argument {Object} options - Modifiers configuration and options |
||
| 2797 | * @returns {Object} The data object, properly modified |
||
| 2798 | */ |
||
| 2799 | function computeStyle(data, options) { |
||
| 2800 | var x = options.x, |
||
| 2801 | y = options.y; |
||
| 2802 | var popper = data.offsets.popper; |
||
| 2803 | |||
| 2804 | // Remove this legacy support in Popper.js v2 |
||
| 2805 | |||
| 2806 | var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) { |
||
| 2807 | return modifier.name === 'applyStyle'; |
||
| 2808 | }).gpuAcceleration; |
||
| 2809 | if (legacyGpuAccelerationOption !== undefined) { |
||
| 2810 | console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!'); |
||
| 2811 | } |
||
| 2812 | var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration; |
||
| 2813 | |||
| 2814 | var offsetParent = getOffsetParent(data.instance.popper); |
||
| 2815 | var offsetParentRect = getBoundingClientRect(offsetParent); |
||
| 2816 | |||
| 2817 | // Styles |
||
| 2818 | var styles = { |
||
| 2819 | position: popper.position |
||
| 2820 | }; |
||
| 2821 | |||
| 2822 | var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox); |
||
| 2823 | |||
| 2824 | var sideA = x === 'bottom' ? 'top' : 'bottom'; |
||
| 2825 | var sideB = y === 'right' ? 'left' : 'right'; |
||
| 2826 | |||
| 2827 | // if gpuAcceleration is set to `true` and transform is supported, |
||
| 2828 | // we use `translate3d` to apply the position to the popper we |
||
| 2829 | // automatically use the supported prefixed version if needed |
||
| 2830 | var prefixedProperty = getSupportedPropertyName('transform'); |
||
| 2831 | |||
| 2832 | // now, let's make a step back and look at this code closely (wtf?) |
||
| 2833 | // If the content of the popper grows once it's been positioned, it |
||
| 2834 | // may happen that the popper gets misplaced because of the new content |
||
| 2835 | // overflowing its reference element |
||
| 2836 | // To avoid this problem, we provide two options (x and y), which allow |
||
| 2837 | // the consumer to define the offset origin. |
||
| 2838 | // If we position a popper on top of a reference element, we can set |
||
| 2839 | // `x` to `top` to make the popper grow towards its top instead of |
||
| 2840 | // its bottom. |
||
| 2841 | var left = void 0, |
||
| 2842 | top = void 0; |
||
| 2843 | if (sideA === 'bottom') { |
||
| 2844 | // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar) |
||
| 2845 | // and not the bottom of the html element |
||
| 2846 | if (offsetParent.nodeName === 'HTML') { |
||
| 2847 | top = -offsetParent.clientHeight + offsets.bottom; |
||
| 2848 | } else { |
||
| 2849 | top = -offsetParentRect.height + offsets.bottom; |
||
| 2850 | } |
||
| 2851 | } else { |
||
| 2852 | top = offsets.top; |
||
| 2853 | } |
||
| 2854 | if (sideB === 'right') { |
||
| 2855 | if (offsetParent.nodeName === 'HTML') { |
||
| 2856 | left = -offsetParent.clientWidth + offsets.right; |
||
| 2857 | } else { |
||
| 2858 | left = -offsetParentRect.width + offsets.right; |
||
| 2859 | } |
||
| 2860 | } else { |
||
| 2861 | left = offsets.left; |
||
| 2862 | } |
||
| 2863 | if (gpuAcceleration && prefixedProperty) { |
||
| 2864 | styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)'; |
||
| 2865 | styles[sideA] = 0; |
||
| 2866 | styles[sideB] = 0; |
||
| 2867 | styles.willChange = 'transform'; |
||
| 2868 | } else { |
||
| 2869 | // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties |
||
| 2870 | var invertTop = sideA === 'bottom' ? -1 : 1; |
||
| 2871 | var invertLeft = sideB === 'right' ? -1 : 1; |
||
| 2872 | styles[sideA] = top * invertTop; |
||
| 2873 | styles[sideB] = left * invertLeft; |
||
| 2874 | styles.willChange = sideA + ', ' + sideB; |
||
| 2875 | } |
||
| 2876 | |||
| 2877 | // Attributes |
||
| 2878 | var attributes = { |
||
| 2879 | 'x-placement': data.placement |
||
| 2880 | }; |
||
| 2881 | |||
| 2882 | // Update `data` attributes, styles and arrowStyles |
||
| 2883 | data.attributes = _extends$1({}, attributes, data.attributes); |
||
| 2884 | data.styles = _extends$1({}, styles, data.styles); |
||
| 2885 | data.arrowStyles = _extends$1({}, data.offsets.arrow, data.arrowStyles); |
||
| 2886 | |||
| 2887 | return data; |
||
| 2888 | } |
||
| 2889 | |||
| 2890 | /** |
||
| 2891 | * Helper used to know if the given modifier depends from another one.<br /> |
||
| 2892 | * It checks if the needed modifier is listed and enabled. |
||
| 2893 | * @method |
||
| 2894 | * @memberof Popper.Utils |
||
| 2895 | * @param {Array} modifiers - list of modifiers |
||
| 2896 | * @param {String} requestingName - name of requesting modifier |
||
| 2897 | * @param {String} requestedName - name of requested modifier |
||
| 2898 | * @returns {Boolean} |
||
| 2899 | */ |
||
| 2900 | function isModifierRequired(modifiers, requestingName, requestedName) { |
||
| 2901 | var requesting = find(modifiers, function (_ref) { |
||
| 2902 | var name = _ref.name; |
||
| 2903 | return name === requestingName; |
||
| 2904 | }); |
||
| 2905 | |||
| 2906 | var isRequired = !!requesting && modifiers.some(function (modifier) { |
||
| 2907 | return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order; |
||
| 2908 | }); |
||
| 2909 | |||
| 2910 | if (!isRequired) { |
||
| 2911 | var _requesting = '`' + requestingName + '`'; |
||
| 2912 | var requested = '`' + requestedName + '`'; |
||
| 2913 | console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!'); |
||
| 2914 | } |
||
| 2915 | return isRequired; |
||
| 2916 | } |
||
| 2917 | |||
| 2918 | /** |
||
| 2919 | * @function |
||
| 2920 | * @memberof Modifiers |
||
| 2921 | * @argument {Object} data - The data object generated by update method |
||
| 2922 | * @argument {Object} options - Modifiers configuration and options |
||
| 2923 | * @returns {Object} The data object, properly modified |
||
| 2924 | */ |
||
| 2925 | function arrow(data, options) { |
||
| 2926 | var _data$offsets$arrow; |
||
| 2927 | |||
| 2928 | // arrow depends on keepTogether in order to work |
||
| 2929 | if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) { |
||
| 2930 | return data; |
||
| 2931 | } |
||
| 2932 | |||
| 2933 | var arrowElement = options.element; |
||
| 2934 | |||
| 2935 | // if arrowElement is a string, suppose it's a CSS selector |
||
| 2936 | if (typeof arrowElement === 'string') { |
||
| 2937 | arrowElement = data.instance.popper.querySelector(arrowElement); |
||
| 2938 | |||
| 2939 | // if arrowElement is not found, don't run the modifier |
||
| 2940 | if (!arrowElement) { |
||
| 2941 | return data; |
||
| 2942 | } |
||
| 2943 | } else { |
||
| 2944 | // if the arrowElement isn't a query selector we must check that the |
||
| 2945 | // provided DOM node is child of its popper node |
||
| 2946 | if (!data.instance.popper.contains(arrowElement)) { |
||
| 2947 | console.warn('WARNING: `arrow.element` must be child of its popper element!'); |
||
| 2948 | return data; |
||
| 2949 | } |
||
| 2950 | } |
||
| 2951 | |||
| 2952 | var placement = data.placement.split('-')[0]; |
||
| 2953 | var _data$offsets = data.offsets, |
||
| 2954 | popper = _data$offsets.popper, |
||
| 2955 | reference = _data$offsets.reference; |
||
| 2956 | |||
| 2957 | var isVertical = ['left', 'right'].indexOf(placement) !== -1; |
||
| 2958 | |||
| 2959 | var len = isVertical ? 'height' : 'width'; |
||
| 2960 | var sideCapitalized = isVertical ? 'Top' : 'Left'; |
||
| 2961 | var side = sideCapitalized.toLowerCase(); |
||
| 2962 | var altSide = isVertical ? 'left' : 'top'; |
||
| 2963 | var opSide = isVertical ? 'bottom' : 'right'; |
||
| 2964 | var arrowElementSize = getOuterSizes(arrowElement)[len]; |
||
| 2965 | |||
| 2966 | // |
||
| 2967 | // extends keepTogether behavior making sure the popper and its |
||
| 2968 | // reference have enough pixels in conjunction |
||
| 2969 | // |
||
| 2970 | |||
| 2971 | // top/left side |
||
| 2972 | if (reference[opSide] - arrowElementSize < popper[side]) { |
||
| 2973 | data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize); |
||
| 2974 | } |
||
| 2975 | // bottom/right side |
||
| 2976 | if (reference[side] + arrowElementSize > popper[opSide]) { |
||
| 2977 | data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide]; |
||
| 2978 | } |
||
| 2979 | data.offsets.popper = getClientRect(data.offsets.popper); |
||
| 2980 | |||
| 2981 | // compute center of the popper |
||
| 2982 | var center = reference[side] + reference[len] / 2 - arrowElementSize / 2; |
||
| 2983 | |||
| 2984 | // Compute the sideValue using the updated popper offsets |
||
| 2985 | // take popper margin in account because we don't have this info available |
||
| 2986 | var css = getStyleComputedProperty(data.instance.popper); |
||
| 2987 | var popperMarginSide = parseFloat(css['margin' + sideCapitalized]); |
||
| 2988 | var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']); |
||
| 2989 | var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide; |
||
| 2990 | |||
| 2991 | // prevent arrowElement from being placed not contiguously to its popper |
||
| 2992 | sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0); |
||
| 2993 | |||
| 2994 | data.arrowElement = arrowElement; |
||
| 2995 | data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow); |
||
| 2996 | |||
| 2997 | return data; |
||
| 2998 | } |
||
| 2999 | |||
| 3000 | /** |
||
| 3001 | * Get the opposite placement variation of the given one |
||
| 3002 | * @method |
||
| 3003 | * @memberof Popper.Utils |
||
| 3004 | * @argument {String} placement variation |
||
| 3005 | * @returns {String} flipped placement variation |
||
| 3006 | */ |
||
| 3007 | function getOppositeVariation(variation) { |
||
| 3008 | if (variation === 'end') { |
||
| 3009 | return 'start'; |
||
| 3010 | } else if (variation === 'start') { |
||
| 3011 | return 'end'; |
||
| 3012 | } |
||
| 3013 | return variation; |
||
| 3014 | } |
||
| 3015 | |||
| 3016 | /** |
||
| 3017 | * List of accepted placements to use as values of the `placement` option.<br /> |
||
| 3018 | * Valid placements are: |
||
| 3019 | * - `auto` |
||
| 3020 | * - `top` |
||
| 3021 | * - `right` |
||
| 3022 | * - `bottom` |
||
| 3023 | * - `left` |
||
| 3024 | * |
||
| 3025 | * Each placement can have a variation from this list: |
||
| 3026 | * - `-start` |
||
| 3027 | * - `-end` |
||
| 3028 | * |
||
| 3029 | * Variations are interpreted easily if you think of them as the left to right |
||
| 3030 | * written languages. Horizontally (`top` and `bottom`), `start` is left and `end` |
||
| 3031 | * is right.<br /> |
||
| 3032 | * Vertically (`left` and `right`), `start` is top and `end` is bottom. |
||
| 3033 | * |
||
| 3034 | * Some valid examples are: |
||
| 3035 | * - `top-end` (on top of reference, right aligned) |
||
| 3036 | * - `right-start` (on right of reference, top aligned) |
||
| 3037 | * - `bottom` (on bottom, centered) |
||
| 3038 | * - `auto-end` (on the side with more space available, alignment depends by placement) |
||
| 3039 | * |
||
| 3040 | * @static |
||
| 3041 | * @type {Array} |
||
| 3042 | * @enum {String} |
||
| 3043 | * @readonly |
||
| 3044 | * @method placements |
||
| 3045 | * @memberof Popper |
||
| 3046 | */ |
||
| 3047 | var placements = ['auto-start', 'auto', 'auto-end', 'top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-end', 'bottom', 'bottom-start', 'left-end', 'left', 'left-start']; |
||
| 3048 | |||
| 3049 | // Get rid of `auto` `auto-start` and `auto-end` |
||
| 3050 | var validPlacements = placements.slice(3); |
||
| 3051 | |||
| 3052 | /** |
||
| 3053 | * Given an initial placement, returns all the subsequent placements |
||
| 3054 | * clockwise (or counter-clockwise). |
||
| 3055 | * |
||
| 3056 | * @method |
||
| 3057 | * @memberof Popper.Utils |
||
| 3058 | * @argument {String} placement - A valid placement (it accepts variations) |
||
| 3059 | * @argument {Boolean} counter - Set to true to walk the placements counterclockwise |
||
| 3060 | * @returns {Array} placements including their variations |
||
| 3061 | */ |
||
| 3062 | function clockwise(placement) { |
||
| 3063 | var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
||
| 3064 | |||
| 3065 | var index = validPlacements.indexOf(placement); |
||
| 3066 | var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index)); |
||
| 3067 | return counter ? arr.reverse() : arr; |
||
| 3068 | } |
||
| 3069 | |||
| 3070 | var BEHAVIORS = { |
||
| 3071 | FLIP: 'flip', |
||
| 3072 | CLOCKWISE: 'clockwise', |
||
| 3073 | COUNTERCLOCKWISE: 'counterclockwise' |
||
| 3074 | }; |
||
| 3075 | |||
| 3076 | /** |
||
| 3077 | * @function |
||
| 3078 | * @memberof Modifiers |
||
| 3079 | * @argument {Object} data - The data object generated by update method |
||
| 3080 | * @argument {Object} options - Modifiers configuration and options |
||
| 3081 | * @returns {Object} The data object, properly modified |
||
| 3082 | */ |
||
| 3083 | function flip(data, options) { |
||
| 3084 | // if `inner` modifier is enabled, we can't use the `flip` modifier |
||
| 3085 | if (isModifierEnabled(data.instance.modifiers, 'inner')) { |
||
| 3086 | return data; |
||
| 3087 | } |
||
| 3088 | |||
| 3089 | if (data.flipped && data.placement === data.originalPlacement) { |
||
| 3090 | // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides |
||
| 3091 | return data; |
||
| 3092 | } |
||
| 3093 | |||
| 3094 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed); |
||
| 3095 | |||
| 3096 | var placement = data.placement.split('-')[0]; |
||
| 3097 | var placementOpposite = getOppositePlacement(placement); |
||
| 3098 | var variation = data.placement.split('-')[1] || ''; |
||
| 3099 | |||
| 3100 | var flipOrder = []; |
||
| 3101 | |||
| 3102 | switch (options.behavior) { |
||
| 3103 | case BEHAVIORS.FLIP: |
||
| 3104 | flipOrder = [placement, placementOpposite]; |
||
| 3105 | break; |
||
| 3106 | case BEHAVIORS.CLOCKWISE: |
||
| 3107 | flipOrder = clockwise(placement); |
||
| 3108 | break; |
||
| 3109 | case BEHAVIORS.COUNTERCLOCKWISE: |
||
| 3110 | flipOrder = clockwise(placement, true); |
||
| 3111 | break; |
||
| 3112 | default: |
||
| 3113 | flipOrder = options.behavior; |
||
| 3114 | } |
||
| 3115 | |||
| 3116 | flipOrder.forEach(function (step, index) { |
||
| 3117 | if (placement !== step || flipOrder.length === index + 1) { |
||
| 3118 | return data; |
||
| 3119 | } |
||
| 3120 | |||
| 3121 | placement = data.placement.split('-')[0]; |
||
| 3122 | placementOpposite = getOppositePlacement(placement); |
||
| 3123 | |||
| 3124 | var popperOffsets = data.offsets.popper; |
||
| 3125 | var refOffsets = data.offsets.reference; |
||
| 3126 | |||
| 3127 | // using floor because the reference offsets may contain decimals we are not going to consider here |
||
| 3128 | var floor = Math.floor; |
||
| 3129 | var overlapsRef = placement === 'left' && floor(popperOffsets.right) > floor(refOffsets.left) || placement === 'right' && floor(popperOffsets.left) < floor(refOffsets.right) || placement === 'top' && floor(popperOffsets.bottom) > floor(refOffsets.top) || placement === 'bottom' && floor(popperOffsets.top) < floor(refOffsets.bottom); |
||
| 3130 | |||
| 3131 | var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left); |
||
| 3132 | var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right); |
||
| 3133 | var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top); |
||
| 3134 | var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom); |
||
| 3135 | |||
| 3136 | var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom; |
||
| 3137 | |||
| 3138 | // flip the variation if required |
||
| 3139 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; |
||
| 3140 | |||
| 3141 | // flips variation if reference element overflows boundaries |
||
| 3142 | var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom); |
||
| 3143 | |||
| 3144 | // flips variation if popper content overflows boundaries |
||
| 3145 | var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop); |
||
| 3146 | |||
| 3147 | var flippedVariation = flippedVariationByRef || flippedVariationByContent; |
||
| 3148 | |||
| 3149 | if (overlapsRef || overflowsBoundaries || flippedVariation) { |
||
| 3150 | // this boolean to detect any flip loop |
||
| 3151 | data.flipped = true; |
||
| 3152 | |||
| 3153 | if (overlapsRef || overflowsBoundaries) { |
||
| 3154 | placement = flipOrder[index + 1]; |
||
| 3155 | } |
||
| 3156 | |||
| 3157 | if (flippedVariation) { |
||
| 3158 | variation = getOppositeVariation(variation); |
||
| 3159 | } |
||
| 3160 | |||
| 3161 | data.placement = placement + (variation ? '-' + variation : ''); |
||
| 3162 | |||
| 3163 | // this object contains `position`, we want to preserve it along with |
||
| 3164 | // any additional property we may add in the future |
||
| 3165 | data.offsets.popper = _extends$1({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement)); |
||
| 3166 | |||
| 3167 | data = runModifiers(data.instance.modifiers, data, 'flip'); |
||
| 3168 | } |
||
| 3169 | }); |
||
| 3170 | return data; |
||
| 3171 | } |
||
| 3172 | |||
| 3173 | /** |
||
| 3174 | * @function |
||
| 3175 | * @memberof Modifiers |
||
| 3176 | * @argument {Object} data - The data object generated by update method |
||
| 3177 | * @argument {Object} options - Modifiers configuration and options |
||
| 3178 | * @returns {Object} The data object, properly modified |
||
| 3179 | */ |
||
| 3180 | function keepTogether(data) { |
||
| 3181 | var _data$offsets = data.offsets, |
||
| 3182 | popper = _data$offsets.popper, |
||
| 3183 | reference = _data$offsets.reference; |
||
| 3184 | |||
| 3185 | var placement = data.placement.split('-')[0]; |
||
| 3186 | var floor = Math.floor; |
||
| 3187 | var isVertical = ['top', 'bottom'].indexOf(placement) !== -1; |
||
| 3188 | var side = isVertical ? 'right' : 'bottom'; |
||
| 3189 | var opSide = isVertical ? 'left' : 'top'; |
||
| 3190 | var measurement = isVertical ? 'width' : 'height'; |
||
| 3191 | |||
| 3192 | if (popper[side] < floor(reference[opSide])) { |
||
| 3193 | data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement]; |
||
| 3194 | } |
||
| 3195 | if (popper[opSide] > floor(reference[side])) { |
||
| 3196 | data.offsets.popper[opSide] = floor(reference[side]); |
||
| 3197 | } |
||
| 3198 | |||
| 3199 | return data; |
||
| 3200 | } |
||
| 3201 | |||
| 3202 | /** |
||
| 3203 | * Converts a string containing value + unit into a px value number |
||
| 3204 | * @function |
||
| 3205 | * @memberof {modifiers~offset} |
||
| 3206 | * @private |
||
| 3207 | * @argument {String} str - Value + unit string |
||
| 3208 | * @argument {String} measurement - `height` or `width` |
||
| 3209 | * @argument {Object} popperOffsets |
||
| 3210 | * @argument {Object} referenceOffsets |
||
| 3211 | * @returns {Number|String} |
||
| 3212 | * Value in pixels, or original string if no values were extracted |
||
| 3213 | */ |
||
| 3214 | function toValue(str, measurement, popperOffsets, referenceOffsets) { |
||
| 3215 | // separate value from unit |
||
| 3216 | var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/); |
||
| 3217 | var value = +split[1]; |
||
| 3218 | var unit = split[2]; |
||
| 3219 | |||
| 3220 | // If it's not a number it's an operator, I guess |
||
| 3221 | if (!value) { |
||
| 3222 | return str; |
||
| 3223 | } |
||
| 3224 | |||
| 3225 | if (unit.indexOf('%') === 0) { |
||
| 3226 | var element = void 0; |
||
| 3227 | switch (unit) { |
||
| 3228 | case '%p': |
||
| 3229 | element = popperOffsets; |
||
| 3230 | break; |
||
| 3231 | case '%': |
||
| 3232 | case '%r': |
||
| 3233 | default: |
||
| 3234 | element = referenceOffsets; |
||
| 3235 | } |
||
| 3236 | |||
| 3237 | var rect = getClientRect(element); |
||
| 3238 | return rect[measurement] / 100 * value; |
||
| 3239 | } else if (unit === 'vh' || unit === 'vw') { |
||
| 3240 | // if is a vh or vw, we calculate the size based on the viewport |
||
| 3241 | var size = void 0; |
||
| 3242 | if (unit === 'vh') { |
||
| 3243 | size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); |
||
| 3244 | } else { |
||
| 3245 | size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); |
||
| 3246 | } |
||
| 3247 | return size / 100 * value; |
||
| 3248 | } else { |
||
| 3249 | // if is an explicit pixel unit, we get rid of the unit and keep the value |
||
| 3250 | // if is an implicit unit, it's px, and we return just the value |
||
| 3251 | return value; |
||
| 3252 | } |
||
| 3253 | } |
||
| 3254 | |||
| 3255 | /** |
||
| 3256 | * Parse an `offset` string to extrapolate `x` and `y` numeric offsets. |
||
| 3257 | * @function |
||
| 3258 | * @memberof {modifiers~offset} |
||
| 3259 | * @private |
||
| 3260 | * @argument {String} offset |
||
| 3261 | * @argument {Object} popperOffsets |
||
| 3262 | * @argument {Object} referenceOffsets |
||
| 3263 | * @argument {String} basePlacement |
||
| 3264 | * @returns {Array} a two cells array with x and y offsets in numbers |
||
| 3265 | */ |
||
| 3266 | function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) { |
||
| 3267 | var offsets = [0, 0]; |
||
| 3268 | |||
| 3269 | // Use height if placement is left or right and index is 0 otherwise use width |
||
| 3270 | // in this way the first offset will use an axis and the second one |
||
| 3271 | // will use the other one |
||
| 3272 | var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1; |
||
| 3273 | |||
| 3274 | // Split the offset string to obtain a list of values and operands |
||
| 3275 | // The regex addresses values with the plus or minus sign in front (+10, -20, etc) |
||
| 3276 | var fragments = offset.split(/(\+|\-)/).map(function (frag) { |
||
| 3277 | return frag.trim(); |
||
| 3278 | }); |
||
| 3279 | |||
| 3280 | // Detect if the offset string contains a pair of values or a single one |
||
| 3281 | // they could be separated by comma or space |
||
| 3282 | var divider = fragments.indexOf(find(fragments, function (frag) { |
||
| 3283 | return frag.search(/,|\s/) !== -1; |
||
| 3284 | })); |
||
| 3285 | |||
| 3286 | if (fragments[divider] && fragments[divider].indexOf(',') === -1) { |
||
| 3287 | console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.'); |
||
| 3288 | } |
||
| 3289 | |||
| 3290 | // If divider is found, we divide the list of values and operands to divide |
||
| 3291 | // them by ofset X and Y. |
||
| 3292 | var splitRegex = /\s*,\s*|\s+/; |
||
| 3293 | var ops = divider !== -1 ? [fragments.slice(0, divider).concat([fragments[divider].split(splitRegex)[0]]), [fragments[divider].split(splitRegex)[1]].concat(fragments.slice(divider + 1))] : [fragments]; |
||
| 3294 | |||
| 3295 | // Convert the values with units to absolute pixels to allow our computations |
||
| 3296 | ops = ops.map(function (op, index) { |
||
| 3297 | // Most of the units rely on the orientation of the popper |
||
| 3298 | var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width'; |
||
| 3299 | var mergeWithPrevious = false; |
||
| 3300 | return op |
||
| 3301 | // This aggregates any `+` or `-` sign that aren't considered operators |
||
| 3302 | // e.g.: 10 + +5 => [10, +, +5] |
||
| 3303 | .reduce(function (a, b) { |
||
| 3304 | if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) { |
||
| 3305 | a[a.length - 1] = b; |
||
| 3306 | mergeWithPrevious = true; |
||
| 3307 | return a; |
||
| 3308 | } else if (mergeWithPrevious) { |
||
| 3309 | a[a.length - 1] += b; |
||
| 3310 | mergeWithPrevious = false; |
||
| 3311 | return a; |
||
| 3312 | } else { |
||
| 3313 | return a.concat(b); |
||
| 3314 | } |
||
| 3315 | }, []) |
||
| 3316 | // Here we convert the string values into number values (in px) |
||
| 3317 | .map(function (str) { |
||
| 3318 | return toValue(str, measurement, popperOffsets, referenceOffsets); |
||
| 3319 | }); |
||
| 3320 | }); |
||
| 3321 | |||
| 3322 | // Loop trough the offsets arrays and execute the operations |
||
| 3323 | ops.forEach(function (op, index) { |
||
| 3324 | op.forEach(function (frag, index2) { |
||
| 3325 | if (isNumeric(frag)) { |
||
| 3326 | offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1); |
||
| 3327 | } |
||
| 3328 | }); |
||
| 3329 | }); |
||
| 3330 | return offsets; |
||
| 3331 | } |
||
| 3332 | |||
| 3333 | /** |
||
| 3334 | * @function |
||
| 3335 | * @memberof Modifiers |
||
| 3336 | * @argument {Object} data - The data object generated by update method |
||
| 3337 | * @argument {Object} options - Modifiers configuration and options |
||
| 3338 | * @argument {Number|String} options.offset=0 |
||
| 3339 | * The offset value as described in the modifier description |
||
| 3340 | * @returns {Object} The data object, properly modified |
||
| 3341 | */ |
||
| 3342 | function offset(data, _ref) { |
||
| 3343 | var offset = _ref.offset; |
||
| 3344 | var placement = data.placement, |
||
| 3345 | _data$offsets = data.offsets, |
||
| 3346 | popper = _data$offsets.popper, |
||
| 3347 | reference = _data$offsets.reference; |
||
| 3348 | |||
| 3349 | var basePlacement = placement.split('-')[0]; |
||
| 3350 | |||
| 3351 | var offsets = void 0; |
||
| 3352 | if (isNumeric(+offset)) { |
||
| 3353 | offsets = [+offset, 0]; |
||
| 3354 | } else { |
||
| 3355 | offsets = parseOffset(offset, popper, reference, basePlacement); |
||
| 3356 | } |
||
| 3357 | |||
| 3358 | if (basePlacement === 'left') { |
||
| 3359 | popper.top += offsets[0]; |
||
| 3360 | popper.left -= offsets[1]; |
||
| 3361 | } else if (basePlacement === 'right') { |
||
| 3362 | popper.top += offsets[0]; |
||
| 3363 | popper.left += offsets[1]; |
||
| 3364 | } else if (basePlacement === 'top') { |
||
| 3365 | popper.left += offsets[0]; |
||
| 3366 | popper.top -= offsets[1]; |
||
| 3367 | } else if (basePlacement === 'bottom') { |
||
| 3368 | popper.left += offsets[0]; |
||
| 3369 | popper.top += offsets[1]; |
||
| 3370 | } |
||
| 3371 | |||
| 3372 | data.popper = popper; |
||
| 3373 | return data; |
||
| 3374 | } |
||
| 3375 | |||
| 3376 | /** |
||
| 3377 | * @function |
||
| 3378 | * @memberof Modifiers |
||
| 3379 | * @argument {Object} data - The data object generated by `update` method |
||
| 3380 | * @argument {Object} options - Modifiers configuration and options |
||
| 3381 | * @returns {Object} The data object, properly modified |
||
| 3382 | */ |
||
| 3383 | function preventOverflow(data, options) { |
||
| 3384 | var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper); |
||
| 3385 | |||
| 3386 | // If offsetParent is the reference element, we really want to |
||
| 3387 | // go one step up and use the next offsetParent as reference to |
||
| 3388 | // avoid to make this modifier completely useless and look like broken |
||
| 3389 | if (data.instance.reference === boundariesElement) { |
||
| 3390 | boundariesElement = getOffsetParent(boundariesElement); |
||
| 3391 | } |
||
| 3392 | |||
| 3393 | // NOTE: DOM access here |
||
| 3394 | // resets the popper's position so that the document size can be calculated excluding |
||
| 3395 | // the size of the popper element itself |
||
| 3396 | var transformProp = getSupportedPropertyName('transform'); |
||
| 3397 | var popperStyles = data.instance.popper.style; // assignment to help minification |
||
| 3398 | var top = popperStyles.top, |
||
| 3399 | left = popperStyles.left, |
||
| 3400 | transform = popperStyles[transformProp]; |
||
| 3401 | |||
| 3402 | popperStyles.top = ''; |
||
| 3403 | popperStyles.left = ''; |
||
| 3404 | popperStyles[transformProp] = ''; |
||
| 3405 | |||
| 3406 | var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed); |
||
| 3407 | |||
| 3408 | // NOTE: DOM access here |
||
| 3409 | // restores the original style properties after the offsets have been computed |
||
| 3410 | popperStyles.top = top; |
||
| 3411 | popperStyles.left = left; |
||
| 3412 | popperStyles[transformProp] = transform; |
||
| 3413 | |||
| 3414 | options.boundaries = boundaries; |
||
| 3415 | |||
| 3416 | var order = options.priority; |
||
| 3417 | var popper = data.offsets.popper; |
||
| 3418 | |||
| 3419 | var check = { |
||
| 3420 | primary: function primary(placement) { |
||
| 3421 | var value = popper[placement]; |
||
| 3422 | if (popper[placement] < boundaries[placement] && !options.escapeWithReference) { |
||
| 3423 | value = Math.max(popper[placement], boundaries[placement]); |
||
| 3424 | } |
||
| 3425 | return defineProperty({}, placement, value); |
||
| 3426 | }, |
||
| 3427 | secondary: function secondary(placement) { |
||
| 3428 | var mainSide = placement === 'right' ? 'left' : 'top'; |
||
| 3429 | var value = popper[mainSide]; |
||
| 3430 | if (popper[placement] > boundaries[placement] && !options.escapeWithReference) { |
||
| 3431 | value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height)); |
||
| 3432 | } |
||
| 3433 | return defineProperty({}, mainSide, value); |
||
| 3434 | } |
||
| 3435 | }; |
||
| 3436 | |||
| 3437 | order.forEach(function (placement) { |
||
| 3438 | var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary'; |
||
| 3439 | popper = _extends$1({}, popper, check[side](placement)); |
||
| 3440 | }); |
||
| 3441 | |||
| 3442 | data.offsets.popper = popper; |
||
| 3443 | |||
| 3444 | return data; |
||
| 3445 | } |
||
| 3446 | |||
| 3447 | /** |
||
| 3448 | * @function |
||
| 3449 | * @memberof Modifiers |
||
| 3450 | * @argument {Object} data - The data object generated by `update` method |
||
| 3451 | * @argument {Object} options - Modifiers configuration and options |
||
| 3452 | * @returns {Object} The data object, properly modified |
||
| 3453 | */ |
||
| 3454 | function shift(data) { |
||
| 3455 | var placement = data.placement; |
||
| 3456 | var basePlacement = placement.split('-')[0]; |
||
| 3457 | var shiftvariation = placement.split('-')[1]; |
||
| 3458 | |||
| 3459 | // if shift shiftvariation is specified, run the modifier |
||
| 3460 | if (shiftvariation) { |
||
| 3461 | var _data$offsets = data.offsets, |
||
| 3462 | reference = _data$offsets.reference, |
||
| 3463 | popper = _data$offsets.popper; |
||
| 3464 | |||
| 3465 | var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1; |
||
| 3466 | var side = isVertical ? 'left' : 'top'; |
||
| 3467 | var measurement = isVertical ? 'width' : 'height'; |
||
| 3468 | |||
| 3469 | var shiftOffsets = { |
||
| 3470 | start: defineProperty({}, side, reference[side]), |
||
| 3471 | end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement]) |
||
| 3472 | }; |
||
| 3473 | |||
| 3474 | data.offsets.popper = _extends$1({}, popper, shiftOffsets[shiftvariation]); |
||
| 3475 | } |
||
| 3476 | |||
| 3477 | return data; |
||
| 3478 | } |
||
| 3479 | |||
| 3480 | /** |
||
| 3481 | * @function |
||
| 3482 | * @memberof Modifiers |
||
| 3483 | * @argument {Object} data - The data object generated by update method |
||
| 3484 | * @argument {Object} options - Modifiers configuration and options |
||
| 3485 | * @returns {Object} The data object, properly modified |
||
| 3486 | */ |
||
| 3487 | function hide(data) { |
||
| 3488 | if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) { |
||
| 3489 | return data; |
||
| 3490 | } |
||
| 3491 | |||
| 3492 | var refRect = data.offsets.reference; |
||
| 3493 | var bound = find(data.instance.modifiers, function (modifier) { |
||
| 3494 | return modifier.name === 'preventOverflow'; |
||
| 3495 | }).boundaries; |
||
| 3496 | |||
| 3497 | if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) { |
||
| 3498 | // Avoid unnecessary DOM access if visibility hasn't changed |
||
| 3499 | if (data.hide === true) { |
||
| 3500 | return data; |
||
| 3501 | } |
||
| 3502 | |||
| 3503 | data.hide = true; |
||
| 3504 | data.attributes['x-out-of-boundaries'] = ''; |
||
| 3505 | } else { |
||
| 3506 | // Avoid unnecessary DOM access if visibility hasn't changed |
||
| 3507 | if (data.hide === false) { |
||
| 3508 | return data; |
||
| 3509 | } |
||
| 3510 | |||
| 3511 | data.hide = false; |
||
| 3512 | data.attributes['x-out-of-boundaries'] = false; |
||
| 3513 | } |
||
| 3514 | |||
| 3515 | return data; |
||
| 3516 | } |
||
| 3517 | |||
| 3518 | /** |
||
| 3519 | * @function |
||
| 3520 | * @memberof Modifiers |
||
| 3521 | * @argument {Object} data - The data object generated by `update` method |
||
| 3522 | * @argument {Object} options - Modifiers configuration and options |
||
| 3523 | * @returns {Object} The data object, properly modified |
||
| 3524 | */ |
||
| 3525 | function inner(data) { |
||
| 3526 | var placement = data.placement; |
||
| 3527 | var basePlacement = placement.split('-')[0]; |
||
| 3528 | var _data$offsets = data.offsets, |
||
| 3529 | popper = _data$offsets.popper, |
||
| 3530 | reference = _data$offsets.reference; |
||
| 3531 | |||
| 3532 | var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1; |
||
| 3533 | |||
| 3534 | var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1; |
||
| 3535 | |||
| 3536 | popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0); |
||
| 3537 | |||
| 3538 | data.placement = getOppositePlacement(placement); |
||
| 3539 | data.offsets.popper = getClientRect(popper); |
||
| 3540 | |||
| 3541 | return data; |
||
| 3542 | } |
||
| 3543 | |||
| 3544 | /** |
||
| 3545 | * Modifier function, each modifier can have a function of this type assigned |
||
| 3546 | * to its `fn` property.<br /> |
||
| 3547 | * These functions will be called on each update, this means that you must |
||
| 3548 | * make sure they are performant enough to avoid performance bottlenecks. |
||
| 3549 | * |
||
| 3550 | * @function ModifierFn |
||
| 3551 | * @argument {dataObject} data - The data object generated by `update` method |
||
| 3552 | * @argument {Object} options - Modifiers configuration and options |
||
| 3553 | * @returns {dataObject} The data object, properly modified |
||
| 3554 | */ |
||
| 3555 | |||
| 3556 | /** |
||
| 3557 | * Modifiers are plugins used to alter the behavior of your poppers.<br /> |
||
| 3558 | * Popper.js uses a set of 9 modifiers to provide all the basic functionalities |
||
| 3559 | * needed by the library. |
||
| 3560 | * |
||
| 3561 | * Usually you don't want to override the `order`, `fn` and `onLoad` props. |
||
| 3562 | * All the other properties are configurations that could be tweaked. |
||
| 3563 | * @namespace modifiers |
||
| 3564 | */ |
||
| 3565 | var modifiers = { |
||
| 3566 | /** |
||
| 3567 | * Modifier used to shift the popper on the start or end of its reference |
||
| 3568 | * element.<br /> |
||
| 3569 | * It will read the variation of the `placement` property.<br /> |
||
| 3570 | * It can be one either `-end` or `-start`. |
||
| 3571 | * @memberof modifiers |
||
| 3572 | * @inner |
||
| 3573 | */ |
||
| 3574 | shift: { |
||
| 3575 | /** @prop {number} order=100 - Index used to define the order of execution */ |
||
| 3576 | order: 100, |
||
| 3577 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3578 | enabled: true, |
||
| 3579 | /** @prop {ModifierFn} */ |
||
| 3580 | fn: shift |
||
| 3581 | }, |
||
| 3582 | |||
| 3583 | /** |
||
| 3584 | * The `offset` modifier can shift your popper on both its axis. |
||
| 3585 | * |
||
| 3586 | * It accepts the following units: |
||
| 3587 | * - `px` or unit-less, interpreted as pixels |
||
| 3588 | * - `%` or `%r`, percentage relative to the length of the reference element |
||
| 3589 | * - `%p`, percentage relative to the length of the popper element |
||
| 3590 | * - `vw`, CSS viewport width unit |
||
| 3591 | * - `vh`, CSS viewport height unit |
||
| 3592 | * |
||
| 3593 | * For length is intended the main axis relative to the placement of the popper.<br /> |
||
| 3594 | * This means that if the placement is `top` or `bottom`, the length will be the |
||
| 3595 | * `width`. In case of `left` or `right`, it will be the `height`. |
||
| 3596 | * |
||
| 3597 | * You can provide a single value (as `Number` or `String`), or a pair of values |
||
| 3598 | * as `String` divided by a comma or one (or more) white spaces.<br /> |
||
| 3599 | * The latter is a deprecated method because it leads to confusion and will be |
||
| 3600 | * removed in v2.<br /> |
||
| 3601 | * Additionally, it accepts additions and subtractions between different units. |
||
| 3602 | * Note that multiplications and divisions aren't supported. |
||
| 3603 | * |
||
| 3604 | * Valid examples are: |
||
| 3605 | * ``` |
||
| 3606 | * 10 |
||
| 3607 | * '10%' |
||
| 3608 | * '10, 10' |
||
| 3609 | * '10%, 10' |
||
| 3610 | * '10 + 10%' |
||
| 3611 | * '10 - 5vh + 3%' |
||
| 3612 | * '-10px + 5vh, 5px - 6%' |
||
| 3613 | * ``` |
||
| 3614 | * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap |
||
| 3615 | * > with their reference element, unfortunately, you will have to disable the `flip` modifier. |
||
| 3616 | * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373). |
||
| 3617 | * |
||
| 3618 | * @memberof modifiers |
||
| 3619 | * @inner |
||
| 3620 | */ |
||
| 3621 | offset: { |
||
| 3622 | /** @prop {number} order=200 - Index used to define the order of execution */ |
||
| 3623 | order: 200, |
||
| 3624 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3625 | enabled: true, |
||
| 3626 | /** @prop {ModifierFn} */ |
||
| 3627 | fn: offset, |
||
| 3628 | /** @prop {Number|String} offset=0 |
||
| 3629 | * The offset value as described in the modifier description |
||
| 3630 | */ |
||
| 3631 | offset: 0 |
||
| 3632 | }, |
||
| 3633 | |||
| 3634 | /** |
||
| 3635 | * Modifier used to prevent the popper from being positioned outside the boundary. |
||
| 3636 | * |
||
| 3637 | * A scenario exists where the reference itself is not within the boundaries.<br /> |
||
| 3638 | * We can say it has "escaped the boundaries" — or just "escaped".<br /> |
||
| 3639 | * In this case we need to decide whether the popper should either: |
||
| 3640 | * |
||
| 3641 | * - detach from the reference and remain "trapped" in the boundaries, or |
||
| 3642 | * - if it should ignore the boundary and "escape with its reference" |
||
| 3643 | * |
||
| 3644 | * When `escapeWithReference` is set to`true` and reference is completely |
||
| 3645 | * outside its boundaries, the popper will overflow (or completely leave) |
||
| 3646 | * the boundaries in order to remain attached to the edge of the reference. |
||
| 3647 | * |
||
| 3648 | * @memberof modifiers |
||
| 3649 | * @inner |
||
| 3650 | */ |
||
| 3651 | preventOverflow: { |
||
| 3652 | /** @prop {number} order=300 - Index used to define the order of execution */ |
||
| 3653 | order: 300, |
||
| 3654 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3655 | enabled: true, |
||
| 3656 | /** @prop {ModifierFn} */ |
||
| 3657 | fn: preventOverflow, |
||
| 3658 | /** |
||
| 3659 | * @prop {Array} [priority=['left','right','top','bottom']] |
||
| 3660 | * Popper will try to prevent overflow following these priorities by default, |
||
| 3661 | * then, it could overflow on the left and on top of the `boundariesElement` |
||
| 3662 | */ |
||
| 3663 | priority: ['left', 'right', 'top', 'bottom'], |
||
| 3664 | /** |
||
| 3665 | * @prop {number} padding=5 |
||
| 3666 | * Amount of pixel used to define a minimum distance between the boundaries |
||
| 3667 | * and the popper. This makes sure the popper always has a little padding |
||
| 3668 | * between the edges of its container |
||
| 3669 | */ |
||
| 3670 | padding: 5, |
||
| 3671 | /** |
||
| 3672 | * @prop {String|HTMLElement} boundariesElement='scrollParent' |
||
| 3673 | * Boundaries used by the modifier. Can be `scrollParent`, `window`, |
||
| 3674 | * `viewport` or any DOM element. |
||
| 3675 | */ |
||
| 3676 | boundariesElement: 'scrollParent' |
||
| 3677 | }, |
||
| 3678 | |||
| 3679 | /** |
||
| 3680 | * Modifier used to make sure the reference and its popper stay near each other |
||
| 3681 | * without leaving any gap between the two. Especially useful when the arrow is |
||
| 3682 | * enabled and you want to ensure that it points to its reference element. |
||
| 3683 | * It cares only about the first axis. You can still have poppers with margin |
||
| 3684 | * between the popper and its reference element. |
||
| 3685 | * @memberof modifiers |
||
| 3686 | * @inner |
||
| 3687 | */ |
||
| 3688 | keepTogether: { |
||
| 3689 | /** @prop {number} order=400 - Index used to define the order of execution */ |
||
| 3690 | order: 400, |
||
| 3691 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3692 | enabled: true, |
||
| 3693 | /** @prop {ModifierFn} */ |
||
| 3694 | fn: keepTogether |
||
| 3695 | }, |
||
| 3696 | |||
| 3697 | /** |
||
| 3698 | * This modifier is used to move the `arrowElement` of the popper to make |
||
| 3699 | * sure it is positioned between the reference element and its popper element. |
||
| 3700 | * It will read the outer size of the `arrowElement` node to detect how many |
||
| 3701 | * pixels of conjunction are needed. |
||
| 3702 | * |
||
| 3703 | * It has no effect if no `arrowElement` is provided. |
||
| 3704 | * @memberof modifiers |
||
| 3705 | * @inner |
||
| 3706 | */ |
||
| 3707 | arrow: { |
||
| 3708 | /** @prop {number} order=500 - Index used to define the order of execution */ |
||
| 3709 | order: 500, |
||
| 3710 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3711 | enabled: true, |
||
| 3712 | /** @prop {ModifierFn} */ |
||
| 3713 | fn: arrow, |
||
| 3714 | /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */ |
||
| 3715 | element: '[x-arrow]' |
||
| 3716 | }, |
||
| 3717 | |||
| 3718 | /** |
||
| 3719 | * Modifier used to flip the popper's placement when it starts to overlap its |
||
| 3720 | * reference element. |
||
| 3721 | * |
||
| 3722 | * Requires the `preventOverflow` modifier before it in order to work. |
||
| 3723 | * |
||
| 3724 | * **NOTE:** this modifier will interrupt the current update cycle and will |
||
| 3725 | * restart it if it detects the need to flip the placement. |
||
| 3726 | * @memberof modifiers |
||
| 3727 | * @inner |
||
| 3728 | */ |
||
| 3729 | flip: { |
||
| 3730 | /** @prop {number} order=600 - Index used to define the order of execution */ |
||
| 3731 | order: 600, |
||
| 3732 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3733 | enabled: true, |
||
| 3734 | /** @prop {ModifierFn} */ |
||
| 3735 | fn: flip, |
||
| 3736 | /** |
||
| 3737 | * @prop {String|Array} behavior='flip' |
||
| 3738 | * The behavior used to change the popper's placement. It can be one of |
||
| 3739 | * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid |
||
| 3740 | * placements (with optional variations) |
||
| 3741 | */ |
||
| 3742 | behavior: 'flip', |
||
| 3743 | /** |
||
| 3744 | * @prop {number} padding=5 |
||
| 3745 | * The popper will flip if it hits the edges of the `boundariesElement` |
||
| 3746 | */ |
||
| 3747 | padding: 5, |
||
| 3748 | /** |
||
| 3749 | * @prop {String|HTMLElement} boundariesElement='viewport' |
||
| 3750 | * The element which will define the boundaries of the popper position. |
||
| 3751 | * The popper will never be placed outside of the defined boundaries |
||
| 3752 | * (except if `keepTogether` is enabled) |
||
| 3753 | */ |
||
| 3754 | boundariesElement: 'viewport', |
||
| 3755 | /** |
||
| 3756 | * @prop {Boolean} flipVariations=false |
||
| 3757 | * The popper will switch placement variation between `-start` and `-end` when |
||
| 3758 | * the reference element overlaps its boundaries. |
||
| 3759 | * |
||
| 3760 | * The original placement should have a set variation. |
||
| 3761 | */ |
||
| 3762 | flipVariations: false, |
||
| 3763 | /** |
||
| 3764 | * @prop {Boolean} flipVariationsByContent=false |
||
| 3765 | * The popper will switch placement variation between `-start` and `-end` when |
||
| 3766 | * the popper element overlaps its reference boundaries. |
||
| 3767 | * |
||
| 3768 | * The original placement should have a set variation. |
||
| 3769 | */ |
||
| 3770 | flipVariationsByContent: false |
||
| 3771 | }, |
||
| 3772 | |||
| 3773 | /** |
||
| 3774 | * Modifier used to make the popper flow toward the inner of the reference element. |
||
| 3775 | * By default, when this modifier is disabled, the popper will be placed outside |
||
| 3776 | * the reference element. |
||
| 3777 | * @memberof modifiers |
||
| 3778 | * @inner |
||
| 3779 | */ |
||
| 3780 | inner: { |
||
| 3781 | /** @prop {number} order=700 - Index used to define the order of execution */ |
||
| 3782 | order: 700, |
||
| 3783 | /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */ |
||
| 3784 | enabled: false, |
||
| 3785 | /** @prop {ModifierFn} */ |
||
| 3786 | fn: inner |
||
| 3787 | }, |
||
| 3788 | |||
| 3789 | /** |
||
| 3790 | * Modifier used to hide the popper when its reference element is outside of the |
||
| 3791 | * popper boundaries. It will set a `x-out-of-boundaries` attribute which can |
||
| 3792 | * be used to hide with a CSS selector the popper when its reference is |
||
| 3793 | * out of boundaries. |
||
| 3794 | * |
||
| 3795 | * Requires the `preventOverflow` modifier before it in order to work. |
||
| 3796 | * @memberof modifiers |
||
| 3797 | * @inner |
||
| 3798 | */ |
||
| 3799 | hide: { |
||
| 3800 | /** @prop {number} order=800 - Index used to define the order of execution */ |
||
| 3801 | order: 800, |
||
| 3802 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3803 | enabled: true, |
||
| 3804 | /** @prop {ModifierFn} */ |
||
| 3805 | fn: hide |
||
| 3806 | }, |
||
| 3807 | |||
| 3808 | /** |
||
| 3809 | * Computes the style that will be applied to the popper element to gets |
||
| 3810 | * properly positioned. |
||
| 3811 | * |
||
| 3812 | * Note that this modifier will not touch the DOM, it just prepares the styles |
||
| 3813 | * so that `applyStyle` modifier can apply it. This separation is useful |
||
| 3814 | * in case you need to replace `applyStyle` with a custom implementation. |
||
| 3815 | * |
||
| 3816 | * This modifier has `850` as `order` value to maintain backward compatibility |
||
| 3817 | * with previous versions of Popper.js. Expect the modifiers ordering method |
||
| 3818 | * to change in future major versions of the library. |
||
| 3819 | * |
||
| 3820 | * @memberof modifiers |
||
| 3821 | * @inner |
||
| 3822 | */ |
||
| 3823 | computeStyle: { |
||
| 3824 | /** @prop {number} order=850 - Index used to define the order of execution */ |
||
| 3825 | order: 850, |
||
| 3826 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3827 | enabled: true, |
||
| 3828 | /** @prop {ModifierFn} */ |
||
| 3829 | fn: computeStyle, |
||
| 3830 | /** |
||
| 3831 | * @prop {Boolean} gpuAcceleration=true |
||
| 3832 | * If true, it uses the CSS 3D transformation to position the popper. |
||
| 3833 | * Otherwise, it will use the `top` and `left` properties |
||
| 3834 | */ |
||
| 3835 | gpuAcceleration: true, |
||
| 3836 | /** |
||
| 3837 | * @prop {string} [x='bottom'] |
||
| 3838 | * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin. |
||
| 3839 | * Change this if your popper should grow in a direction different from `bottom` |
||
| 3840 | */ |
||
| 3841 | x: 'bottom', |
||
| 3842 | /** |
||
| 3843 | * @prop {string} [x='left'] |
||
| 3844 | * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin. |
||
| 3845 | * Change this if your popper should grow in a direction different from `right` |
||
| 3846 | */ |
||
| 3847 | y: 'right' |
||
| 3848 | }, |
||
| 3849 | |||
| 3850 | /** |
||
| 3851 | * Applies the computed styles to the popper element. |
||
| 3852 | * |
||
| 3853 | * All the DOM manipulations are limited to this modifier. This is useful in case |
||
| 3854 | * you want to integrate Popper.js inside a framework or view library and you |
||
| 3855 | * want to delegate all the DOM manipulations to it. |
||
| 3856 | * |
||
| 3857 | * Note that if you disable this modifier, you must make sure the popper element |
||
| 3858 | * has its position set to `absolute` before Popper.js can do its work! |
||
| 3859 | * |
||
| 3860 | * Just disable this modifier and define your own to achieve the desired effect. |
||
| 3861 | * |
||
| 3862 | * @memberof modifiers |
||
| 3863 | * @inner |
||
| 3864 | */ |
||
| 3865 | applyStyle: { |
||
| 3866 | /** @prop {number} order=900 - Index used to define the order of execution */ |
||
| 3867 | order: 900, |
||
| 3868 | /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */ |
||
| 3869 | enabled: true, |
||
| 3870 | /** @prop {ModifierFn} */ |
||
| 3871 | fn: applyStyle, |
||
| 3872 | /** @prop {Function} */ |
||
| 3873 | onLoad: applyStyleOnLoad, |
||
| 3874 | /** |
||
| 3875 | * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier |
||
| 3876 | * @prop {Boolean} gpuAcceleration=true |
||
| 3877 | * If true, it uses the CSS 3D transformation to position the popper. |
||
| 3878 | * Otherwise, it will use the `top` and `left` properties |
||
| 3879 | */ |
||
| 3880 | gpuAcceleration: undefined |
||
| 3881 | } |
||
| 3882 | }; |
||
| 3883 | |||
| 3884 | /** |
||
| 3885 | * The `dataObject` is an object containing all the information used by Popper.js. |
||
| 3886 | * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks. |
||
| 3887 | * @name dataObject |
||
| 3888 | * @property {Object} data.instance The Popper.js instance |
||
| 3889 | * @property {String} data.placement Placement applied to popper |
||
| 3890 | * @property {String} data.originalPlacement Placement originally defined on init |
||
| 3891 | * @property {Boolean} data.flipped True if popper has been flipped by flip modifier |
||
| 3892 | * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper |
||
| 3893 | * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier |
||
| 3894 | * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`) |
||
| 3895 | * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`) |
||
| 3896 | * @property {Object} data.boundaries Offsets of the popper boundaries |
||
| 3897 | * @property {Object} data.offsets The measurements of popper, reference and arrow elements |
||
| 3898 | * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values |
||
| 3899 | * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values |
||
| 3900 | * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0 |
||
| 3901 | */ |
||
| 3902 | |||
| 3903 | /** |
||
| 3904 | * Default options provided to Popper.js constructor.<br /> |
||
| 3905 | * These can be overridden using the `options` argument of Popper.js.<br /> |
||
| 3906 | * To override an option, simply pass an object with the same |
||
| 3907 | * structure of the `options` object, as the 3rd argument. For example: |
||
| 3908 | * ``` |
||
| 3909 | * new Popper(ref, pop, { |
||
| 3910 | * modifiers: { |
||
| 3911 | * preventOverflow: { enabled: false } |
||
| 3912 | * } |
||
| 3913 | * }) |
||
| 3914 | * ``` |
||
| 3915 | * @type {Object} |
||
| 3916 | * @static |
||
| 3917 | * @memberof Popper |
||
| 3918 | */ |
||
| 3919 | var Defaults = { |
||
| 3920 | /** |
||
| 3921 | * Popper's placement. |
||
| 3922 | * @prop {Popper.placements} placement='bottom' |
||
| 3923 | */ |
||
| 3924 | placement: 'bottom', |
||
| 3925 | |||
| 3926 | /** |
||
| 3927 | * Set this to true if you want popper to position it self in 'fixed' mode |
||
| 3928 | * @prop {Boolean} positionFixed=false |
||
| 3929 | */ |
||
| 3930 | positionFixed: false, |
||
| 3931 | |||
| 3932 | /** |
||
| 3933 | * Whether events (resize, scroll) are initially enabled. |
||
| 3934 | * @prop {Boolean} eventsEnabled=true |
||
| 3935 | */ |
||
| 3936 | eventsEnabled: true, |
||
| 3937 | |||
| 3938 | /** |
||
| 3939 | * Set to true if you want to automatically remove the popper when |
||
| 3940 | * you call the `destroy` method. |
||
| 3941 | * @prop {Boolean} removeOnDestroy=false |
||
| 3942 | */ |
||
| 3943 | removeOnDestroy: false, |
||
| 3944 | |||
| 3945 | /** |
||
| 3946 | * Callback called when the popper is created.<br /> |
||
| 3947 | * By default, it is set to no-op.<br /> |
||
| 3948 | * Access Popper.js instance with `data.instance`. |
||
| 3949 | * @prop {onCreate} |
||
| 3950 | */ |
||
| 3951 | onCreate: function onCreate() {}, |
||
| 3952 | |||
| 3953 | /** |
||
| 3954 | * Callback called when the popper is updated. This callback is not called |
||
| 3955 | * on the initialization/creation of the popper, but only on subsequent |
||
| 3956 | * updates.<br /> |
||
| 3957 | * By default, it is set to no-op.<br /> |
||
| 3958 | * Access Popper.js instance with `data.instance`. |
||
| 3959 | * @prop {onUpdate} |
||
| 3960 | */ |
||
| 3961 | onUpdate: function onUpdate() {}, |
||
| 3962 | |||
| 3963 | /** |
||
| 3964 | * List of modifiers used to modify the offsets before they are applied to the popper. |
||
| 3965 | * They provide most of the functionalities of Popper.js. |
||
| 3966 | * @prop {modifiers} |
||
| 3967 | */ |
||
| 3968 | modifiers: modifiers |
||
| 3969 | }; |
||
| 3970 | |||
| 3971 | /** |
||
| 3972 | * @callback onCreate |
||
| 3973 | * @param {dataObject} data |
||
| 3974 | */ |
||
| 3975 | |||
| 3976 | /** |
||
| 3977 | * @callback onUpdate |
||
| 3978 | * @param {dataObject} data |
||
| 3979 | */ |
||
| 3980 | |||
| 3981 | // Utils |
||
| 3982 | // Methods |
||
| 3983 | var Popper = function () { |
||
| 3984 | /** |
||
| 3985 | * Creates a new Popper.js instance. |
||
| 3986 | * @class Popper |
||
| 3987 | * @param {Element|referenceObject} reference - The reference element used to position the popper |
||
| 3988 | * @param {Element} popper - The HTML / XML element used as the popper |
||
| 3989 | * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults) |
||
| 3990 | * @return {Object} instance - The generated Popper.js instance |
||
| 3991 | */ |
||
| 3992 | function Popper(reference, popper) { |
||
| 3993 | var _this = this; |
||
| 3994 | |||
| 3995 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
||
| 3996 | classCallCheck(this, Popper); |
||
| 3997 | |||
| 3998 | this.scheduleUpdate = function () { |
||
| 3999 | return requestAnimationFrame(_this.update); |
||
| 4000 | }; |
||
| 4001 | |||
| 4002 | // make update() debounced, so that it only runs at most once-per-tick |
||
| 4003 | this.update = debounce(this.update.bind(this)); |
||
| 4004 | |||
| 4005 | // with {} we create a new object with the options inside it |
||
| 4006 | this.options = _extends$1({}, Popper.Defaults, options); |
||
| 4007 | |||
| 4008 | // init state |
||
| 4009 | this.state = { |
||
| 4010 | isDestroyed: false, |
||
| 4011 | isCreated: false, |
||
| 4012 | scrollParents: [] |
||
| 4013 | }; |
||
| 4014 | |||
| 4015 | // get reference and popper elements (allow jQuery wrappers) |
||
| 4016 | this.reference = reference && reference.jquery ? reference[0] : reference; |
||
| 4017 | this.popper = popper && popper.jquery ? popper[0] : popper; |
||
| 4018 | |||
| 4019 | // Deep merge modifiers options |
||
| 4020 | this.options.modifiers = {}; |
||
| 4021 | Object.keys(_extends$1({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) { |
||
| 4022 | _this.options.modifiers[name] = _extends$1({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {}); |
||
| 4023 | }); |
||
| 4024 | |||
| 4025 | // Refactoring modifiers' list (Object => Array) |
||
| 4026 | this.modifiers = Object.keys(this.options.modifiers).map(function (name) { |
||
| 4027 | return _extends$1({ |
||
| 4028 | name: name |
||
| 4029 | }, _this.options.modifiers[name]); |
||
| 4030 | }) |
||
| 4031 | // sort the modifiers by order |
||
| 4032 | .sort(function (a, b) { |
||
| 4033 | return a.order - b.order; |
||
| 4034 | }); |
||
| 4035 | |||
| 4036 | // modifiers have the ability to execute arbitrary code when Popper.js get inited |
||
| 4037 | // such code is executed in the same order of its modifier |
||
| 4038 | // they could add new properties to their options configuration |
||
| 4039 | // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`! |
||
| 4040 | this.modifiers.forEach(function (modifierOptions) { |
||
| 4041 | if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) { |
||
| 4042 | modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state); |
||
| 4043 | } |
||
| 4044 | }); |
||
| 4045 | |||
| 4046 | // fire the first update to position the popper in the right place |
||
| 4047 | this.update(); |
||
| 4048 | |||
| 4049 | var eventsEnabled = this.options.eventsEnabled; |
||
| 4050 | if (eventsEnabled) { |
||
| 4051 | // setup event listeners, they will take care of update the position in specific situations |
||
| 4052 | this.enableEventListeners(); |
||
| 4053 | } |
||
| 4054 | |||
| 4055 | this.state.eventsEnabled = eventsEnabled; |
||
| 4056 | } |
||
| 4057 | |||
| 4058 | // We can't use class properties because they don't get listed in the |
||
| 4059 | // class prototype and break stuff like Sinon stubs |
||
| 4060 | |||
| 4061 | |||
| 4062 | createClass(Popper, [{ |
||
| 4063 | key: 'update', |
||
| 4064 | value: function update$$1() { |
||
| 4065 | return update.call(this); |
||
| 4066 | } |
||
| 4067 | }, { |
||
| 4068 | key: 'destroy', |
||
| 4069 | value: function destroy$$1() { |
||
| 4070 | return destroy.call(this); |
||
| 4071 | } |
||
| 4072 | }, { |
||
| 4073 | key: 'enableEventListeners', |
||
| 4074 | value: function enableEventListeners$$1() { |
||
| 4075 | return enableEventListeners.call(this); |
||
| 4076 | } |
||
| 4077 | }, { |
||
| 4078 | key: 'disableEventListeners', |
||
| 4079 | value: function disableEventListeners$$1() { |
||
| 4080 | return disableEventListeners.call(this); |
||
| 4081 | } |
||
| 4082 | |||
| 4083 | /** |
||
| 4084 | * Schedules an update. It will run on the next UI update available. |
||
| 4085 | * @method scheduleUpdate |
||
| 4086 | * @memberof Popper |
||
| 4087 | */ |
||
| 4088 | |||
| 4089 | |||
| 4090 | /** |
||
| 4091 | * Collection of utilities useful when writing custom modifiers. |
||
| 4092 | * Starting from version 1.7, this method is available only if you |
||
| 4093 | * include `popper-utils.js` before `popper.js`. |
||
| 4094 | * |
||
| 4095 | * **DEPRECATION**: This way to access PopperUtils is deprecated |
||
| 4096 | * and will be removed in v2! Use the PopperUtils module directly instead. |
||
| 4097 | * Due to the high instability of the methods contained in Utils, we can't |
||
| 4098 | * guarantee them to follow semver. Use them at your own risk! |
||
| 4099 | * @static |
||
| 4100 | * @private |
||
| 4101 | * @type {Object} |
||
| 4102 | * @deprecated since version 1.8 |
||
| 4103 | * @member Utils |
||
| 4104 | * @memberof Popper |
||
| 4105 | */ |
||
| 4106 | |||
| 4107 | }]); |
||
| 4108 | return Popper; |
||
| 4109 | }(); |
||
| 4110 | |||
| 4111 | /** |
||
| 4112 | * The `referenceObject` is an object that provides an interface compatible with Popper.js |
||
| 4113 | * and lets you use it as replacement of a real DOM node.<br /> |
||
| 4114 | * You can use this method to position a popper relatively to a set of coordinates |
||
| 4115 | * in case you don't have a DOM node to use as reference. |
||
| 4116 | * |
||
| 4117 | * ``` |
||
| 4118 | * new Popper(referenceObject, popperNode); |
||
| 4119 | * ``` |
||
| 4120 | * |
||
| 4121 | * NB: This feature isn't supported in Internet Explorer 10. |
||
| 4122 | * @name referenceObject |
||
| 4123 | * @property {Function} data.getBoundingClientRect |
||
| 4124 | * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method. |
||
| 4125 | * @property {number} data.clientWidth |
||
| 4126 | * An ES6 getter that will return the width of the virtual reference element. |
||
| 4127 | * @property {number} data.clientHeight |
||
| 4128 | * An ES6 getter that will return the height of the virtual reference element. |
||
| 4129 | */ |
||
| 4130 | |||
| 4131 | |||
| 4132 | Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils; |
||
| 4133 | Popper.placements = placements; |
||
| 4134 | Popper.Defaults = Defaults; |
||
| 4135 | |||
| 4136 | /** |
||
| 4137 | * ------------------------------------------------------------------------ |
||
| 4138 | * Constants |
||
| 4139 | * ------------------------------------------------------------------------ |
||
| 4140 | */ |
||
| 4141 | |||
| 4142 | var NAME$4 = 'dropdown'; |
||
| 4143 | var VERSION$4 = '4.5.3'; |
||
| 4144 | var DATA_KEY$4 = 'bs.dropdown'; |
||
| 4145 | var EVENT_KEY$4 = "." + DATA_KEY$4; |
||
| 4146 | var DATA_API_KEY$4 = '.data-api'; |
||
| 4147 | var JQUERY_NO_CONFLICT$4 = $__default['default'].fn[NAME$4]; |
||
| 4148 | var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key |
||
| 4149 | |||
| 4150 | var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key |
||
| 4151 | |||
| 4152 | var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key |
||
| 4153 | |||
| 4154 | var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key |
||
| 4155 | |||
| 4156 | var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key |
||
| 4157 | |||
| 4158 | var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) |
||
| 4159 | |||
| 4160 | var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE); |
||
| 4161 | var EVENT_HIDE$1 = "hide" + EVENT_KEY$4; |
||
| 4162 | var EVENT_HIDDEN$1 = "hidden" + EVENT_KEY$4; |
||
| 4163 | var EVENT_SHOW$1 = "show" + EVENT_KEY$4; |
||
| 4164 | var EVENT_SHOWN$1 = "shown" + EVENT_KEY$4; |
||
| 4165 | var EVENT_CLICK = "click" + EVENT_KEY$4; |
||
| 4166 | var EVENT_CLICK_DATA_API$4 = "click" + EVENT_KEY$4 + DATA_API_KEY$4; |
||
| 4167 | var EVENT_KEYDOWN_DATA_API = "keydown" + EVENT_KEY$4 + DATA_API_KEY$4; |
||
| 4168 | var EVENT_KEYUP_DATA_API = "keyup" + EVENT_KEY$4 + DATA_API_KEY$4; |
||
| 4169 | var CLASS_NAME_DISABLED = 'disabled'; |
||
| 4170 | var CLASS_NAME_SHOW$2 = 'show'; |
||
| 4171 | var CLASS_NAME_DROPUP = 'dropup'; |
||
| 4172 | var CLASS_NAME_DROPRIGHT = 'dropright'; |
||
| 4173 | var CLASS_NAME_DROPLEFT = 'dropleft'; |
||
| 4174 | var CLASS_NAME_MENURIGHT = 'dropdown-menu-right'; |
||
| 4175 | var CLASS_NAME_POSITION_STATIC = 'position-static'; |
||
| 4176 | var SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]'; |
||
| 4177 | var SELECTOR_FORM_CHILD = '.dropdown form'; |
||
| 4178 | var SELECTOR_MENU = '.dropdown-menu'; |
||
| 4179 | var SELECTOR_NAVBAR_NAV = '.navbar-nav'; |
||
| 4180 | var SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; |
||
| 4181 | var PLACEMENT_TOP = 'top-start'; |
||
| 4182 | var PLACEMENT_TOPEND = 'top-end'; |
||
| 4183 | var PLACEMENT_BOTTOM = 'bottom-start'; |
||
| 4184 | var PLACEMENT_BOTTOMEND = 'bottom-end'; |
||
| 4185 | var PLACEMENT_RIGHT = 'right-start'; |
||
| 4186 | var PLACEMENT_LEFT = 'left-start'; |
||
| 4187 | var Default$2 = { |
||
| 4188 | offset: 0, |
||
| 4189 | flip: true, |
||
| 4190 | boundary: 'scrollParent', |
||
| 4191 | reference: 'toggle', |
||
| 4192 | display: 'dynamic', |
||
| 4193 | popperConfig: null |
||
| 4194 | }; |
||
| 4195 | var DefaultType$2 = { |
||
| 4196 | offset: '(number|string|function)', |
||
| 4197 | flip: 'boolean', |
||
| 4198 | boundary: '(string|element)', |
||
| 4199 | reference: '(string|element)', |
||
| 4200 | display: 'string', |
||
| 4201 | popperConfig: '(null|object)' |
||
| 4202 | }; |
||
| 4203 | /** |
||
| 4204 | * ------------------------------------------------------------------------ |
||
| 4205 | * Class Definition |
||
| 4206 | * ------------------------------------------------------------------------ |
||
| 4207 | */ |
||
| 4208 | |||
| 4209 | var Dropdown = /*#__PURE__*/function () { |
||
| 4210 | function Dropdown(element, config) { |
||
| 4211 | this._element = element; |
||
| 4212 | this._popper = null; |
||
| 4213 | this._config = this._getConfig(config); |
||
| 4214 | this._menu = this._getMenuElement(); |
||
| 4215 | this._inNavbar = this._detectNavbar(); |
||
| 4216 | |||
| 4217 | this._addEventListeners(); |
||
| 4218 | } // Getters |
||
| 4219 | |||
| 4220 | |||
| 4221 | var _proto = Dropdown.prototype; |
||
| 4222 | |||
| 4223 | // Public |
||
| 4224 | _proto.toggle = function toggle() { |
||
| 4225 | if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED)) { |
||
| 4226 | return; |
||
| 4227 | } |
||
| 4228 | |||
| 4229 | var isActive = $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2); |
||
| 4230 | |||
| 4231 | Dropdown._clearMenus(); |
||
| 4232 | |||
| 4233 | if (isActive) { |
||
| 4234 | return; |
||
| 4235 | } |
||
| 4236 | |||
| 4237 | this.show(true); |
||
| 4238 | }; |
||
| 4239 | |||
| 4240 | _proto.show = function show(usePopper) { |
||
| 4241 | if (usePopper === void 0) { |
||
| 4242 | usePopper = false; |
||
| 4243 | } |
||
| 4244 | |||
| 4245 | if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) { |
||
| 4246 | return; |
||
| 4247 | } |
||
| 4248 | |||
| 4249 | var relatedTarget = { |
||
| 4250 | relatedTarget: this._element |
||
| 4251 | }; |
||
| 4252 | var showEvent = $__default['default'].Event(EVENT_SHOW$1, relatedTarget); |
||
| 4253 | |||
| 4254 | var parent = Dropdown._getParentFromElement(this._element); |
||
| 4255 | |||
| 4256 | $__default['default'](parent).trigger(showEvent); |
||
| 4257 | |||
| 4258 | if (showEvent.isDefaultPrevented()) { |
||
| 4259 | return; |
||
| 4260 | } // Disable totally Popper.js for Dropdown in Navbar |
||
| 4261 | |||
| 4262 | |||
| 4263 | if (!this._inNavbar && usePopper) { |
||
| 4264 | /** |
||
| 4265 | * Check for Popper dependency |
||
| 4266 | * Popper - https://popper.js.org |
||
| 4267 | */ |
||
| 4268 | if (typeof Popper === 'undefined') { |
||
| 4269 | throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)'); |
||
| 4270 | } |
||
| 4271 | |||
| 4272 | var referenceElement = this._element; |
||
| 4273 | |||
| 4274 | if (this._config.reference === 'parent') { |
||
| 4275 | referenceElement = parent; |
||
| 4276 | } else if (Util.isElement(this._config.reference)) { |
||
| 4277 | referenceElement = this._config.reference; // Check if it's jQuery element |
||
| 4278 | |||
| 4279 | if (typeof this._config.reference.jquery !== 'undefined') { |
||
| 4280 | referenceElement = this._config.reference[0]; |
||
| 4281 | } |
||
| 4282 | } // If boundary is not `scrollParent`, then set position to `static` |
||
| 4283 | // to allow the menu to "escape" the scroll parent's boundaries |
||
| 4284 | // https://github.com/twbs/bootstrap/issues/24251 |
||
| 4285 | |||
| 4286 | |||
| 4287 | if (this._config.boundary !== 'scrollParent') { |
||
| 4288 | $__default['default'](parent).addClass(CLASS_NAME_POSITION_STATIC); |
||
| 4289 | } |
||
| 4290 | |||
| 4291 | this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); |
||
| 4292 | } // If this is a touch-enabled device we add extra |
||
| 4293 | // empty mouseover listeners to the body's immediate children; |
||
| 4294 | // only needed because of broken event delegation on iOS |
||
| 4295 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
||
| 4296 | |||
| 4297 | |||
| 4298 | if ('ontouchstart' in document.documentElement && $__default['default'](parent).closest(SELECTOR_NAVBAR_NAV).length === 0) { |
||
| 4299 | $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop); |
||
| 4300 | } |
||
| 4301 | |||
| 4302 | this._element.focus(); |
||
| 4303 | |||
| 4304 | this._element.setAttribute('aria-expanded', true); |
||
| 4305 | |||
| 4306 | $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2); |
||
| 4307 | $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_SHOWN$1, relatedTarget)); |
||
| 4308 | }; |
||
| 4309 | |||
| 4310 | _proto.hide = function hide() { |
||
| 4311 | if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || !$__default['default'](this._menu).hasClass(CLASS_NAME_SHOW$2)) { |
||
| 4312 | return; |
||
| 4313 | } |
||
| 4314 | |||
| 4315 | var relatedTarget = { |
||
| 4316 | relatedTarget: this._element |
||
| 4317 | }; |
||
| 4318 | var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget); |
||
| 4319 | |||
| 4320 | var parent = Dropdown._getParentFromElement(this._element); |
||
| 4321 | |||
| 4322 | $__default['default'](parent).trigger(hideEvent); |
||
| 4323 | |||
| 4324 | if (hideEvent.isDefaultPrevented()) { |
||
| 4325 | return; |
||
| 4326 | } |
||
| 4327 | |||
| 4328 | if (this._popper) { |
||
| 4329 | this._popper.destroy(); |
||
| 4330 | } |
||
| 4331 | |||
| 4332 | $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW$2); |
||
| 4333 | $__default['default'](parent).toggleClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget)); |
||
| 4334 | }; |
||
| 4335 | |||
| 4336 | _proto.dispose = function dispose() { |
||
| 4337 | $__default['default'].removeData(this._element, DATA_KEY$4); |
||
| 4338 | $__default['default'](this._element).off(EVENT_KEY$4); |
||
| 4339 | this._element = null; |
||
| 4340 | this._menu = null; |
||
| 4341 | |||
| 4342 | if (this._popper !== null) { |
||
| 4343 | this._popper.destroy(); |
||
| 4344 | |||
| 4345 | this._popper = null; |
||
| 4346 | } |
||
| 4347 | }; |
||
| 4348 | |||
| 4349 | _proto.update = function update() { |
||
| 4350 | this._inNavbar = this._detectNavbar(); |
||
| 4351 | |||
| 4352 | if (this._popper !== null) { |
||
| 4353 | this._popper.scheduleUpdate(); |
||
| 4354 | } |
||
| 4355 | } // Private |
||
| 4356 | ; |
||
| 4357 | |||
| 4358 | _proto._addEventListeners = function _addEventListeners() { |
||
| 4359 | var _this = this; |
||
| 4360 | |||
| 4361 | $__default['default'](this._element).on(EVENT_CLICK, function (event) { |
||
| 4362 | event.preventDefault(); |
||
| 4363 | event.stopPropagation(); |
||
| 4364 | |||
| 4365 | _this.toggle(); |
||
| 4366 | }); |
||
| 4367 | }; |
||
| 4368 | |||
| 4369 | _proto._getConfig = function _getConfig(config) { |
||
| 4370 | config = _extends({}, this.constructor.Default, $__default['default'](this._element).data(), config); |
||
| 4371 | Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType); |
||
| 4372 | return config; |
||
| 4373 | }; |
||
| 4374 | |||
| 4375 | _proto._getMenuElement = function _getMenuElement() { |
||
| 4376 | if (!this._menu) { |
||
| 4377 | var parent = Dropdown._getParentFromElement(this._element); |
||
| 4378 | |||
| 4379 | if (parent) { |
||
| 4380 | this._menu = parent.querySelector(SELECTOR_MENU); |
||
| 4381 | } |
||
| 4382 | } |
||
| 4383 | |||
| 4384 | return this._menu; |
||
| 4385 | }; |
||
| 4386 | |||
| 4387 | _proto._getPlacement = function _getPlacement() { |
||
| 4388 | var $parentDropdown = $__default['default'](this._element.parentNode); |
||
| 4389 | var placement = PLACEMENT_BOTTOM; // Handle dropup |
||
| 4390 | |||
| 4391 | if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) { |
||
| 4392 | placement = $__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP; |
||
| 4393 | } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) { |
||
| 4394 | placement = PLACEMENT_RIGHT; |
||
| 4395 | } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) { |
||
| 4396 | placement = PLACEMENT_LEFT; |
||
| 4397 | } else if ($__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT)) { |
||
| 4398 | placement = PLACEMENT_BOTTOMEND; |
||
| 4399 | } |
||
| 4400 | |||
| 4401 | return placement; |
||
| 4402 | }; |
||
| 4403 | |||
| 4404 | _proto._detectNavbar = function _detectNavbar() { |
||
| 4405 | return $__default['default'](this._element).closest('.navbar').length > 0; |
||
| 4406 | }; |
||
| 4407 | |||
| 4408 | _proto._getOffset = function _getOffset() { |
||
| 4409 | var _this2 = this; |
||
| 4410 | |||
| 4411 | var offset = {}; |
||
| 4412 | |||
| 4413 | if (typeof this._config.offset === 'function') { |
||
| 4414 | offset.fn = function (data) { |
||
| 4415 | data.offsets = _extends({}, data.offsets, _this2._config.offset(data.offsets, _this2._element) || {}); |
||
| 4416 | return data; |
||
| 4417 | }; |
||
| 4418 | } else { |
||
| 4419 | offset.offset = this._config.offset; |
||
| 4420 | } |
||
| 4421 | |||
| 4422 | return offset; |
||
| 4423 | }; |
||
| 4424 | |||
| 4425 | _proto._getPopperConfig = function _getPopperConfig() { |
||
| 4426 | var popperConfig = { |
||
| 4427 | placement: this._getPlacement(), |
||
| 4428 | modifiers: { |
||
| 4429 | offset: this._getOffset(), |
||
| 4430 | flip: { |
||
| 4431 | enabled: this._config.flip |
||
| 4432 | }, |
||
| 4433 | preventOverflow: { |
||
| 4434 | boundariesElement: this._config.boundary |
||
| 4435 | } |
||
| 4436 | } |
||
| 4437 | }; // Disable Popper.js if we have a static display |
||
| 4438 | |||
| 4439 | if (this._config.display === 'static') { |
||
| 4440 | popperConfig.modifiers.applyStyle = { |
||
| 4441 | enabled: false |
||
| 4442 | }; |
||
| 4443 | } |
||
| 4444 | |||
| 4445 | return _extends({}, popperConfig, this._config.popperConfig); |
||
| 4446 | } // Static |
||
| 4447 | ; |
||
| 4448 | |||
| 4449 | Dropdown._jQueryInterface = function _jQueryInterface(config) { |
||
| 4450 | return this.each(function () { |
||
| 4451 | var data = $__default['default'](this).data(DATA_KEY$4); |
||
| 4452 | |||
| 4453 | var _config = typeof config === 'object' ? config : null; |
||
| 4454 | |||
| 4455 | if (!data) { |
||
| 4456 | data = new Dropdown(this, _config); |
||
| 4457 | $__default['default'](this).data(DATA_KEY$4, data); |
||
| 4458 | } |
||
| 4459 | |||
| 4460 | if (typeof config === 'string') { |
||
| 4461 | if (typeof data[config] === 'undefined') { |
||
| 4462 | throw new TypeError("No method named \"" + config + "\""); |
||
| 4463 | } |
||
| 4464 | |||
| 4465 | data[config](); |
||
| 4466 | } |
||
| 4467 | }); |
||
| 4468 | }; |
||
| 4469 | |||
| 4470 | Dropdown._clearMenus = function _clearMenus(event) { |
||
| 4471 | if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) { |
||
| 4472 | return; |
||
| 4473 | } |
||
| 4474 | |||
| 4475 | var toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2)); |
||
| 4476 | |||
| 4477 | for (var i = 0, len = toggles.length; i < len; i++) { |
||
| 4478 | var parent = Dropdown._getParentFromElement(toggles[i]); |
||
| 4479 | |||
| 4480 | var context = $__default['default'](toggles[i]).data(DATA_KEY$4); |
||
| 4481 | var relatedTarget = { |
||
| 4482 | relatedTarget: toggles[i] |
||
| 4483 | }; |
||
| 4484 | |||
| 4485 | if (event && event.type === 'click') { |
||
| 4486 | relatedTarget.clickEvent = event; |
||
| 4487 | } |
||
| 4488 | |||
| 4489 | if (!context) { |
||
| 4490 | continue; |
||
| 4491 | } |
||
| 4492 | |||
| 4493 | var dropdownMenu = context._menu; |
||
| 4494 | |||
| 4495 | if (!$__default['default'](parent).hasClass(CLASS_NAME_SHOW$2)) { |
||
| 4496 | continue; |
||
| 4497 | } |
||
| 4498 | |||
| 4499 | if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $__default['default'].contains(parent, event.target)) { |
||
| 4500 | continue; |
||
| 4501 | } |
||
| 4502 | |||
| 4503 | var hideEvent = $__default['default'].Event(EVENT_HIDE$1, relatedTarget); |
||
| 4504 | $__default['default'](parent).trigger(hideEvent); |
||
| 4505 | |||
| 4506 | if (hideEvent.isDefaultPrevented()) { |
||
| 4507 | continue; |
||
| 4508 | } // If this is a touch-enabled device we remove the extra |
||
| 4509 | // empty mouseover listeners we added for iOS support |
||
| 4510 | |||
| 4511 | |||
| 4512 | if ('ontouchstart' in document.documentElement) { |
||
| 4513 | $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop); |
||
| 4514 | } |
||
| 4515 | |||
| 4516 | toggles[i].setAttribute('aria-expanded', 'false'); |
||
| 4517 | |||
| 4518 | if (context._popper) { |
||
| 4519 | context._popper.destroy(); |
||
| 4520 | } |
||
| 4521 | |||
| 4522 | $__default['default'](dropdownMenu).removeClass(CLASS_NAME_SHOW$2); |
||
| 4523 | $__default['default'](parent).removeClass(CLASS_NAME_SHOW$2).trigger($__default['default'].Event(EVENT_HIDDEN$1, relatedTarget)); |
||
| 4524 | } |
||
| 4525 | }; |
||
| 4526 | |||
| 4527 | Dropdown._getParentFromElement = function _getParentFromElement(element) { |
||
| 4528 | var parent; |
||
| 4529 | var selector = Util.getSelectorFromElement(element); |
||
| 4530 | |||
| 4531 | if (selector) { |
||
| 4532 | parent = document.querySelector(selector); |
||
| 4533 | } |
||
| 4534 | |||
| 4535 | return parent || element.parentNode; |
||
| 4536 | } // eslint-disable-next-line complexity |
||
| 4537 | ; |
||
| 4538 | |||
| 4539 | Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { |
||
| 4540 | // If not input/textarea: |
||
| 4541 | // - And not a key in REGEXP_KEYDOWN => not a dropdown command |
||
| 4542 | // If input/textarea: |
||
| 4543 | // - If space key => not a dropdown command |
||
| 4544 | // - If key is other than escape |
||
| 4545 | // - If key is not up or down => not a dropdown command |
||
| 4546 | // - If trigger inside the menu => not a dropdown command |
||
| 4547 | 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 || $__default['default'](event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { |
||
| 4548 | return; |
||
| 4549 | } |
||
| 4550 | |||
| 4551 | if (this.disabled || $__default['default'](this).hasClass(CLASS_NAME_DISABLED)) { |
||
| 4552 | return; |
||
| 4553 | } |
||
| 4554 | |||
| 4555 | var parent = Dropdown._getParentFromElement(this); |
||
| 4556 | |||
| 4557 | var isActive = $__default['default'](parent).hasClass(CLASS_NAME_SHOW$2); |
||
| 4558 | |||
| 4559 | if (!isActive && event.which === ESCAPE_KEYCODE) { |
||
| 4560 | return; |
||
| 4561 | } |
||
| 4562 | |||
| 4563 | event.preventDefault(); |
||
| 4564 | event.stopPropagation(); |
||
| 4565 | |||
| 4566 | if (!isActive || event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE) { |
||
| 4567 | if (event.which === ESCAPE_KEYCODE) { |
||
| 4568 | $__default['default'](parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus'); |
||
| 4569 | } |
||
| 4570 | |||
| 4571 | $__default['default'](this).trigger('click'); |
||
| 4572 | return; |
||
| 4573 | } |
||
| 4574 | |||
| 4575 | var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) { |
||
| 4576 | return $__default['default'](item).is(':visible'); |
||
| 4577 | }); |
||
| 4578 | |||
| 4579 | if (items.length === 0) { |
||
| 4580 | return; |
||
| 4581 | } |
||
| 4582 | |||
| 4583 | var index = items.indexOf(event.target); |
||
| 4584 | |||
| 4585 | if (event.which === ARROW_UP_KEYCODE && index > 0) { |
||
| 4586 | // Up |
||
| 4587 | index--; |
||
| 4588 | } |
||
| 4589 | |||
| 4590 | if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { |
||
| 4591 | // Down |
||
| 4592 | index++; |
||
| 4593 | } |
||
| 4594 | |||
| 4595 | if (index < 0) { |
||
| 4596 | index = 0; |
||
| 4597 | } |
||
| 4598 | |||
| 4599 | items[index].focus(); |
||
| 4600 | }; |
||
| 4601 | |||
| 4602 | _createClass(Dropdown, null, [{ |
||
| 4603 | key: "VERSION", |
||
| 4604 | get: function get() { |
||
| 4605 | return VERSION$4; |
||
| 4606 | } |
||
| 4607 | }, { |
||
| 4608 | key: "Default", |
||
| 4609 | get: function get() { |
||
| 4610 | return Default$2; |
||
| 4611 | } |
||
| 4612 | }, { |
||
| 4613 | key: "DefaultType", |
||
| 4614 | get: function get() { |
||
| 4615 | return DefaultType$2; |
||
| 4616 | } |
||
| 4617 | }]); |
||
| 4618 | |||
| 4619 | return Dropdown; |
||
| 4620 | }(); |
||
| 4621 | /** |
||
| 4622 | * ------------------------------------------------------------------------ |
||
| 4623 | * Data Api implementation |
||
| 4624 | * ------------------------------------------------------------------------ |
||
| 4625 | */ |
||
| 4626 | |||
| 4627 | |||
| 4628 | $__default['default'](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) { |
||
| 4629 | event.preventDefault(); |
||
| 4630 | event.stopPropagation(); |
||
| 4631 | |||
| 4632 | Dropdown._jQueryInterface.call($__default['default'](this), 'toggle'); |
||
| 4633 | }).on(EVENT_CLICK_DATA_API$4, SELECTOR_FORM_CHILD, function (e) { |
||
| 4634 | e.stopPropagation(); |
||
| 4635 | }); |
||
| 4636 | /** |
||
| 4637 | * ------------------------------------------------------------------------ |
||
| 4638 | * jQuery |
||
| 4639 | * ------------------------------------------------------------------------ |
||
| 4640 | */ |
||
| 4641 | |||
| 4642 | $__default['default'].fn[NAME$4] = Dropdown._jQueryInterface; |
||
| 4643 | $__default['default'].fn[NAME$4].Constructor = Dropdown; |
||
| 4644 | |||
| 4645 | $__default['default'].fn[NAME$4].noConflict = function () { |
||
| 4646 | $__default['default'].fn[NAME$4] = JQUERY_NO_CONFLICT$4; |
||
| 4647 | return Dropdown._jQueryInterface; |
||
| 4648 | }; |
||
| 4649 | |||
| 4650 | /** |
||
| 4651 | * ------------------------------------------------------------------------ |
||
| 4652 | * Constants |
||
| 4653 | * ------------------------------------------------------------------------ |
||
| 4654 | */ |
||
| 4655 | |||
| 4656 | var NAME$5 = 'modal'; |
||
| 4657 | var VERSION$5 = '4.5.3'; |
||
| 4658 | var DATA_KEY$5 = 'bs.modal'; |
||
| 4659 | var EVENT_KEY$5 = "." + DATA_KEY$5; |
||
| 4660 | var DATA_API_KEY$5 = '.data-api'; |
||
| 4661 | var JQUERY_NO_CONFLICT$5 = $__default['default'].fn[NAME$5]; |
||
| 4662 | var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key |
||
| 4663 | |||
| 4664 | var Default$3 = { |
||
| 4665 | backdrop: true, |
||
| 4666 | keyboard: true, |
||
| 4667 | focus: true, |
||
| 4668 | show: true |
||
| 4669 | }; |
||
| 4670 | var DefaultType$3 = { |
||
| 4671 | backdrop: '(boolean|string)', |
||
| 4672 | keyboard: 'boolean', |
||
| 4673 | focus: 'boolean', |
||
| 4674 | show: 'boolean' |
||
| 4675 | }; |
||
| 4676 | var EVENT_HIDE$2 = "hide" + EVENT_KEY$5; |
||
| 4677 | var EVENT_HIDE_PREVENTED = "hidePrevented" + EVENT_KEY$5; |
||
| 4678 | var EVENT_HIDDEN$2 = "hidden" + EVENT_KEY$5; |
||
| 4679 | var EVENT_SHOW$2 = "show" + EVENT_KEY$5; |
||
| 4680 | var EVENT_SHOWN$2 = "shown" + EVENT_KEY$5; |
||
| 4681 | var EVENT_FOCUSIN = "focusin" + EVENT_KEY$5; |
||
| 4682 | var EVENT_RESIZE = "resize" + EVENT_KEY$5; |
||
| 4683 | var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY$5; |
||
| 4684 | var EVENT_KEYDOWN_DISMISS = "keydown.dismiss" + EVENT_KEY$5; |
||
| 4685 | var EVENT_MOUSEUP_DISMISS = "mouseup.dismiss" + EVENT_KEY$5; |
||
| 4686 | var EVENT_MOUSEDOWN_DISMISS = "mousedown.dismiss" + EVENT_KEY$5; |
||
| 4687 | var EVENT_CLICK_DATA_API$5 = "click" + EVENT_KEY$5 + DATA_API_KEY$5; |
||
| 4688 | var CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable'; |
||
| 4689 | var CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure'; |
||
| 4690 | var CLASS_NAME_BACKDROP = 'modal-backdrop'; |
||
| 4691 | var CLASS_NAME_OPEN = 'modal-open'; |
||
| 4692 | var CLASS_NAME_FADE$1 = 'fade'; |
||
| 4693 | var CLASS_NAME_SHOW$3 = 'show'; |
||
| 4694 | var CLASS_NAME_STATIC = 'modal-static'; |
||
| 4695 | var SELECTOR_DIALOG = '.modal-dialog'; |
||
| 4696 | var SELECTOR_MODAL_BODY = '.modal-body'; |
||
| 4697 | var SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]'; |
||
| 4698 | var SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]'; |
||
| 4699 | var SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; |
||
| 4700 | var SELECTOR_STICKY_CONTENT = '.sticky-top'; |
||
| 4701 | /** |
||
| 4702 | * ------------------------------------------------------------------------ |
||
| 4703 | * Class Definition |
||
| 4704 | * ------------------------------------------------------------------------ |
||
| 4705 | */ |
||
| 4706 | |||
| 4707 | var Modal = /*#__PURE__*/function () { |
||
| 4708 | function Modal(element, config) { |
||
| 4709 | this._config = this._getConfig(config); |
||
| 4710 | this._element = element; |
||
| 4711 | this._dialog = element.querySelector(SELECTOR_DIALOG); |
||
| 4712 | this._backdrop = null; |
||
| 4713 | this._isShown = false; |
||
| 4714 | this._isBodyOverflowing = false; |
||
| 4715 | this._ignoreBackdropClick = false; |
||
| 4716 | this._isTransitioning = false; |
||
| 4717 | this._scrollbarWidth = 0; |
||
| 4718 | } // Getters |
||
| 4719 | |||
| 4720 | |||
| 4721 | var _proto = Modal.prototype; |
||
| 4722 | |||
| 4723 | // Public |
||
| 4724 | _proto.toggle = function toggle(relatedTarget) { |
||
| 4725 | return this._isShown ? this.hide() : this.show(relatedTarget); |
||
| 4726 | }; |
||
| 4727 | |||
| 4728 | _proto.show = function show(relatedTarget) { |
||
| 4729 | var _this = this; |
||
| 4730 | |||
| 4731 | if (this._isShown || this._isTransitioning) { |
||
| 4732 | return; |
||
| 4733 | } |
||
| 4734 | |||
| 4735 | if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) { |
||
| 4736 | this._isTransitioning = true; |
||
| 4737 | } |
||
| 4738 | |||
| 4739 | var showEvent = $__default['default'].Event(EVENT_SHOW$2, { |
||
| 4740 | relatedTarget: relatedTarget |
||
| 4741 | }); |
||
| 4742 | $__default['default'](this._element).trigger(showEvent); |
||
| 4743 | |||
| 4744 | if (this._isShown || showEvent.isDefaultPrevented()) { |
||
| 4745 | return; |
||
| 4746 | } |
||
| 4747 | |||
| 4748 | this._isShown = true; |
||
| 4749 | |||
| 4750 | this._checkScrollbar(); |
||
| 4751 | |||
| 4752 | this._setScrollbar(); |
||
| 4753 | |||
| 4754 | this._adjustDialog(); |
||
| 4755 | |||
| 4756 | this._setEscapeEvent(); |
||
| 4757 | |||
| 4758 | this._setResizeEvent(); |
||
| 4759 | |||
| 4760 | $__default['default'](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function (event) { |
||
| 4761 | return _this.hide(event); |
||
| 4762 | }); |
||
| 4763 | $__default['default'](this._dialog).on(EVENT_MOUSEDOWN_DISMISS, function () { |
||
| 4764 | $__default['default'](_this._element).one(EVENT_MOUSEUP_DISMISS, function (event) { |
||
| 4765 | if ($__default['default'](event.target).is(_this._element)) { |
||
| 4766 | _this._ignoreBackdropClick = true; |
||
| 4767 | } |
||
| 4768 | }); |
||
| 4769 | }); |
||
| 4770 | |||
| 4771 | this._showBackdrop(function () { |
||
| 4772 | return _this._showElement(relatedTarget); |
||
| 4773 | }); |
||
| 4774 | }; |
||
| 4775 | |||
| 4776 | _proto.hide = function hide(event) { |
||
| 4777 | var _this2 = this; |
||
| 4778 | |||
| 4779 | if (event) { |
||
| 4780 | event.preventDefault(); |
||
| 4781 | } |
||
| 4782 | |||
| 4783 | if (!this._isShown || this._isTransitioning) { |
||
| 4784 | return; |
||
| 4785 | } |
||
| 4786 | |||
| 4787 | var hideEvent = $__default['default'].Event(EVENT_HIDE$2); |
||
| 4788 | $__default['default'](this._element).trigger(hideEvent); |
||
| 4789 | |||
| 4790 | if (!this._isShown || hideEvent.isDefaultPrevented()) { |
||
| 4791 | return; |
||
| 4792 | } |
||
| 4793 | |||
| 4794 | this._isShown = false; |
||
| 4795 | var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1); |
||
| 4796 | |||
| 4797 | if (transition) { |
||
| 4798 | this._isTransitioning = true; |
||
| 4799 | } |
||
| 4800 | |||
| 4801 | this._setEscapeEvent(); |
||
| 4802 | |||
| 4803 | this._setResizeEvent(); |
||
| 4804 | |||
| 4805 | $__default['default'](document).off(EVENT_FOCUSIN); |
||
| 4806 | $__default['default'](this._element).removeClass(CLASS_NAME_SHOW$3); |
||
| 4807 | $__default['default'](this._element).off(EVENT_CLICK_DISMISS); |
||
| 4808 | $__default['default'](this._dialog).off(EVENT_MOUSEDOWN_DISMISS); |
||
| 4809 | |||
| 4810 | if (transition) { |
||
| 4811 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); |
||
| 4812 | $__default['default'](this._element).one(Util.TRANSITION_END, function (event) { |
||
| 4813 | return _this2._hideModal(event); |
||
| 4814 | }).emulateTransitionEnd(transitionDuration); |
||
| 4815 | } else { |
||
| 4816 | this._hideModal(); |
||
| 4817 | } |
||
| 4818 | }; |
||
| 4819 | |||
| 4820 | _proto.dispose = function dispose() { |
||
| 4821 | [window, this._element, this._dialog].forEach(function (htmlElement) { |
||
| 4822 | return $__default['default'](htmlElement).off(EVENT_KEY$5); |
||
| 4823 | }); |
||
| 4824 | /** |
||
| 4825 | * `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API` |
||
| 4826 | * Do not move `document` in `htmlElements` array |
||
| 4827 | * It will remove `EVENT_CLICK_DATA_API` event that should remain |
||
| 4828 | */ |
||
| 4829 | |||
| 4830 | $__default['default'](document).off(EVENT_FOCUSIN); |
||
| 4831 | $__default['default'].removeData(this._element, DATA_KEY$5); |
||
| 4832 | this._config = null; |
||
| 4833 | this._element = null; |
||
| 4834 | this._dialog = null; |
||
| 4835 | this._backdrop = null; |
||
| 4836 | this._isShown = null; |
||
| 4837 | this._isBodyOverflowing = null; |
||
| 4838 | this._ignoreBackdropClick = null; |
||
| 4839 | this._isTransitioning = null; |
||
| 4840 | this._scrollbarWidth = null; |
||
| 4841 | }; |
||
| 4842 | |||
| 4843 | _proto.handleUpdate = function handleUpdate() { |
||
| 4844 | this._adjustDialog(); |
||
| 4845 | } // Private |
||
| 4846 | ; |
||
| 4847 | |||
| 4848 | _proto._getConfig = function _getConfig(config) { |
||
| 4849 | config = _extends({}, Default$3, config); |
||
| 4850 | Util.typeCheckConfig(NAME$5, config, DefaultType$3); |
||
| 4851 | return config; |
||
| 4852 | }; |
||
| 4853 | |||
| 4854 | _proto._triggerBackdropTransition = function _triggerBackdropTransition() { |
||
| 4855 | var _this3 = this; |
||
| 4856 | |||
| 4857 | if (this._config.backdrop === 'static') { |
||
| 4858 | var hideEventPrevented = $__default['default'].Event(EVENT_HIDE_PREVENTED); |
||
| 4859 | $__default['default'](this._element).trigger(hideEventPrevented); |
||
| 4860 | |||
| 4861 | if (hideEventPrevented.isDefaultPrevented()) { |
||
| 4862 | return; |
||
| 4863 | } |
||
| 4864 | |||
| 4865 | var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; |
||
| 4866 | |||
| 4867 | if (!isModalOverflowing) { |
||
| 4868 | this._element.style.overflowY = 'hidden'; |
||
| 4869 | } |
||
| 4870 | |||
| 4871 | this._element.classList.add(CLASS_NAME_STATIC); |
||
| 4872 | |||
| 4873 | var modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog); |
||
| 4874 | $__default['default'](this._element).off(Util.TRANSITION_END); |
||
| 4875 | $__default['default'](this._element).one(Util.TRANSITION_END, function () { |
||
| 4876 | _this3._element.classList.remove(CLASS_NAME_STATIC); |
||
| 4877 | |||
| 4878 | if (!isModalOverflowing) { |
||
| 4879 | $__default['default'](_this3._element).one(Util.TRANSITION_END, function () { |
||
| 4880 | _this3._element.style.overflowY = ''; |
||
| 4881 | }).emulateTransitionEnd(_this3._element, modalTransitionDuration); |
||
| 4882 | } |
||
| 4883 | }).emulateTransitionEnd(modalTransitionDuration); |
||
| 4884 | |||
| 4885 | this._element.focus(); |
||
| 4886 | } else { |
||
| 4887 | this.hide(); |
||
| 4888 | } |
||
| 4889 | }; |
||
| 4890 | |||
| 4891 | _proto._showElement = function _showElement(relatedTarget) { |
||
| 4892 | var _this4 = this; |
||
| 4893 | |||
| 4894 | var transition = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1); |
||
| 4895 | var modalBody = this._dialog ? this._dialog.querySelector(SELECTOR_MODAL_BODY) : null; |
||
| 4896 | |||
| 4897 | if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { |
||
| 4898 | // Don't move modal's DOM position |
||
| 4899 | document.body.appendChild(this._element); |
||
| 4900 | } |
||
| 4901 | |||
| 4902 | this._element.style.display = 'block'; |
||
| 4903 | |||
| 4904 | this._element.removeAttribute('aria-hidden'); |
||
| 4905 | |||
| 4906 | this._element.setAttribute('aria-modal', true); |
||
| 4907 | |||
| 4908 | this._element.setAttribute('role', 'dialog'); |
||
| 4909 | |||
| 4910 | if ($__default['default'](this._dialog).hasClass(CLASS_NAME_SCROLLABLE) && modalBody) { |
||
| 4911 | modalBody.scrollTop = 0; |
||
| 4912 | } else { |
||
| 4913 | this._element.scrollTop = 0; |
||
| 4914 | } |
||
| 4915 | |||
| 4916 | if (transition) { |
||
| 4917 | Util.reflow(this._element); |
||
| 4918 | } |
||
| 4919 | |||
| 4920 | $__default['default'](this._element).addClass(CLASS_NAME_SHOW$3); |
||
| 4921 | |||
| 4922 | if (this._config.focus) { |
||
| 4923 | this._enforceFocus(); |
||
| 4924 | } |
||
| 4925 | |||
| 4926 | var shownEvent = $__default['default'].Event(EVENT_SHOWN$2, { |
||
| 4927 | relatedTarget: relatedTarget |
||
| 4928 | }); |
||
| 4929 | |||
| 4930 | var transitionComplete = function transitionComplete() { |
||
| 4931 | if (_this4._config.focus) { |
||
| 4932 | _this4._element.focus(); |
||
| 4933 | } |
||
| 4934 | |||
| 4935 | _this4._isTransitioning = false; |
||
| 4936 | $__default['default'](_this4._element).trigger(shownEvent); |
||
| 4937 | }; |
||
| 4938 | |||
| 4939 | if (transition) { |
||
| 4940 | var transitionDuration = Util.getTransitionDurationFromElement(this._dialog); |
||
| 4941 | $__default['default'](this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration); |
||
| 4942 | } else { |
||
| 4943 | transitionComplete(); |
||
| 4944 | } |
||
| 4945 | }; |
||
| 4946 | |||
| 4947 | _proto._enforceFocus = function _enforceFocus() { |
||
| 4948 | var _this5 = this; |
||
| 4949 | |||
| 4950 | $__default['default'](document).off(EVENT_FOCUSIN) // Guard against infinite focus loop |
||
| 4951 | .on(EVENT_FOCUSIN, function (event) { |
||
| 4952 | if (document !== event.target && _this5._element !== event.target && $__default['default'](_this5._element).has(event.target).length === 0) { |
||
| 4953 | _this5._element.focus(); |
||
| 4954 | } |
||
| 4955 | }); |
||
| 4956 | }; |
||
| 4957 | |||
| 4958 | _proto._setEscapeEvent = function _setEscapeEvent() { |
||
| 4959 | var _this6 = this; |
||
| 4960 | |||
| 4961 | if (this._isShown) { |
||
| 4962 | $__default['default'](this._element).on(EVENT_KEYDOWN_DISMISS, function (event) { |
||
| 4963 | if (_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) { |
||
| 4964 | event.preventDefault(); |
||
| 4965 | |||
| 4966 | _this6.hide(); |
||
| 4967 | } else if (!_this6._config.keyboard && event.which === ESCAPE_KEYCODE$1) { |
||
| 4968 | _this6._triggerBackdropTransition(); |
||
| 4969 | } |
||
| 4970 | }); |
||
| 4971 | } else if (!this._isShown) { |
||
| 4972 | $__default['default'](this._element).off(EVENT_KEYDOWN_DISMISS); |
||
| 4973 | } |
||
| 4974 | }; |
||
| 4975 | |||
| 4976 | _proto._setResizeEvent = function _setResizeEvent() { |
||
| 4977 | var _this7 = this; |
||
| 4978 | |||
| 4979 | if (this._isShown) { |
||
| 4980 | $__default['default'](window).on(EVENT_RESIZE, function (event) { |
||
| 4981 | return _this7.handleUpdate(event); |
||
| 4982 | }); |
||
| 4983 | } else { |
||
| 4984 | $__default['default'](window).off(EVENT_RESIZE); |
||
| 4985 | } |
||
| 4986 | }; |
||
| 4987 | |||
| 4988 | _proto._hideModal = function _hideModal() { |
||
| 4989 | var _this8 = this; |
||
| 4990 | |||
| 4991 | this._element.style.display = 'none'; |
||
| 4992 | |||
| 4993 | this._element.setAttribute('aria-hidden', true); |
||
| 4994 | |||
| 4995 | this._element.removeAttribute('aria-modal'); |
||
| 4996 | |||
| 4997 | this._element.removeAttribute('role'); |
||
| 4998 | |||
| 4999 | this._isTransitioning = false; |
||
| 5000 | |||
| 5001 | this._showBackdrop(function () { |
||
| 5002 | $__default['default'](document.body).removeClass(CLASS_NAME_OPEN); |
||
| 5003 | |||
| 5004 | _this8._resetAdjustments(); |
||
| 5005 | |||
| 5006 | _this8._resetScrollbar(); |
||
| 5007 | |||
| 5008 | $__default['default'](_this8._element).trigger(EVENT_HIDDEN$2); |
||
| 5009 | }); |
||
| 5010 | }; |
||
| 5011 | |||
| 5012 | _proto._removeBackdrop = function _removeBackdrop() { |
||
| 5013 | if (this._backdrop) { |
||
| 5014 | $__default['default'](this._backdrop).remove(); |
||
| 5015 | this._backdrop = null; |
||
| 5016 | } |
||
| 5017 | }; |
||
| 5018 | |||
| 5019 | _proto._showBackdrop = function _showBackdrop(callback) { |
||
| 5020 | var _this9 = this; |
||
| 5021 | |||
| 5022 | var animate = $__default['default'](this._element).hasClass(CLASS_NAME_FADE$1) ? CLASS_NAME_FADE$1 : ''; |
||
| 5023 | |||
| 5024 | if (this._isShown && this._config.backdrop) { |
||
| 5025 | this._backdrop = document.createElement('div'); |
||
| 5026 | this._backdrop.className = CLASS_NAME_BACKDROP; |
||
| 5027 | |||
| 5028 | if (animate) { |
||
| 5029 | this._backdrop.classList.add(animate); |
||
| 5030 | } |
||
| 5031 | |||
| 5032 | $__default['default'](this._backdrop).appendTo(document.body); |
||
| 5033 | $__default['default'](this._element).on(EVENT_CLICK_DISMISS, function (event) { |
||
| 5034 | if (_this9._ignoreBackdropClick) { |
||
| 5035 | _this9._ignoreBackdropClick = false; |
||
| 5036 | return; |
||
| 5037 | } |
||
| 5038 | |||
| 5039 | if (event.target !== event.currentTarget) { |
||
| 5040 | return; |
||
| 5041 | } |
||
| 5042 | |||
| 5043 | _this9._triggerBackdropTransition(); |
||
| 5044 | }); |
||
| 5045 | |||
| 5046 | if (animate) { |
||
| 5047 | Util.reflow(this._backdrop); |
||
| 5048 | } |
||
| 5049 | |||
| 5050 | $__default['default'](this._backdrop).addClass(CLASS_NAME_SHOW$3); |
||
| 5051 | |||
| 5052 | if (!callback) { |
||
| 5053 | return; |
||
| 5054 | } |
||
| 5055 | |||
| 5056 | if (!animate) { |
||
| 5057 | callback(); |
||
| 5058 | return; |
||
| 5059 | } |
||
| 5060 | |||
| 5061 | var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); |
||
| 5062 | $__default['default'](this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration); |
||
| 5063 | } else if (!this._isShown && this._backdrop) { |
||
| 5064 | $__default['default'](this._backdrop).removeClass(CLASS_NAME_SHOW$3); |
||
| 5065 | |||
| 5066 | var callbackRemove = function callbackRemove() { |
||
| 5067 | _this9._removeBackdrop(); |
||
| 5068 | |||
| 5069 | if (callback) { |
||
| 5070 | callback(); |
||
| 5071 | } |
||
| 5072 | }; |
||
| 5073 | |||
| 5074 | if ($__default['default'](this._element).hasClass(CLASS_NAME_FADE$1)) { |
||
| 5075 | var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop); |
||
| 5076 | |||
| 5077 | $__default['default'](this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration); |
||
| 5078 | } else { |
||
| 5079 | callbackRemove(); |
||
| 5080 | } |
||
| 5081 | } else if (callback) { |
||
| 5082 | callback(); |
||
| 5083 | } |
||
| 5084 | } // ---------------------------------------------------------------------- |
||
| 5085 | // the following methods are used to handle overflowing modals |
||
| 5086 | // todo (fat): these should probably be refactored out of modal.js |
||
| 5087 | // ---------------------------------------------------------------------- |
||
| 5088 | ; |
||
| 5089 | |||
| 5090 | _proto._adjustDialog = function _adjustDialog() { |
||
| 5091 | var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; |
||
| 5092 | |||
| 5093 | if (!this._isBodyOverflowing && isModalOverflowing) { |
||
| 5094 | this._element.style.paddingLeft = this._scrollbarWidth + "px"; |
||
| 5095 | } |
||
| 5096 | |||
| 5097 | if (this._isBodyOverflowing && !isModalOverflowing) { |
||
| 5098 | this._element.style.paddingRight = this._scrollbarWidth + "px"; |
||
| 5099 | } |
||
| 5100 | }; |
||
| 5101 | |||
| 5102 | _proto._resetAdjustments = function _resetAdjustments() { |
||
| 5103 | this._element.style.paddingLeft = ''; |
||
| 5104 | this._element.style.paddingRight = ''; |
||
| 5105 | }; |
||
| 5106 | |||
| 5107 | _proto._checkScrollbar = function _checkScrollbar() { |
||
| 5108 | var rect = document.body.getBoundingClientRect(); |
||
| 5109 | this._isBodyOverflowing = Math.round(rect.left + rect.right) < window.innerWidth; |
||
| 5110 | this._scrollbarWidth = this._getScrollbarWidth(); |
||
| 5111 | }; |
||
| 5112 | |||
| 5113 | _proto._setScrollbar = function _setScrollbar() { |
||
| 5114 | var _this10 = this; |
||
| 5115 | |||
| 5116 | if (this._isBodyOverflowing) { |
||
| 5117 | // Note: DOMNode.style.paddingRight returns the actual value or '' if not set |
||
| 5118 | // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set |
||
| 5119 | var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); |
||
| 5120 | var stickyContent = [].slice.call(document.querySelectorAll(SELECTOR_STICKY_CONTENT)); // Adjust fixed content padding |
||
| 5121 | |||
| 5122 | $__default['default'](fixedContent).each(function (index, element) { |
||
| 5123 | var actualPadding = element.style.paddingRight; |
||
| 5124 | var calculatedPadding = $__default['default'](element).css('padding-right'); |
||
| 5125 | $__default['default'](element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px"); |
||
| 5126 | }); // Adjust sticky content margin |
||
| 5127 | |||
| 5128 | $__default['default'](stickyContent).each(function (index, element) { |
||
| 5129 | var actualMargin = element.style.marginRight; |
||
| 5130 | var calculatedMargin = $__default['default'](element).css('margin-right'); |
||
| 5131 | $__default['default'](element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px"); |
||
| 5132 | }); // Adjust body padding |
||
| 5133 | |||
| 5134 | var actualPadding = document.body.style.paddingRight; |
||
| 5135 | var calculatedPadding = $__default['default'](document.body).css('padding-right'); |
||
| 5136 | $__default['default'](document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px"); |
||
| 5137 | } |
||
| 5138 | |||
| 5139 | $__default['default'](document.body).addClass(CLASS_NAME_OPEN); |
||
| 5140 | }; |
||
| 5141 | |||
| 5142 | _proto._resetScrollbar = function _resetScrollbar() { |
||
| 5143 | // Restore fixed content padding |
||
| 5144 | var fixedContent = [].slice.call(document.querySelectorAll(SELECTOR_FIXED_CONTENT)); |
||
| 5145 | $__default['default'](fixedContent).each(function (index, element) { |
||
| 5146 | var padding = $__default['default'](element).data('padding-right'); |
||
| 5147 | $__default['default'](element).removeData('padding-right'); |
||
| 5148 | element.style.paddingRight = padding ? padding : ''; |
||
| 5149 | }); // Restore sticky content |
||
| 5150 | |||
| 5151 | var elements = [].slice.call(document.querySelectorAll("" + SELECTOR_STICKY_CONTENT)); |
||
| 5152 | $__default['default'](elements).each(function (index, element) { |
||
| 5153 | var margin = $__default['default'](element).data('margin-right'); |
||
| 5154 | |||
| 5155 | if (typeof margin !== 'undefined') { |
||
| 5156 | $__default['default'](element).css('margin-right', margin).removeData('margin-right'); |
||
| 5157 | } |
||
| 5158 | }); // Restore body padding |
||
| 5159 | |||
| 5160 | var padding = $__default['default'](document.body).data('padding-right'); |
||
| 5161 | $__default['default'](document.body).removeData('padding-right'); |
||
| 5162 | document.body.style.paddingRight = padding ? padding : ''; |
||
| 5163 | }; |
||
| 5164 | |||
| 5165 | _proto._getScrollbarWidth = function _getScrollbarWidth() { |
||
| 5166 | // thx d.walsh |
||
| 5167 | var scrollDiv = document.createElement('div'); |
||
| 5168 | scrollDiv.className = CLASS_NAME_SCROLLBAR_MEASURER; |
||
| 5169 | document.body.appendChild(scrollDiv); |
||
| 5170 | var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth; |
||
| 5171 | document.body.removeChild(scrollDiv); |
||
| 5172 | return scrollbarWidth; |
||
| 5173 | } // Static |
||
| 5174 | ; |
||
| 5175 | |||
| 5176 | Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { |
||
| 5177 | return this.each(function () { |
||
| 5178 | var data = $__default['default'](this).data(DATA_KEY$5); |
||
| 5179 | |||
| 5180 | var _config = _extends({}, Default$3, $__default['default'](this).data(), typeof config === 'object' && config ? config : {}); |
||
| 5181 | |||
| 5182 | if (!data) { |
||
| 5183 | data = new Modal(this, _config); |
||
| 5184 | $__default['default'](this).data(DATA_KEY$5, data); |
||
| 5185 | } |
||
| 5186 | |||
| 5187 | if (typeof config === 'string') { |
||
| 5188 | if (typeof data[config] === 'undefined') { |
||
| 5189 | throw new TypeError("No method named \"" + config + "\""); |
||
| 5190 | } |
||
| 5191 | |||
| 5192 | data[config](relatedTarget); |
||
| 5193 | } else if (_config.show) { |
||
| 5194 | data.show(relatedTarget); |
||
| 5195 | } |
||
| 5196 | }); |
||
| 5197 | }; |
||
| 5198 | |||
| 5199 | _createClass(Modal, null, [{ |
||
| 5200 | key: "VERSION", |
||
| 5201 | get: function get() { |
||
| 5202 | return VERSION$5; |
||
| 5203 | } |
||
| 5204 | }, { |
||
| 5205 | key: "Default", |
||
| 5206 | get: function get() { |
||
| 5207 | return Default$3; |
||
| 5208 | } |
||
| 5209 | }]); |
||
| 5210 | |||
| 5211 | return Modal; |
||
| 5212 | }(); |
||
| 5213 | /** |
||
| 5214 | * ------------------------------------------------------------------------ |
||
| 5215 | * Data Api implementation |
||
| 5216 | * ------------------------------------------------------------------------ |
||
| 5217 | */ |
||
| 5218 | |||
| 5219 | |||
| 5220 | $__default['default'](document).on(EVENT_CLICK_DATA_API$5, SELECTOR_DATA_TOGGLE$3, function (event) { |
||
| 5221 | var _this11 = this; |
||
| 5222 | |||
| 5223 | var target; |
||
| 5224 | var selector = Util.getSelectorFromElement(this); |
||
| 5225 | |||
| 5226 | if (selector) { |
||
| 5227 | target = document.querySelector(selector); |
||
| 5228 | } |
||
| 5229 | |||
| 5230 | var config = $__default['default'](target).data(DATA_KEY$5) ? 'toggle' : _extends({}, $__default['default'](target).data(), $__default['default'](this).data()); |
||
| 5231 | |||
| 5232 | if (this.tagName === 'A' || this.tagName === 'AREA') { |
||
| 5233 | event.preventDefault(); |
||
| 5234 | } |
||
| 5235 | |||
| 5236 | var $target = $__default['default'](target).one(EVENT_SHOW$2, function (showEvent) { |
||
| 5237 | if (showEvent.isDefaultPrevented()) { |
||
| 5238 | // Only register focus restorer if modal will actually get shown |
||
| 5239 | return; |
||
| 5240 | } |
||
| 5241 | |||
| 5242 | $target.one(EVENT_HIDDEN$2, function () { |
||
| 5243 | if ($__default['default'](_this11).is(':visible')) { |
||
| 5244 | _this11.focus(); |
||
| 5245 | } |
||
| 5246 | }); |
||
| 5247 | }); |
||
| 5248 | |||
| 5249 | Modal._jQueryInterface.call($__default['default'](target), config, this); |
||
| 5250 | }); |
||
| 5251 | /** |
||
| 5252 | * ------------------------------------------------------------------------ |
||
| 5253 | * jQuery |
||
| 5254 | * ------------------------------------------------------------------------ |
||
| 5255 | */ |
||
| 5256 | |||
| 5257 | $__default['default'].fn[NAME$5] = Modal._jQueryInterface; |
||
| 5258 | $__default['default'].fn[NAME$5].Constructor = Modal; |
||
| 5259 | |||
| 5260 | $__default['default'].fn[NAME$5].noConflict = function () { |
||
| 5261 | $__default['default'].fn[NAME$5] = JQUERY_NO_CONFLICT$5; |
||
| 5262 | return Modal._jQueryInterface; |
||
| 5263 | }; |
||
| 5264 | |||
| 5265 | /** |
||
| 5266 | * -------------------------------------------------------------------------- |
||
| 5267 | * Bootstrap (v4.5.3): tools/sanitizer.js |
||
| 5268 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
||
| 5269 | * -------------------------------------------------------------------------- |
||
| 5270 | */ |
||
| 5271 | var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']; |
||
| 5272 | var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; |
||
| 5273 | var DefaultWhitelist = { |
||
| 5274 | // Global attributes allowed on any supplied element below. |
||
| 5275 | '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], |
||
| 5276 | a: ['target', 'href', 'title', 'rel'], |
||
| 5277 | area: [], |
||
| 5278 | b: [], |
||
| 5279 | br: [], |
||
| 5280 | col: [], |
||
| 5281 | code: [], |
||
| 5282 | div: [], |
||
| 5283 | em: [], |
||
| 5284 | hr: [], |
||
| 5285 | h1: [], |
||
| 5286 | h2: [], |
||
| 5287 | h3: [], |
||
| 5288 | h4: [], |
||
| 5289 | h5: [], |
||
| 5290 | h6: [], |
||
| 5291 | i: [], |
||
| 5292 | img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], |
||
| 5293 | li: [], |
||
| 5294 | ol: [], |
||
| 5295 | p: [], |
||
| 5296 | pre: [], |
||
| 5297 | s: [], |
||
| 5298 | small: [], |
||
| 5299 | span: [], |
||
| 5300 | sub: [], |
||
| 5301 | sup: [], |
||
| 5302 | strong: [], |
||
| 5303 | u: [], |
||
| 5304 | ul: [] |
||
| 5305 | }; |
||
| 5306 | /** |
||
| 5307 | * A pattern that recognizes a commonly useful subset of URLs that are safe. |
||
| 5308 | * |
||
| 5309 | * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts |
||
| 5310 | */ |
||
| 5311 | |||
| 5312 | var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi; |
||
| 5313 | /** |
||
| 5314 | * A pattern that matches safe data URLs. Only matches image, video and audio types. |
||
| 5315 | * |
||
| 5316 | * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts |
||
| 5317 | */ |
||
| 5318 | |||
| 5319 | var 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; |
||
| 5320 | |||
| 5321 | function allowedAttribute(attr, allowedAttributeList) { |
||
| 5322 | var attrName = attr.nodeName.toLowerCase(); |
||
| 5323 | |||
| 5324 | if (allowedAttributeList.indexOf(attrName) !== -1) { |
||
| 5325 | if (uriAttrs.indexOf(attrName) !== -1) { |
||
| 5326 | return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN)); |
||
| 5327 | } |
||
| 5328 | |||
| 5329 | return true; |
||
| 5330 | } |
||
| 5331 | |||
| 5332 | var regExp = allowedAttributeList.filter(function (attrRegex) { |
||
| 5333 | return attrRegex instanceof RegExp; |
||
| 5334 | }); // Check if a regular expression validates the attribute. |
||
| 5335 | |||
| 5336 | for (var i = 0, len = regExp.length; i < len; i++) { |
||
| 5337 | if (attrName.match(regExp[i])) { |
||
| 5338 | return true; |
||
| 5339 | } |
||
| 5340 | } |
||
| 5341 | |||
| 5342 | return false; |
||
| 5343 | } |
||
| 5344 | |||
| 5345 | function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) { |
||
| 5346 | if (unsafeHtml.length === 0) { |
||
| 5347 | return unsafeHtml; |
||
| 5348 | } |
||
| 5349 | |||
| 5350 | if (sanitizeFn && typeof sanitizeFn === 'function') { |
||
| 5351 | return sanitizeFn(unsafeHtml); |
||
| 5352 | } |
||
| 5353 | |||
| 5354 | var domParser = new window.DOMParser(); |
||
| 5355 | var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); |
||
| 5356 | var whitelistKeys = Object.keys(whiteList); |
||
| 5357 | var elements = [].slice.call(createdDocument.body.querySelectorAll('*')); |
||
| 5358 | |||
| 5359 | var _loop = function _loop(i, len) { |
||
| 5360 | var el = elements[i]; |
||
| 5361 | var elName = el.nodeName.toLowerCase(); |
||
| 5362 | |||
| 5363 | if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) { |
||
| 5364 | el.parentNode.removeChild(el); |
||
| 5365 | return "continue"; |
||
| 5366 | } |
||
| 5367 | |||
| 5368 | var attributeList = [].slice.call(el.attributes); |
||
| 5369 | var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []); |
||
| 5370 | attributeList.forEach(function (attr) { |
||
| 5371 | if (!allowedAttribute(attr, whitelistedAttributes)) { |
||
| 5372 | el.removeAttribute(attr.nodeName); |
||
| 5373 | } |
||
| 5374 | }); |
||
| 5375 | }; |
||
| 5376 | |||
| 5377 | for (var i = 0, len = elements.length; i < len; i++) { |
||
| 5378 | var _ret = _loop(i); |
||
| 5379 | |||
| 5380 | if (_ret === "continue") continue; |
||
| 5381 | } |
||
| 5382 | |||
| 5383 | return createdDocument.body.innerHTML; |
||
| 5384 | } |
||
| 5385 | |||
| 5386 | /** |
||
| 5387 | * ------------------------------------------------------------------------ |
||
| 5388 | * Constants |
||
| 5389 | * ------------------------------------------------------------------------ |
||
| 5390 | */ |
||
| 5391 | |||
| 5392 | var NAME$6 = 'tooltip'; |
||
| 5393 | var VERSION$6 = '4.5.3'; |
||
| 5394 | var DATA_KEY$6 = 'bs.tooltip'; |
||
| 5395 | var EVENT_KEY$6 = "." + DATA_KEY$6; |
||
| 5396 | var JQUERY_NO_CONFLICT$6 = $__default['default'].fn[NAME$6]; |
||
| 5397 | var CLASS_PREFIX = 'bs-tooltip'; |
||
| 5398 | var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g'); |
||
| 5399 | var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']; |
||
| 5400 | var DefaultType$4 = { |
||
| 5401 | animation: 'boolean', |
||
| 5402 | template: 'string', |
||
| 5403 | title: '(string|element|function)', |
||
| 5404 | trigger: 'string', |
||
| 5405 | delay: '(number|object)', |
||
| 5406 | html: 'boolean', |
||
| 5407 | selector: '(string|boolean)', |
||
| 5408 | placement: '(string|function)', |
||
| 5409 | offset: '(number|string|function)', |
||
| 5410 | container: '(string|element|boolean)', |
||
| 5411 | fallbackPlacement: '(string|array)', |
||
| 5412 | boundary: '(string|element)', |
||
| 5413 | sanitize: 'boolean', |
||
| 5414 | sanitizeFn: '(null|function)', |
||
| 5415 | whiteList: 'object', |
||
| 5416 | popperConfig: '(null|object)' |
||
| 5417 | }; |
||
| 5418 | var AttachmentMap = { |
||
| 5419 | AUTO: 'auto', |
||
| 5420 | TOP: 'top', |
||
| 5421 | RIGHT: 'right', |
||
| 5422 | BOTTOM: 'bottom', |
||
| 5423 | LEFT: 'left' |
||
| 5424 | }; |
||
| 5425 | var Default$4 = { |
||
| 5426 | animation: true, |
||
| 5427 | template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>', |
||
| 5428 | trigger: 'hover focus', |
||
| 5429 | title: '', |
||
| 5430 | delay: 0, |
||
| 5431 | html: false, |
||
| 5432 | selector: false, |
||
| 5433 | placement: 'top', |
||
| 5434 | offset: 0, |
||
| 5435 | container: false, |
||
| 5436 | fallbackPlacement: 'flip', |
||
| 5437 | boundary: 'scrollParent', |
||
| 5438 | sanitize: true, |
||
| 5439 | sanitizeFn: null, |
||
| 5440 | whiteList: DefaultWhitelist, |
||
| 5441 | popperConfig: null |
||
| 5442 | }; |
||
| 5443 | var HOVER_STATE_SHOW = 'show'; |
||
| 5444 | var HOVER_STATE_OUT = 'out'; |
||
| 5445 | var Event = { |
||
| 5446 | HIDE: "hide" + EVENT_KEY$6, |
||
| 5447 | HIDDEN: "hidden" + EVENT_KEY$6, |
||
| 5448 | SHOW: "show" + EVENT_KEY$6, |
||
| 5449 | SHOWN: "shown" + EVENT_KEY$6, |
||
| 5450 | INSERTED: "inserted" + EVENT_KEY$6, |
||
| 5451 | CLICK: "click" + EVENT_KEY$6, |
||
| 5452 | FOCUSIN: "focusin" + EVENT_KEY$6, |
||
| 5453 | FOCUSOUT: "focusout" + EVENT_KEY$6, |
||
| 5454 | MOUSEENTER: "mouseenter" + EVENT_KEY$6, |
||
| 5455 | MOUSELEAVE: "mouseleave" + EVENT_KEY$6 |
||
| 5456 | }; |
||
| 5457 | var CLASS_NAME_FADE$2 = 'fade'; |
||
| 5458 | var CLASS_NAME_SHOW$4 = 'show'; |
||
| 5459 | var SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; |
||
| 5460 | var SELECTOR_ARROW = '.arrow'; |
||
| 5461 | var TRIGGER_HOVER = 'hover'; |
||
| 5462 | var TRIGGER_FOCUS = 'focus'; |
||
| 5463 | var TRIGGER_CLICK = 'click'; |
||
| 5464 | var TRIGGER_MANUAL = 'manual'; |
||
| 5465 | /** |
||
| 5466 | * ------------------------------------------------------------------------ |
||
| 5467 | * Class Definition |
||
| 5468 | * ------------------------------------------------------------------------ |
||
| 5469 | */ |
||
| 5470 | |||
| 5471 | var Tooltip = /*#__PURE__*/function () { |
||
| 5472 | function Tooltip(element, config) { |
||
| 5473 | if (typeof Popper === 'undefined') { |
||
| 5474 | throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)'); |
||
| 5475 | } // private |
||
| 5476 | |||
| 5477 | |||
| 5478 | this._isEnabled = true; |
||
| 5479 | this._timeout = 0; |
||
| 5480 | this._hoverState = ''; |
||
| 5481 | this._activeTrigger = {}; |
||
| 5482 | this._popper = null; // Protected |
||
| 5483 | |||
| 5484 | this.element = element; |
||
| 5485 | this.config = this._getConfig(config); |
||
| 5486 | this.tip = null; |
||
| 5487 | |||
| 5488 | this._setListeners(); |
||
| 5489 | } // Getters |
||
| 5490 | |||
| 5491 | |||
| 5492 | var _proto = Tooltip.prototype; |
||
| 5493 | |||
| 5494 | // Public |
||
| 5495 | _proto.enable = function enable() { |
||
| 5496 | this._isEnabled = true; |
||
| 5497 | }; |
||
| 5498 | |||
| 5499 | _proto.disable = function disable() { |
||
| 5500 | this._isEnabled = false; |
||
| 5501 | }; |
||
| 5502 | |||
| 5503 | _proto.toggleEnabled = function toggleEnabled() { |
||
| 5504 | this._isEnabled = !this._isEnabled; |
||
| 5505 | }; |
||
| 5506 | |||
| 5507 | _proto.toggle = function toggle(event) { |
||
| 5508 | if (!this._isEnabled) { |
||
| 5509 | return; |
||
| 5510 | } |
||
| 5511 | |||
| 5512 | if (event) { |
||
| 5513 | var dataKey = this.constructor.DATA_KEY; |
||
| 5514 | var context = $__default['default'](event.currentTarget).data(dataKey); |
||
| 5515 | |||
| 5516 | if (!context) { |
||
| 5517 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); |
||
| 5518 | $__default['default'](event.currentTarget).data(dataKey, context); |
||
| 5519 | } |
||
| 5520 | |||
| 5521 | context._activeTrigger.click = !context._activeTrigger.click; |
||
| 5522 | |||
| 5523 | if (context._isWithActiveTrigger()) { |
||
| 5524 | context._enter(null, context); |
||
| 5525 | } else { |
||
| 5526 | context._leave(null, context); |
||
| 5527 | } |
||
| 5528 | } else { |
||
| 5529 | if ($__default['default'](this.getTipElement()).hasClass(CLASS_NAME_SHOW$4)) { |
||
| 5530 | this._leave(null, this); |
||
| 5531 | |||
| 5532 | return; |
||
| 5533 | } |
||
| 5534 | |||
| 5535 | this._enter(null, this); |
||
| 5536 | } |
||
| 5537 | }; |
||
| 5538 | |||
| 5539 | _proto.dispose = function dispose() { |
||
| 5540 | clearTimeout(this._timeout); |
||
| 5541 | $__default['default'].removeData(this.element, this.constructor.DATA_KEY); |
||
| 5542 | $__default['default'](this.element).off(this.constructor.EVENT_KEY); |
||
| 5543 | $__default['default'](this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler); |
||
| 5544 | |||
| 5545 | if (this.tip) { |
||
| 5546 | $__default['default'](this.tip).remove(); |
||
| 5547 | } |
||
| 5548 | |||
| 5549 | this._isEnabled = null; |
||
| 5550 | this._timeout = null; |
||
| 5551 | this._hoverState = null; |
||
| 5552 | this._activeTrigger = null; |
||
| 5553 | |||
| 5554 | if (this._popper) { |
||
| 5555 | this._popper.destroy(); |
||
| 5556 | } |
||
| 5557 | |||
| 5558 | this._popper = null; |
||
| 5559 | this.element = null; |
||
| 5560 | this.config = null; |
||
| 5561 | this.tip = null; |
||
| 5562 | }; |
||
| 5563 | |||
| 5564 | _proto.show = function show() { |
||
| 5565 | var _this = this; |
||
| 5566 | |||
| 5567 | if ($__default['default'](this.element).css('display') === 'none') { |
||
| 5568 | throw new Error('Please use show on visible elements'); |
||
| 5569 | } |
||
| 5570 | |||
| 5571 | var showEvent = $__default['default'].Event(this.constructor.Event.SHOW); |
||
| 5572 | |||
| 5573 | if (this.isWithContent() && this._isEnabled) { |
||
| 5574 | $__default['default'](this.element).trigger(showEvent); |
||
| 5575 | var shadowRoot = Util.findShadowRoot(this.element); |
||
| 5576 | var isInTheDom = $__default['default'].contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element); |
||
| 5577 | |||
| 5578 | if (showEvent.isDefaultPrevented() || !isInTheDom) { |
||
| 5579 | return; |
||
| 5580 | } |
||
| 5581 | |||
| 5582 | var tip = this.getTipElement(); |
||
| 5583 | var tipId = Util.getUID(this.constructor.NAME); |
||
| 5584 | tip.setAttribute('id', tipId); |
||
| 5585 | this.element.setAttribute('aria-describedby', tipId); |
||
| 5586 | this.setContent(); |
||
| 5587 | |||
| 5588 | if (this.config.animation) { |
||
| 5589 | $__default['default'](tip).addClass(CLASS_NAME_FADE$2); |
||
| 5590 | } |
||
| 5591 | |||
| 5592 | var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; |
||
| 5593 | |||
| 5594 | var attachment = this._getAttachment(placement); |
||
| 5595 | |||
| 5596 | this.addAttachmentClass(attachment); |
||
| 5597 | |||
| 5598 | var container = this._getContainer(); |
||
| 5599 | |||
| 5600 | $__default['default'](tip).data(this.constructor.DATA_KEY, this); |
||
| 5601 | |||
| 5602 | if (!$__default['default'].contains(this.element.ownerDocument.documentElement, this.tip)) { |
||
| 5603 | $__default['default'](tip).appendTo(container); |
||
| 5604 | } |
||
| 5605 | |||
| 5606 | $__default['default'](this.element).trigger(this.constructor.Event.INSERTED); |
||
| 5607 | this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment)); |
||
| 5608 | $__default['default'](tip).addClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we add extra |
||
| 5609 | // empty mouseover listeners to the body's immediate children; |
||
| 5610 | // only needed because of broken event delegation on iOS |
||
| 5611 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
||
| 5612 | |||
| 5613 | if ('ontouchstart' in document.documentElement) { |
||
| 5614 | $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop); |
||
| 5615 | } |
||
| 5616 | |||
| 5617 | var complete = function complete() { |
||
| 5618 | if (_this.config.animation) { |
||
| 5619 | _this._fixTransition(); |
||
| 5620 | } |
||
| 5621 | |||
| 5622 | var prevHoverState = _this._hoverState; |
||
| 5623 | _this._hoverState = null; |
||
| 5624 | $__default['default'](_this.element).trigger(_this.constructor.Event.SHOWN); |
||
| 5625 | |||
| 5626 | if (prevHoverState === HOVER_STATE_OUT) { |
||
| 5627 | _this._leave(null, _this); |
||
| 5628 | } |
||
| 5629 | }; |
||
| 5630 | |||
| 5631 | if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) { |
||
| 5632 | var transitionDuration = Util.getTransitionDurationFromElement(this.tip); |
||
| 5633 | $__default['default'](this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 5634 | } else { |
||
| 5635 | complete(); |
||
| 5636 | } |
||
| 5637 | } |
||
| 5638 | }; |
||
| 5639 | |||
| 5640 | _proto.hide = function hide(callback) { |
||
| 5641 | var _this2 = this; |
||
| 5642 | |||
| 5643 | var tip = this.getTipElement(); |
||
| 5644 | var hideEvent = $__default['default'].Event(this.constructor.Event.HIDE); |
||
| 5645 | |||
| 5646 | var complete = function complete() { |
||
| 5647 | if (_this2._hoverState !== HOVER_STATE_SHOW && tip.parentNode) { |
||
| 5648 | tip.parentNode.removeChild(tip); |
||
| 5649 | } |
||
| 5650 | |||
| 5651 | _this2._cleanTipClass(); |
||
| 5652 | |||
| 5653 | _this2.element.removeAttribute('aria-describedby'); |
||
| 5654 | |||
| 5655 | $__default['default'](_this2.element).trigger(_this2.constructor.Event.HIDDEN); |
||
| 5656 | |||
| 5657 | if (_this2._popper !== null) { |
||
| 5658 | _this2._popper.destroy(); |
||
| 5659 | } |
||
| 5660 | |||
| 5661 | if (callback) { |
||
| 5662 | callback(); |
||
| 5663 | } |
||
| 5664 | }; |
||
| 5665 | |||
| 5666 | $__default['default'](this.element).trigger(hideEvent); |
||
| 5667 | |||
| 5668 | if (hideEvent.isDefaultPrevented()) { |
||
| 5669 | return; |
||
| 5670 | } |
||
| 5671 | |||
| 5672 | $__default['default'](tip).removeClass(CLASS_NAME_SHOW$4); // If this is a touch-enabled device we remove the extra |
||
| 5673 | // empty mouseover listeners we added for iOS support |
||
| 5674 | |||
| 5675 | if ('ontouchstart' in document.documentElement) { |
||
| 5676 | $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop); |
||
| 5677 | } |
||
| 5678 | |||
| 5679 | this._activeTrigger[TRIGGER_CLICK] = false; |
||
| 5680 | this._activeTrigger[TRIGGER_FOCUS] = false; |
||
| 5681 | this._activeTrigger[TRIGGER_HOVER] = false; |
||
| 5682 | |||
| 5683 | if ($__default['default'](this.tip).hasClass(CLASS_NAME_FADE$2)) { |
||
| 5684 | var transitionDuration = Util.getTransitionDurationFromElement(tip); |
||
| 5685 | $__default['default'](tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 5686 | } else { |
||
| 5687 | complete(); |
||
| 5688 | } |
||
| 5689 | |||
| 5690 | this._hoverState = ''; |
||
| 5691 | }; |
||
| 5692 | |||
| 5693 | _proto.update = function update() { |
||
| 5694 | if (this._popper !== null) { |
||
| 5695 | this._popper.scheduleUpdate(); |
||
| 5696 | } |
||
| 5697 | } // Protected |
||
| 5698 | ; |
||
| 5699 | |||
| 5700 | _proto.isWithContent = function isWithContent() { |
||
| 5701 | return Boolean(this.getTitle()); |
||
| 5702 | }; |
||
| 5703 | |||
| 5704 | _proto.addAttachmentClass = function addAttachmentClass(attachment) { |
||
| 5705 | $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment); |
||
| 5706 | }; |
||
| 5707 | |||
| 5708 | _proto.getTipElement = function getTipElement() { |
||
| 5709 | this.tip = this.tip || $__default['default'](this.config.template)[0]; |
||
| 5710 | return this.tip; |
||
| 5711 | }; |
||
| 5712 | |||
| 5713 | _proto.setContent = function setContent() { |
||
| 5714 | var tip = this.getTipElement(); |
||
| 5715 | this.setElementContent($__default['default'](tip.querySelectorAll(SELECTOR_TOOLTIP_INNER)), this.getTitle()); |
||
| 5716 | $__default['default'](tip).removeClass(CLASS_NAME_FADE$2 + " " + CLASS_NAME_SHOW$4); |
||
| 5717 | }; |
||
| 5718 | |||
| 5719 | _proto.setElementContent = function setElementContent($element, content) { |
||
| 5720 | if (typeof content === 'object' && (content.nodeType || content.jquery)) { |
||
| 5721 | // Content is a DOM node or a jQuery |
||
| 5722 | if (this.config.html) { |
||
| 5723 | if (!$__default['default'](content).parent().is($element)) { |
||
| 5724 | $element.empty().append(content); |
||
| 5725 | } |
||
| 5726 | } else { |
||
| 5727 | $element.text($__default['default'](content).text()); |
||
| 5728 | } |
||
| 5729 | |||
| 5730 | return; |
||
| 5731 | } |
||
| 5732 | |||
| 5733 | if (this.config.html) { |
||
| 5734 | if (this.config.sanitize) { |
||
| 5735 | content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn); |
||
| 5736 | } |
||
| 5737 | |||
| 5738 | $element.html(content); |
||
| 5739 | } else { |
||
| 5740 | $element.text(content); |
||
| 5741 | } |
||
| 5742 | }; |
||
| 5743 | |||
| 5744 | _proto.getTitle = function getTitle() { |
||
| 5745 | var title = this.element.getAttribute('data-original-title'); |
||
| 5746 | |||
| 5747 | if (!title) { |
||
| 5748 | title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; |
||
| 5749 | } |
||
| 5750 | |||
| 5751 | return title; |
||
| 5752 | } // Private |
||
| 5753 | ; |
||
| 5754 | |||
| 5755 | _proto._getPopperConfig = function _getPopperConfig(attachment) { |
||
| 5756 | var _this3 = this; |
||
| 5757 | |||
| 5758 | var defaultBsConfig = { |
||
| 5759 | placement: attachment, |
||
| 5760 | modifiers: { |
||
| 5761 | offset: this._getOffset(), |
||
| 5762 | flip: { |
||
| 5763 | behavior: this.config.fallbackPlacement |
||
| 5764 | }, |
||
| 5765 | arrow: { |
||
| 5766 | element: SELECTOR_ARROW |
||
| 5767 | }, |
||
| 5768 | preventOverflow: { |
||
| 5769 | boundariesElement: this.config.boundary |
||
| 5770 | } |
||
| 5771 | }, |
||
| 5772 | onCreate: function onCreate(data) { |
||
| 5773 | if (data.originalPlacement !== data.placement) { |
||
| 5774 | _this3._handlePopperPlacementChange(data); |
||
| 5775 | } |
||
| 5776 | }, |
||
| 5777 | onUpdate: function onUpdate(data) { |
||
| 5778 | return _this3._handlePopperPlacementChange(data); |
||
| 5779 | } |
||
| 5780 | }; |
||
| 5781 | return _extends({}, defaultBsConfig, this.config.popperConfig); |
||
| 5782 | }; |
||
| 5783 | |||
| 5784 | _proto._getOffset = function _getOffset() { |
||
| 5785 | var _this4 = this; |
||
| 5786 | |||
| 5787 | var offset = {}; |
||
| 5788 | |||
| 5789 | if (typeof this.config.offset === 'function') { |
||
| 5790 | offset.fn = function (data) { |
||
| 5791 | data.offsets = _extends({}, data.offsets, _this4.config.offset(data.offsets, _this4.element) || {}); |
||
| 5792 | return data; |
||
| 5793 | }; |
||
| 5794 | } else { |
||
| 5795 | offset.offset = this.config.offset; |
||
| 5796 | } |
||
| 5797 | |||
| 5798 | return offset; |
||
| 5799 | }; |
||
| 5800 | |||
| 5801 | _proto._getContainer = function _getContainer() { |
||
| 5802 | if (this.config.container === false) { |
||
| 5803 | return document.body; |
||
| 5804 | } |
||
| 5805 | |||
| 5806 | if (Util.isElement(this.config.container)) { |
||
| 5807 | return $__default['default'](this.config.container); |
||
| 5808 | } |
||
| 5809 | |||
| 5810 | return $__default['default'](document).find(this.config.container); |
||
| 5811 | }; |
||
| 5812 | |||
| 5813 | _proto._getAttachment = function _getAttachment(placement) { |
||
| 5814 | return AttachmentMap[placement.toUpperCase()]; |
||
| 5815 | }; |
||
| 5816 | |||
| 5817 | _proto._setListeners = function _setListeners() { |
||
| 5818 | var _this5 = this; |
||
| 5819 | |||
| 5820 | var triggers = this.config.trigger.split(' '); |
||
| 5821 | triggers.forEach(function (trigger) { |
||
| 5822 | if (trigger === 'click') { |
||
| 5823 | $__default['default'](_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) { |
||
| 5824 | return _this5.toggle(event); |
||
| 5825 | }); |
||
| 5826 | } else if (trigger !== TRIGGER_MANUAL) { |
||
| 5827 | var eventIn = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN; |
||
| 5828 | var eventOut = trigger === TRIGGER_HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT; |
||
| 5829 | $__default['default'](_this5.element).on(eventIn, _this5.config.selector, function (event) { |
||
| 5830 | return _this5._enter(event); |
||
| 5831 | }).on(eventOut, _this5.config.selector, function (event) { |
||
| 5832 | return _this5._leave(event); |
||
| 5833 | }); |
||
| 5834 | } |
||
| 5835 | }); |
||
| 5836 | |||
| 5837 | this._hideModalHandler = function () { |
||
| 5838 | if (_this5.element) { |
||
| 5839 | _this5.hide(); |
||
| 5840 | } |
||
| 5841 | }; |
||
| 5842 | |||
| 5843 | $__default['default'](this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler); |
||
| 5844 | |||
| 5845 | if (this.config.selector) { |
||
| 5846 | this.config = _extends({}, this.config, { |
||
| 5847 | trigger: 'manual', |
||
| 5848 | selector: '' |
||
| 5849 | }); |
||
| 5850 | } else { |
||
| 5851 | this._fixTitle(); |
||
| 5852 | } |
||
| 5853 | }; |
||
| 5854 | |||
| 5855 | _proto._fixTitle = function _fixTitle() { |
||
| 5856 | var titleType = typeof this.element.getAttribute('data-original-title'); |
||
| 5857 | |||
| 5858 | if (this.element.getAttribute('title') || titleType !== 'string') { |
||
| 5859 | this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); |
||
| 5860 | this.element.setAttribute('title', ''); |
||
| 5861 | } |
||
| 5862 | }; |
||
| 5863 | |||
| 5864 | _proto._enter = function _enter(event, context) { |
||
| 5865 | var dataKey = this.constructor.DATA_KEY; |
||
| 5866 | context = context || $__default['default'](event.currentTarget).data(dataKey); |
||
| 5867 | |||
| 5868 | if (!context) { |
||
| 5869 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); |
||
| 5870 | $__default['default'](event.currentTarget).data(dataKey, context); |
||
| 5871 | } |
||
| 5872 | |||
| 5873 | if (event) { |
||
| 5874 | context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; |
||
| 5875 | } |
||
| 5876 | |||
| 5877 | if ($__default['default'](context.getTipElement()).hasClass(CLASS_NAME_SHOW$4) || context._hoverState === HOVER_STATE_SHOW) { |
||
| 5878 | context._hoverState = HOVER_STATE_SHOW; |
||
| 5879 | return; |
||
| 5880 | } |
||
| 5881 | |||
| 5882 | clearTimeout(context._timeout); |
||
| 5883 | context._hoverState = HOVER_STATE_SHOW; |
||
| 5884 | |||
| 5885 | if (!context.config.delay || !context.config.delay.show) { |
||
| 5886 | context.show(); |
||
| 5887 | return; |
||
| 5888 | } |
||
| 5889 | |||
| 5890 | context._timeout = setTimeout(function () { |
||
| 5891 | if (context._hoverState === HOVER_STATE_SHOW) { |
||
| 5892 | context.show(); |
||
| 5893 | } |
||
| 5894 | }, context.config.delay.show); |
||
| 5895 | }; |
||
| 5896 | |||
| 5897 | _proto._leave = function _leave(event, context) { |
||
| 5898 | var dataKey = this.constructor.DATA_KEY; |
||
| 5899 | context = context || $__default['default'](event.currentTarget).data(dataKey); |
||
| 5900 | |||
| 5901 | if (!context) { |
||
| 5902 | context = new this.constructor(event.currentTarget, this._getDelegateConfig()); |
||
| 5903 | $__default['default'](event.currentTarget).data(dataKey, context); |
||
| 5904 | } |
||
| 5905 | |||
| 5906 | if (event) { |
||
| 5907 | context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = false; |
||
| 5908 | } |
||
| 5909 | |||
| 5910 | if (context._isWithActiveTrigger()) { |
||
| 5911 | return; |
||
| 5912 | } |
||
| 5913 | |||
| 5914 | clearTimeout(context._timeout); |
||
| 5915 | context._hoverState = HOVER_STATE_OUT; |
||
| 5916 | |||
| 5917 | if (!context.config.delay || !context.config.delay.hide) { |
||
| 5918 | context.hide(); |
||
| 5919 | return; |
||
| 5920 | } |
||
| 5921 | |||
| 5922 | context._timeout = setTimeout(function () { |
||
| 5923 | if (context._hoverState === HOVER_STATE_OUT) { |
||
| 5924 | context.hide(); |
||
| 5925 | } |
||
| 5926 | }, context.config.delay.hide); |
||
| 5927 | }; |
||
| 5928 | |||
| 5929 | _proto._isWithActiveTrigger = function _isWithActiveTrigger() { |
||
| 5930 | for (var trigger in this._activeTrigger) { |
||
| 5931 | if (this._activeTrigger[trigger]) { |
||
| 5932 | return true; |
||
| 5933 | } |
||
| 5934 | } |
||
| 5935 | |||
| 5936 | return false; |
||
| 5937 | }; |
||
| 5938 | |||
| 5939 | _proto._getConfig = function _getConfig(config) { |
||
| 5940 | var dataAttributes = $__default['default'](this.element).data(); |
||
| 5941 | Object.keys(dataAttributes).forEach(function (dataAttr) { |
||
| 5942 | if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) { |
||
| 5943 | delete dataAttributes[dataAttr]; |
||
| 5944 | } |
||
| 5945 | }); |
||
| 5946 | config = _extends({}, this.constructor.Default, dataAttributes, typeof config === 'object' && config ? config : {}); |
||
| 5947 | |||
| 5948 | if (typeof config.delay === 'number') { |
||
| 5949 | config.delay = { |
||
| 5950 | show: config.delay, |
||
| 5951 | hide: config.delay |
||
| 5952 | }; |
||
| 5953 | } |
||
| 5954 | |||
| 5955 | if (typeof config.title === 'number') { |
||
| 5956 | config.title = config.title.toString(); |
||
| 5957 | } |
||
| 5958 | |||
| 5959 | if (typeof config.content === 'number') { |
||
| 5960 | config.content = config.content.toString(); |
||
| 5961 | } |
||
| 5962 | |||
| 5963 | Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType); |
||
| 5964 | |||
| 5965 | if (config.sanitize) { |
||
| 5966 | config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn); |
||
| 5967 | } |
||
| 5968 | |||
| 5969 | return config; |
||
| 5970 | }; |
||
| 5971 | |||
| 5972 | _proto._getDelegateConfig = function _getDelegateConfig() { |
||
| 5973 | var config = {}; |
||
| 5974 | |||
| 5975 | if (this.config) { |
||
| 5976 | for (var key in this.config) { |
||
| 5977 | if (this.constructor.Default[key] !== this.config[key]) { |
||
| 5978 | config[key] = this.config[key]; |
||
| 5979 | } |
||
| 5980 | } |
||
| 5981 | } |
||
| 5982 | |||
| 5983 | return config; |
||
| 5984 | }; |
||
| 5985 | |||
| 5986 | _proto._cleanTipClass = function _cleanTipClass() { |
||
| 5987 | var $tip = $__default['default'](this.getTipElement()); |
||
| 5988 | var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX); |
||
| 5989 | |||
| 5990 | if (tabClass !== null && tabClass.length) { |
||
| 5991 | $tip.removeClass(tabClass.join('')); |
||
| 5992 | } |
||
| 5993 | }; |
||
| 5994 | |||
| 5995 | _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) { |
||
| 5996 | this.tip = popperData.instance.popper; |
||
| 5997 | |||
| 5998 | this._cleanTipClass(); |
||
| 5999 | |||
| 6000 | this.addAttachmentClass(this._getAttachment(popperData.placement)); |
||
| 6001 | }; |
||
| 6002 | |||
| 6003 | _proto._fixTransition = function _fixTransition() { |
||
| 6004 | var tip = this.getTipElement(); |
||
| 6005 | var initConfigAnimation = this.config.animation; |
||
| 6006 | |||
| 6007 | if (tip.getAttribute('x-placement') !== null) { |
||
| 6008 | return; |
||
| 6009 | } |
||
| 6010 | |||
| 6011 | $__default['default'](tip).removeClass(CLASS_NAME_FADE$2); |
||
| 6012 | this.config.animation = false; |
||
| 6013 | this.hide(); |
||
| 6014 | this.show(); |
||
| 6015 | this.config.animation = initConfigAnimation; |
||
| 6016 | } // Static |
||
| 6017 | ; |
||
| 6018 | |||
| 6019 | Tooltip._jQueryInterface = function _jQueryInterface(config) { |
||
| 6020 | return this.each(function () { |
||
| 6021 | var $element = $__default['default'](this); |
||
| 6022 | var data = $element.data(DATA_KEY$6); |
||
| 6023 | |||
| 6024 | var _config = typeof config === 'object' && config; |
||
| 6025 | |||
| 6026 | if (!data && /dispose|hide/.test(config)) { |
||
| 6027 | return; |
||
| 6028 | } |
||
| 6029 | |||
| 6030 | if (!data) { |
||
| 6031 | data = new Tooltip(this, _config); |
||
| 6032 | $element.data(DATA_KEY$6, data); |
||
| 6033 | } |
||
| 6034 | |||
| 6035 | if (typeof config === 'string') { |
||
| 6036 | if (typeof data[config] === 'undefined') { |
||
| 6037 | throw new TypeError("No method named \"" + config + "\""); |
||
| 6038 | } |
||
| 6039 | |||
| 6040 | data[config](); |
||
| 6041 | } |
||
| 6042 | }); |
||
| 6043 | }; |
||
| 6044 | |||
| 6045 | _createClass(Tooltip, null, [{ |
||
| 6046 | key: "VERSION", |
||
| 6047 | get: function get() { |
||
| 6048 | return VERSION$6; |
||
| 6049 | } |
||
| 6050 | }, { |
||
| 6051 | key: "Default", |
||
| 6052 | get: function get() { |
||
| 6053 | return Default$4; |
||
| 6054 | } |
||
| 6055 | }, { |
||
| 6056 | key: "NAME", |
||
| 6057 | get: function get() { |
||
| 6058 | return NAME$6; |
||
| 6059 | } |
||
| 6060 | }, { |
||
| 6061 | key: "DATA_KEY", |
||
| 6062 | get: function get() { |
||
| 6063 | return DATA_KEY$6; |
||
| 6064 | } |
||
| 6065 | }, { |
||
| 6066 | key: "Event", |
||
| 6067 | get: function get() { |
||
| 6068 | return Event; |
||
| 6069 | } |
||
| 6070 | }, { |
||
| 6071 | key: "EVENT_KEY", |
||
| 6072 | get: function get() { |
||
| 6073 | return EVENT_KEY$6; |
||
| 6074 | } |
||
| 6075 | }, { |
||
| 6076 | key: "DefaultType", |
||
| 6077 | get: function get() { |
||
| 6078 | return DefaultType$4; |
||
| 6079 | } |
||
| 6080 | }]); |
||
| 6081 | |||
| 6082 | return Tooltip; |
||
| 6083 | }(); |
||
| 6084 | /** |
||
| 6085 | * ------------------------------------------------------------------------ |
||
| 6086 | * jQuery |
||
| 6087 | * ------------------------------------------------------------------------ |
||
| 6088 | */ |
||
| 6089 | |||
| 6090 | |||
| 6091 | $__default['default'].fn[NAME$6] = Tooltip._jQueryInterface; |
||
| 6092 | $__default['default'].fn[NAME$6].Constructor = Tooltip; |
||
| 6093 | |||
| 6094 | $__default['default'].fn[NAME$6].noConflict = function () { |
||
| 6095 | $__default['default'].fn[NAME$6] = JQUERY_NO_CONFLICT$6; |
||
| 6096 | return Tooltip._jQueryInterface; |
||
| 6097 | }; |
||
| 6098 | |||
| 6099 | /** |
||
| 6100 | * ------------------------------------------------------------------------ |
||
| 6101 | * Constants |
||
| 6102 | * ------------------------------------------------------------------------ |
||
| 6103 | */ |
||
| 6104 | |||
| 6105 | var NAME$7 = 'popover'; |
||
| 6106 | var VERSION$7 = '4.5.3'; |
||
| 6107 | var DATA_KEY$7 = 'bs.popover'; |
||
| 6108 | var EVENT_KEY$7 = "." + DATA_KEY$7; |
||
| 6109 | var JQUERY_NO_CONFLICT$7 = $__default['default'].fn[NAME$7]; |
||
| 6110 | var CLASS_PREFIX$1 = 'bs-popover'; |
||
| 6111 | var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g'); |
||
| 6112 | |||
| 6113 | var Default$5 = _extends({}, Tooltip.Default, { |
||
| 6114 | placement: 'right', |
||
| 6115 | trigger: 'click', |
||
| 6116 | content: '', |
||
| 6117 | template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>' |
||
| 6118 | }); |
||
| 6119 | |||
| 6120 | var DefaultType$5 = _extends({}, Tooltip.DefaultType, { |
||
| 6121 | content: '(string|element|function)' |
||
| 6122 | }); |
||
| 6123 | |||
| 6124 | var CLASS_NAME_FADE$3 = 'fade'; |
||
| 6125 | var CLASS_NAME_SHOW$5 = 'show'; |
||
| 6126 | var SELECTOR_TITLE = '.popover-header'; |
||
| 6127 | var SELECTOR_CONTENT = '.popover-body'; |
||
| 6128 | var Event$1 = { |
||
| 6129 | HIDE: "hide" + EVENT_KEY$7, |
||
| 6130 | HIDDEN: "hidden" + EVENT_KEY$7, |
||
| 6131 | SHOW: "show" + EVENT_KEY$7, |
||
| 6132 | SHOWN: "shown" + EVENT_KEY$7, |
||
| 6133 | INSERTED: "inserted" + EVENT_KEY$7, |
||
| 6134 | CLICK: "click" + EVENT_KEY$7, |
||
| 6135 | FOCUSIN: "focusin" + EVENT_KEY$7, |
||
| 6136 | FOCUSOUT: "focusout" + EVENT_KEY$7, |
||
| 6137 | MOUSEENTER: "mouseenter" + EVENT_KEY$7, |
||
| 6138 | MOUSELEAVE: "mouseleave" + EVENT_KEY$7 |
||
| 6139 | }; |
||
| 6140 | /** |
||
| 6141 | * ------------------------------------------------------------------------ |
||
| 6142 | * Class Definition |
||
| 6143 | * ------------------------------------------------------------------------ |
||
| 6144 | */ |
||
| 6145 | |||
| 6146 | var Popover = /*#__PURE__*/function (_Tooltip) { |
||
| 6147 | _inheritsLoose(Popover, _Tooltip); |
||
| 6148 | |||
| 6149 | function Popover() { |
||
| 6150 | return _Tooltip.apply(this, arguments) || this; |
||
| 6151 | } |
||
| 6152 | |||
| 6153 | var _proto = Popover.prototype; |
||
| 6154 | |||
| 6155 | // Overrides |
||
| 6156 | _proto.isWithContent = function isWithContent() { |
||
| 6157 | return this.getTitle() || this._getContent(); |
||
| 6158 | }; |
||
| 6159 | |||
| 6160 | _proto.addAttachmentClass = function addAttachmentClass(attachment) { |
||
| 6161 | $__default['default'](this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment); |
||
| 6162 | }; |
||
| 6163 | |||
| 6164 | _proto.getTipElement = function getTipElement() { |
||
| 6165 | this.tip = this.tip || $__default['default'](this.config.template)[0]; |
||
| 6166 | return this.tip; |
||
| 6167 | }; |
||
| 6168 | |||
| 6169 | _proto.setContent = function setContent() { |
||
| 6170 | var $tip = $__default['default'](this.getTipElement()); // We use append for html objects to maintain js events |
||
| 6171 | |||
| 6172 | this.setElementContent($tip.find(SELECTOR_TITLE), this.getTitle()); |
||
| 6173 | |||
| 6174 | var content = this._getContent(); |
||
| 6175 | |||
| 6176 | if (typeof content === 'function') { |
||
| 6177 | content = content.call(this.element); |
||
| 6178 | } |
||
| 6179 | |||
| 6180 | this.setElementContent($tip.find(SELECTOR_CONTENT), content); |
||
| 6181 | $tip.removeClass(CLASS_NAME_FADE$3 + " " + CLASS_NAME_SHOW$5); |
||
| 6182 | } // Private |
||
| 6183 | ; |
||
| 6184 | |||
| 6185 | _proto._getContent = function _getContent() { |
||
| 6186 | return this.element.getAttribute('data-content') || this.config.content; |
||
| 6187 | }; |
||
| 6188 | |||
| 6189 | _proto._cleanTipClass = function _cleanTipClass() { |
||
| 6190 | var $tip = $__default['default'](this.getTipElement()); |
||
| 6191 | var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1); |
||
| 6192 | |||
| 6193 | if (tabClass !== null && tabClass.length > 0) { |
||
| 6194 | $tip.removeClass(tabClass.join('')); |
||
| 6195 | } |
||
| 6196 | } // Static |
||
| 6197 | ; |
||
| 6198 | |||
| 6199 | Popover._jQueryInterface = function _jQueryInterface(config) { |
||
| 6200 | return this.each(function () { |
||
| 6201 | var data = $__default['default'](this).data(DATA_KEY$7); |
||
| 6202 | |||
| 6203 | var _config = typeof config === 'object' ? config : null; |
||
| 6204 | |||
| 6205 | if (!data && /dispose|hide/.test(config)) { |
||
| 6206 | return; |
||
| 6207 | } |
||
| 6208 | |||
| 6209 | if (!data) { |
||
| 6210 | data = new Popover(this, _config); |
||
| 6211 | $__default['default'](this).data(DATA_KEY$7, data); |
||
| 6212 | } |
||
| 6213 | |||
| 6214 | if (typeof config === 'string') { |
||
| 6215 | if (typeof data[config] === 'undefined') { |
||
| 6216 | throw new TypeError("No method named \"" + config + "\""); |
||
| 6217 | } |
||
| 6218 | |||
| 6219 | data[config](); |
||
| 6220 | } |
||
| 6221 | }); |
||
| 6222 | }; |
||
| 6223 | |||
| 6224 | _createClass(Popover, null, [{ |
||
| 6225 | key: "VERSION", |
||
| 6226 | // Getters |
||
| 6227 | get: function get() { |
||
| 6228 | return VERSION$7; |
||
| 6229 | } |
||
| 6230 | }, { |
||
| 6231 | key: "Default", |
||
| 6232 | get: function get() { |
||
| 6233 | return Default$5; |
||
| 6234 | } |
||
| 6235 | }, { |
||
| 6236 | key: "NAME", |
||
| 6237 | get: function get() { |
||
| 6238 | return NAME$7; |
||
| 6239 | } |
||
| 6240 | }, { |
||
| 6241 | key: "DATA_KEY", |
||
| 6242 | get: function get() { |
||
| 6243 | return DATA_KEY$7; |
||
| 6244 | } |
||
| 6245 | }, { |
||
| 6246 | key: "Event", |
||
| 6247 | get: function get() { |
||
| 6248 | return Event$1; |
||
| 6249 | } |
||
| 6250 | }, { |
||
| 6251 | key: "EVENT_KEY", |
||
| 6252 | get: function get() { |
||
| 6253 | return EVENT_KEY$7; |
||
| 6254 | } |
||
| 6255 | }, { |
||
| 6256 | key: "DefaultType", |
||
| 6257 | get: function get() { |
||
| 6258 | return DefaultType$5; |
||
| 6259 | } |
||
| 6260 | }]); |
||
| 6261 | |||
| 6262 | return Popover; |
||
| 6263 | }(Tooltip); |
||
| 6264 | /** |
||
| 6265 | * ------------------------------------------------------------------------ |
||
| 6266 | * jQuery |
||
| 6267 | * ------------------------------------------------------------------------ |
||
| 6268 | */ |
||
| 6269 | |||
| 6270 | |||
| 6271 | $__default['default'].fn[NAME$7] = Popover._jQueryInterface; |
||
| 6272 | $__default['default'].fn[NAME$7].Constructor = Popover; |
||
| 6273 | |||
| 6274 | $__default['default'].fn[NAME$7].noConflict = function () { |
||
| 6275 | $__default['default'].fn[NAME$7] = JQUERY_NO_CONFLICT$7; |
||
| 6276 | return Popover._jQueryInterface; |
||
| 6277 | }; |
||
| 6278 | |||
| 6279 | /** |
||
| 6280 | * ------------------------------------------------------------------------ |
||
| 6281 | * Constants |
||
| 6282 | * ------------------------------------------------------------------------ |
||
| 6283 | */ |
||
| 6284 | |||
| 6285 | var NAME$8 = 'scrollspy'; |
||
| 6286 | var VERSION$8 = '4.5.3'; |
||
| 6287 | var DATA_KEY$8 = 'bs.scrollspy'; |
||
| 6288 | var EVENT_KEY$8 = "." + DATA_KEY$8; |
||
| 6289 | var DATA_API_KEY$6 = '.data-api'; |
||
| 6290 | var JQUERY_NO_CONFLICT$8 = $__default['default'].fn[NAME$8]; |
||
| 6291 | var Default$6 = { |
||
| 6292 | offset: 10, |
||
| 6293 | method: 'auto', |
||
| 6294 | target: '' |
||
| 6295 | }; |
||
| 6296 | var DefaultType$6 = { |
||
| 6297 | offset: 'number', |
||
| 6298 | method: 'string', |
||
| 6299 | target: '(string|element)' |
||
| 6300 | }; |
||
| 6301 | var EVENT_ACTIVATE = "activate" + EVENT_KEY$8; |
||
| 6302 | var EVENT_SCROLL = "scroll" + EVENT_KEY$8; |
||
| 6303 | var EVENT_LOAD_DATA_API$2 = "load" + EVENT_KEY$8 + DATA_API_KEY$6; |
||
| 6304 | var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; |
||
| 6305 | var CLASS_NAME_ACTIVE$2 = 'active'; |
||
| 6306 | var SELECTOR_DATA_SPY = '[data-spy="scroll"]'; |
||
| 6307 | var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; |
||
| 6308 | var SELECTOR_NAV_LINKS = '.nav-link'; |
||
| 6309 | var SELECTOR_NAV_ITEMS = '.nav-item'; |
||
| 6310 | var SELECTOR_LIST_ITEMS = '.list-group-item'; |
||
| 6311 | var SELECTOR_DROPDOWN = '.dropdown'; |
||
| 6312 | var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item'; |
||
| 6313 | var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; |
||
| 6314 | var METHOD_OFFSET = 'offset'; |
||
| 6315 | var METHOD_POSITION = 'position'; |
||
| 6316 | /** |
||
| 6317 | * ------------------------------------------------------------------------ |
||
| 6318 | * Class Definition |
||
| 6319 | * ------------------------------------------------------------------------ |
||
| 6320 | */ |
||
| 6321 | |||
| 6322 | var ScrollSpy = /*#__PURE__*/function () { |
||
| 6323 | function ScrollSpy(element, config) { |
||
| 6324 | var _this = this; |
||
| 6325 | |||
| 6326 | this._element = element; |
||
| 6327 | this._scrollElement = element.tagName === 'BODY' ? window : element; |
||
| 6328 | this._config = this._getConfig(config); |
||
| 6329 | this._selector = this._config.target + " " + SELECTOR_NAV_LINKS + "," + (this._config.target + " " + SELECTOR_LIST_ITEMS + ",") + (this._config.target + " " + SELECTOR_DROPDOWN_ITEMS); |
||
| 6330 | this._offsets = []; |
||
| 6331 | this._targets = []; |
||
| 6332 | this._activeTarget = null; |
||
| 6333 | this._scrollHeight = 0; |
||
| 6334 | $__default['default'](this._scrollElement).on(EVENT_SCROLL, function (event) { |
||
| 6335 | return _this._process(event); |
||
| 6336 | }); |
||
| 6337 | this.refresh(); |
||
| 6338 | |||
| 6339 | this._process(); |
||
| 6340 | } // Getters |
||
| 6341 | |||
| 6342 | |||
| 6343 | var _proto = ScrollSpy.prototype; |
||
| 6344 | |||
| 6345 | // Public |
||
| 6346 | _proto.refresh = function refresh() { |
||
| 6347 | var _this2 = this; |
||
| 6348 | |||
| 6349 | var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; |
||
| 6350 | var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; |
||
| 6351 | var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; |
||
| 6352 | this._offsets = []; |
||
| 6353 | this._targets = []; |
||
| 6354 | this._scrollHeight = this._getScrollHeight(); |
||
| 6355 | var targets = [].slice.call(document.querySelectorAll(this._selector)); |
||
| 6356 | targets.map(function (element) { |
||
| 6357 | var target; |
||
| 6358 | var targetSelector = Util.getSelectorFromElement(element); |
||
| 6359 | |||
| 6360 | if (targetSelector) { |
||
| 6361 | target = document.querySelector(targetSelector); |
||
| 6362 | } |
||
| 6363 | |||
| 6364 | if (target) { |
||
| 6365 | var targetBCR = target.getBoundingClientRect(); |
||
| 6366 | |||
| 6367 | if (targetBCR.width || targetBCR.height) { |
||
| 6368 | // TODO (fat): remove sketch reliance on jQuery position/offset |
||
| 6369 | return [$__default['default'](target)[offsetMethod]().top + offsetBase, targetSelector]; |
||
| 6370 | } |
||
| 6371 | } |
||
| 6372 | |||
| 6373 | return null; |
||
| 6374 | }).filter(function (item) { |
||
| 6375 | return item; |
||
| 6376 | }).sort(function (a, b) { |
||
| 6377 | return a[0] - b[0]; |
||
| 6378 | }).forEach(function (item) { |
||
| 6379 | _this2._offsets.push(item[0]); |
||
| 6380 | |||
| 6381 | _this2._targets.push(item[1]); |
||
| 6382 | }); |
||
| 6383 | }; |
||
| 6384 | |||
| 6385 | _proto.dispose = function dispose() { |
||
| 6386 | $__default['default'].removeData(this._element, DATA_KEY$8); |
||
| 6387 | $__default['default'](this._scrollElement).off(EVENT_KEY$8); |
||
| 6388 | this._element = null; |
||
| 6389 | this._scrollElement = null; |
||
| 6390 | this._config = null; |
||
| 6391 | this._selector = null; |
||
| 6392 | this._offsets = null; |
||
| 6393 | this._targets = null; |
||
| 6394 | this._activeTarget = null; |
||
| 6395 | this._scrollHeight = null; |
||
| 6396 | } // Private |
||
| 6397 | ; |
||
| 6398 | |||
| 6399 | _proto._getConfig = function _getConfig(config) { |
||
| 6400 | config = _extends({}, Default$6, typeof config === 'object' && config ? config : {}); |
||
| 6401 | |||
| 6402 | if (typeof config.target !== 'string' && Util.isElement(config.target)) { |
||
| 6403 | var id = $__default['default'](config.target).attr('id'); |
||
| 6404 | |||
| 6405 | if (!id) { |
||
| 6406 | id = Util.getUID(NAME$8); |
||
| 6407 | $__default['default'](config.target).attr('id', id); |
||
| 6408 | } |
||
| 6409 | |||
| 6410 | config.target = "#" + id; |
||
| 6411 | } |
||
| 6412 | |||
| 6413 | Util.typeCheckConfig(NAME$8, config, DefaultType$6); |
||
| 6414 | return config; |
||
| 6415 | }; |
||
| 6416 | |||
| 6417 | _proto._getScrollTop = function _getScrollTop() { |
||
| 6418 | return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; |
||
| 6419 | }; |
||
| 6420 | |||
| 6421 | _proto._getScrollHeight = function _getScrollHeight() { |
||
| 6422 | return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); |
||
| 6423 | }; |
||
| 6424 | |||
| 6425 | _proto._getOffsetHeight = function _getOffsetHeight() { |
||
| 6426 | return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; |
||
| 6427 | }; |
||
| 6428 | |||
| 6429 | _proto._process = function _process() { |
||
| 6430 | var scrollTop = this._getScrollTop() + this._config.offset; |
||
| 6431 | |||
| 6432 | var scrollHeight = this._getScrollHeight(); |
||
| 6433 | |||
| 6434 | var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); |
||
| 6435 | |||
| 6436 | if (this._scrollHeight !== scrollHeight) { |
||
| 6437 | this.refresh(); |
||
| 6438 | } |
||
| 6439 | |||
| 6440 | if (scrollTop >= maxScroll) { |
||
| 6441 | var target = this._targets[this._targets.length - 1]; |
||
| 6442 | |||
| 6443 | if (this._activeTarget !== target) { |
||
| 6444 | this._activate(target); |
||
| 6445 | } |
||
| 6446 | |||
| 6447 | return; |
||
| 6448 | } |
||
| 6449 | |||
| 6450 | if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { |
||
| 6451 | this._activeTarget = null; |
||
| 6452 | |||
| 6453 | this._clear(); |
||
| 6454 | |||
| 6455 | return; |
||
| 6456 | } |
||
| 6457 | |||
| 6458 | for (var i = this._offsets.length; i--;) { |
||
| 6459 | var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); |
||
| 6460 | |||
| 6461 | if (isActiveTarget) { |
||
| 6462 | this._activate(this._targets[i]); |
||
| 6463 | } |
||
| 6464 | } |
||
| 6465 | }; |
||
| 6466 | |||
| 6467 | _proto._activate = function _activate(target) { |
||
| 6468 | this._activeTarget = target; |
||
| 6469 | |||
| 6470 | this._clear(); |
||
| 6471 | |||
| 6472 | var queries = this._selector.split(',').map(function (selector) { |
||
| 6473 | return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]"; |
||
| 6474 | }); |
||
| 6475 | |||
| 6476 | var $link = $__default['default']([].slice.call(document.querySelectorAll(queries.join(',')))); |
||
| 6477 | |||
| 6478 | if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) { |
||
| 6479 | $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE$2); |
||
| 6480 | $link.addClass(CLASS_NAME_ACTIVE$2); |
||
| 6481 | } else { |
||
| 6482 | // Set triggered link as active |
||
| 6483 | $link.addClass(CLASS_NAME_ACTIVE$2); // Set triggered links parents as active |
||
| 6484 | // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor |
||
| 6485 | |||
| 6486 | $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 |
||
| 6487 | |||
| 6488 | $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE$2); |
||
| 6489 | } |
||
| 6490 | |||
| 6491 | $__default['default'](this._scrollElement).trigger(EVENT_ACTIVATE, { |
||
| 6492 | relatedTarget: target |
||
| 6493 | }); |
||
| 6494 | }; |
||
| 6495 | |||
| 6496 | _proto._clear = function _clear() { |
||
| 6497 | [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) { |
||
| 6498 | return node.classList.contains(CLASS_NAME_ACTIVE$2); |
||
| 6499 | }).forEach(function (node) { |
||
| 6500 | return node.classList.remove(CLASS_NAME_ACTIVE$2); |
||
| 6501 | }); |
||
| 6502 | } // Static |
||
| 6503 | ; |
||
| 6504 | |||
| 6505 | ScrollSpy._jQueryInterface = function _jQueryInterface(config) { |
||
| 6506 | return this.each(function () { |
||
| 6507 | var data = $__default['default'](this).data(DATA_KEY$8); |
||
| 6508 | |||
| 6509 | var _config = typeof config === 'object' && config; |
||
| 6510 | |||
| 6511 | if (!data) { |
||
| 6512 | data = new ScrollSpy(this, _config); |
||
| 6513 | $__default['default'](this).data(DATA_KEY$8, data); |
||
| 6514 | } |
||
| 6515 | |||
| 6516 | if (typeof config === 'string') { |
||
| 6517 | if (typeof data[config] === 'undefined') { |
||
| 6518 | throw new TypeError("No method named \"" + config + "\""); |
||
| 6519 | } |
||
| 6520 | |||
| 6521 | data[config](); |
||
| 6522 | } |
||
| 6523 | }); |
||
| 6524 | }; |
||
| 6525 | |||
| 6526 | _createClass(ScrollSpy, null, [{ |
||
| 6527 | key: "VERSION", |
||
| 6528 | get: function get() { |
||
| 6529 | return VERSION$8; |
||
| 6530 | } |
||
| 6531 | }, { |
||
| 6532 | key: "Default", |
||
| 6533 | get: function get() { |
||
| 6534 | return Default$6; |
||
| 6535 | } |
||
| 6536 | }]); |
||
| 6537 | |||
| 6538 | return ScrollSpy; |
||
| 6539 | }(); |
||
| 6540 | /** |
||
| 6541 | * ------------------------------------------------------------------------ |
||
| 6542 | * Data Api implementation |
||
| 6543 | * ------------------------------------------------------------------------ |
||
| 6544 | */ |
||
| 6545 | |||
| 6546 | |||
| 6547 | $__default['default'](window).on(EVENT_LOAD_DATA_API$2, function () { |
||
| 6548 | var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY)); |
||
| 6549 | var scrollSpysLength = scrollSpys.length; |
||
| 6550 | |||
| 6551 | for (var i = scrollSpysLength; i--;) { |
||
| 6552 | var $spy = $__default['default'](scrollSpys[i]); |
||
| 6553 | |||
| 6554 | ScrollSpy._jQueryInterface.call($spy, $spy.data()); |
||
| 6555 | } |
||
| 6556 | }); |
||
| 6557 | /** |
||
| 6558 | * ------------------------------------------------------------------------ |
||
| 6559 | * jQuery |
||
| 6560 | * ------------------------------------------------------------------------ |
||
| 6561 | */ |
||
| 6562 | |||
| 6563 | $__default['default'].fn[NAME$8] = ScrollSpy._jQueryInterface; |
||
| 6564 | $__default['default'].fn[NAME$8].Constructor = ScrollSpy; |
||
| 6565 | |||
| 6566 | $__default['default'].fn[NAME$8].noConflict = function () { |
||
| 6567 | $__default['default'].fn[NAME$8] = JQUERY_NO_CONFLICT$8; |
||
| 6568 | return ScrollSpy._jQueryInterface; |
||
| 6569 | }; |
||
| 6570 | |||
| 6571 | /** |
||
| 6572 | * ------------------------------------------------------------------------ |
||
| 6573 | * Constants |
||
| 6574 | * ------------------------------------------------------------------------ |
||
| 6575 | */ |
||
| 6576 | |||
| 6577 | var NAME$9 = 'tab'; |
||
| 6578 | var VERSION$9 = '4.5.3'; |
||
| 6579 | var DATA_KEY$9 = 'bs.tab'; |
||
| 6580 | var EVENT_KEY$9 = "." + DATA_KEY$9; |
||
| 6581 | var DATA_API_KEY$7 = '.data-api'; |
||
| 6582 | var JQUERY_NO_CONFLICT$9 = $__default['default'].fn[NAME$9]; |
||
| 6583 | var EVENT_HIDE$3 = "hide" + EVENT_KEY$9; |
||
| 6584 | var EVENT_HIDDEN$3 = "hidden" + EVENT_KEY$9; |
||
| 6585 | var EVENT_SHOW$3 = "show" + EVENT_KEY$9; |
||
| 6586 | var EVENT_SHOWN$3 = "shown" + EVENT_KEY$9; |
||
| 6587 | var EVENT_CLICK_DATA_API$6 = "click" + EVENT_KEY$9 + DATA_API_KEY$7; |
||
| 6588 | var CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; |
||
| 6589 | var CLASS_NAME_ACTIVE$3 = 'active'; |
||
| 6590 | var CLASS_NAME_DISABLED$1 = 'disabled'; |
||
| 6591 | var CLASS_NAME_FADE$4 = 'fade'; |
||
| 6592 | var CLASS_NAME_SHOW$6 = 'show'; |
||
| 6593 | var SELECTOR_DROPDOWN$1 = '.dropdown'; |
||
| 6594 | var SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; |
||
| 6595 | var SELECTOR_ACTIVE$2 = '.active'; |
||
| 6596 | var SELECTOR_ACTIVE_UL = '> li > .active'; |
||
| 6597 | var SELECTOR_DATA_TOGGLE$4 = '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]'; |
||
| 6598 | var SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; |
||
| 6599 | var SELECTOR_DROPDOWN_ACTIVE_CHILD = '> .dropdown-menu .active'; |
||
| 6600 | /** |
||
| 6601 | * ------------------------------------------------------------------------ |
||
| 6602 | * Class Definition |
||
| 6603 | * ------------------------------------------------------------------------ |
||
| 6604 | */ |
||
| 6605 | |||
| 6606 | var Tab = /*#__PURE__*/function () { |
||
| 6607 | function Tab(element) { |
||
| 6608 | this._element = element; |
||
| 6609 | } // Getters |
||
| 6610 | |||
| 6611 | |||
| 6612 | var _proto = Tab.prototype; |
||
| 6613 | |||
| 6614 | // Public |
||
| 6615 | _proto.show = function show() { |
||
| 6616 | var _this = this; |
||
| 6617 | |||
| 6618 | if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $__default['default'](this._element).hasClass(CLASS_NAME_ACTIVE$3) || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED$1)) { |
||
| 6619 | return; |
||
| 6620 | } |
||
| 6621 | |||
| 6622 | var target; |
||
| 6623 | var previous; |
||
| 6624 | var listElement = $__default['default'](this._element).closest(SELECTOR_NAV_LIST_GROUP$1)[0]; |
||
| 6625 | var selector = Util.getSelectorFromElement(this._element); |
||
| 6626 | |||
| 6627 | if (listElement) { |
||
| 6628 | var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE$2; |
||
| 6629 | previous = $__default['default'].makeArray($__default['default'](listElement).find(itemSelector)); |
||
| 6630 | previous = previous[previous.length - 1]; |
||
| 6631 | } |
||
| 6632 | |||
| 6633 | var hideEvent = $__default['default'].Event(EVENT_HIDE$3, { |
||
| 6634 | relatedTarget: this._element |
||
| 6635 | }); |
||
| 6636 | var showEvent = $__default['default'].Event(EVENT_SHOW$3, { |
||
| 6637 | relatedTarget: previous |
||
| 6638 | }); |
||
| 6639 | |||
| 6640 | if (previous) { |
||
| 6641 | $__default['default'](previous).trigger(hideEvent); |
||
| 6642 | } |
||
| 6643 | |||
| 6644 | $__default['default'](this._element).trigger(showEvent); |
||
| 6645 | |||
| 6646 | if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { |
||
| 6647 | return; |
||
| 6648 | } |
||
| 6649 | |||
| 6650 | if (selector) { |
||
| 6651 | target = document.querySelector(selector); |
||
| 6652 | } |
||
| 6653 | |||
| 6654 | this._activate(this._element, listElement); |
||
| 6655 | |||
| 6656 | var complete = function complete() { |
||
| 6657 | var hiddenEvent = $__default['default'].Event(EVENT_HIDDEN$3, { |
||
| 6658 | relatedTarget: _this._element |
||
| 6659 | }); |
||
| 6660 | var shownEvent = $__default['default'].Event(EVENT_SHOWN$3, { |
||
| 6661 | relatedTarget: previous |
||
| 6662 | }); |
||
| 6663 | $__default['default'](previous).trigger(hiddenEvent); |
||
| 6664 | $__default['default'](_this._element).trigger(shownEvent); |
||
| 6665 | }; |
||
| 6666 | |||
| 6667 | if (target) { |
||
| 6668 | this._activate(target, target.parentNode, complete); |
||
| 6669 | } else { |
||
| 6670 | complete(); |
||
| 6671 | } |
||
| 6672 | }; |
||
| 6673 | |||
| 6674 | _proto.dispose = function dispose() { |
||
| 6675 | $__default['default'].removeData(this._element, DATA_KEY$9); |
||
| 6676 | this._element = null; |
||
| 6677 | } // Private |
||
| 6678 | ; |
||
| 6679 | |||
| 6680 | _proto._activate = function _activate(element, container, callback) { |
||
| 6681 | var _this2 = this; |
||
| 6682 | |||
| 6683 | var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $__default['default'](container).find(SELECTOR_ACTIVE_UL) : $__default['default'](container).children(SELECTOR_ACTIVE$2); |
||
| 6684 | var active = activeElements[0]; |
||
| 6685 | var isTransitioning = callback && active && $__default['default'](active).hasClass(CLASS_NAME_FADE$4); |
||
| 6686 | |||
| 6687 | var complete = function complete() { |
||
| 6688 | return _this2._transitionComplete(element, active, callback); |
||
| 6689 | }; |
||
| 6690 | |||
| 6691 | if (active && isTransitioning) { |
||
| 6692 | var transitionDuration = Util.getTransitionDurationFromElement(active); |
||
| 6693 | $__default['default'](active).removeClass(CLASS_NAME_SHOW$6).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 6694 | } else { |
||
| 6695 | complete(); |
||
| 6696 | } |
||
| 6697 | }; |
||
| 6698 | |||
| 6699 | _proto._transitionComplete = function _transitionComplete(element, active, callback) { |
||
| 6700 | if (active) { |
||
| 6701 | $__default['default'](active).removeClass(CLASS_NAME_ACTIVE$3); |
||
| 6702 | var dropdownChild = $__default['default'](active.parentNode).find(SELECTOR_DROPDOWN_ACTIVE_CHILD)[0]; |
||
| 6703 | |||
| 6704 | if (dropdownChild) { |
||
| 6705 | $__default['default'](dropdownChild).removeClass(CLASS_NAME_ACTIVE$3); |
||
| 6706 | } |
||
| 6707 | |||
| 6708 | if (active.getAttribute('role') === 'tab') { |
||
| 6709 | active.setAttribute('aria-selected', false); |
||
| 6710 | } |
||
| 6711 | } |
||
| 6712 | |||
| 6713 | $__default['default'](element).addClass(CLASS_NAME_ACTIVE$3); |
||
| 6714 | |||
| 6715 | if (element.getAttribute('role') === 'tab') { |
||
| 6716 | element.setAttribute('aria-selected', true); |
||
| 6717 | } |
||
| 6718 | |||
| 6719 | Util.reflow(element); |
||
| 6720 | |||
| 6721 | if (element.classList.contains(CLASS_NAME_FADE$4)) { |
||
| 6722 | element.classList.add(CLASS_NAME_SHOW$6); |
||
| 6723 | } |
||
| 6724 | |||
| 6725 | if (element.parentNode && $__default['default'](element.parentNode).hasClass(CLASS_NAME_DROPDOWN_MENU)) { |
||
| 6726 | var dropdownElement = $__default['default'](element).closest(SELECTOR_DROPDOWN$1)[0]; |
||
| 6727 | |||
| 6728 | if (dropdownElement) { |
||
| 6729 | var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(SELECTOR_DROPDOWN_TOGGLE$1)); |
||
| 6730 | $__default['default'](dropdownToggleList).addClass(CLASS_NAME_ACTIVE$3); |
||
| 6731 | } |
||
| 6732 | |||
| 6733 | element.setAttribute('aria-expanded', true); |
||
| 6734 | } |
||
| 6735 | |||
| 6736 | if (callback) { |
||
| 6737 | callback(); |
||
| 6738 | } |
||
| 6739 | } // Static |
||
| 6740 | ; |
||
| 6741 | |||
| 6742 | Tab._jQueryInterface = function _jQueryInterface(config) { |
||
| 6743 | return this.each(function () { |
||
| 6744 | var $this = $__default['default'](this); |
||
| 6745 | var data = $this.data(DATA_KEY$9); |
||
| 6746 | |||
| 6747 | if (!data) { |
||
| 6748 | data = new Tab(this); |
||
| 6749 | $this.data(DATA_KEY$9, data); |
||
| 6750 | } |
||
| 6751 | |||
| 6752 | if (typeof config === 'string') { |
||
| 6753 | if (typeof data[config] === 'undefined') { |
||
| 6754 | throw new TypeError("No method named \"" + config + "\""); |
||
| 6755 | } |
||
| 6756 | |||
| 6757 | data[config](); |
||
| 6758 | } |
||
| 6759 | }); |
||
| 6760 | }; |
||
| 6761 | |||
| 6762 | _createClass(Tab, null, [{ |
||
| 6763 | key: "VERSION", |
||
| 6764 | get: function get() { |
||
| 6765 | return VERSION$9; |
||
| 6766 | } |
||
| 6767 | }]); |
||
| 6768 | |||
| 6769 | return Tab; |
||
| 6770 | }(); |
||
| 6771 | /** |
||
| 6772 | * ------------------------------------------------------------------------ |
||
| 6773 | * Data Api implementation |
||
| 6774 | * ------------------------------------------------------------------------ |
||
| 6775 | */ |
||
| 6776 | |||
| 6777 | |||
| 6778 | $__default['default'](document).on(EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$4, function (event) { |
||
| 6779 | event.preventDefault(); |
||
| 6780 | |||
| 6781 | Tab._jQueryInterface.call($__default['default'](this), 'show'); |
||
| 6782 | }); |
||
| 6783 | /** |
||
| 6784 | * ------------------------------------------------------------------------ |
||
| 6785 | * jQuery |
||
| 6786 | * ------------------------------------------------------------------------ |
||
| 6787 | */ |
||
| 6788 | |||
| 6789 | $__default['default'].fn[NAME$9] = Tab._jQueryInterface; |
||
| 6790 | $__default['default'].fn[NAME$9].Constructor = Tab; |
||
| 6791 | |||
| 6792 | $__default['default'].fn[NAME$9].noConflict = function () { |
||
| 6793 | $__default['default'].fn[NAME$9] = JQUERY_NO_CONFLICT$9; |
||
| 6794 | return Tab._jQueryInterface; |
||
| 6795 | }; |
||
| 6796 | |||
| 6797 | /** |
||
| 6798 | * ------------------------------------------------------------------------ |
||
| 6799 | * Constants |
||
| 6800 | * ------------------------------------------------------------------------ |
||
| 6801 | */ |
||
| 6802 | |||
| 6803 | var NAME$a = 'toast'; |
||
| 6804 | var VERSION$a = '4.5.3'; |
||
| 6805 | var DATA_KEY$a = 'bs.toast'; |
||
| 6806 | var EVENT_KEY$a = "." + DATA_KEY$a; |
||
| 6807 | var JQUERY_NO_CONFLICT$a = $__default['default'].fn[NAME$a]; |
||
| 6808 | var EVENT_CLICK_DISMISS$1 = "click.dismiss" + EVENT_KEY$a; |
||
| 6809 | var EVENT_HIDE$4 = "hide" + EVENT_KEY$a; |
||
| 6810 | var EVENT_HIDDEN$4 = "hidden" + EVENT_KEY$a; |
||
| 6811 | var EVENT_SHOW$4 = "show" + EVENT_KEY$a; |
||
| 6812 | var EVENT_SHOWN$4 = "shown" + EVENT_KEY$a; |
||
| 6813 | var CLASS_NAME_FADE$5 = 'fade'; |
||
| 6814 | var CLASS_NAME_HIDE = 'hide'; |
||
| 6815 | var CLASS_NAME_SHOW$7 = 'show'; |
||
| 6816 | var CLASS_NAME_SHOWING = 'showing'; |
||
| 6817 | var DefaultType$7 = { |
||
| 6818 | animation: 'boolean', |
||
| 6819 | autohide: 'boolean', |
||
| 6820 | delay: 'number' |
||
| 6821 | }; |
||
| 6822 | var Default$7 = { |
||
| 6823 | animation: true, |
||
| 6824 | autohide: true, |
||
| 6825 | delay: 500 |
||
| 6826 | }; |
||
| 6827 | var SELECTOR_DATA_DISMISS$1 = '[data-dismiss="toast"]'; |
||
| 6828 | /** |
||
| 6829 | * ------------------------------------------------------------------------ |
||
| 6830 | * Class Definition |
||
| 6831 | * ------------------------------------------------------------------------ |
||
| 6832 | */ |
||
| 6833 | |||
| 6834 | var Toast = /*#__PURE__*/function () { |
||
| 6835 | function Toast(element, config) { |
||
| 6836 | this._element = element; |
||
| 6837 | this._config = this._getConfig(config); |
||
| 6838 | this._timeout = null; |
||
| 6839 | |||
| 6840 | this._setListeners(); |
||
| 6841 | } // Getters |
||
| 6842 | |||
| 6843 | |||
| 6844 | var _proto = Toast.prototype; |
||
| 6845 | |||
| 6846 | // Public |
||
| 6847 | _proto.show = function show() { |
||
| 6848 | var _this = this; |
||
| 6849 | |||
| 6850 | var showEvent = $__default['default'].Event(EVENT_SHOW$4); |
||
| 6851 | $__default['default'](this._element).trigger(showEvent); |
||
| 6852 | |||
| 6853 | if (showEvent.isDefaultPrevented()) { |
||
| 6854 | return; |
||
| 6855 | } |
||
| 6856 | |||
| 6857 | this._clearTimeout(); |
||
| 6858 | |||
| 6859 | if (this._config.animation) { |
||
| 6860 | this._element.classList.add(CLASS_NAME_FADE$5); |
||
| 6861 | } |
||
| 6862 | |||
| 6863 | var complete = function complete() { |
||
| 6864 | _this._element.classList.remove(CLASS_NAME_SHOWING); |
||
| 6865 | |||
| 6866 | _this._element.classList.add(CLASS_NAME_SHOW$7); |
||
| 6867 | |||
| 6868 | $__default['default'](_this._element).trigger(EVENT_SHOWN$4); |
||
| 6869 | |||
| 6870 | if (_this._config.autohide) { |
||
| 6871 | _this._timeout = setTimeout(function () { |
||
| 6872 | _this.hide(); |
||
| 6873 | }, _this._config.delay); |
||
| 6874 | } |
||
| 6875 | }; |
||
| 6876 | |||
| 6877 | this._element.classList.remove(CLASS_NAME_HIDE); |
||
| 6878 | |||
| 6879 | Util.reflow(this._element); |
||
| 6880 | |||
| 6881 | this._element.classList.add(CLASS_NAME_SHOWING); |
||
| 6882 | |||
| 6883 | if (this._config.animation) { |
||
| 6884 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); |
||
| 6885 | $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 6886 | } else { |
||
| 6887 | complete(); |
||
| 6888 | } |
||
| 6889 | }; |
||
| 6890 | |||
| 6891 | _proto.hide = function hide() { |
||
| 6892 | if (!this._element.classList.contains(CLASS_NAME_SHOW$7)) { |
||
| 6893 | return; |
||
| 6894 | } |
||
| 6895 | |||
| 6896 | var hideEvent = $__default['default'].Event(EVENT_HIDE$4); |
||
| 6897 | $__default['default'](this._element).trigger(hideEvent); |
||
| 6898 | |||
| 6899 | if (hideEvent.isDefaultPrevented()) { |
||
| 6900 | return; |
||
| 6901 | } |
||
| 6902 | |||
| 6903 | this._close(); |
||
| 6904 | }; |
||
| 6905 | |||
| 6906 | _proto.dispose = function dispose() { |
||
| 6907 | this._clearTimeout(); |
||
| 6908 | |||
| 6909 | if (this._element.classList.contains(CLASS_NAME_SHOW$7)) { |
||
| 6910 | this._element.classList.remove(CLASS_NAME_SHOW$7); |
||
| 6911 | } |
||
| 6912 | |||
| 6913 | $__default['default'](this._element).off(EVENT_CLICK_DISMISS$1); |
||
| 6914 | $__default['default'].removeData(this._element, DATA_KEY$a); |
||
| 6915 | this._element = null; |
||
| 6916 | this._config = null; |
||
| 6917 | } // Private |
||
| 6918 | ; |
||
| 6919 | |||
| 6920 | _proto._getConfig = function _getConfig(config) { |
||
| 6921 | config = _extends({}, Default$7, $__default['default'](this._element).data(), typeof config === 'object' && config ? config : {}); |
||
| 6922 | Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType); |
||
| 6923 | return config; |
||
| 6924 | }; |
||
| 6925 | |||
| 6926 | _proto._setListeners = function _setListeners() { |
||
| 6927 | var _this2 = this; |
||
| 6928 | |||
| 6929 | $__default['default'](this._element).on(EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, function () { |
||
| 6930 | return _this2.hide(); |
||
| 6931 | }); |
||
| 6932 | }; |
||
| 6933 | |||
| 6934 | _proto._close = function _close() { |
||
| 6935 | var _this3 = this; |
||
| 6936 | |||
| 6937 | var complete = function complete() { |
||
| 6938 | _this3._element.classList.add(CLASS_NAME_HIDE); |
||
| 6939 | |||
| 6940 | $__default['default'](_this3._element).trigger(EVENT_HIDDEN$4); |
||
| 6941 | }; |
||
| 6942 | |||
| 6943 | this._element.classList.remove(CLASS_NAME_SHOW$7); |
||
| 6944 | |||
| 6945 | if (this._config.animation) { |
||
| 6946 | var transitionDuration = Util.getTransitionDurationFromElement(this._element); |
||
| 6947 | $__default['default'](this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration); |
||
| 6948 | } else { |
||
| 6949 | complete(); |
||
| 6950 | } |
||
| 6951 | }; |
||
| 6952 | |||
| 6953 | _proto._clearTimeout = function _clearTimeout() { |
||
| 6954 | clearTimeout(this._timeout); |
||
| 6955 | this._timeout = null; |
||
| 6956 | } // Static |
||
| 6957 | ; |
||
| 6958 | |||
| 6959 | Toast._jQueryInterface = function _jQueryInterface(config) { |
||
| 6960 | return this.each(function () { |
||
| 6961 | var $element = $__default['default'](this); |
||
| 6962 | var data = $element.data(DATA_KEY$a); |
||
| 6963 | |||
| 6964 | var _config = typeof config === 'object' && config; |
||
| 6965 | |||
| 6966 | if (!data) { |
||
| 6967 | data = new Toast(this, _config); |
||
| 6968 | $element.data(DATA_KEY$a, data); |
||
| 6969 | } |
||
| 6970 | |||
| 6971 | if (typeof config === 'string') { |
||
| 6972 | if (typeof data[config] === 'undefined') { |
||
| 6973 | throw new TypeError("No method named \"" + config + "\""); |
||
| 6974 | } |
||
| 6975 | |||
| 6976 | data[config](this); |
||
| 6977 | } |
||
| 6978 | }); |
||
| 6979 | }; |
||
| 6980 | |||
| 6981 | _createClass(Toast, null, [{ |
||
| 6982 | key: "VERSION", |
||
| 6983 | get: function get() { |
||
| 6984 | return VERSION$a; |
||
| 6985 | } |
||
| 6986 | }, { |
||
| 6987 | key: "DefaultType", |
||
| 6988 | get: function get() { |
||
| 6989 | return DefaultType$7; |
||
| 6990 | } |
||
| 6991 | }, { |
||
| 6992 | key: "Default", |
||
| 6993 | get: function get() { |
||
| 6994 | return Default$7; |
||
| 6995 | } |
||
| 6996 | }]); |
||
| 6997 | |||
| 6998 | return Toast; |
||
| 6999 | }(); |
||
| 7000 | /** |
||
| 7001 | * ------------------------------------------------------------------------ |
||
| 7002 | * jQuery |
||
| 7003 | * ------------------------------------------------------------------------ |
||
| 7004 | */ |
||
| 7005 | |||
| 7006 | |||
| 7007 | $__default['default'].fn[NAME$a] = Toast._jQueryInterface; |
||
| 7008 | $__default['default'].fn[NAME$a].Constructor = Toast; |
||
| 7009 | |||
| 7010 | $__default['default'].fn[NAME$a].noConflict = function () { |
||
| 7011 | $__default['default'].fn[NAME$a] = JQUERY_NO_CONFLICT$a; |
||
| 7012 | return Toast._jQueryInterface; |
||
| 7013 | }; |
||
| 7014 | |||
| 7015 | exports.Alert = Alert; |
||
| 7016 | exports.Button = Button; |
||
| 7017 | exports.Carousel = Carousel; |
||
| 7018 | exports.Collapse = Collapse; |
||
| 7019 | exports.Dropdown = Dropdown; |
||
| 7020 | exports.Modal = Modal; |
||
| 7021 | exports.Popover = Popover; |
||
| 7022 | exports.Scrollspy = ScrollSpy; |
||
| 7023 | exports.Tab = Tab; |
||
| 7024 | exports.Toast = Toast; |
||
| 7025 | exports.Tooltip = Tooltip; |
||
| 7026 | exports.Util = Util; |
||
| 7027 | |||
| 7028 | Object.defineProperty(exports, '__esModule', { value: true }); |
||
| 7029 | |||
| 7030 | }))); |
||
| 7031 | //# sourceMappingURL=bootstrap.bundle.js.map |