diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/dropdown.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/dropdown.js | 116 |
1 files changed, 59 insertions, 57 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/dropdown.js b/vendor/twbs/bootstrap/js/dist/dropdown.js index f4c39b535..9ba052ef6 100644 --- a/vendor/twbs/bootstrap/js/dist/dropdown.js +++ b/vendor/twbs/bootstrap/js/dist/dropdown.js @@ -1,5 +1,5 @@ /*! - * Bootstrap dropdown.js v4.5.2 (https://getbootstrap.com/) + * Bootstrap dropdown.js v4.5.3 (https://getbootstrap.com/) * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ @@ -9,9 +9,11 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.jQuery, global.Popper, global.Util)); }(this, (function ($, Popper, Util) { 'use strict'; - $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $; - Popper = Popper && Object.prototype.hasOwnProperty.call(Popper, 'default') ? Popper['default'] : Popper; - Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util; + function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + + var $__default = /*#__PURE__*/_interopDefaultLegacy($); + var Popper__default = /*#__PURE__*/_interopDefaultLegacy(Popper); + var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util); function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } @@ -25,11 +27,11 @@ */ var NAME = 'dropdown'; - var VERSION = '4.5.2'; + var VERSION = '4.5.3'; var DATA_KEY = 'bs.dropdown'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; - var JQUERY_NO_CONFLICT = $.fn[NAME]; + var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME]; var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key @@ -107,11 +109,11 @@ // Public _proto.toggle = function toggle() { - if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED)) { + if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED)) { return; } - var isActive = $(this._menu).hasClass(CLASS_NAME_SHOW); + var isActive = $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW); Dropdown._clearMenus(); @@ -127,18 +129,18 @@ usePopper = false; } - if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || $(this._menu).hasClass(CLASS_NAME_SHOW)) { + if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || $__default['default'](this._menu).hasClass(CLASS_NAME_SHOW)) { return; } var relatedTarget = { relatedTarget: this._element }; - var showEvent = $.Event(EVENT_SHOW, relatedTarget); + var showEvent = $__default['default'].Event(EVENT_SHOW, relatedTarget); var parent = Dropdown._getParentFromElement(this._element); - $(parent).trigger(showEvent); + $__default['default'](parent).trigger(showEvent); if (showEvent.isDefaultPrevented()) { return; @@ -150,7 +152,7 @@ * Check for Popper dependency * Popper - https://popper.js.org */ - if (typeof Popper === 'undefined') { + if (typeof Popper__default['default'] === 'undefined') { throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)'); } @@ -158,7 +160,7 @@ if (this._config.reference === 'parent') { referenceElement = parent; - } else if (Util.isElement(this._config.reference)) { + } else if (Util__default['default'].isElement(this._config.reference)) { referenceElement = this._config.reference; // Check if it's jQuery element if (typeof this._config.reference.jquery !== 'undefined') { @@ -170,41 +172,41 @@ if (this._config.boundary !== 'scrollParent') { - $(parent).addClass(CLASS_NAME_POSITION_STATIC); + $__default['default'](parent).addClass(CLASS_NAME_POSITION_STATIC); } - this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig()); + this._popper = new Popper__default['default'](referenceElement, this._menu, this._getPopperConfig()); } // If this is a touch-enabled device we add extra // empty mouseover listeners to the body's immediate children; // only needed because of broken event delegation on iOS // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html - if ('ontouchstart' in document.documentElement && $(parent).closest(SELECTOR_NAVBAR_NAV).length === 0) { - $(document.body).children().on('mouseover', null, $.noop); + if ('ontouchstart' in document.documentElement && $__default['default'](parent).closest(SELECTOR_NAVBAR_NAV).length === 0) { + $__default['default'](document.body).children().on('mouseover', null, $__default['default'].noop); } this._element.focus(); this._element.setAttribute('aria-expanded', true); - $(this._menu).toggleClass(CLASS_NAME_SHOW); - $(parent).toggleClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_SHOWN, relatedTarget)); + $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW); + $__default['default'](parent).toggleClass(CLASS_NAME_SHOW).trigger($__default['default'].Event(EVENT_SHOWN, relatedTarget)); }; _proto.hide = function hide() { - if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || !$(this._menu).hasClass(CLASS_NAME_SHOW)) { + if (this._element.disabled || $__default['default'](this._element).hasClass(CLASS_NAME_DISABLED) || !$__default['default'](this._menu).hasClass(CLASS_NAME_SHOW)) { return; } var relatedTarget = { relatedTarget: this._element }; - var hideEvent = $.Event(EVENT_HIDE, relatedTarget); + var hideEvent = $__default['default'].Event(EVENT_HIDE, relatedTarget); var parent = Dropdown._getParentFromElement(this._element); - $(parent).trigger(hideEvent); + $__default['default'](parent).trigger(hideEvent); if (hideEvent.isDefaultPrevented()) { return; @@ -214,13 +216,13 @@ this._popper.destroy(); } - $(this._menu).toggleClass(CLASS_NAME_SHOW); - $(parent).toggleClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget)); + $__default['default'](this._menu).toggleClass(CLASS_NAME_SHOW); + $__default['default'](parent).toggleClass(CLASS_NAME_SHOW).trigger($__default['default'].Event(EVENT_HIDDEN, relatedTarget)); }; _proto.dispose = function dispose() { - $.removeData(this._element, DATA_KEY); - $(this._element).off(EVENT_KEY); + $__default['default'].removeData(this._element, DATA_KEY); + $__default['default'](this._element).off(EVENT_KEY); this._element = null; this._menu = null; @@ -243,7 +245,7 @@ _proto._addEventListeners = function _addEventListeners() { var _this = this; - $(this._element).on(EVENT_CLICK, function (event) { + $__default['default'](this._element).on(EVENT_CLICK, function (event) { event.preventDefault(); event.stopPropagation(); @@ -252,8 +254,8 @@ }; _proto._getConfig = function _getConfig(config) { - config = _extends({}, this.constructor.Default, $(this._element).data(), config); - Util.typeCheckConfig(NAME, config, this.constructor.DefaultType); + config = _extends({}, this.constructor.Default, $__default['default'](this._element).data(), config); + Util__default['default'].typeCheckConfig(NAME, config, this.constructor.DefaultType); return config; }; @@ -270,16 +272,16 @@ }; _proto._getPlacement = function _getPlacement() { - var $parentDropdown = $(this._element.parentNode); + var $parentDropdown = $__default['default'](this._element.parentNode); var placement = PLACEMENT_BOTTOM; // Handle dropup if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) { - placement = $(this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP; + placement = $__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT) ? PLACEMENT_TOPEND : PLACEMENT_TOP; } else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) { placement = PLACEMENT_RIGHT; } else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) { placement = PLACEMENT_LEFT; - } else if ($(this._menu).hasClass(CLASS_NAME_MENURIGHT)) { + } else if ($__default['default'](this._menu).hasClass(CLASS_NAME_MENURIGHT)) { placement = PLACEMENT_BOTTOMEND; } @@ -287,7 +289,7 @@ }; _proto._detectNavbar = function _detectNavbar() { - return $(this._element).closest('.navbar').length > 0; + return $__default['default'](this._element).closest('.navbar').length > 0; }; _proto._getOffset = function _getOffset() { @@ -333,13 +335,13 @@ Dropdown._jQueryInterface = function _jQueryInterface(config) { return this.each(function () { - var data = $(this).data(DATA_KEY); + var data = $__default['default'](this).data(DATA_KEY); var _config = typeof config === 'object' ? config : null; if (!data) { data = new Dropdown(this, _config); - $(this).data(DATA_KEY, data); + $__default['default'](this).data(DATA_KEY, data); } if (typeof config === 'string') { @@ -362,7 +364,7 @@ for (var i = 0, len = toggles.length; i < len; i++) { var parent = Dropdown._getParentFromElement(toggles[i]); - var context = $(toggles[i]).data(DATA_KEY); + var context = $__default['default'](toggles[i]).data(DATA_KEY); var relatedTarget = { relatedTarget: toggles[i] }; @@ -377,16 +379,16 @@ var dropdownMenu = context._menu; - if (!$(parent).hasClass(CLASS_NAME_SHOW)) { + if (!$__default['default'](parent).hasClass(CLASS_NAME_SHOW)) { continue; } - if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) { + 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)) { continue; } - var hideEvent = $.Event(EVENT_HIDE, relatedTarget); - $(parent).trigger(hideEvent); + var hideEvent = $__default['default'].Event(EVENT_HIDE, relatedTarget); + $__default['default'](parent).trigger(hideEvent); if (hideEvent.isDefaultPrevented()) { continue; @@ -395,7 +397,7 @@ if ('ontouchstart' in document.documentElement) { - $(document.body).children().off('mouseover', null, $.noop); + $__default['default'](document.body).children().off('mouseover', null, $__default['default'].noop); } toggles[i].setAttribute('aria-expanded', 'false'); @@ -404,14 +406,14 @@ context._popper.destroy(); } - $(dropdownMenu).removeClass(CLASS_NAME_SHOW); - $(parent).removeClass(CLASS_NAME_SHOW).trigger($.Event(EVENT_HIDDEN, relatedTarget)); + $__default['default'](dropdownMenu).removeClass(CLASS_NAME_SHOW); + $__default['default'](parent).removeClass(CLASS_NAME_SHOW).trigger($__default['default'].Event(EVENT_HIDDEN, relatedTarget)); } }; Dropdown._getParentFromElement = function _getParentFromElement(element) { var parent; - var selector = Util.getSelectorFromElement(element); + var selector = Util__default['default'].getSelectorFromElement(element); if (selector) { parent = document.querySelector(selector); @@ -429,17 +431,17 @@ // - If key is other than escape // - If key is not up or down => not a dropdown command // - If trigger inside the menu => not a dropdown command - if (/input|textarea/i.test(event.target.tagName) ? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE && (event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE || $(event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) { + 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)) { return; } - if (this.disabled || $(this).hasClass(CLASS_NAME_DISABLED)) { + if (this.disabled || $__default['default'](this).hasClass(CLASS_NAME_DISABLED)) { return; } var parent = Dropdown._getParentFromElement(this); - var isActive = $(parent).hasClass(CLASS_NAME_SHOW); + var isActive = $__default['default'](parent).hasClass(CLASS_NAME_SHOW); if (!isActive && event.which === ESCAPE_KEYCODE) { return; @@ -448,17 +450,17 @@ event.preventDefault(); event.stopPropagation(); - if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) { + if (!isActive || event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE) { if (event.which === ESCAPE_KEYCODE) { - $(parent.querySelector(SELECTOR_DATA_TOGGLE)).trigger('focus'); + $__default['default'](parent.querySelector(SELECTOR_DATA_TOGGLE)).trigger('focus'); } - $(this).trigger('click'); + $__default['default'](this).trigger('click'); return; } var items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS)).filter(function (item) { - return $(item).is(':visible'); + return $__default['default'](item).is(':visible'); }); if (items.length === 0) { @@ -510,11 +512,11 @@ */ - $(document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { + $__default['default'](document).on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler).on(EVENT_CLICK_DATA_API + " " + EVENT_KEYUP_DATA_API, Dropdown._clearMenus).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { event.preventDefault(); event.stopPropagation(); - Dropdown._jQueryInterface.call($(this), 'toggle'); + Dropdown._jQueryInterface.call($__default['default'](this), 'toggle'); }).on(EVENT_CLICK_DATA_API, SELECTOR_FORM_CHILD, function (e) { e.stopPropagation(); }); @@ -524,11 +526,11 @@ * ------------------------------------------------------------------------ */ - $.fn[NAME] = Dropdown._jQueryInterface; - $.fn[NAME].Constructor = Dropdown; + $__default['default'].fn[NAME] = Dropdown._jQueryInterface; + $__default['default'].fn[NAME].Constructor = Dropdown; - $.fn[NAME].noConflict = function () { - $.fn[NAME] = JQUERY_NO_CONFLICT; + $__default['default'].fn[NAME].noConflict = function () { + $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT; return Dropdown._jQueryInterface; }; |