diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/collapse.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/collapse.js | 166 |
1 files changed, 55 insertions, 111 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/collapse.js b/vendor/twbs/bootstrap/js/dist/collapse.js index d46dfec84..7f192dadc 100644 --- a/vendor/twbs/bootstrap/js/dist/collapse.js +++ b/vendor/twbs/bootstrap/js/dist/collapse.js @@ -1,67 +1,22 @@ /*! - * Bootstrap collapse.js v4.3.1 (https://getbootstrap.com/) - * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * Bootstrap collapse.js v4.5.2 (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) */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) : typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) : - (global = global || self, global.Collapse = factory(global.jQuery, global.Util)); -}(this, function ($, Util) { 'use strict'; - - $ = $ && $.hasOwnProperty('default') ? $['default'] : $; - Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util; - - function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } - } - - function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; - } - - function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Collapse = factory(global.jQuery, global.Util)); +}(this, (function ($, Util) { 'use strict'; - return obj; - } + $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $; + Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util; - function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); + 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); } - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } - - return target; - } + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * ------------------------------------------------------------------------ * Constants @@ -69,7 +24,7 @@ */ var NAME = 'collapse'; - var VERSION = '4.3.1'; + var VERSION = '4.5.2'; var DATA_KEY = 'bs.collapse'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -82,43 +37,32 @@ toggle: 'boolean', parent: '(string|element)' }; - var Event = { - SHOW: "show" + EVENT_KEY, - SHOWN: "shown" + EVENT_KEY, - HIDE: "hide" + EVENT_KEY, - HIDDEN: "hidden" + EVENT_KEY, - CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY - }; - var ClassName = { - SHOW: 'show', - COLLAPSE: 'collapse', - COLLAPSING: 'collapsing', - COLLAPSED: 'collapsed' - }; - var Dimension = { - WIDTH: 'width', - HEIGHT: 'height' - }; - var Selector = { - ACTIVES: '.show, .collapsing', - DATA_TOGGLE: '[data-toggle="collapse"]' - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ - - }; + var EVENT_SHOW = "show" + EVENT_KEY; + var EVENT_SHOWN = "shown" + EVENT_KEY; + var EVENT_HIDE = "hide" + EVENT_KEY; + var EVENT_HIDDEN = "hidden" + EVENT_KEY; + var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY; + var CLASS_NAME_SHOW = 'show'; + var CLASS_NAME_COLLAPSE = 'collapse'; + var CLASS_NAME_COLLAPSING = 'collapsing'; + var CLASS_NAME_COLLAPSED = 'collapsed'; + var DIMENSION_WIDTH = 'width'; + var DIMENSION_HEIGHT = 'height'; + var SELECTOR_ACTIVES = '.show, .collapsing'; + var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]'; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - var Collapse = - /*#__PURE__*/ - function () { + var Collapse = /*#__PURE__*/function () { function Collapse(element, config) { this._isTransitioning = false; this._element = element; this._config = this._getConfig(config); this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]"))); - var toggleList = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE)); + var toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE)); for (var i = 0, len = toggleList.length; i < len; i++) { var elem = toggleList[i]; @@ -150,7 +94,7 @@ // Public _proto.toggle = function toggle() { - if ($(this._element).hasClass(ClassName.SHOW)) { + if ($(this._element).hasClass(CLASS_NAME_SHOW)) { this.hide(); } else { this.show(); @@ -160,7 +104,7 @@ _proto.show = function show() { var _this = this; - if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || $(this._element).hasClass(CLASS_NAME_SHOW)) { return; } @@ -168,12 +112,12 @@ var activesData; if (this._parent) { - actives = [].slice.call(this._parent.querySelectorAll(Selector.ACTIVES)).filter(function (elem) { + actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES)).filter(function (elem) { if (typeof _this._config.parent === 'string') { return elem.getAttribute('data-parent') === _this._config.parent; } - return elem.classList.contains(ClassName.COLLAPSE); + return elem.classList.contains(CLASS_NAME_COLLAPSE); }); if (actives.length === 0) { @@ -189,7 +133,7 @@ } } - var startEvent = $.Event(Event.SHOW); + var startEvent = $.Event(EVENT_SHOW); $(this._element).trigger(startEvent); if (startEvent.isDefaultPrevented()) { @@ -206,22 +150,22 @@ var dimension = this._getDimension(); - $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); + $(this._element).removeClass(CLASS_NAME_COLLAPSE).addClass(CLASS_NAME_COLLAPSING); this._element.style[dimension] = 0; if (this._triggerArray.length) { - $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); + $(this._triggerArray).removeClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', true); } this.setTransitioning(true); var complete = function complete() { - $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); + $(_this._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW); _this._element.style[dimension] = ''; _this.setTransitioning(false); - $(_this._element).trigger(Event.SHOWN); + $(_this._element).trigger(EVENT_SHOWN); }; var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); @@ -234,11 +178,11 @@ _proto.hide = function hide() { var _this2 = this; - if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || !$(this._element).hasClass(CLASS_NAME_SHOW)) { return; } - var startEvent = $.Event(Event.HIDE); + var startEvent = $.Event(EVENT_HIDE); $(this._element).trigger(startEvent); if (startEvent.isDefaultPrevented()) { @@ -249,7 +193,7 @@ this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px"; Util.reflow(this._element); - $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW); + $(this._element).addClass(CLASS_NAME_COLLAPSING).removeClass(CLASS_NAME_COLLAPSE + " " + CLASS_NAME_SHOW); var triggerArrayLength = this._triggerArray.length; if (triggerArrayLength > 0) { @@ -260,8 +204,8 @@ if (selector !== null) { var $elem = $([].slice.call(document.querySelectorAll(selector))); - if (!$elem.hasClass(ClassName.SHOW)) { - $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); + if (!$elem.hasClass(CLASS_NAME_SHOW)) { + $(trigger).addClass(CLASS_NAME_COLLAPSED).attr('aria-expanded', false); } } } @@ -272,7 +216,7 @@ var complete = function complete() { _this2.setTransitioning(false); - $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + $(_this2._element).removeClass(CLASS_NAME_COLLAPSING).addClass(CLASS_NAME_COLLAPSE).trigger(EVENT_HIDDEN); }; this._element.style[dimension] = ''; @@ -295,7 +239,7 @@ ; _proto._getConfig = function _getConfig(config) { - config = _objectSpread({}, Default, config); + config = _extends({}, Default, config); config.toggle = Boolean(config.toggle); // Coerce string values Util.typeCheckConfig(NAME, config, DefaultType); @@ -303,8 +247,8 @@ }; _proto._getDimension = function _getDimension() { - var hasWidth = $(this._element).hasClass(Dimension.WIDTH); - return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + var hasWidth = $(this._element).hasClass(DIMENSION_WIDTH); + return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT; }; _proto._getParent = function _getParent() { @@ -331,10 +275,10 @@ }; _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { - var isOpen = $(element).hasClass(ClassName.SHOW); + var isOpen = $(element).hasClass(CLASS_NAME_SHOW); if (triggerArray.length) { - $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); + $(triggerArray).toggleClass(CLASS_NAME_COLLAPSED, !isOpen).attr('aria-expanded', isOpen); } } // Static ; @@ -349,9 +293,9 @@ var $this = $(this); var data = $this.data(DATA_KEY); - var _config = _objectSpread({}, Default, $this.data(), typeof config === 'object' && config ? config : {}); + var _config = _extends({}, Default, $this.data(), typeof config === 'object' && config ? config : {}); - if (!data && _config.toggle && /show|hide/.test(config)) { + if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { _config.toggle = false; } @@ -391,7 +335,7 @@ */ - $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + $(document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { // preventDefault only for <a> elements (which change the URL) not inside the collapsible element if (event.currentTarget.tagName === 'A') { event.preventDefault(); @@ -424,5 +368,5 @@ return Collapse; -})); +}))); //# sourceMappingURL=collapse.js.map |