aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/scrollspy.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
committerMario <mario@mariovavti.com>2021-10-08 12:24:19 +0000
commite6dac085cb1d601da1fc63bfd59d811612fa6ef4 (patch)
treef5b704b613c9c8d347857b4e7f8dd0b19cdd7df3 /vendor/twbs/bootstrap/js/dist/scrollspy.js
parentf5f357060bf0ebcb0b8352519375953d993437e7 (diff)
downloadvolse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.gz
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.tar.bz2
volse-hubzilla-e6dac085cb1d601da1fc63bfd59d811612fa6ef4.zip
update composer libs
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/scrollspy.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/scrollspy.js113
1 files changed, 47 insertions, 66 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/scrollspy.js b/vendor/twbs/bootstrap/js/dist/scrollspy.js
index 04f9b77e2..c6f94ca06 100644
--- a/vendor/twbs/bootstrap/js/dist/scrollspy.js
+++ b/vendor/twbs/bootstrap/js/dist/scrollspy.js
@@ -1,30 +1,28 @@
/*!
- * Bootstrap scrollspy.js v5.0.2 (https://getbootstrap.com/)
+ * Bootstrap scrollspy.js v5.1.2 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
- typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/event-handler', './dom/manipulator', './base-component'], factory) :
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.SelectorEngine, global.EventHandler, global.Manipulator, global.Base));
-}(this, (function (SelectorEngine, EventHandler, Manipulator, BaseComponent) { 'use strict';
+ 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')) :
+ typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
+})(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
- var SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
- var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
- var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
- var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
+ const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
+ const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
+ const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
+ const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.2): util/index.js
+ * Bootstrap (v5.1.2): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
- const MAX_UID = 1000000;
-
const toType = obj => {
if (obj === null || obj === undefined) {
return `${obj}`;
@@ -32,20 +30,6 @@
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
};
- /**
- * --------------------------------------------------------------------------
- * Public Util Api
- * --------------------------------------------------------------------------
- */
-
-
- const getUID = prefix => {
- do {
- prefix += Math.floor(Math.random() * MAX_UID);
- } while (document.getElementById(prefix));
-
- return prefix;
- };
const getSelector = element => {
let selector = element.getAttribute('data-bs-target');
@@ -93,6 +77,19 @@
return typeof obj.nodeType !== 'undefined';
};
+ const getElement = obj => {
+ if (isElement(obj)) {
+ // it's a jQuery object or a node element
+ return obj.jquery ? obj[0] : obj;
+ }
+
+ if (typeof obj === 'string' && obj.length > 0) {
+ return document.querySelector(obj);
+ }
+
+ return null;
+ };
+
const typeCheckConfig = (componentName, config, configTypes) => {
Object.keys(configTypes).forEach(property => {
const expectedTypes = configTypes[property];
@@ -155,7 +152,7 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v5.0.2): scrollspy.js
+ * Bootstrap (v5.1.2): scrollspy.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -189,6 +186,7 @@
const SELECTOR_NAV_LINKS = '.nav-link';
const SELECTOR_NAV_ITEMS = '.nav-item';
const SELECTOR_LIST_ITEMS = '.list-group-item';
+ const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`;
const SELECTOR_DROPDOWN = '.dropdown';
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
const METHOD_OFFSET = 'offset';
@@ -199,17 +197,16 @@
* ------------------------------------------------------------------------
*/
- class ScrollSpy extends BaseComponent__default['default'] {
+ class ScrollSpy extends BaseComponent__default.default {
constructor(element, config) {
super(element);
this._scrollElement = this._element.tagName === 'BODY' ? window : this._element;
this._config = this._getConfig(config);
- this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`;
this._offsets = [];
this._targets = [];
this._activeTarget = null;
this._scrollHeight = 0;
- EventHandler__default['default'].on(this._scrollElement, EVENT_SCROLL, () => this._process());
+ EventHandler__default.default.on(this._scrollElement, EVENT_SCROLL, () => this._process());
this.refresh();
this._process();
@@ -232,16 +229,16 @@
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
- const targets = SelectorEngine__default['default'].find(this._selector);
+ const targets = SelectorEngine__default.default.find(SELECTOR_LINK_ITEMS, this._config.target);
targets.map(element => {
const targetSelector = getSelectorFromElement(element);
- const target = targetSelector ? SelectorEngine__default['default'].findOne(targetSelector) : null;
+ const target = targetSelector ? SelectorEngine__default.default.findOne(targetSelector) : null;
if (target) {
const targetBCR = target.getBoundingClientRect();
if (targetBCR.width || targetBCR.height) {
- return [Manipulator__default['default'][offsetMethod](target).top + offsetBase, targetSelector];
+ return [Manipulator__default.default[offsetMethod](target).top + offsetBase, targetSelector];
}
}
@@ -254,30 +251,17 @@
}
dispose() {
- EventHandler__default['default'].off(this._scrollElement, EVENT_KEY);
+ EventHandler__default.default.off(this._scrollElement, EVENT_KEY);
super.dispose();
} // Private
_getConfig(config) {
config = { ...Default,
- ...Manipulator__default['default'].getDataAttributes(this._element),
+ ...Manipulator__default.default.getDataAttributes(this._element),
...(typeof config === 'object' && config ? config : {})
};
-
- if (typeof config.target !== 'string' && isElement(config.target)) {
- let {
- id
- } = config.target;
-
- if (!id) {
- id = getUID(NAME);
- config.target.id = id;
- }
-
- config.target = `#${id}`;
- }
-
+ config.target = getElement(config.target) || document.documentElement;
typeCheckConfig(NAME, config, DefaultType);
return config;
}
@@ -337,34 +321,31 @@
this._clear();
- const queries = this._selector.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
-
- const link = SelectorEngine__default['default'].findOne(queries.join(','));
+ const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`);
+ const link = SelectorEngine__default.default.findOne(queries.join(','), this._config.target);
+ link.classList.add(CLASS_NAME_ACTIVE);
if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) {
- SelectorEngine__default['default'].findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
- link.classList.add(CLASS_NAME_ACTIVE);
+ SelectorEngine__default.default.findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE);
} else {
- // Set triggered link as active
- link.classList.add(CLASS_NAME_ACTIVE);
- SelectorEngine__default['default'].parents(link, SELECTOR_NAV_LIST_GROUP).forEach(listGroup => {
+ SelectorEngine__default.default.parents(link, SELECTOR_NAV_LIST_GROUP).forEach(listGroup => {
// Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
- 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
+ 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
- SelectorEngine__default['default'].prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => {
- SelectorEngine__default['default'].children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE));
+ SelectorEngine__default.default.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => {
+ SelectorEngine__default.default.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE));
});
});
}
- EventHandler__default['default'].trigger(this._scrollElement, EVENT_ACTIVATE, {
+ EventHandler__default.default.trigger(this._scrollElement, EVENT_ACTIVATE, {
relatedTarget: target
});
}
_clear() {
- SelectorEngine__default['default'].find(this._selector).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE));
+ SelectorEngine__default.default.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE));
} // Static
@@ -392,8 +373,8 @@
*/
- EventHandler__default['default'].on(window, EVENT_LOAD_DATA_API, () => {
- SelectorEngine__default['default'].find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy));
+ EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => {
+ SelectorEngine__default.default.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy));
});
/**
* ------------------------------------------------------------------------
@@ -406,5 +387,5 @@
return ScrollSpy;
-})));
+}));
//# sourceMappingURL=scrollspy.js.map