OSDN Git Service

Modify the dependency on path
[bytom/vapor.git] / tools / side_chain_tool / web / node_modules / bootstrap / js / dist / collapse.js
1 (function (global, factory) {
2   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
3   typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
4   (global.Collapse = factory(global.jQuery,global.Util));
5 }(this, (function ($,Util) { 'use strict';
6
7   $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
8   Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
9
10   function _defineProperties(target, props) {
11     for (var i = 0; i < props.length; i++) {
12       var descriptor = props[i];
13       descriptor.enumerable = descriptor.enumerable || false;
14       descriptor.configurable = true;
15       if ("value" in descriptor) descriptor.writable = true;
16       Object.defineProperty(target, descriptor.key, descriptor);
17     }
18   }
19
20   function _createClass(Constructor, protoProps, staticProps) {
21     if (protoProps) _defineProperties(Constructor.prototype, protoProps);
22     if (staticProps) _defineProperties(Constructor, staticProps);
23     return Constructor;
24   }
25
26   function _defineProperty(obj, key, value) {
27     if (key in obj) {
28       Object.defineProperty(obj, key, {
29         value: value,
30         enumerable: true,
31         configurable: true,
32         writable: true
33       });
34     } else {
35       obj[key] = value;
36     }
37
38     return obj;
39   }
40
41   function _objectSpread(target) {
42     for (var i = 1; i < arguments.length; i++) {
43       var source = arguments[i] != null ? arguments[i] : {};
44       var ownKeys = Object.keys(source);
45
46       if (typeof Object.getOwnPropertySymbols === 'function') {
47         ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
48           return Object.getOwnPropertyDescriptor(source, sym).enumerable;
49         }));
50       }
51
52       ownKeys.forEach(function (key) {
53         _defineProperty(target, key, source[key]);
54       });
55     }
56
57     return target;
58   }
59
60   /**
61    * --------------------------------------------------------------------------
62    * Bootstrap (v4.1.3): collapse.js
63    * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
64    * --------------------------------------------------------------------------
65    */
66
67   var Collapse = function ($$$1) {
68     /**
69      * ------------------------------------------------------------------------
70      * Constants
71      * ------------------------------------------------------------------------
72      */
73     var NAME = 'collapse';
74     var VERSION = '4.1.3';
75     var DATA_KEY = 'bs.collapse';
76     var EVENT_KEY = "." + DATA_KEY;
77     var DATA_API_KEY = '.data-api';
78     var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
79     var Default = {
80       toggle: true,
81       parent: ''
82     };
83     var DefaultType = {
84       toggle: 'boolean',
85       parent: '(string|element)'
86     };
87     var Event = {
88       SHOW: "show" + EVENT_KEY,
89       SHOWN: "shown" + EVENT_KEY,
90       HIDE: "hide" + EVENT_KEY,
91       HIDDEN: "hidden" + EVENT_KEY,
92       CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
93     };
94     var ClassName = {
95       SHOW: 'show',
96       COLLAPSE: 'collapse',
97       COLLAPSING: 'collapsing',
98       COLLAPSED: 'collapsed'
99     };
100     var Dimension = {
101       WIDTH: 'width',
102       HEIGHT: 'height'
103     };
104     var Selector = {
105       ACTIVES: '.show, .collapsing',
106       DATA_TOGGLE: '[data-toggle="collapse"]'
107       /**
108        * ------------------------------------------------------------------------
109        * Class Definition
110        * ------------------------------------------------------------------------
111        */
112
113     };
114
115     var Collapse =
116     /*#__PURE__*/
117     function () {
118       function Collapse(element, config) {
119         this._isTransitioning = false;
120         this._element = element;
121         this._config = this._getConfig(config);
122         this._triggerArray = $$$1.makeArray(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
123         var toggleList = [].slice.call(document.querySelectorAll(Selector.DATA_TOGGLE));
124
125         for (var i = 0, len = toggleList.length; i < len; i++) {
126           var elem = toggleList[i];
127           var selector = Util.getSelectorFromElement(elem);
128           var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
129             return foundElem === element;
130           });
131
132           if (selector !== null && filterElement.length > 0) {
133             this._selector = selector;
134
135             this._triggerArray.push(elem);
136           }
137         }
138
139         this._parent = this._config.parent ? this._getParent() : null;
140
141         if (!this._config.parent) {
142           this._addAriaAndCollapsedClass(this._element, this._triggerArray);
143         }
144
145         if (this._config.toggle) {
146           this.toggle();
147         }
148       } // Getters
149
150
151       var _proto = Collapse.prototype;
152
153       // Public
154       _proto.toggle = function toggle() {
155         if ($$$1(this._element).hasClass(ClassName.SHOW)) {
156           this.hide();
157         } else {
158           this.show();
159         }
160       };
161
162       _proto.show = function show() {
163         var _this = this;
164
165         if (this._isTransitioning || $$$1(this._element).hasClass(ClassName.SHOW)) {
166           return;
167         }
168
169         var actives;
170         var activesData;
171
172         if (this._parent) {
173           actives = [].slice.call(this._parent.querySelectorAll(Selector.ACTIVES)).filter(function (elem) {
174             return elem.getAttribute('data-parent') === _this._config.parent;
175           });
176
177           if (actives.length === 0) {
178             actives = null;
179           }
180         }
181
182         if (actives) {
183           activesData = $$$1(actives).not(this._selector).data(DATA_KEY);
184
185           if (activesData && activesData._isTransitioning) {
186             return;
187           }
188         }
189
190         var startEvent = $$$1.Event(Event.SHOW);
191         $$$1(this._element).trigger(startEvent);
192
193         if (startEvent.isDefaultPrevented()) {
194           return;
195         }
196
197         if (actives) {
198           Collapse._jQueryInterface.call($$$1(actives).not(this._selector), 'hide');
199
200           if (!activesData) {
201             $$$1(actives).data(DATA_KEY, null);
202           }
203         }
204
205         var dimension = this._getDimension();
206
207         $$$1(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
208         this._element.style[dimension] = 0;
209
210         if (this._triggerArray.length) {
211           $$$1(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true);
212         }
213
214         this.setTransitioning(true);
215
216         var complete = function complete() {
217           $$$1(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW);
218           _this._element.style[dimension] = '';
219
220           _this.setTransitioning(false);
221
222           $$$1(_this._element).trigger(Event.SHOWN);
223         };
224
225         var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
226         var scrollSize = "scroll" + capitalizedDimension;
227         var transitionDuration = Util.getTransitionDurationFromElement(this._element);
228         $$$1(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
229         this._element.style[dimension] = this._element[scrollSize] + "px";
230       };
231
232       _proto.hide = function hide() {
233         var _this2 = this;
234
235         if (this._isTransitioning || !$$$1(this._element).hasClass(ClassName.SHOW)) {
236           return;
237         }
238
239         var startEvent = $$$1.Event(Event.HIDE);
240         $$$1(this._element).trigger(startEvent);
241
242         if (startEvent.isDefaultPrevented()) {
243           return;
244         }
245
246         var dimension = this._getDimension();
247
248         this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
249         Util.reflow(this._element);
250         $$$1(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
251         var triggerArrayLength = this._triggerArray.length;
252
253         if (triggerArrayLength > 0) {
254           for (var i = 0; i < triggerArrayLength; i++) {
255             var trigger = this._triggerArray[i];
256             var selector = Util.getSelectorFromElement(trigger);
257
258             if (selector !== null) {
259               var $elem = $$$1([].slice.call(document.querySelectorAll(selector)));
260
261               if (!$elem.hasClass(ClassName.SHOW)) {
262                 $$$1(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
263               }
264             }
265           }
266         }
267
268         this.setTransitioning(true);
269
270         var complete = function complete() {
271           _this2.setTransitioning(false);
272
273           $$$1(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN);
274         };
275
276         this._element.style[dimension] = '';
277         var transitionDuration = Util.getTransitionDurationFromElement(this._element);
278         $$$1(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
279       };
280
281       _proto.setTransitioning = function setTransitioning(isTransitioning) {
282         this._isTransitioning = isTransitioning;
283       };
284
285       _proto.dispose = function dispose() {
286         $$$1.removeData(this._element, DATA_KEY);
287         this._config = null;
288         this._parent = null;
289         this._element = null;
290         this._triggerArray = null;
291         this._isTransitioning = null;
292       }; // Private
293
294
295       _proto._getConfig = function _getConfig(config) {
296         config = _objectSpread({}, Default, config);
297         config.toggle = Boolean(config.toggle); // Coerce string values
298
299         Util.typeCheckConfig(NAME, config, DefaultType);
300         return config;
301       };
302
303       _proto._getDimension = function _getDimension() {
304         var hasWidth = $$$1(this._element).hasClass(Dimension.WIDTH);
305         return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
306       };
307
308       _proto._getParent = function _getParent() {
309         var _this3 = this;
310
311         var parent = null;
312
313         if (Util.isElement(this._config.parent)) {
314           parent = this._config.parent; // It's a jQuery object
315
316           if (typeof this._config.parent.jquery !== 'undefined') {
317             parent = this._config.parent[0];
318           }
319         } else {
320           parent = document.querySelector(this._config.parent);
321         }
322
323         var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
324         var children = [].slice.call(parent.querySelectorAll(selector));
325         $$$1(children).each(function (i, element) {
326           _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
327         });
328         return parent;
329       };
330
331       _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
332         if (element) {
333           var isOpen = $$$1(element).hasClass(ClassName.SHOW);
334
335           if (triggerArray.length) {
336             $$$1(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
337           }
338         }
339       }; // Static
340
341
342       Collapse._getTargetFromElement = function _getTargetFromElement(element) {
343         var selector = Util.getSelectorFromElement(element);
344         return selector ? document.querySelector(selector) : null;
345       };
346
347       Collapse._jQueryInterface = function _jQueryInterface(config) {
348         return this.each(function () {
349           var $this = $$$1(this);
350           var data = $this.data(DATA_KEY);
351
352           var _config = _objectSpread({}, Default, $this.data(), typeof config === 'object' && config ? config : {});
353
354           if (!data && _config.toggle && /show|hide/.test(config)) {
355             _config.toggle = false;
356           }
357
358           if (!data) {
359             data = new Collapse(this, _config);
360             $this.data(DATA_KEY, data);
361           }
362
363           if (typeof config === 'string') {
364             if (typeof data[config] === 'undefined') {
365               throw new TypeError("No method named \"" + config + "\"");
366             }
367
368             data[config]();
369           }
370         });
371       };
372
373       _createClass(Collapse, null, [{
374         key: "VERSION",
375         get: function get() {
376           return VERSION;
377         }
378       }, {
379         key: "Default",
380         get: function get() {
381           return Default;
382         }
383       }]);
384
385       return Collapse;
386     }();
387     /**
388      * ------------------------------------------------------------------------
389      * Data Api implementation
390      * ------------------------------------------------------------------------
391      */
392
393
394     $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
395       // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
396       if (event.currentTarget.tagName === 'A') {
397         event.preventDefault();
398       }
399
400       var $trigger = $$$1(this);
401       var selector = Util.getSelectorFromElement(this);
402       var selectors = [].slice.call(document.querySelectorAll(selector));
403       $$$1(selectors).each(function () {
404         var $target = $$$1(this);
405         var data = $target.data(DATA_KEY);
406         var config = data ? 'toggle' : $trigger.data();
407
408         Collapse._jQueryInterface.call($target, config);
409       });
410     });
411     /**
412      * ------------------------------------------------------------------------
413      * jQuery
414      * ------------------------------------------------------------------------
415      */
416
417     $$$1.fn[NAME] = Collapse._jQueryInterface;
418     $$$1.fn[NAME].Constructor = Collapse;
419
420     $$$1.fn[NAME].noConflict = function () {
421       $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
422       return Collapse._jQueryInterface;
423     };
424
425     return Collapse;
426   }($);
427
428   return Collapse;
429
430 })));
431 //# sourceMappingURL=collapse.js.map