bootstrap 4.5.2 → 5.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/assets/javascripts/bootstrap-sprockets.js +12 -8
- data/assets/javascripts/bootstrap.js +1876 -1220
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/javascripts/bootstrap/alert.js +133 -48
- data/assets/javascripts/bootstrap/button.js +56 -123
- data/assets/javascripts/bootstrap/carousel.js +268 -129
- data/assets/javascripts/bootstrap/collapse.js +285 -106
- data/assets/javascripts/bootstrap/dom/data.js +81 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +311 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +100 -0
- data/assets/javascripts/bootstrap/dom/polyfill.js +110 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +98 -0
- data/assets/javascripts/bootstrap/dropdown.js +235 -161
- data/assets/javascripts/bootstrap/modal.js +322 -193
- data/assets/javascripts/bootstrap/popover.js +72 -41
- data/assets/javascripts/bootstrap/scrollspy.js +151 -56
- data/assets/javascripts/bootstrap/tab.js +151 -64
- data/assets/javascripts/bootstrap/toast.js +163 -65
- data/assets/javascripts/bootstrap/tooltip.js +336 -155
- data/assets/stylesheets/_bootstrap-grid.scss +51 -15
- data/assets/stylesheets/_bootstrap-reboot.scss +4 -1
- data/assets/stylesheets/_bootstrap.scss +14 -8
- data/assets/stylesheets/bootstrap/_alert.scss +3 -3
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +3 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
- data/assets/stylesheets/bootstrap/_buttons.scss +27 -45
- data/assets/stylesheets/bootstrap/_card.scss +18 -64
- data/assets/stylesheets/bootstrap/_carousel.scss +13 -15
- data/assets/stylesheets/bootstrap/_close.scss +9 -13
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +10 -7
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +82 -20
- data/assets/stylesheets/bootstrap/_grid.scss +3 -54
- data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +6 -3
- data/assets/stylesheets/bootstrap/_mixins.scss +6 -12
- data/assets/stylesheets/bootstrap/_modal.scss +34 -39
- data/assets/stylesheets/bootstrap/_nav.scss +8 -8
- data/assets/stylesheets/bootstrap/_navbar.scss +42 -74
- data/assets/stylesheets/bootstrap/_pagination.scss +7 -20
- data/assets/stylesheets/bootstrap/_popover.scss +5 -5
- data/assets/stylesheets/bootstrap/_progress.scss +2 -4
- data/assets/stylesheets/bootstrap/_reboot.scss +300 -164
- data/assets/stylesheets/bootstrap/_root.scss +5 -9
- data/assets/stylesheets/bootstrap/_spinners.scss +2 -2
- data/assets/stylesheets/bootstrap/_tables.scss +80 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +2 -4
- data/assets/stylesheets/bootstrap/_tooltip.scss +5 -5
- data/assets/stylesheets/bootstrap/_transitions.scss +0 -1
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +503 -18
- data/assets/stylesheets/bootstrap/_variables.scss +544 -424
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +142 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +116 -0
- data/assets/stylesheets/bootstrap/forms/_form-file.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +136 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +82 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +140 -0
- data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
- data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
- data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_embed.scss +31 -0
- data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_screenreaders.scss +8 -0
- data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +0 -4
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +11 -8
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +62 -47
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +4 -4
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +22 -67
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +84 -32
- data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -1
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +15 -8
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +16 -22
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +49 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +234 -126
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +3 -3
- metadata +31 -39
- data/assets/javascripts/bootstrap/util.js +0 -192
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -523
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -192
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -141
- data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -23
- data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
- data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -80
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
- data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
- data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
- data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
- data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
- data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
- data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
- data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
- data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
- data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_interactions.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
- data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
- data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
- data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
- data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
- data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
- data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
- data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
- data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
@@ -1,18 +1,143 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap collapse.js
|
2
|
+
* Bootstrap collapse.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
3
3
|
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('
|
8
|
-
typeof define === 'function' && define.amd ? define(['
|
9
|
-
(global =
|
10
|
-
}(this, (function (
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) :
|
9
|
+
(global = global || self, global.Collapse = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine));
|
10
|
+
}(this, (function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
Data = Data && Object.prototype.hasOwnProperty.call(Data, 'default') ? Data['default'] : Data;
|
13
|
+
EventHandler = EventHandler && Object.prototype.hasOwnProperty.call(EventHandler, 'default') ? EventHandler['default'] : EventHandler;
|
14
|
+
Manipulator = Manipulator && Object.prototype.hasOwnProperty.call(Manipulator, 'default') ? Manipulator['default'] : Manipulator;
|
15
|
+
SelectorEngine = SelectorEngine && Object.prototype.hasOwnProperty.call(SelectorEngine, 'default') ? SelectorEngine['default'] : SelectorEngine;
|
14
16
|
|
15
|
-
|
17
|
+
/**
|
18
|
+
* --------------------------------------------------------------------------
|
19
|
+
* Bootstrap (v5.0.0-alpha1): util/index.js
|
20
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
21
|
+
* --------------------------------------------------------------------------
|
22
|
+
*/
|
23
|
+
var MILLISECONDS_MULTIPLIER = 1000;
|
24
|
+
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
25
|
+
|
26
|
+
var toType = function toType(obj) {
|
27
|
+
if (obj === null || obj === undefined) {
|
28
|
+
return "" + obj;
|
29
|
+
}
|
30
|
+
|
31
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
32
|
+
};
|
33
|
+
|
34
|
+
var getSelector = function getSelector(element) {
|
35
|
+
var selector = element.getAttribute('data-target');
|
36
|
+
|
37
|
+
if (!selector || selector === '#') {
|
38
|
+
var hrefAttr = element.getAttribute('href');
|
39
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
40
|
+
}
|
41
|
+
|
42
|
+
return selector;
|
43
|
+
};
|
44
|
+
|
45
|
+
var getSelectorFromElement = function getSelectorFromElement(element) {
|
46
|
+
var selector = getSelector(element);
|
47
|
+
|
48
|
+
if (selector) {
|
49
|
+
return document.querySelector(selector) ? selector : null;
|
50
|
+
}
|
51
|
+
|
52
|
+
return null;
|
53
|
+
};
|
54
|
+
|
55
|
+
var getElementFromSelector = function getElementFromSelector(element) {
|
56
|
+
var selector = getSelector(element);
|
57
|
+
return selector ? document.querySelector(selector) : null;
|
58
|
+
};
|
59
|
+
|
60
|
+
var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
|
61
|
+
if (!element) {
|
62
|
+
return 0;
|
63
|
+
} // Get transition-duration of the element
|
64
|
+
|
65
|
+
|
66
|
+
var _window$getComputedSt = window.getComputedStyle(element),
|
67
|
+
transitionDuration = _window$getComputedSt.transitionDuration,
|
68
|
+
transitionDelay = _window$getComputedSt.transitionDelay;
|
69
|
+
|
70
|
+
var floatTransitionDuration = parseFloat(transitionDuration);
|
71
|
+
var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
|
72
|
+
|
73
|
+
if (!floatTransitionDuration && !floatTransitionDelay) {
|
74
|
+
return 0;
|
75
|
+
} // If multiple durations are defined, take the first
|
76
|
+
|
77
|
+
|
78
|
+
transitionDuration = transitionDuration.split(',')[0];
|
79
|
+
transitionDelay = transitionDelay.split(',')[0];
|
80
|
+
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
81
|
+
};
|
82
|
+
|
83
|
+
var triggerTransitionEnd = function triggerTransitionEnd(element) {
|
84
|
+
element.dispatchEvent(new Event(TRANSITION_END));
|
85
|
+
};
|
86
|
+
|
87
|
+
var isElement = function isElement(obj) {
|
88
|
+
return (obj[0] || obj).nodeType;
|
89
|
+
};
|
90
|
+
|
91
|
+
var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
|
92
|
+
var called = false;
|
93
|
+
var durationPadding = 5;
|
94
|
+
var emulatedDuration = duration + durationPadding;
|
95
|
+
|
96
|
+
function listener() {
|
97
|
+
called = true;
|
98
|
+
element.removeEventListener(TRANSITION_END, listener);
|
99
|
+
}
|
100
|
+
|
101
|
+
element.addEventListener(TRANSITION_END, listener);
|
102
|
+
setTimeout(function () {
|
103
|
+
if (!called) {
|
104
|
+
triggerTransitionEnd(element);
|
105
|
+
}
|
106
|
+
}, emulatedDuration);
|
107
|
+
};
|
108
|
+
|
109
|
+
var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
|
110
|
+
Object.keys(configTypes).forEach(function (property) {
|
111
|
+
var expectedTypes = configTypes[property];
|
112
|
+
var value = config[property];
|
113
|
+
var valueType = value && isElement(value) ? 'element' : toType(value);
|
114
|
+
|
115
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
116
|
+
throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
|
117
|
+
}
|
118
|
+
});
|
119
|
+
};
|
120
|
+
|
121
|
+
var reflow = function reflow(element) {
|
122
|
+
return element.offsetHeight;
|
123
|
+
};
|
124
|
+
|
125
|
+
var getjQuery = function getjQuery() {
|
126
|
+
var _window = window,
|
127
|
+
jQuery = _window.jQuery;
|
128
|
+
|
129
|
+
if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
|
130
|
+
return jQuery;
|
131
|
+
}
|
132
|
+
|
133
|
+
return null;
|
134
|
+
};
|
135
|
+
|
136
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
137
|
+
|
138
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
139
|
+
|
140
|
+
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; } return obj; }
|
16
141
|
|
17
142
|
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); } }
|
18
143
|
|
@@ -24,11 +149,10 @@
|
|
24
149
|
*/
|
25
150
|
|
26
151
|
var NAME = 'collapse';
|
27
|
-
var VERSION = '
|
152
|
+
var VERSION = '5.0.0-alpha1';
|
28
153
|
var DATA_KEY = 'bs.collapse';
|
29
154
|
var EVENT_KEY = "." + DATA_KEY;
|
30
155
|
var DATA_API_KEY = '.data-api';
|
31
|
-
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
32
156
|
var Default = {
|
33
157
|
toggle: true,
|
34
158
|
parent: ''
|
@@ -46,8 +170,8 @@
|
|
46
170
|
var CLASS_NAME_COLLAPSE = 'collapse';
|
47
171
|
var CLASS_NAME_COLLAPSING = 'collapsing';
|
48
172
|
var CLASS_NAME_COLLAPSED = 'collapsed';
|
49
|
-
var
|
50
|
-
var
|
173
|
+
var WIDTH = 'width';
|
174
|
+
var HEIGHT = 'height';
|
51
175
|
var SELECTOR_ACTIVES = '.show, .collapsing';
|
52
176
|
var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
|
53
177
|
/**
|
@@ -61,17 +185,17 @@
|
|
61
185
|
this._isTransitioning = false;
|
62
186
|
this._element = element;
|
63
187
|
this._config = this._getConfig(config);
|
64
|
-
this._triggerArray =
|
65
|
-
var toggleList =
|
188
|
+
this._triggerArray = SelectorEngine.find(SELECTOR_DATA_TOGGLE + "[href=\"#" + element.id + "\"]," + (SELECTOR_DATA_TOGGLE + "[data-target=\"#" + element.id + "\"]"));
|
189
|
+
var toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE);
|
66
190
|
|
67
191
|
for (var i = 0, len = toggleList.length; i < len; i++) {
|
68
192
|
var elem = toggleList[i];
|
69
|
-
var selector =
|
70
|
-
var filterElement =
|
193
|
+
var selector = getSelectorFromElement(elem);
|
194
|
+
var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
|
71
195
|
return foundElem === element;
|
72
196
|
});
|
73
197
|
|
74
|
-
if (selector !== null && filterElement.length
|
198
|
+
if (selector !== null && filterElement.length) {
|
75
199
|
this._selector = selector;
|
76
200
|
|
77
201
|
this._triggerArray.push(elem);
|
@@ -87,6 +211,8 @@
|
|
87
211
|
if (this._config.toggle) {
|
88
212
|
this.toggle();
|
89
213
|
}
|
214
|
+
|
215
|
+
Data.setData(element, DATA_KEY, this);
|
90
216
|
} // Getters
|
91
217
|
|
92
218
|
|
@@ -94,7 +220,7 @@
|
|
94
220
|
|
95
221
|
// Public
|
96
222
|
_proto.toggle = function toggle() {
|
97
|
-
if (
|
223
|
+
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
|
98
224
|
this.hide();
|
99
225
|
} else {
|
100
226
|
this.show();
|
@@ -104,7 +230,7 @@
|
|
104
230
|
_proto.show = function show() {
|
105
231
|
var _this = this;
|
106
232
|
|
107
|
-
if (this._isTransitioning ||
|
233
|
+
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
|
108
234
|
return;
|
109
235
|
}
|
110
236
|
|
@@ -112,7 +238,7 @@
|
|
112
238
|
var activesData;
|
113
239
|
|
114
240
|
if (this._parent) {
|
115
|
-
actives =
|
241
|
+
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
|
116
242
|
if (typeof _this._config.parent === 'string') {
|
117
243
|
return elem.getAttribute('data-parent') === _this._config.parent;
|
118
244
|
}
|
@@ -125,88 +251,106 @@
|
|
125
251
|
}
|
126
252
|
}
|
127
253
|
|
254
|
+
var container = SelectorEngine.findOne(this._selector);
|
255
|
+
|
128
256
|
if (actives) {
|
129
|
-
|
257
|
+
var tempActiveData = actives.filter(function (elem) {
|
258
|
+
return container !== elem;
|
259
|
+
});
|
260
|
+
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null;
|
130
261
|
|
131
262
|
if (activesData && activesData._isTransitioning) {
|
132
263
|
return;
|
133
264
|
}
|
134
265
|
}
|
135
266
|
|
136
|
-
var startEvent =
|
137
|
-
$(this._element).trigger(startEvent);
|
267
|
+
var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
|
138
268
|
|
139
|
-
if (startEvent.
|
269
|
+
if (startEvent.defaultPrevented) {
|
140
270
|
return;
|
141
271
|
}
|
142
272
|
|
143
273
|
if (actives) {
|
144
|
-
|
274
|
+
actives.forEach(function (elemActive) {
|
275
|
+
if (container !== elemActive) {
|
276
|
+
Collapse.collapseInterface(elemActive, 'hide');
|
277
|
+
}
|
145
278
|
|
146
|
-
|
147
|
-
|
148
|
-
|
279
|
+
if (!activesData) {
|
280
|
+
Data.setData(elemActive, DATA_KEY, null);
|
281
|
+
}
|
282
|
+
});
|
149
283
|
}
|
150
284
|
|
151
285
|
var dimension = this._getDimension();
|
152
286
|
|
153
|
-
|
287
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSE);
|
288
|
+
|
289
|
+
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
290
|
+
|
154
291
|
this._element.style[dimension] = 0;
|
155
292
|
|
156
293
|
if (this._triggerArray.length) {
|
157
|
-
|
294
|
+
this._triggerArray.forEach(function (element) {
|
295
|
+
element.classList.remove(CLASS_NAME_COLLAPSED);
|
296
|
+
element.setAttribute('aria-expanded', true);
|
297
|
+
});
|
158
298
|
}
|
159
299
|
|
160
300
|
this.setTransitioning(true);
|
161
301
|
|
162
302
|
var complete = function complete() {
|
163
|
-
|
303
|
+
_this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
304
|
+
|
305
|
+
_this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
|
306
|
+
|
164
307
|
_this._element.style[dimension] = '';
|
165
308
|
|
166
309
|
_this.setTransitioning(false);
|
167
310
|
|
168
|
-
|
311
|
+
EventHandler.trigger(_this._element, EVENT_SHOWN);
|
169
312
|
};
|
170
313
|
|
171
314
|
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
|
172
315
|
var scrollSize = "scroll" + capitalizedDimension;
|
173
|
-
var transitionDuration =
|
174
|
-
|
316
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
317
|
+
EventHandler.one(this._element, TRANSITION_END, complete);
|
318
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
175
319
|
this._element.style[dimension] = this._element[scrollSize] + "px";
|
176
320
|
};
|
177
321
|
|
178
322
|
_proto.hide = function hide() {
|
179
323
|
var _this2 = this;
|
180
324
|
|
181
|
-
if (this._isTransitioning ||
|
325
|
+
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
|
182
326
|
return;
|
183
327
|
}
|
184
328
|
|
185
|
-
var startEvent =
|
186
|
-
$(this._element).trigger(startEvent);
|
329
|
+
var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
|
187
330
|
|
188
|
-
if (startEvent.
|
331
|
+
if (startEvent.defaultPrevented) {
|
189
332
|
return;
|
190
333
|
}
|
191
334
|
|
192
335
|
var dimension = this._getDimension();
|
193
336
|
|
194
337
|
this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
|
195
|
-
|
196
|
-
|
338
|
+
reflow(this._element);
|
339
|
+
|
340
|
+
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
341
|
+
|
342
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
|
343
|
+
|
197
344
|
var triggerArrayLength = this._triggerArray.length;
|
198
345
|
|
199
346
|
if (triggerArrayLength > 0) {
|
200
347
|
for (var i = 0; i < triggerArrayLength; i++) {
|
201
348
|
var trigger = this._triggerArray[i];
|
202
|
-
var
|
203
|
-
|
204
|
-
if (selector !== null) {
|
205
|
-
var $elem = $([].slice.call(document.querySelectorAll(selector)));
|
349
|
+
var elem = getElementFromSelector(trigger);
|
206
350
|
|
207
|
-
|
208
|
-
|
209
|
-
|
351
|
+
if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
|
352
|
+
trigger.classList.add(CLASS_NAME_COLLAPSED);
|
353
|
+
trigger.setAttribute('aria-expanded', false);
|
210
354
|
}
|
211
355
|
}
|
212
356
|
}
|
@@ -216,12 +360,17 @@
|
|
216
360
|
var complete = function complete() {
|
217
361
|
_this2.setTransitioning(false);
|
218
362
|
|
219
|
-
|
363
|
+
_this2._element.classList.remove(CLASS_NAME_COLLAPSING);
|
364
|
+
|
365
|
+
_this2._element.classList.add(CLASS_NAME_COLLAPSE);
|
366
|
+
|
367
|
+
EventHandler.trigger(_this2._element, EVENT_HIDDEN);
|
220
368
|
};
|
221
369
|
|
222
370
|
this._element.style[dimension] = '';
|
223
|
-
var transitionDuration =
|
224
|
-
|
371
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
372
|
+
EventHandler.one(this._element, TRANSITION_END, complete);
|
373
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
225
374
|
};
|
226
375
|
|
227
376
|
_proto.setTransitioning = function setTransitioning(isTransitioning) {
|
@@ -229,7 +378,7 @@
|
|
229
378
|
};
|
230
379
|
|
231
380
|
_proto.dispose = function dispose() {
|
232
|
-
|
381
|
+
Data.removeData(this._element, DATA_KEY);
|
233
382
|
this._config = null;
|
234
383
|
this._parent = null;
|
235
384
|
this._element = null;
|
@@ -239,81 +388,93 @@
|
|
239
388
|
;
|
240
389
|
|
241
390
|
_proto._getConfig = function _getConfig(config) {
|
242
|
-
config =
|
391
|
+
config = _objectSpread(_objectSpread({}, Default), config);
|
243
392
|
config.toggle = Boolean(config.toggle); // Coerce string values
|
244
393
|
|
245
|
-
|
394
|
+
typeCheckConfig(NAME, config, DefaultType);
|
246
395
|
return config;
|
247
396
|
};
|
248
397
|
|
249
398
|
_proto._getDimension = function _getDimension() {
|
250
|
-
var hasWidth =
|
251
|
-
|
399
|
+
var hasWidth = this._element.classList.contains(WIDTH);
|
400
|
+
|
401
|
+
return hasWidth ? WIDTH : HEIGHT;
|
252
402
|
};
|
253
403
|
|
254
404
|
_proto._getParent = function _getParent() {
|
255
405
|
var _this3 = this;
|
256
406
|
|
257
|
-
var parent;
|
407
|
+
var parent = this._config.parent;
|
258
408
|
|
259
|
-
if (
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
parent = this._config.parent[0];
|
409
|
+
if (isElement(parent)) {
|
410
|
+
// it's a jQuery object
|
411
|
+
if (typeof parent.jquery !== 'undefined' || typeof parent[0] !== 'undefined') {
|
412
|
+
parent = parent[0];
|
264
413
|
}
|
265
414
|
} else {
|
266
|
-
parent =
|
415
|
+
parent = SelectorEngine.findOne(parent);
|
267
416
|
}
|
268
417
|
|
269
|
-
var selector = "[data-
|
270
|
-
|
271
|
-
|
272
|
-
|
418
|
+
var selector = SELECTOR_DATA_TOGGLE + "[data-parent=\"" + parent + "\"]";
|
419
|
+
SelectorEngine.find(selector, parent).forEach(function (element) {
|
420
|
+
var selected = getElementFromSelector(element);
|
421
|
+
|
422
|
+
_this3._addAriaAndCollapsedClass(selected, [element]);
|
273
423
|
});
|
274
424
|
return parent;
|
275
425
|
};
|
276
426
|
|
277
427
|
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
|
278
|
-
|
428
|
+
if (element) {
|
429
|
+
var isOpen = element.classList.contains(CLASS_NAME_SHOW);
|
430
|
+
|
431
|
+
if (triggerArray.length) {
|
432
|
+
triggerArray.forEach(function (elem) {
|
433
|
+
if (isOpen) {
|
434
|
+
elem.classList.remove(CLASS_NAME_COLLAPSED);
|
435
|
+
} else {
|
436
|
+
elem.classList.add(CLASS_NAME_COLLAPSED);
|
437
|
+
}
|
279
438
|
|
280
|
-
|
281
|
-
|
439
|
+
elem.setAttribute('aria-expanded', isOpen);
|
440
|
+
});
|
441
|
+
}
|
282
442
|
}
|
283
443
|
} // Static
|
284
444
|
;
|
285
445
|
|
286
|
-
Collapse.
|
287
|
-
var
|
288
|
-
return selector ? document.querySelector(selector) : null;
|
289
|
-
};
|
446
|
+
Collapse.collapseInterface = function collapseInterface(element, config) {
|
447
|
+
var data = Data.getData(element, DATA_KEY);
|
290
448
|
|
291
|
-
|
292
|
-
return this.each(function () {
|
293
|
-
var $this = $(this);
|
294
|
-
var data = $this.data(DATA_KEY);
|
449
|
+
var _config = _objectSpread(_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(element)), typeof config === 'object' && config ? config : {});
|
295
450
|
|
296
|
-
|
451
|
+
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
|
452
|
+
_config.toggle = false;
|
453
|
+
}
|
297
454
|
|
298
|
-
|
299
|
-
|
300
|
-
|
455
|
+
if (!data) {
|
456
|
+
data = new Collapse(element, _config);
|
457
|
+
}
|
301
458
|
|
302
|
-
|
303
|
-
|
304
|
-
|
459
|
+
if (typeof config === 'string') {
|
460
|
+
if (typeof data[config] === 'undefined') {
|
461
|
+
throw new TypeError("No method named \"" + config + "\"");
|
305
462
|
}
|
306
463
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
}
|
464
|
+
data[config]();
|
465
|
+
}
|
466
|
+
};
|
311
467
|
|
312
|
-
|
313
|
-
|
468
|
+
Collapse.jQueryInterface = function jQueryInterface(config) {
|
469
|
+
return this.each(function () {
|
470
|
+
Collapse.collapseInterface(this, config);
|
314
471
|
});
|
315
472
|
};
|
316
473
|
|
474
|
+
Collapse.getInstance = function getInstance(element) {
|
475
|
+
return Data.getData(element, DATA_KEY);
|
476
|
+
};
|
477
|
+
|
317
478
|
_createClass(Collapse, null, [{
|
318
479
|
key: "VERSION",
|
319
480
|
get: function get() {
|
@@ -335,36 +496,54 @@
|
|
335
496
|
*/
|
336
497
|
|
337
498
|
|
338
|
-
|
499
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
339
500
|
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
|
340
|
-
if (event.
|
501
|
+
if (event.target.tagName === 'A') {
|
341
502
|
event.preventDefault();
|
342
503
|
}
|
343
504
|
|
344
|
-
var
|
345
|
-
var selector =
|
346
|
-
var
|
347
|
-
|
348
|
-
var
|
349
|
-
var
|
350
|
-
|
505
|
+
var triggerData = Manipulator.getDataAttributes(this);
|
506
|
+
var selector = getSelectorFromElement(this);
|
507
|
+
var selectorElements = SelectorEngine.find(selector);
|
508
|
+
selectorElements.forEach(function (element) {
|
509
|
+
var data = Data.getData(element, DATA_KEY);
|
510
|
+
var config;
|
511
|
+
|
512
|
+
if (data) {
|
513
|
+
// update parent attribute
|
514
|
+
if (data._parent === null && typeof triggerData.parent === 'string') {
|
515
|
+
data._config.parent = triggerData.parent;
|
516
|
+
data._parent = data._getParent();
|
517
|
+
}
|
351
518
|
|
352
|
-
|
519
|
+
config = 'toggle';
|
520
|
+
} else {
|
521
|
+
config = triggerData;
|
522
|
+
}
|
523
|
+
|
524
|
+
Collapse.collapseInterface(element, config);
|
353
525
|
});
|
354
526
|
});
|
527
|
+
var $ = getjQuery();
|
355
528
|
/**
|
356
529
|
* ------------------------------------------------------------------------
|
357
530
|
* jQuery
|
358
531
|
* ------------------------------------------------------------------------
|
532
|
+
* add .collapse to jQuery only if jQuery is present
|
359
533
|
*/
|
360
534
|
|
361
|
-
|
362
|
-
$.fn[NAME].Constructor = Collapse;
|
535
|
+
/* istanbul ignore if */
|
363
536
|
|
364
|
-
|
365
|
-
$.fn[NAME]
|
366
|
-
|
367
|
-
|
537
|
+
if ($) {
|
538
|
+
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
539
|
+
$.fn[NAME] = Collapse.jQueryInterface;
|
540
|
+
$.fn[NAME].Constructor = Collapse;
|
541
|
+
|
542
|
+
$.fn[NAME].noConflict = function () {
|
543
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
544
|
+
return Collapse.jQueryInterface;
|
545
|
+
};
|
546
|
+
}
|
368
547
|
|
369
548
|
return Collapse;
|
370
549
|
|