bootstrap 4.6.2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +7 -4
- data/assets/javascripts/bootstrap/alert.js +192 -115
- data/assets/javascripts/bootstrap/base-component.js +63 -0
- data/assets/javascripts/bootstrap/button.js +96 -179
- data/assets/javascripts/bootstrap/carousel.js +472 -359
- data/assets/javascripts/bootstrap/collapse.js +379 -225
- data/assets/javascripts/bootstrap/dom/data.js +68 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +322 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +85 -0
- data/assets/javascripts/bootstrap/dropdown.js +472 -355
- data/assets/javascripts/bootstrap/modal.js +612 -438
- data/assets/javascripts/bootstrap/offcanvas.js +671 -0
- data/assets/javascripts/bootstrap/popover.js +138 -167
- data/assets/javascripts/bootstrap/scrollspy.js +250 -192
- data/assets/javascripts/bootstrap/tab.js +241 -144
- data/assets/javascripts/bootstrap/toast.js +223 -157
- data/assets/javascripts/bootstrap/tooltip.js +651 -487
- data/assets/javascripts/bootstrap-global-this-define.js +6 -0
- data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
- data/assets/javascripts/bootstrap-sprockets.js +8 -1
- data/assets/javascripts/bootstrap.js +3277 -2590
- 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 +18 -10
- data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
- data/assets/stylesheets/bootstrap/_alert.scss +15 -10
- data/assets/stylesheets/bootstrap/_badge.scss +2 -27
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +3 -17
- data/assets/stylesheets/bootstrap/_button-group.scss +21 -45
- data/assets/stylesheets/bootstrap/_buttons.scss +29 -60
- data/assets/stylesheets/bootstrap/_card.scss +20 -91
- data/assets/stylesheets/bootstrap/_carousel.scss +64 -35
- data/assets/stylesheets/bootstrap/_close.scss +30 -30
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +84 -36
- data/assets/stylesheets/bootstrap/_forms.scss +9 -347
- data/assets/stylesheets/bootstrap/_functions.scss +84 -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 +28 -8
- data/assets/stylesheets/bootstrap/_mixins.scss +8 -13
- data/assets/stylesheets/bootstrap/_modal.scss +45 -57
- data/assets/stylesheets/bootstrap/_nav.scss +20 -6
- data/assets/stylesheets/bootstrap/_navbar.scss +45 -71
- data/assets/stylesheets/bootstrap/_offcanvas.scss +77 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +10 -20
- data/assets/stylesheets/bootstrap/_popover.scss +24 -36
- data/assets/stylesheets/bootstrap/_progress.scss +5 -4
- data/assets/stylesheets/bootstrap/_reboot.scss +316 -179
- data/assets/stylesheets/bootstrap/_root.scss +5 -8
- data/assets/stylesheets/bootstrap/_spinners.scss +11 -7
- data/assets/stylesheets/bootstrap/_tables.scss +79 -114
- data/assets/stylesheets/bootstrap/_toasts.scss +20 -15
- data/assets/stylesheets/bootstrap/_tooltip.scss +21 -21
- data/assets/stylesheets/bootstrap/_transitions.scss +2 -7
- data/assets/stylesheets/bootstrap/_type.scss +38 -59
- data/assets/stylesheets/bootstrap/_utilities.scss +594 -18
- data/assets/stylesheets/bootstrap/_variables.scss +800 -485
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +61 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +67 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -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/_position.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -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/helpers/_visually-hidden.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +10 -8
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +71 -48
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +10 -8
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +39 -97
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +90 -34
- data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
- data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +17 -8
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +3 -3
- 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 +68 -0
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +214 -130
- data/bootstrap.gemspec +1 -3
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +19 -16
- data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
- data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
- data/test/dummy_rails/app/views/pages/root.html +89 -0
- data/test/dummy_rails/config/application.rb +0 -3
- data/test/gemfiles/rails_6_1.gemfile +7 -0
- metadata +45 -73
- 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/_screen-reader.scss +0 -34
- 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/dummy_rails/app/views/pages/root.html.slim +0 -58
- /data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
@@ -1,159 +1,240 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap scrollspy.js
|
3
|
-
* Copyright 2011-
|
2
|
+
* Bootstrap scrollspy.js v5.0.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2021 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 = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.
|
10
|
-
}
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
|
10
|
+
}(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
|
11
11
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
13
13
|
|
14
|
-
var
|
15
|
-
var
|
14
|
+
var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
15
|
+
var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
16
|
+
var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
17
|
+
var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
/**
|
20
|
+
* --------------------------------------------------------------------------
|
21
|
+
* Bootstrap (v5.0.0): util/index.js
|
22
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
23
|
+
* --------------------------------------------------------------------------
|
24
|
+
*/
|
25
|
+
const MAX_UID = 1000000;
|
26
|
+
|
27
|
+
const toType = obj => {
|
28
|
+
if (obj === null || obj === undefined) {
|
29
|
+
return `${obj}`;
|
24
30
|
}
|
25
|
-
}
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
}
|
32
|
+
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
|
33
|
+
};
|
34
|
+
/**
|
35
|
+
* --------------------------------------------------------------------------
|
36
|
+
* Public Util Api
|
37
|
+
* --------------------------------------------------------------------------
|
38
|
+
*/
|
35
39
|
|
36
|
-
function _extends() {
|
37
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
38
|
-
for (var i = 1; i < arguments.length; i++) {
|
39
|
-
var source = arguments[i];
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
const getUID = prefix => {
|
42
|
+
do {
|
43
|
+
prefix += Math.floor(Math.random() * MAX_UID);
|
44
|
+
} while (document.getElementById(prefix));
|
45
|
+
|
46
|
+
return prefix;
|
47
|
+
};
|
48
|
+
|
49
|
+
const getSelector = element => {
|
50
|
+
let selector = element.getAttribute('data-bs-target');
|
51
|
+
|
52
|
+
if (!selector || selector === '#') {
|
53
|
+
let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
|
54
|
+
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
|
55
|
+
// `document.querySelector` will rightfully complain it is invalid.
|
56
|
+
// See https://github.com/twbs/bootstrap/issues/32273
|
57
|
+
|
58
|
+
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
|
59
|
+
return null;
|
60
|
+
} // Just in case some CMS puts out a full URL with the anchor appended
|
61
|
+
|
62
|
+
|
63
|
+
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
|
64
|
+
hrefAttr = `#${hrefAttr.split('#')[1]}`;
|
46
65
|
}
|
47
66
|
|
48
|
-
|
49
|
-
}
|
50
|
-
|
51
|
-
|
67
|
+
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
|
68
|
+
}
|
69
|
+
|
70
|
+
return selector;
|
71
|
+
};
|
72
|
+
|
73
|
+
const getSelectorFromElement = element => {
|
74
|
+
const selector = getSelector(element);
|
75
|
+
|
76
|
+
if (selector) {
|
77
|
+
return document.querySelector(selector) ? selector : null;
|
78
|
+
}
|
79
|
+
|
80
|
+
return null;
|
81
|
+
};
|
82
|
+
|
83
|
+
const isElement = obj => (obj[0] || obj).nodeType;
|
84
|
+
|
85
|
+
const typeCheckConfig = (componentName, config, configTypes) => {
|
86
|
+
Object.keys(configTypes).forEach(property => {
|
87
|
+
const expectedTypes = configTypes[property];
|
88
|
+
const value = config[property];
|
89
|
+
const valueType = value && isElement(value) ? 'element' : toType(value);
|
90
|
+
|
91
|
+
if (!new RegExp(expectedTypes).test(valueType)) {
|
92
|
+
throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
|
93
|
+
}
|
94
|
+
});
|
95
|
+
};
|
96
|
+
|
97
|
+
const getjQuery = () => {
|
98
|
+
const {
|
99
|
+
jQuery
|
100
|
+
} = window;
|
101
|
+
|
102
|
+
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
103
|
+
return jQuery;
|
104
|
+
}
|
105
|
+
|
106
|
+
return null;
|
107
|
+
};
|
108
|
+
|
109
|
+
const onDOMContentLoaded = callback => {
|
110
|
+
if (document.readyState === 'loading') {
|
111
|
+
document.addEventListener('DOMContentLoaded', callback);
|
112
|
+
} else {
|
113
|
+
callback();
|
114
|
+
}
|
115
|
+
};
|
116
|
+
|
117
|
+
const defineJQueryPlugin = (name, plugin) => {
|
118
|
+
onDOMContentLoaded(() => {
|
119
|
+
const $ = getjQuery();
|
120
|
+
/* istanbul ignore if */
|
121
|
+
|
122
|
+
if ($) {
|
123
|
+
const JQUERY_NO_CONFLICT = $.fn[name];
|
124
|
+
$.fn[name] = plugin.jQueryInterface;
|
125
|
+
$.fn[name].Constructor = plugin;
|
126
|
+
|
127
|
+
$.fn[name].noConflict = () => {
|
128
|
+
$.fn[name] = JQUERY_NO_CONFLICT;
|
129
|
+
return plugin.jQueryInterface;
|
130
|
+
};
|
131
|
+
}
|
132
|
+
});
|
133
|
+
};
|
52
134
|
|
53
135
|
/**
|
136
|
+
* --------------------------------------------------------------------------
|
137
|
+
* Bootstrap (v5.0.0): scrollspy.js
|
138
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
139
|
+
* --------------------------------------------------------------------------
|
140
|
+
*/
|
141
|
+
/**
|
142
|
+
* ------------------------------------------------------------------------
|
54
143
|
* Constants
|
144
|
+
* ------------------------------------------------------------------------
|
55
145
|
*/
|
56
146
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
var JQUERY_NO_CONFLICT = $__default["default"].fn[NAME];
|
63
|
-
var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
|
64
|
-
var CLASS_NAME_ACTIVE = 'active';
|
65
|
-
var EVENT_ACTIVATE = "activate" + EVENT_KEY;
|
66
|
-
var EVENT_SCROLL = "scroll" + EVENT_KEY;
|
67
|
-
var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
|
68
|
-
var METHOD_OFFSET = 'offset';
|
69
|
-
var METHOD_POSITION = 'position';
|
70
|
-
var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
|
71
|
-
var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
|
72
|
-
var SELECTOR_NAV_LINKS = '.nav-link';
|
73
|
-
var SELECTOR_NAV_ITEMS = '.nav-item';
|
74
|
-
var SELECTOR_LIST_ITEMS = '.list-group-item';
|
75
|
-
var SELECTOR_DROPDOWN = '.dropdown';
|
76
|
-
var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item';
|
77
|
-
var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
|
78
|
-
var Default = {
|
147
|
+
const NAME = 'scrollspy';
|
148
|
+
const DATA_KEY = 'bs.scrollspy';
|
149
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
150
|
+
const DATA_API_KEY = '.data-api';
|
151
|
+
const Default = {
|
79
152
|
offset: 10,
|
80
153
|
method: 'auto',
|
81
154
|
target: ''
|
82
155
|
};
|
83
|
-
|
156
|
+
const DefaultType = {
|
84
157
|
offset: 'number',
|
85
158
|
method: 'string',
|
86
159
|
target: '(string|element)'
|
87
160
|
};
|
161
|
+
const EVENT_ACTIVATE = `activate${EVENT_KEY}`;
|
162
|
+
const EVENT_SCROLL = `scroll${EVENT_KEY}`;
|
163
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
164
|
+
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
|
165
|
+
const CLASS_NAME_ACTIVE = 'active';
|
166
|
+
const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
|
167
|
+
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
|
168
|
+
const SELECTOR_NAV_LINKS = '.nav-link';
|
169
|
+
const SELECTOR_NAV_ITEMS = '.nav-item';
|
170
|
+
const SELECTOR_LIST_ITEMS = '.list-group-item';
|
171
|
+
const SELECTOR_DROPDOWN = '.dropdown';
|
172
|
+
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
|
173
|
+
const METHOD_OFFSET = 'offset';
|
174
|
+
const METHOD_POSITION = 'position';
|
88
175
|
/**
|
89
|
-
*
|
176
|
+
* ------------------------------------------------------------------------
|
177
|
+
* Class Definition
|
178
|
+
* ------------------------------------------------------------------------
|
90
179
|
*/
|
91
180
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
this._element = element;
|
97
|
-
this._scrollElement = element.tagName === 'BODY' ? window : element;
|
181
|
+
class ScrollSpy extends BaseComponent__default['default'] {
|
182
|
+
constructor(element, config) {
|
183
|
+
super(element);
|
184
|
+
this._scrollElement = this._element.tagName === 'BODY' ? window : this._element;
|
98
185
|
this._config = this._getConfig(config);
|
99
|
-
this._selector = this._config.target
|
186
|
+
this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
|
100
187
|
this._offsets = [];
|
101
188
|
this._targets = [];
|
102
189
|
this._activeTarget = null;
|
103
190
|
this._scrollHeight = 0;
|
104
|
-
|
105
|
-
return _this._process(event);
|
106
|
-
});
|
191
|
+
EventHandler__default['default'].on(this._scrollElement, EVENT_SCROLL, () => this._process());
|
107
192
|
this.refresh();
|
108
193
|
|
109
194
|
this._process();
|
110
195
|
} // Getters
|
111
196
|
|
112
197
|
|
113
|
-
|
198
|
+
static get Default() {
|
199
|
+
return Default;
|
200
|
+
}
|
114
201
|
|
115
|
-
|
116
|
-
|
117
|
-
|
202
|
+
static get DATA_KEY() {
|
203
|
+
return DATA_KEY;
|
204
|
+
} // Public
|
118
205
|
|
119
|
-
|
120
|
-
|
121
|
-
|
206
|
+
|
207
|
+
refresh() {
|
208
|
+
const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
|
209
|
+
const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
|
210
|
+
const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
|
122
211
|
this._offsets = [];
|
123
212
|
this._targets = [];
|
124
213
|
this._scrollHeight = this._getScrollHeight();
|
125
|
-
|
126
|
-
targets.map(
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
if (targetSelector) {
|
131
|
-
target = document.querySelector(targetSelector);
|
132
|
-
}
|
214
|
+
const targets = SelectorEngine__default['default'].find(this._selector);
|
215
|
+
targets.map(element => {
|
216
|
+
const targetSelector = getSelectorFromElement(element);
|
217
|
+
const target = targetSelector ? SelectorEngine__default['default'].findOne(targetSelector) : null;
|
133
218
|
|
134
219
|
if (target) {
|
135
|
-
|
220
|
+
const targetBCR = target.getBoundingClientRect();
|
136
221
|
|
137
222
|
if (targetBCR.width || targetBCR.height) {
|
138
|
-
|
139
|
-
return [$__default["default"](target)[offsetMethod]().top + offsetBase, targetSelector];
|
223
|
+
return [Manipulator__default['default'][offsetMethod](target).top + offsetBase, targetSelector];
|
140
224
|
}
|
141
225
|
}
|
142
226
|
|
143
227
|
return null;
|
144
|
-
}).filter(
|
145
|
-
|
146
|
-
}).forEach(function (item) {
|
147
|
-
_this2._offsets.push(item[0]);
|
228
|
+
}).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => {
|
229
|
+
this._offsets.push(item[0]);
|
148
230
|
|
149
|
-
|
231
|
+
this._targets.push(item[1]);
|
150
232
|
});
|
151
|
-
}
|
233
|
+
}
|
152
234
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
this._element = null;
|
235
|
+
dispose() {
|
236
|
+
super.dispose();
|
237
|
+
EventHandler__default['default'].off(this._scrollElement, EVENT_KEY);
|
157
238
|
this._scrollElement = null;
|
158
239
|
this._config = null;
|
159
240
|
this._selector = null;
|
@@ -162,51 +243,56 @@
|
|
162
243
|
this._activeTarget = null;
|
163
244
|
this._scrollHeight = null;
|
164
245
|
} // Private
|
165
|
-
;
|
166
246
|
|
167
|
-
_proto._getConfig = function _getConfig(config) {
|
168
|
-
config = _extends({}, Default, typeof config === 'object' && config ? config : {});
|
169
247
|
|
170
|
-
|
171
|
-
|
248
|
+
_getConfig(config) {
|
249
|
+
config = { ...Default,
|
250
|
+
...Manipulator__default['default'].getDataAttributes(this._element),
|
251
|
+
...(typeof config === 'object' && config ? config : {})
|
252
|
+
};
|
253
|
+
|
254
|
+
if (typeof config.target !== 'string' && isElement(config.target)) {
|
255
|
+
let {
|
256
|
+
id
|
257
|
+
} = config.target;
|
172
258
|
|
173
259
|
if (!id) {
|
174
|
-
id =
|
175
|
-
|
260
|
+
id = getUID(NAME);
|
261
|
+
config.target.id = id;
|
176
262
|
}
|
177
263
|
|
178
|
-
config.target =
|
264
|
+
config.target = `#${id}`;
|
179
265
|
}
|
180
266
|
|
181
|
-
|
267
|
+
typeCheckConfig(NAME, config, DefaultType);
|
182
268
|
return config;
|
183
|
-
}
|
269
|
+
}
|
184
270
|
|
185
|
-
|
271
|
+
_getScrollTop() {
|
186
272
|
return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
|
187
|
-
}
|
273
|
+
}
|
188
274
|
|
189
|
-
|
275
|
+
_getScrollHeight() {
|
190
276
|
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
191
|
-
}
|
277
|
+
}
|
192
278
|
|
193
|
-
|
279
|
+
_getOffsetHeight() {
|
194
280
|
return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
|
195
|
-
}
|
281
|
+
}
|
196
282
|
|
197
|
-
|
198
|
-
|
283
|
+
_process() {
|
284
|
+
const scrollTop = this._getScrollTop() + this._config.offset;
|
199
285
|
|
200
|
-
|
286
|
+
const scrollHeight = this._getScrollHeight();
|
201
287
|
|
202
|
-
|
288
|
+
const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
|
203
289
|
|
204
290
|
if (this._scrollHeight !== scrollHeight) {
|
205
291
|
this.refresh();
|
206
292
|
}
|
207
293
|
|
208
294
|
if (scrollTop >= maxScroll) {
|
209
|
-
|
295
|
+
const target = this._targets[this._targets.length - 1];
|
210
296
|
|
211
297
|
if (this._activeTarget !== target) {
|
212
298
|
this._activate(target);
|
@@ -223,115 +309,87 @@
|
|
223
309
|
return;
|
224
310
|
}
|
225
311
|
|
226
|
-
for (
|
227
|
-
|
312
|
+
for (let i = this._offsets.length; i--;) {
|
313
|
+
const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
|
228
314
|
|
229
315
|
if (isActiveTarget) {
|
230
316
|
this._activate(this._targets[i]);
|
231
317
|
}
|
232
318
|
}
|
233
|
-
}
|
319
|
+
}
|
234
320
|
|
235
|
-
|
321
|
+
_activate(target) {
|
236
322
|
this._activeTarget = target;
|
237
323
|
|
238
324
|
this._clear();
|
239
325
|
|
240
|
-
|
241
|
-
return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
|
242
|
-
});
|
326
|
+
const queries = this._selector.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
|
243
327
|
|
244
|
-
|
328
|
+
const link = SelectorEngine__default['default'].findOne(queries.join(','));
|
245
329
|
|
246
|
-
if (
|
247
|
-
|
248
|
-
|
330
|
+
if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
|
331
|
+
SelectorEngine__default['default'].findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
|
332
|
+
link.classList.add(CLASS_NAME_ACTIVE);
|
249
333
|
} else {
|
250
334
|
// Set triggered link as active
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
335
|
+
link.classList.add(CLASS_NAME_ACTIVE);
|
336
|
+
SelectorEngine__default['default'].parents(link, SELECTOR_NAV_LIST_GROUP).forEach(listGroup => {
|
337
|
+
// Set triggered links parents as active
|
338
|
+
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
339
|
+
SelectorEngine__default['default'].prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE)); // Handle special case when .nav-link is inside .nav-item
|
340
|
+
|
341
|
+
SelectorEngine__default['default'].prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => {
|
342
|
+
SelectorEngine__default['default'].children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE));
|
343
|
+
});
|
344
|
+
});
|
257
345
|
}
|
258
346
|
|
259
|
-
|
347
|
+
EventHandler__default['default'].trigger(this._scrollElement, EVENT_ACTIVATE, {
|
260
348
|
relatedTarget: target
|
261
349
|
});
|
262
|
-
}
|
350
|
+
}
|
263
351
|
|
264
|
-
|
265
|
-
[].
|
266
|
-
return node.classList.contains(CLASS_NAME_ACTIVE);
|
267
|
-
}).forEach(function (node) {
|
268
|
-
return node.classList.remove(CLASS_NAME_ACTIVE);
|
269
|
-
});
|
352
|
+
_clear() {
|
353
|
+
SelectorEngine__default['default'].find(this._selector).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE));
|
270
354
|
} // Static
|
271
|
-
;
|
272
355
|
|
273
|
-
ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
|
274
|
-
return this.each(function () {
|
275
|
-
var data = $__default["default"](this).data(DATA_KEY);
|
276
356
|
|
277
|
-
|
357
|
+
static jQueryInterface(config) {
|
358
|
+
return this.each(function () {
|
359
|
+
const data = ScrollSpy.getInstance(this) || new ScrollSpy(this, typeof config === 'object' ? config : {});
|
278
360
|
|
279
|
-
if (
|
280
|
-
|
281
|
-
$__default["default"](this).data(DATA_KEY, data);
|
361
|
+
if (typeof config !== 'string') {
|
362
|
+
return;
|
282
363
|
}
|
283
364
|
|
284
|
-
if (typeof config === '
|
285
|
-
|
286
|
-
throw new TypeError("No method named \"" + config + "\"");
|
287
|
-
}
|
288
|
-
|
289
|
-
data[config]();
|
365
|
+
if (typeof data[config] === 'undefined') {
|
366
|
+
throw new TypeError(`No method named "${config}"`);
|
290
367
|
}
|
291
|
-
});
|
292
|
-
};
|
293
368
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
return VERSION;
|
298
|
-
}
|
299
|
-
}, {
|
300
|
-
key: "Default",
|
301
|
-
get: function get() {
|
302
|
-
return Default;
|
303
|
-
}
|
304
|
-
}]);
|
369
|
+
data[config]();
|
370
|
+
});
|
371
|
+
}
|
305
372
|
|
306
|
-
|
307
|
-
}();
|
373
|
+
}
|
308
374
|
/**
|
309
|
-
*
|
375
|
+
* ------------------------------------------------------------------------
|
376
|
+
* Data Api implementation
|
377
|
+
* ------------------------------------------------------------------------
|
310
378
|
*/
|
311
379
|
|
312
380
|
|
313
|
-
|
314
|
-
|
315
|
-
var scrollSpysLength = scrollSpys.length;
|
316
|
-
|
317
|
-
for (var i = scrollSpysLength; i--;) {
|
318
|
-
var $spy = $__default["default"](scrollSpys[i]);
|
319
|
-
|
320
|
-
ScrollSpy._jQueryInterface.call($spy, $spy.data());
|
321
|
-
}
|
381
|
+
EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
|
382
|
+
SelectorEngine__default['default'].find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy));
|
322
383
|
});
|
323
384
|
/**
|
385
|
+
* ------------------------------------------------------------------------
|
324
386
|
* jQuery
|
387
|
+
* ------------------------------------------------------------------------
|
388
|
+
* add .ScrollSpy to jQuery only if jQuery is present
|
325
389
|
*/
|
326
390
|
|
327
|
-
|
328
|
-
$__default["default"].fn[NAME].Constructor = ScrollSpy;
|
329
|
-
|
330
|
-
$__default["default"].fn[NAME].noConflict = function () {
|
331
|
-
$__default["default"].fn[NAME] = JQUERY_NO_CONFLICT;
|
332
|
-
return ScrollSpy._jQueryInterface;
|
333
|
-
};
|
391
|
+
defineJQueryPlugin(NAME, ScrollSpy);
|
334
392
|
|
335
393
|
return ScrollSpy;
|
336
394
|
|
337
|
-
}));
|
395
|
+
})));
|