bootstrap 4.3.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +55 -0
- data/CHANGELOG.md +2 -14
- data/README.md +28 -5
- data/assets/javascripts/bootstrap/alert.js +54 -163
- data/assets/javascripts/bootstrap/base-component.js +83 -0
- data/assets/javascripts/bootstrap/button.js +44 -152
- data/assets/javascripts/bootstrap/carousel.js +289 -569
- data/assets/javascripts/bootstrap/collapse.js +170 -349
- data/assets/javascripts/bootstrap/dom/data.js +62 -0
- data/assets/javascripts/bootstrap/dom/event-handler.js +236 -0
- data/assets/javascripts/bootstrap/dom/manipulator.js +71 -0
- data/assets/javascripts/bootstrap/dom/selector-engine.js +103 -0
- data/assets/javascripts/bootstrap/dropdown.js +303 -496
- data/assets/javascripts/bootstrap/modal.js +229 -559
- data/assets/javascripts/bootstrap/offcanvas.js +245 -0
- data/assets/javascripts/bootstrap/popover.js +61 -226
- data/assets/javascripts/bootstrap/scrollspy.js +217 -317
- data/assets/javascripts/bootstrap/tab.js +220 -212
- data/assets/javascripts/bootstrap/toast.js +145 -229
- data/assets/javascripts/bootstrap/tooltip.js +421 -782
- data/assets/javascripts/bootstrap/util/backdrop.js +139 -0
- data/assets/javascripts/bootstrap/util/component-functions.js +41 -0
- data/assets/javascripts/bootstrap/util/config.js +67 -0
- data/assets/javascripts/bootstrap/util/focustrap.js +113 -0
- data/assets/javascripts/bootstrap/util/index.js +281 -0
- data/assets/javascripts/bootstrap/util/sanitizer.js +110 -0
- data/assets/javascripts/bootstrap/util/scrollbar.js +112 -0
- data/assets/javascripts/bootstrap/util/swipe.js +134 -0
- data/assets/javascripts/bootstrap/util/template-factory.js +150 -0
- 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 +23 -7
- data/assets/javascripts/bootstrap.js +3690 -3639
- data/assets/javascripts/bootstrap.min.js +4 -4
- data/assets/stylesheets/_bootstrap-grid.scss +53 -20
- data/assets/stylesheets/_bootstrap-reboot.scss +5 -7
- data/assets/stylesheets/_bootstrap.scss +21 -13
- data/assets/stylesheets/bootstrap/_accordion.scss +158 -0
- data/assets/stylesheets/bootstrap/_alert.scss +32 -15
- data/assets/stylesheets/bootstrap/_badge.scss +15 -31
- data/assets/stylesheets/bootstrap/_breadcrumb.scss +23 -24
- data/assets/stylesheets/bootstrap/_button-group.scss +27 -48
- data/assets/stylesheets/bootstrap/_buttons.scss +139 -69
- data/assets/stylesheets/bootstrap/_card.scss +91 -141
- data/assets/stylesheets/bootstrap/_carousel.scss +86 -39
- data/assets/stylesheets/bootstrap/_close.scss +51 -29
- data/assets/stylesheets/bootstrap/_containers.scss +41 -0
- data/assets/stylesheets/bootstrap/_dropdown.scss +131 -72
- data/assets/stylesheets/bootstrap/_forms.scss +9 -330
- data/assets/stylesheets/bootstrap/_functions.scss +244 -28
- data/assets/stylesheets/bootstrap/_grid.scss +18 -31
- data/assets/stylesheets/bootstrap/_helpers.scss +12 -0
- data/assets/stylesheets/bootstrap/_images.scss +3 -3
- data/assets/stylesheets/bootstrap/_list-group.scss +101 -53
- data/assets/stylesheets/bootstrap/_maps.scss +174 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +13 -18
- data/assets/stylesheets/bootstrap/_modal.scss +120 -112
- data/assets/stylesheets/bootstrap/_nav.scss +113 -24
- data/assets/stylesheets/bootstrap/_navbar.scss +145 -150
- data/assets/stylesheets/bootstrap/_offcanvas.scss +146 -0
- data/assets/stylesheets/bootstrap/_pagination.scss +74 -38
- data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
- data/assets/stylesheets/bootstrap/_popover.scss +99 -74
- data/assets/stylesheets/bootstrap/_progress.scss +40 -15
- data/assets/stylesheets/bootstrap/_reboot.scss +342 -215
- data/assets/stylesheets/bootstrap/_root.scss +174 -9
- data/assets/stylesheets/bootstrap/_spinners.scss +52 -22
- data/assets/stylesheets/bootstrap/_tables.scss +101 -115
- data/assets/stylesheets/bootstrap/_toasts.scss +54 -25
- data/assets/stylesheets/bootstrap/_tooltip.scss +67 -63
- data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
- data/assets/stylesheets/bootstrap/_type.scss +42 -61
- data/assets/stylesheets/bootstrap/_utilities.scss +806 -17
- data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
- data/assets/stylesheets/bootstrap/_variables.scss +1235 -615
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +19 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +94 -0
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +188 -0
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +214 -0
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +80 -0
- data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +132 -0
- data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
- data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
- data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +8 -0
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +30 -0
- data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
- data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
- data/assets/stylesheets/bootstrap/helpers/_position.scss +36 -0
- data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
- data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -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/helpers/_vr.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +11 -6
- data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_banner.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
- data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
- data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +20 -16
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +60 -97
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +34 -27
- data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
- data/assets/stylesheets/bootstrap/mixins/_container.scss +11 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +77 -116
- data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +133 -33
- data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +7 -2
- data/assets/stylesheets/bootstrap/mixins/_pagination.scss +7 -19
- data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +24 -0
- data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +97 -0
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +33 -0
- data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +276 -132
- data/bootstrap.gemspec +4 -6
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +31 -7
- data/tasks/updater/network.rb +10 -4
- data/tasks/updater/scss.rb +1 -1
- data/tasks/updater.rb +2 -2
- data/test/dummy_rails/app/assets/config/manifest.js +3 -0
- data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
- data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
- 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_5_2.gemfile +8 -0
- data/test/gemfiles/rails_6_0.gemfile +7 -0
- data/test/gemfiles/rails_6_1.gemfile +7 -0
- data/test/gemfiles/rails_7_0.gemfile +7 -0
- data/test/support/dummy_rails_integration.rb +3 -1
- data/test/test_helper.rb +18 -12
- metadata +86 -84
- data/.travis.yml +0 -17
- data/assets/javascripts/bootstrap/util.js +0 -171
- data/assets/stylesheets/bootstrap/_code.scss +0 -48
- data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
- data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
- 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 -21
- 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 -66
- data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
- data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
- data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
- 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 -16
- 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/_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,373 +1,273 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap scrollspy.js
|
3
|
-
* Copyright 2011-
|
4
|
-
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/
|
2
|
+
* Bootstrap scrollspy.js v5.3.0 (https://getbootstrap.com/)
|
3
|
+
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
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 = global || self, global.
|
10
|
-
}(this, function (
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./util/index.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './dom/selector-engine', './util/index'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollspy = factory(global.BaseComponent, global.EventHandler, global.SelectorEngine, global.Index));
|
10
|
+
})(this, (function (BaseComponent, EventHandler, SelectorEngine, index_js) { 'use strict';
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
19
|
-
descriptor.configurable = true;
|
20
|
-
if ("value" in descriptor) descriptor.writable = true;
|
21
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
26
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
27
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
28
|
-
return Constructor;
|
29
|
-
}
|
30
|
-
|
31
|
-
function _defineProperty(obj, key, value) {
|
32
|
-
if (key in obj) {
|
33
|
-
Object.defineProperty(obj, key, {
|
34
|
-
value: value,
|
35
|
-
enumerable: true,
|
36
|
-
configurable: true,
|
37
|
-
writable: true
|
38
|
-
});
|
39
|
-
} else {
|
40
|
-
obj[key] = value;
|
41
|
-
}
|
42
|
-
|
43
|
-
return obj;
|
44
|
-
}
|
45
|
-
|
46
|
-
function _objectSpread(target) {
|
47
|
-
for (var i = 1; i < arguments.length; i++) {
|
48
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
49
|
-
var ownKeys = Object.keys(source);
|
50
|
-
|
51
|
-
if (typeof Object.getOwnPropertySymbols === 'function') {
|
52
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
53
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
54
|
-
}));
|
55
|
-
}
|
56
|
-
|
57
|
-
ownKeys.forEach(function (key) {
|
58
|
-
_defineProperty(target, key, source[key]);
|
59
|
-
});
|
60
|
-
}
|
12
|
+
/**
|
13
|
+
* --------------------------------------------------------------------------
|
14
|
+
* Bootstrap scrollspy.js
|
15
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
|
+
* --------------------------------------------------------------------------
|
17
|
+
*/
|
61
18
|
|
62
|
-
return target;
|
63
|
-
}
|
64
19
|
|
65
20
|
/**
|
66
|
-
* ------------------------------------------------------------------------
|
67
21
|
* Constants
|
68
|
-
* ------------------------------------------------------------------------
|
69
22
|
*/
|
70
23
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
24
|
+
const NAME = 'scrollspy';
|
25
|
+
const DATA_KEY = 'bs.scrollspy';
|
26
|
+
const EVENT_KEY = `.${DATA_KEY}`;
|
27
|
+
const DATA_API_KEY = '.data-api';
|
28
|
+
const EVENT_ACTIVATE = `activate${EVENT_KEY}`;
|
29
|
+
const EVENT_CLICK = `click${EVENT_KEY}`;
|
30
|
+
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`;
|
31
|
+
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
|
32
|
+
const CLASS_NAME_ACTIVE = 'active';
|
33
|
+
const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]';
|
34
|
+
const SELECTOR_TARGET_LINKS = '[href]';
|
35
|
+
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
|
36
|
+
const SELECTOR_NAV_LINKS = '.nav-link';
|
37
|
+
const SELECTOR_NAV_ITEMS = '.nav-item';
|
38
|
+
const SELECTOR_LIST_ITEMS = '.list-group-item';
|
39
|
+
const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`;
|
40
|
+
const SELECTOR_DROPDOWN = '.dropdown';
|
41
|
+
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
|
42
|
+
const Default = {
|
43
|
+
offset: null,
|
44
|
+
// TODO: v6 @deprecated, keep it for backwards compatibility reasons
|
45
|
+
rootMargin: '0px 0px -25%',
|
46
|
+
smoothScroll: false,
|
47
|
+
target: null,
|
48
|
+
threshold: [0.1, 0.5, 1]
|
81
49
|
};
|
82
|
-
|
83
|
-
offset: 'number',
|
84
|
-
|
85
|
-
|
50
|
+
const DefaultType = {
|
51
|
+
offset: '(number|null)',
|
52
|
+
// TODO v6 @deprecated, keep it for backwards compatibility reasons
|
53
|
+
rootMargin: 'string',
|
54
|
+
smoothScroll: 'boolean',
|
55
|
+
target: 'element',
|
56
|
+
threshold: 'array'
|
86
57
|
};
|
87
|
-
var Event = {
|
88
|
-
ACTIVATE: "activate" + EVENT_KEY,
|
89
|
-
SCROLL: "scroll" + EVENT_KEY,
|
90
|
-
LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY
|
91
|
-
};
|
92
|
-
var ClassName = {
|
93
|
-
DROPDOWN_ITEM: 'dropdown-item',
|
94
|
-
DROPDOWN_MENU: 'dropdown-menu',
|
95
|
-
ACTIVE: 'active'
|
96
|
-
};
|
97
|
-
var Selector = {
|
98
|
-
DATA_SPY: '[data-spy="scroll"]',
|
99
|
-
ACTIVE: '.active',
|
100
|
-
NAV_LIST_GROUP: '.nav, .list-group',
|
101
|
-
NAV_LINKS: '.nav-link',
|
102
|
-
NAV_ITEMS: '.nav-item',
|
103
|
-
LIST_ITEMS: '.list-group-item',
|
104
|
-
DROPDOWN: '.dropdown',
|
105
|
-
DROPDOWN_ITEMS: '.dropdown-item',
|
106
|
-
DROPDOWN_TOGGLE: '.dropdown-toggle'
|
107
|
-
};
|
108
|
-
var OffsetMethod = {
|
109
|
-
OFFSET: 'offset',
|
110
|
-
POSITION: 'position'
|
111
|
-
/**
|
112
|
-
* ------------------------------------------------------------------------
|
113
|
-
* Class Definition
|
114
|
-
* ------------------------------------------------------------------------
|
115
|
-
*/
|
116
58
|
|
117
|
-
|
59
|
+
/**
|
60
|
+
* Class definition
|
61
|
+
*/
|
118
62
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
function ScrollSpy(element, config) {
|
123
|
-
var _this = this;
|
63
|
+
class ScrollSpy extends BaseComponent {
|
64
|
+
constructor(element, config) {
|
65
|
+
super(element, config);
|
124
66
|
|
125
|
-
this._element
|
126
|
-
this.
|
127
|
-
this.
|
128
|
-
this.
|
129
|
-
this._offsets = [];
|
130
|
-
this._targets = [];
|
67
|
+
// this._element is the observablesContainer and config.target the menu links wrapper
|
68
|
+
this._targetLinks = new Map();
|
69
|
+
this._observableSections = new Map();
|
70
|
+
this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element;
|
131
71
|
this._activeTarget = null;
|
132
|
-
this.
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
} // Getters
|
140
|
-
|
72
|
+
this._observer = null;
|
73
|
+
this._previousScrollData = {
|
74
|
+
visibleEntryTop: 0,
|
75
|
+
parentScrollTop: 0
|
76
|
+
};
|
77
|
+
this.refresh(); // initialize
|
78
|
+
}
|
141
79
|
|
142
|
-
|
80
|
+
// Getters
|
81
|
+
static get Default() {
|
82
|
+
return Default;
|
83
|
+
}
|
84
|
+
static get DefaultType() {
|
85
|
+
return DefaultType;
|
86
|
+
}
|
87
|
+
static get NAME() {
|
88
|
+
return NAME;
|
89
|
+
}
|
143
90
|
|
144
91
|
// Public
|
145
|
-
|
146
|
-
|
92
|
+
refresh() {
|
93
|
+
this._initializeTargetsAndObservables();
|
94
|
+
this._maybeEnableSmoothScroll();
|
95
|
+
if (this._observer) {
|
96
|
+
this._observer.disconnect();
|
97
|
+
} else {
|
98
|
+
this._observer = this._getNewObserver();
|
99
|
+
}
|
100
|
+
for (const section of this._observableSections.values()) {
|
101
|
+
this._observer.observe(section);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
dispose() {
|
105
|
+
this._observer.disconnect();
|
106
|
+
super.dispose();
|
107
|
+
}
|
147
108
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
this._targets = [];
|
153
|
-
this._scrollHeight = this._getScrollHeight();
|
154
|
-
var targets = [].slice.call(document.querySelectorAll(this._selector));
|
155
|
-
targets.map(function (element) {
|
156
|
-
var target;
|
157
|
-
var targetSelector = Util.getSelectorFromElement(element);
|
109
|
+
// Private
|
110
|
+
_configAfterMerge(config) {
|
111
|
+
// TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case
|
112
|
+
config.target = index_js.getElement(config.target) || document.body;
|
158
113
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
114
|
+
// TODO: v6 Only for backwards compatibility reasons. Use rootMargin only
|
115
|
+
config.rootMargin = config.offset ? `${config.offset}px 0px -30%` : config.rootMargin;
|
116
|
+
if (typeof config.threshold === 'string') {
|
117
|
+
config.threshold = config.threshold.split(',').map(value => Number.parseFloat(value));
|
118
|
+
}
|
119
|
+
return config;
|
120
|
+
}
|
121
|
+
_maybeEnableSmoothScroll() {
|
122
|
+
if (!this._config.smoothScroll) {
|
123
|
+
return;
|
124
|
+
}
|
165
125
|
|
166
|
-
|
167
|
-
|
168
|
-
|
126
|
+
// unregister any previous listeners
|
127
|
+
EventHandler.off(this._config.target, EVENT_CLICK);
|
128
|
+
EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => {
|
129
|
+
const observableSection = this._observableSections.get(event.target.hash);
|
130
|
+
if (observableSection) {
|
131
|
+
event.preventDefault();
|
132
|
+
const root = this._rootElement || window;
|
133
|
+
const height = observableSection.offsetTop - this._element.offsetTop;
|
134
|
+
if (root.scrollTo) {
|
135
|
+
root.scrollTo({
|
136
|
+
top: height,
|
137
|
+
behavior: 'smooth'
|
138
|
+
});
|
139
|
+
return;
|
169
140
|
}
|
170
|
-
}
|
171
141
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
}).sort(function (a, b) {
|
176
|
-
return a[0] - b[0];
|
177
|
-
}).forEach(function (item) {
|
178
|
-
_this2._offsets.push(item[0]);
|
179
|
-
|
180
|
-
_this2._targets.push(item[1]);
|
142
|
+
// Chrome 60 doesn't support `scrollTo`
|
143
|
+
root.scrollTop = height;
|
144
|
+
}
|
181
145
|
});
|
182
|
-
}
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
this.
|
190
|
-
|
191
|
-
this._offsets = null;
|
192
|
-
this._targets = null;
|
193
|
-
this._activeTarget = null;
|
194
|
-
this._scrollHeight = null;
|
195
|
-
} // Private
|
196
|
-
;
|
197
|
-
|
198
|
-
_proto._getConfig = function _getConfig(config) {
|
199
|
-
config = _objectSpread({}, Default, typeof config === 'object' && config ? config : {});
|
200
|
-
|
201
|
-
if (typeof config.target !== 'string') {
|
202
|
-
var id = $(config.target).attr('id');
|
146
|
+
}
|
147
|
+
_getNewObserver() {
|
148
|
+
const options = {
|
149
|
+
root: this._rootElement,
|
150
|
+
threshold: this._config.threshold,
|
151
|
+
rootMargin: this._config.rootMargin
|
152
|
+
};
|
153
|
+
return new IntersectionObserver(entries => this._observerCallback(entries), options);
|
154
|
+
}
|
203
155
|
|
204
|
-
|
205
|
-
|
206
|
-
|
156
|
+
// The logic of selection
|
157
|
+
_observerCallback(entries) {
|
158
|
+
const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`);
|
159
|
+
const activate = entry => {
|
160
|
+
this._previousScrollData.visibleEntryTop = entry.target.offsetTop;
|
161
|
+
this._process(targetElement(entry));
|
162
|
+
};
|
163
|
+
const parentScrollTop = (this._rootElement || document.documentElement).scrollTop;
|
164
|
+
const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop;
|
165
|
+
this._previousScrollData.parentScrollTop = parentScrollTop;
|
166
|
+
for (const entry of entries) {
|
167
|
+
if (!entry.isIntersecting) {
|
168
|
+
this._activeTarget = null;
|
169
|
+
this._clearActiveClass(targetElement(entry));
|
170
|
+
continue;
|
171
|
+
}
|
172
|
+
const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop;
|
173
|
+
// if we are scrolling down, pick the bigger offsetTop
|
174
|
+
if (userScrollsDown && entryIsLowerThanPrevious) {
|
175
|
+
activate(entry);
|
176
|
+
// if parent isn't scrolled, let's keep the first visible item, breaking the iteration
|
177
|
+
if (!parentScrollTop) {
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
continue;
|
207
181
|
}
|
208
182
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
return config;
|
214
|
-
};
|
215
|
-
|
216
|
-
_proto._getScrollTop = function _getScrollTop() {
|
217
|
-
return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
|
218
|
-
};
|
219
|
-
|
220
|
-
_proto._getScrollHeight = function _getScrollHeight() {
|
221
|
-
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
|
222
|
-
};
|
223
|
-
|
224
|
-
_proto._getOffsetHeight = function _getOffsetHeight() {
|
225
|
-
return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
|
226
|
-
};
|
227
|
-
|
228
|
-
_proto._process = function _process() {
|
229
|
-
var scrollTop = this._getScrollTop() + this._config.offset;
|
230
|
-
|
231
|
-
var scrollHeight = this._getScrollHeight();
|
232
|
-
|
233
|
-
var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
|
234
|
-
|
235
|
-
if (this._scrollHeight !== scrollHeight) {
|
236
|
-
this.refresh();
|
183
|
+
// if we are scrolling up, pick the smallest offsetTop
|
184
|
+
if (!userScrollsDown && !entryIsLowerThanPrevious) {
|
185
|
+
activate(entry);
|
186
|
+
}
|
237
187
|
}
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
188
|
+
}
|
189
|
+
_initializeTargetsAndObservables() {
|
190
|
+
this._targetLinks = new Map();
|
191
|
+
this._observableSections = new Map();
|
192
|
+
const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target);
|
193
|
+
for (const anchor of targetLinks) {
|
194
|
+
// ensure that the anchor has an id and is not disabled
|
195
|
+
if (!anchor.hash || index_js.isDisabled(anchor)) {
|
196
|
+
continue;
|
244
197
|
}
|
198
|
+
const observableSection = SelectorEngine.findOne(decodeURI(anchor.hash), this._element);
|
245
199
|
|
246
|
-
|
200
|
+
// ensure that the observableSection exists & is visible
|
201
|
+
if (index_js.isVisible(observableSection)) {
|
202
|
+
this._targetLinks.set(decodeURI(anchor.hash), anchor);
|
203
|
+
this._observableSections.set(anchor.hash, observableSection);
|
204
|
+
}
|
247
205
|
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
this._clear();
|
253
|
-
|
206
|
+
}
|
207
|
+
_process(target) {
|
208
|
+
if (this._activeTarget === target) {
|
254
209
|
return;
|
255
210
|
}
|
256
|
-
|
257
|
-
var offsetLength = this._offsets.length;
|
258
|
-
|
259
|
-
for (var i = offsetLength; i--;) {
|
260
|
-
var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
|
261
|
-
|
262
|
-
if (isActiveTarget) {
|
263
|
-
this._activate(this._targets[i]);
|
264
|
-
}
|
265
|
-
}
|
266
|
-
};
|
267
|
-
|
268
|
-
_proto._activate = function _activate(target) {
|
211
|
+
this._clearActiveClass(this._config.target);
|
269
212
|
this._activeTarget = target;
|
270
|
-
|
271
|
-
this.
|
272
|
-
|
273
|
-
|
274
|
-
return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
|
213
|
+
target.classList.add(CLASS_NAME_ACTIVE);
|
214
|
+
this._activateParents(target);
|
215
|
+
EventHandler.trigger(this._element, EVENT_ACTIVATE, {
|
216
|
+
relatedTarget: target
|
275
217
|
});
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
if (
|
280
|
-
|
281
|
-
|
282
|
-
}
|
283
|
-
|
284
|
-
|
218
|
+
}
|
219
|
+
_activateParents(target) {
|
220
|
+
// Activate dropdown parents
|
221
|
+
if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
|
222
|
+
SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
|
223
|
+
return;
|
224
|
+
}
|
225
|
+
for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) {
|
226
|
+
// Set triggered links parents as active
|
285
227
|
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
$link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
|
228
|
+
for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) {
|
229
|
+
item.classList.add(CLASS_NAME_ACTIVE);
|
230
|
+
}
|
290
231
|
}
|
232
|
+
}
|
233
|
+
_clearActiveClass(parent) {
|
234
|
+
parent.classList.remove(CLASS_NAME_ACTIVE);
|
235
|
+
const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE}`, parent);
|
236
|
+
for (const node of activeNodes) {
|
237
|
+
node.classList.remove(CLASS_NAME_ACTIVE);
|
238
|
+
}
|
239
|
+
}
|
291
240
|
|
292
|
-
|
293
|
-
|
294
|
-
});
|
295
|
-
};
|
296
|
-
|
297
|
-
_proto._clear = function _clear() {
|
298
|
-
[].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
|
299
|
-
return node.classList.contains(ClassName.ACTIVE);
|
300
|
-
}).forEach(function (node) {
|
301
|
-
return node.classList.remove(ClassName.ACTIVE);
|
302
|
-
});
|
303
|
-
} // Static
|
304
|
-
;
|
305
|
-
|
306
|
-
ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
|
241
|
+
// Static
|
242
|
+
static jQueryInterface(config) {
|
307
243
|
return this.each(function () {
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
if (!data) {
|
313
|
-
data = new ScrollSpy(this, _config);
|
314
|
-
$(this).data(DATA_KEY, data);
|
244
|
+
const data = ScrollSpy.getOrCreateInstance(this, config);
|
245
|
+
if (typeof config !== 'string') {
|
246
|
+
return;
|
315
247
|
}
|
316
|
-
|
317
|
-
|
318
|
-
if (typeof data[config] === 'undefined') {
|
319
|
-
throw new TypeError("No method named \"" + config + "\"");
|
320
|
-
}
|
321
|
-
|
322
|
-
data[config]();
|
248
|
+
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
|
249
|
+
throw new TypeError(`No method named "${config}"`);
|
323
250
|
}
|
251
|
+
data[config]();
|
324
252
|
});
|
325
|
-
}
|
326
|
-
|
327
|
-
_createClass(ScrollSpy, null, [{
|
328
|
-
key: "VERSION",
|
329
|
-
get: function get() {
|
330
|
-
return VERSION;
|
331
|
-
}
|
332
|
-
}, {
|
333
|
-
key: "Default",
|
334
|
-
get: function get() {
|
335
|
-
return Default;
|
336
|
-
}
|
337
|
-
}]);
|
253
|
+
}
|
254
|
+
}
|
338
255
|
|
339
|
-
return ScrollSpy;
|
340
|
-
}();
|
341
256
|
/**
|
342
|
-
*
|
343
|
-
* Data Api implementation
|
344
|
-
* ------------------------------------------------------------------------
|
257
|
+
* Data API implementation
|
345
258
|
*/
|
346
259
|
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
var scrollSpysLength = scrollSpys.length;
|
351
|
-
|
352
|
-
for (var i = scrollSpysLength; i--;) {
|
353
|
-
var $spy = $(scrollSpys[i]);
|
354
|
-
|
355
|
-
ScrollSpy._jQueryInterface.call($spy, $spy.data());
|
260
|
+
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
|
261
|
+
for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) {
|
262
|
+
ScrollSpy.getOrCreateInstance(spy);
|
356
263
|
}
|
357
264
|
});
|
265
|
+
|
358
266
|
/**
|
359
|
-
* ------------------------------------------------------------------------
|
360
267
|
* jQuery
|
361
|
-
* ------------------------------------------------------------------------
|
362
268
|
*/
|
363
269
|
|
364
|
-
|
365
|
-
$.fn[NAME].Constructor = ScrollSpy;
|
366
|
-
|
367
|
-
$.fn[NAME].noConflict = function () {
|
368
|
-
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
369
|
-
return ScrollSpy._jQueryInterface;
|
370
|
-
};
|
270
|
+
index_js.defineJQueryPlugin(ScrollSpy);
|
371
271
|
|
372
272
|
return ScrollSpy;
|
373
273
|
|