bootstrap 4.6.2.1 → 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/CHANGELOG.md +0 -4
- data/README.md +1 -7
- data/Rakefile +4 -16
- data/assets/javascripts/bootstrap/alert.js +148 -73
- data/assets/javascripts/bootstrap/button.js +71 -154
- data/assets/javascripts/bootstrap/carousel.js +315 -209
- data/assets/javascripts/bootstrap/collapse.js +307 -153
- 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 +257 -205
- data/assets/javascripts/bootstrap/modal.js +354 -250
- data/assets/javascripts/bootstrap/popover.js +85 -94
- data/assets/javascripts/bootstrap/scrollspy.js +179 -107
- data/assets/javascripts/bootstrap/tab.js +170 -99
- data/assets/javascripts/bootstrap/toast.js +181 -110
- data/assets/javascripts/bootstrap/tooltip.js +375 -226
- data/assets/javascripts/bootstrap-sprockets.js +5 -1
- data/assets/javascripts/bootstrap.js +2260 -1550
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +53 -18
- data/assets/stylesheets/_bootstrap-reboot.scss +6 -3
- data/assets/stylesheets/_bootstrap.scss +16 -10
- data/assets/stylesheets/bootstrap/_alert.scss +3 -4
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
- data/assets/stylesheets/bootstrap/_buttons.scss +27 -45
- data/assets/stylesheets/bootstrap/_card.scss +22 -68
- data/assets/stylesheets/bootstrap/_carousel.scss +15 -20
- data/assets/stylesheets/bootstrap/_close.scss +9 -13
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +12 -9
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +82 -69
- data/assets/stylesheets/bootstrap/_grid.scss +3 -54
- data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
- data/assets/stylesheets/bootstrap/_images.scss +1 -1
- data/assets/stylesheets/bootstrap/_list-group.scss +7 -4
- data/assets/stylesheets/bootstrap/_mixins.scss +6 -12
- data/assets/stylesheets/bootstrap/_modal.scss +36 -41
- data/assets/stylesheets/bootstrap/_nav.scss +7 -9
- data/assets/stylesheets/bootstrap/_navbar.scss +42 -82
- data/assets/stylesheets/bootstrap/_pagination.scss +7 -20
- data/assets/stylesheets/bootstrap/_popover.scss +14 -14
- data/assets/stylesheets/bootstrap/_progress.scss +3 -5
- data/assets/stylesheets/bootstrap/_reboot.scss +304 -172
- data/assets/stylesheets/bootstrap/_root.scss +5 -8
- data/assets/stylesheets/bootstrap/_spinners.scss +8 -17
- data/assets/stylesheets/bootstrap/_tables.scss +80 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +2 -4
- data/assets/stylesheets/bootstrap/_tooltip.scss +9 -9
- data/assets/stylesheets/bootstrap/_transitions.scss +0 -7
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +503 -18
- data/assets/stylesheets/bootstrap/_variables.scss +548 -437
- 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/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/_border-radius.scss +1 -1
- 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 +23 -85
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +86 -34
- 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 +3 -3
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +18 -24
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +2 -2
- 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 +214 -130
- data/bootstrap.gemspec +3 -1
- data/lib/bootstrap/engine.rb +1 -17
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +6 -18
- data/tasks/updater/network.rb +1 -7
- metadata +49 -47
- data/assets/javascripts/bootstrap/util.js +0 -189
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -526
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -211
- data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
- data/assets/stylesheets/bootstrap/_media.scss +0 -8
- data/assets/stylesheets/bootstrap/_print.scss +0 -132
- 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
- data/test/gemfiles/rails_7_0_dartsass.gemfile +0 -8
- data/test/gemfiles/rails_7_0_sassc.gemfile +0 -8
- /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,78 +1,158 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap collapse.js
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap collapse.js v5.0.0-alpha1 (https://getbootstrap.com/)
|
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
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
+
|
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;
|
16
|
+
|
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;
|
24
29
|
}
|
25
|
-
}
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
30
|
-
Object.defineProperty(Constructor, "prototype", {
|
31
|
-
writable: false
|
32
|
-
});
|
33
|
-
return Constructor;
|
34
|
-
}
|
31
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
32
|
+
};
|
35
33
|
|
36
|
-
function
|
37
|
-
|
38
|
-
for (var i = 1; i < arguments.length; i++) {
|
39
|
-
var source = arguments[i];
|
34
|
+
var getSelector = function getSelector(element) {
|
35
|
+
var selector = element.getAttribute('data-target');
|
40
36
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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);
|
46
105
|
}
|
106
|
+
}, emulatedDuration);
|
107
|
+
};
|
47
108
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
+
};
|
52
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; }
|
141
|
+
|
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); } }
|
143
|
+
|
144
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
53
145
|
/**
|
146
|
+
* ------------------------------------------------------------------------
|
54
147
|
* Constants
|
148
|
+
* ------------------------------------------------------------------------
|
55
149
|
*/
|
56
150
|
|
57
151
|
var NAME = 'collapse';
|
58
|
-
var VERSION = '
|
152
|
+
var VERSION = '5.0.0-alpha1';
|
59
153
|
var DATA_KEY = 'bs.collapse';
|
60
154
|
var EVENT_KEY = "." + DATA_KEY;
|
61
155
|
var DATA_API_KEY = '.data-api';
|
62
|
-
var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
|
63
|
-
var CLASS_NAME_SHOW = 'show';
|
64
|
-
var CLASS_NAME_COLLAPSE = 'collapse';
|
65
|
-
var CLASS_NAME_COLLAPSING = 'collapsing';
|
66
|
-
var CLASS_NAME_COLLAPSED = 'collapsed';
|
67
|
-
var DIMENSION_WIDTH = 'width';
|
68
|
-
var DIMENSION_HEIGHT = 'height';
|
69
|
-
var EVENT_SHOW = "show" + EVENT_KEY;
|
70
|
-
var EVENT_SHOWN = "shown" + EVENT_KEY;
|
71
|
-
var EVENT_HIDE = "hide" + EVENT_KEY;
|
72
|
-
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
73
|
-
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
74
|
-
var SELECTOR_ACTIVES = '.show, .collapsing';
|
75
|
-
var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
|
76
156
|
var Default = {
|
77
157
|
toggle: true,
|
78
158
|
parent: ''
|
@@ -81,8 +161,23 @@
|
|
81
161
|
toggle: 'boolean',
|
82
162
|
parent: '(string|element)'
|
83
163
|
};
|
164
|
+
var EVENT_SHOW = "show" + EVENT_KEY;
|
165
|
+
var EVENT_SHOWN = "shown" + EVENT_KEY;
|
166
|
+
var EVENT_HIDE = "hide" + EVENT_KEY;
|
167
|
+
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
168
|
+
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
|
169
|
+
var CLASS_NAME_SHOW = 'show';
|
170
|
+
var CLASS_NAME_COLLAPSE = 'collapse';
|
171
|
+
var CLASS_NAME_COLLAPSING = 'collapsing';
|
172
|
+
var CLASS_NAME_COLLAPSED = 'collapsed';
|
173
|
+
var WIDTH = 'width';
|
174
|
+
var HEIGHT = 'height';
|
175
|
+
var SELECTOR_ACTIVES = '.show, .collapsing';
|
176
|
+
var SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]';
|
84
177
|
/**
|
85
|
-
*
|
178
|
+
* ------------------------------------------------------------------------
|
179
|
+
* Class Definition
|
180
|
+
* ------------------------------------------------------------------------
|
86
181
|
*/
|
87
182
|
|
88
183
|
var Collapse = /*#__PURE__*/function () {
|
@@ -90,17 +185,17 @@
|
|
90
185
|
this._isTransitioning = false;
|
91
186
|
this._element = element;
|
92
187
|
this._config = this._getConfig(config);
|
93
|
-
this._triggerArray =
|
94
|
-
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);
|
95
190
|
|
96
191
|
for (var i = 0, len = toggleList.length; i < len; i++) {
|
97
192
|
var elem = toggleList[i];
|
98
|
-
var selector =
|
99
|
-
var filterElement =
|
193
|
+
var selector = getSelectorFromElement(elem);
|
194
|
+
var filterElement = SelectorEngine.find(selector).filter(function (foundElem) {
|
100
195
|
return foundElem === element;
|
101
196
|
});
|
102
197
|
|
103
|
-
if (selector !== null && filterElement.length
|
198
|
+
if (selector !== null && filterElement.length) {
|
104
199
|
this._selector = selector;
|
105
200
|
|
106
201
|
this._triggerArray.push(elem);
|
@@ -116,6 +211,8 @@
|
|
116
211
|
if (this._config.toggle) {
|
117
212
|
this.toggle();
|
118
213
|
}
|
214
|
+
|
215
|
+
Data.setData(element, DATA_KEY, this);
|
119
216
|
} // Getters
|
120
217
|
|
121
218
|
|
@@ -123,7 +220,7 @@
|
|
123
220
|
|
124
221
|
// Public
|
125
222
|
_proto.toggle = function toggle() {
|
126
|
-
if (
|
223
|
+
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
|
127
224
|
this.hide();
|
128
225
|
} else {
|
129
226
|
this.show();
|
@@ -133,7 +230,7 @@
|
|
133
230
|
_proto.show = function show() {
|
134
231
|
var _this = this;
|
135
232
|
|
136
|
-
if (this._isTransitioning ||
|
233
|
+
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW)) {
|
137
234
|
return;
|
138
235
|
}
|
139
236
|
|
@@ -141,7 +238,7 @@
|
|
141
238
|
var activesData;
|
142
239
|
|
143
240
|
if (this._parent) {
|
144
|
-
actives =
|
241
|
+
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(function (elem) {
|
145
242
|
if (typeof _this._config.parent === 'string') {
|
146
243
|
return elem.getAttribute('data-parent') === _this._config.parent;
|
147
244
|
}
|
@@ -154,88 +251,106 @@
|
|
154
251
|
}
|
155
252
|
}
|
156
253
|
|
254
|
+
var container = SelectorEngine.findOne(this._selector);
|
255
|
+
|
157
256
|
if (actives) {
|
158
|
-
|
257
|
+
var tempActiveData = actives.filter(function (elem) {
|
258
|
+
return container !== elem;
|
259
|
+
});
|
260
|
+
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null;
|
159
261
|
|
160
262
|
if (activesData && activesData._isTransitioning) {
|
161
263
|
return;
|
162
264
|
}
|
163
265
|
}
|
164
266
|
|
165
|
-
var startEvent =
|
166
|
-
$__default["default"](this._element).trigger(startEvent);
|
267
|
+
var startEvent = EventHandler.trigger(this._element, EVENT_SHOW);
|
167
268
|
|
168
|
-
if (startEvent.
|
269
|
+
if (startEvent.defaultPrevented) {
|
169
270
|
return;
|
170
271
|
}
|
171
272
|
|
172
273
|
if (actives) {
|
173
|
-
|
274
|
+
actives.forEach(function (elemActive) {
|
275
|
+
if (container !== elemActive) {
|
276
|
+
Collapse.collapseInterface(elemActive, 'hide');
|
277
|
+
}
|
174
278
|
|
175
|
-
|
176
|
-
|
177
|
-
|
279
|
+
if (!activesData) {
|
280
|
+
Data.setData(elemActive, DATA_KEY, null);
|
281
|
+
}
|
282
|
+
});
|
178
283
|
}
|
179
284
|
|
180
285
|
var dimension = this._getDimension();
|
181
286
|
|
182
|
-
|
287
|
+
this._element.classList.remove(CLASS_NAME_COLLAPSE);
|
288
|
+
|
289
|
+
this._element.classList.add(CLASS_NAME_COLLAPSING);
|
290
|
+
|
183
291
|
this._element.style[dimension] = 0;
|
184
292
|
|
185
293
|
if (this._triggerArray.length) {
|
186
|
-
|
294
|
+
this._triggerArray.forEach(function (element) {
|
295
|
+
element.classList.remove(CLASS_NAME_COLLAPSED);
|
296
|
+
element.setAttribute('aria-expanded', true);
|
297
|
+
});
|
187
298
|
}
|
188
299
|
|
189
300
|
this.setTransitioning(true);
|
190
301
|
|
191
302
|
var complete = function complete() {
|
192
|
-
|
303
|
+
_this._element.classList.remove(CLASS_NAME_COLLAPSING);
|
304
|
+
|
305
|
+
_this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW);
|
306
|
+
|
193
307
|
_this._element.style[dimension] = '';
|
194
308
|
|
195
309
|
_this.setTransitioning(false);
|
196
310
|
|
197
|
-
|
311
|
+
EventHandler.trigger(_this._element, EVENT_SHOWN);
|
198
312
|
};
|
199
313
|
|
200
314
|
var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
|
201
315
|
var scrollSize = "scroll" + capitalizedDimension;
|
202
|
-
var transitionDuration =
|
203
|
-
|
316
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
317
|
+
EventHandler.one(this._element, TRANSITION_END, complete);
|
318
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
204
319
|
this._element.style[dimension] = this._element[scrollSize] + "px";
|
205
320
|
};
|
206
321
|
|
207
322
|
_proto.hide = function hide() {
|
208
323
|
var _this2 = this;
|
209
324
|
|
210
|
-
if (this._isTransitioning ||
|
325
|
+
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW)) {
|
211
326
|
return;
|
212
327
|
}
|
213
328
|
|
214
|
-
var startEvent =
|
215
|
-
$__default["default"](this._element).trigger(startEvent);
|
329
|
+
var startEvent = EventHandler.trigger(this._element, EVENT_HIDE);
|
216
330
|
|
217
|
-
if (startEvent.
|
331
|
+
if (startEvent.defaultPrevented) {
|
218
332
|
return;
|
219
333
|
}
|
220
334
|
|
221
335
|
var dimension = this._getDimension();
|
222
336
|
|
223
337
|
this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
|
224
|
-
|
225
|
-
|
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
|
+
|
226
344
|
var triggerArrayLength = this._triggerArray.length;
|
227
345
|
|
228
346
|
if (triggerArrayLength > 0) {
|
229
347
|
for (var i = 0; i < triggerArrayLength; i++) {
|
230
348
|
var trigger = this._triggerArray[i];
|
231
|
-
var
|
232
|
-
|
233
|
-
if (selector !== null) {
|
234
|
-
var $elem = $__default["default"]([].slice.call(document.querySelectorAll(selector)));
|
349
|
+
var elem = getElementFromSelector(trigger);
|
235
350
|
|
236
|
-
|
237
|
-
|
238
|
-
|
351
|
+
if (elem && !elem.classList.contains(CLASS_NAME_SHOW)) {
|
352
|
+
trigger.classList.add(CLASS_NAME_COLLAPSED);
|
353
|
+
trigger.setAttribute('aria-expanded', false);
|
239
354
|
}
|
240
355
|
}
|
241
356
|
}
|
@@ -245,12 +360,17 @@
|
|
245
360
|
var complete = function complete() {
|
246
361
|
_this2.setTransitioning(false);
|
247
362
|
|
248
|
-
|
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);
|
249
368
|
};
|
250
369
|
|
251
370
|
this._element.style[dimension] = '';
|
252
|
-
var transitionDuration =
|
253
|
-
|
371
|
+
var transitionDuration = getTransitionDurationFromElement(this._element);
|
372
|
+
EventHandler.one(this._element, TRANSITION_END, complete);
|
373
|
+
emulateTransitionEnd(this._element, transitionDuration);
|
254
374
|
};
|
255
375
|
|
256
376
|
_proto.setTransitioning = function setTransitioning(isTransitioning) {
|
@@ -258,7 +378,7 @@
|
|
258
378
|
};
|
259
379
|
|
260
380
|
_proto.dispose = function dispose() {
|
261
|
-
|
381
|
+
Data.removeData(this._element, DATA_KEY);
|
262
382
|
this._config = null;
|
263
383
|
this._parent = null;
|
264
384
|
this._element = null;
|
@@ -268,81 +388,93 @@
|
|
268
388
|
;
|
269
389
|
|
270
390
|
_proto._getConfig = function _getConfig(config) {
|
271
|
-
config =
|
391
|
+
config = _objectSpread(_objectSpread({}, Default), config);
|
272
392
|
config.toggle = Boolean(config.toggle); // Coerce string values
|
273
393
|
|
274
|
-
|
394
|
+
typeCheckConfig(NAME, config, DefaultType);
|
275
395
|
return config;
|
276
396
|
};
|
277
397
|
|
278
398
|
_proto._getDimension = function _getDimension() {
|
279
|
-
var hasWidth =
|
280
|
-
|
399
|
+
var hasWidth = this._element.classList.contains(WIDTH);
|
400
|
+
|
401
|
+
return hasWidth ? WIDTH : HEIGHT;
|
281
402
|
};
|
282
403
|
|
283
404
|
_proto._getParent = function _getParent() {
|
284
405
|
var _this3 = this;
|
285
406
|
|
286
|
-
var parent;
|
407
|
+
var parent = this._config.parent;
|
287
408
|
|
288
|
-
if (
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
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];
|
293
413
|
}
|
294
414
|
} else {
|
295
|
-
parent =
|
415
|
+
parent = SelectorEngine.findOne(parent);
|
296
416
|
}
|
297
417
|
|
298
|
-
var selector = "[data-
|
299
|
-
|
300
|
-
|
301
|
-
|
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]);
|
302
423
|
});
|
303
424
|
return parent;
|
304
425
|
};
|
305
426
|
|
306
427
|
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
|
307
|
-
|
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
|
+
}
|
308
438
|
|
309
|
-
|
310
|
-
|
439
|
+
elem.setAttribute('aria-expanded', isOpen);
|
440
|
+
});
|
441
|
+
}
|
311
442
|
}
|
312
443
|
} // Static
|
313
444
|
;
|
314
445
|
|
315
|
-
Collapse.
|
316
|
-
var
|
317
|
-
return selector ? document.querySelector(selector) : null;
|
318
|
-
};
|
446
|
+
Collapse.collapseInterface = function collapseInterface(element, config) {
|
447
|
+
var data = Data.getData(element, DATA_KEY);
|
319
448
|
|
320
|
-
|
321
|
-
return this.each(function () {
|
322
|
-
var $element = $__default["default"](this);
|
323
|
-
var data = $element.data(DATA_KEY);
|
449
|
+
var _config = _objectSpread(_objectSpread(_objectSpread({}, Default), Manipulator.getDataAttributes(element)), typeof config === 'object' && config ? config : {});
|
324
450
|
|
325
|
-
|
451
|
+
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
|
452
|
+
_config.toggle = false;
|
453
|
+
}
|
326
454
|
|
327
|
-
|
328
|
-
|
329
|
-
|
455
|
+
if (!data) {
|
456
|
+
data = new Collapse(element, _config);
|
457
|
+
}
|
330
458
|
|
331
|
-
|
332
|
-
|
333
|
-
|
459
|
+
if (typeof config === 'string') {
|
460
|
+
if (typeof data[config] === 'undefined') {
|
461
|
+
throw new TypeError("No method named \"" + config + "\"");
|
334
462
|
}
|
335
463
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
}
|
464
|
+
data[config]();
|
465
|
+
}
|
466
|
+
};
|
340
467
|
|
341
|
-
|
342
|
-
|
468
|
+
Collapse.jQueryInterface = function jQueryInterface(config) {
|
469
|
+
return this.each(function () {
|
470
|
+
Collapse.collapseInterface(this, config);
|
343
471
|
});
|
344
472
|
};
|
345
473
|
|
474
|
+
Collapse.getInstance = function getInstance(element) {
|
475
|
+
return Data.getData(element, DATA_KEY);
|
476
|
+
};
|
477
|
+
|
346
478
|
_createClass(Collapse, null, [{
|
347
479
|
key: "VERSION",
|
348
480
|
get: function get() {
|
@@ -358,39 +490,61 @@
|
|
358
490
|
return Collapse;
|
359
491
|
}();
|
360
492
|
/**
|
361
|
-
*
|
493
|
+
* ------------------------------------------------------------------------
|
494
|
+
* Data Api implementation
|
495
|
+
* ------------------------------------------------------------------------
|
362
496
|
*/
|
363
497
|
|
364
498
|
|
365
|
-
|
499
|
+
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
366
500
|
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
|
367
|
-
if (event.
|
501
|
+
if (event.target.tagName === 'A') {
|
368
502
|
event.preventDefault();
|
369
503
|
}
|
370
504
|
|
371
|
-
var
|
372
|
-
var selector =
|
373
|
-
var
|
374
|
-
|
375
|
-
var
|
376
|
-
var
|
377
|
-
|
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
|
+
}
|
378
518
|
|
379
|
-
|
519
|
+
config = 'toggle';
|
520
|
+
} else {
|
521
|
+
config = triggerData;
|
522
|
+
}
|
523
|
+
|
524
|
+
Collapse.collapseInterface(element, config);
|
380
525
|
});
|
381
526
|
});
|
527
|
+
var $ = getjQuery();
|
382
528
|
/**
|
529
|
+
* ------------------------------------------------------------------------
|
383
530
|
* jQuery
|
531
|
+
* ------------------------------------------------------------------------
|
532
|
+
* add .collapse to jQuery only if jQuery is present
|
384
533
|
*/
|
385
534
|
|
386
|
-
|
387
|
-
$__default["default"].fn[NAME].Constructor = Collapse;
|
535
|
+
/* istanbul ignore if */
|
388
536
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
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
|
+
}
|
393
547
|
|
394
548
|
return Collapse;
|
395
549
|
|
396
|
-
}));
|
550
|
+
})));
|