mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-12 00:08:59 +01:00
1 line
18 KiB
Plaintext
1 line
18 KiB
Plaintext
{"version":3,"sources":["js/src/collapse.js"],"names":[],"mappings":";;;;;;;;;;;;;AAUA,IAAM,QAAQ,GAAG,CAAC,UAAC,CAAC,EAAK;;;;;;;;AASvB,MAAM,IAAI,GAAkB,UAAU,CAAA;AACtC,MAAM,OAAO,GAAe,OAAO,CAAA;AACnC,MAAM,QAAQ,GAAc,aAAa,CAAA;AACzC,MAAM,SAAS,SAAiB,QAAQ,AAAE,CAAA;AAC1C,MAAM,YAAY,GAAU,WAAW,CAAA;AACvC,MAAM,kBAAkB,GAAI,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;AACtC,MAAM,mBAAmB,GAAG,GAAG,CAAA;;AAE/B,MAAM,OAAO,GAAG;AACd,UAAM,EAAG,IAAI;AACb,UAAM,EAAG,EAAE;GACZ,CAAA;;AAED,MAAM,WAAW,GAAG;AAClB,UAAM,EAAG,SAAS;AAClB,UAAM,EAAG,QAAQ;GAClB,CAAA;;AAED,MAAM,KAAK,GAAG;AACZ,QAAI,WAAoB,SAAS,AAAE;AACnC,SAAK,YAAoB,SAAS,AAAE;AACpC,QAAI,WAAoB,SAAS,AAAE;AACnC,UAAM,aAAoB,SAAS,AAAE;AACrC,kBAAc,YAAW,SAAS,GAAG,YAAY,AAAE;GACpD,CAAA;;AAED,MAAM,SAAS,GAAG;AAChB,MAAE,EAAW,IAAI;AACjB,YAAQ,EAAK,UAAU;AACvB,cAAU,EAAG,YAAY;AACzB,aAAS,EAAI,WAAW;GACzB,CAAA;;AAED,MAAM,SAAS,GAAG;AAChB,SAAK,EAAI,OAAO;AAChB,UAAM,EAAG,QAAQ;GAClB,CAAA;;AAED,MAAM,QAAQ,GAAG;AACf,WAAO,EAAO,oCAAoC;AAClD,eAAW,EAAG,0BAA0B;GACzC,CAAA;;;;;;;;MASK,QAAQ;AAED,aAFP,QAAQ,CAEA,OA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AAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;GAClD,CAAC,CAAA;;;;;;;;AASF,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAe,QAAQ,CAAC,gBAAgB,CAAA;AAClD,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,GAAG,QAAQ,CAAA;AACjC,GAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,UAAU,GAAI,YAAY;AACnC,KAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAA;AAC/B,WAAO,QAAQ,CAAC,gBAAgB,CAAA;GACjC,CAAA;;AAED,SAAO,QAAQ,CAAA;CAEhB,CAAA,CAAE,MAAM,CAAC,CAAA","file":"js/src/collapse.js","sourcesContent":["import Util from './util'\n\n\n/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.0.0): collapse.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * --------------------------------------------------------------------------\n */\n\nconst Collapse = (($) => {\n\n\n /**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\n const NAME = 'collapse'\n const VERSION = '4.0.0'\n const DATA_KEY = 'bs.collapse'\n const EVENT_KEY = `.${DATA_KEY}`\n const DATA_API_KEY = '.data-api'\n const JQUERY_NO_CONFLICT = $.fn[NAME]\n const TRANSITION_DURATION = 600\n\n const Default = {\n toggle : true,\n parent : ''\n }\n\n const DefaultType = {\n toggle : 'boolean',\n parent : 'string'\n }\n\n const Event = {\n SHOW : `show${EVENT_KEY}`,\n SHOWN : `shown${EVENT_KEY}`,\n HIDE : `hide${EVENT_KEY}`,\n HIDDEN : `hidden${EVENT_KEY}`,\n CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`\n }\n\n const ClassName = {\n IN : 'in',\n COLLAPSE : 'collapse',\n COLLAPSING : 'collapsing',\n COLLAPSED : 'collapsed'\n }\n\n const Dimension = {\n WIDTH : 'width',\n HEIGHT : 'height'\n }\n\n const Selector = {\n ACTIVES : '.panel > .in, .panel > .collapsing',\n DATA_TOGGLE : '[data-toggle=\"collapse\"]'\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n class Collapse {\n\n constructor(element, config) {\n this._isTransitioning = false\n this._element = element\n this._config = this._getConfig(config)\n this._triggerArray = $.makeArray($(\n `[data-toggle=\"collapse\"][href=\"#${element.id}\"],` +\n `[data-toggle=\"collapse\"][data-target=\"#${element.id}\"]`\n ))\n\n this._parent = this._config.parent ? this._getParent() : null\n\n if (!this._config.parent) {\n this._addAriaAndCollapsedClass(this._element, this._triggerArray)\n }\n\n if (this._config.toggle) {\n this.toggle()\n }\n }\n\n\n // getters\n\n static get VERSION() {\n return VERSION\n }\n\n static get Default() {\n return Default\n }\n\n\n // public\n\n toggle() {\n if ($(this._element).hasClass(ClassName.IN)) {\n this.hide()\n } else {\n this.show()\n }\n }\n\n show() {\n if (this._isTransitioning ||\n $(this._element).hasClass(ClassName.IN)) {\n return\n }\n\n let actives\n let activesData\n\n if (this._parent) {\n actives = $.makeArray($(Selector.ACTIVES))\n if (!actives.length) {\n actives = null\n }\n }\n\n if (actives) {\n activesData = $(actives).data(DATA_KEY)\n if (activesData && activesData._isTransitioning) {\n return\n }\n }\n\n let startEvent = $.Event(Event.SHOW)\n $(this._element).trigger(startEvent)\n if (startEvent.isDefaultPrevented()) {\n return\n }\n\n if (actives) {\n Collapse._jQueryInterface.call($(actives), 'hide')\n if (!activesData) {\n $(actives).data(DATA_KEY, null)\n }\n }\n\n let dimension = this._getDimension()\n\n $(this._element)\n .removeClass(ClassName.COLLAPSE)\n .addClass(ClassName.COLLAPSING)\n\n this._element.style[dimension] = 0\n this._element.setAttribute('aria-expanded', true)\n\n if (this._triggerArray.length) {\n $(this._triggerArray)\n .removeClass(ClassName.COLLAPSED)\n .attr('aria-expanded', true)\n }\n\n this.setTransitioning(true)\n\n let complete = () => {\n $(this._element)\n .removeClass(ClassName.COLLAPSING)\n .addClass(ClassName.COLLAPSE)\n .addClass(ClassName.IN)\n\n this._element.style[dimension] = ''\n\n this.setTransitioning(false)\n\n $(this._element).trigger(Event.SHOWN)\n }\n\n if (!Util.supportsTransitionEnd()) {\n complete()\n return\n }\n\n let capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1)\n let scrollSize = `scroll${capitalizedDimension}`\n\n $(this._element)\n .one(Util.TRANSITION_END, complete)\n .emulateTransitionEnd(TRANSITION_DURATION)\n\n this._element.style[dimension] = `${this._element[scrollSize]}px`\n }\n\n hide() {\n if (this._isTransitioning ||\n !$(this._element).hasClass(ClassName.IN)) {\n return\n }\n\n let startEvent = $.Event(Event.HIDE)\n $(this._element).trigger(startEvent)\n if (startEvent.isDefaultPrevented()) {\n return\n }\n\n let dimension = this._getDimension()\n let offsetDimension = dimension === Dimension.WIDTH ?\n 'offsetWidth' : 'offsetHeight'\n\n this._element.style[dimension] = `${this._element[offsetDimension]}px`\n\n Util.reflow(this._element)\n\n $(this._element)\n .addClass(ClassName.COLLAPSING)\n .removeClass(ClassName.COLLAPSE)\n .removeClass(ClassName.IN)\n\n this._element.setAttribute('aria-expanded', false)\n\n if (this._triggerArray.length) {\n $(this._triggerArray)\n .addClass(ClassName.COLLAPSED)\n .attr('aria-expanded', false)\n }\n\n this.setTransitioning(true)\n\n let complete = () => {\n this.setTransitioning(false)\n $(this._element)\n .removeClass(ClassName.COLLAPSING)\n .addClass(ClassName.COLLAPSE)\n .trigger(Event.HIDDEN)\n }\n\n this._element.style[dimension] = 0\n\n if (!Util.supportsTransitionEnd()) {\n complete()\n return\n }\n\n $(this._element)\n .one(Util.TRANSITION_END, complete)\n .emulateTransitionEnd(TRANSITION_DURATION)\n }\n\n setTransitioning(isTransitioning) {\n this._isTransitioning = isTransitioning\n }\n\n dispose() {\n $.removeData(this._element, DATA_KEY)\n\n this._config = null\n this._parent = null\n this._element = null\n this._triggerArray = null\n this._isTransitioning = null\n }\n\n\n // private\n\n _getConfig(config) {\n config = $.extend({}, Default, config)\n config.toggle = Boolean(config.toggle) // coerce string values\n Util.typeCheckConfig(NAME, config, DefaultType)\n return config\n }\n\n _getDimension() {\n let hasWidth = $(this._element).hasClass(Dimension.WIDTH)\n return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT\n }\n\n _getParent() {\n let parent = $(this._config.parent)[0]\n let selector =\n `[data-toggle=\"collapse\"][data-parent=\"${this._config.parent}\"]`\n\n $(parent).find(selector).each((i, element) => {\n this._addAriaAndCollapsedClass(\n Collapse._getTargetFromElement(element),\n [element]\n )\n })\n\n return parent\n }\n\n _addAriaAndCollapsedClass(element, triggerArray) {\n if (element) {\n let isOpen = $(element).hasClass(ClassName.IN)\n element.setAttribute('aria-expanded', isOpen)\n\n if (triggerArray.length) {\n $(triggerArray)\n .toggleClass(ClassName.COLLAPSED, !isOpen)\n .attr('aria-expanded', isOpen)\n }\n }\n }\n\n\n // static\n\n static _getTargetFromElement(element) {\n let selector = Util.getSelectorFromElement(element)\n return selector ? $(selector)[0] : null\n }\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let $this = $(this)\n let data = $this.data(DATA_KEY)\n let _config = $.extend(\n {},\n Default,\n $this.data(),\n typeof config === 'object' && config\n )\n\n if (!data && _config.toggle && /show|hide/.test(config)) {\n _config.toggle = false\n }\n\n if (!data) {\n data = new Collapse(this, _config)\n $this.data(DATA_KEY, data)\n }\n\n if (typeof config === 'string') {\n data[config]()\n }\n })\n }\n\n }\n\n\n /**\n * ------------------------------------------------------------------------\n * Data Api implementation\n * ------------------------------------------------------------------------\n */\n\n $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {\n event.preventDefault()\n\n let target = Collapse._getTargetFromElement(this)\n let data = $(target).data(DATA_KEY)\n let config = data ? 'toggle' : $(this).data()\n\n Collapse._jQueryInterface.call($(target), config)\n })\n\n\n /**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n $.fn[NAME] = Collapse._jQueryInterface\n $.fn[NAME].Constructor = Collapse\n $.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT\n return Collapse._jQueryInterface\n }\n\n return Collapse\n\n})(jQuery)\n\nexport default Collapse\n"]} |