diff options
author | Mario <mario@mariovavti.com> | 2020-11-27 08:04:00 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-11-27 08:04:00 +0000 |
commit | f4bb7bcbff3770387c2fecfa91ce4a60b916a474 (patch) | |
tree | ea007e664d435f1f3d63c87bfe1600484d2bd46c /vendor/twbs/bootstrap/js/src/scrollspy.js | |
parent | 07e5b8295ea9d342f66d8119d88bd58124b548e6 (diff) | |
download | volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.gz volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.bz2 volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.zip |
update composer libs
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/scrollspy.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/src/scrollspy.js | 120 |
1 files changed, 62 insertions, 58 deletions
diff --git a/vendor/twbs/bootstrap/js/src/scrollspy.js b/vendor/twbs/bootstrap/js/src/scrollspy.js index 78b5e7191..7daa51e86 100644 --- a/vendor/twbs/bootstrap/js/src/scrollspy.js +++ b/vendor/twbs/bootstrap/js/src/scrollspy.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.5.2): scrollspy.js + * Bootstrap (v4.5.3): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -14,42 +14,42 @@ import Util from './util' * ------------------------------------------------------------------------ */ -const NAME = 'scrollspy' -const VERSION = '4.5.2' -const DATA_KEY = 'bs.scrollspy' -const EVENT_KEY = `.${DATA_KEY}` -const DATA_API_KEY = '.data-api' +const NAME = 'scrollspy' +const VERSION = '4.5.3' +const DATA_KEY = 'bs.scrollspy' +const EVENT_KEY = `.${DATA_KEY}` +const DATA_API_KEY = '.data-api' const JQUERY_NO_CONFLICT = $.fn[NAME] const Default = { - offset : 10, - method : 'auto', - target : '' + offset: 10, + method: 'auto', + target: '' } const DefaultType = { - offset : 'number', - method : 'string', - target : '(string|element)' + offset: 'number', + method: 'string', + target: '(string|element)' } -const EVENT_ACTIVATE = `activate${EVENT_KEY}` -const EVENT_SCROLL = `scroll${EVENT_KEY}` +const EVENT_ACTIVATE = `activate${EVENT_KEY}` +const EVENT_SCROLL = `scroll${EVENT_KEY}` const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}` const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item' -const CLASS_NAME_ACTIVE = 'active' - -const SELECTOR_DATA_SPY = '[data-spy="scroll"]' -const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group' -const SELECTOR_NAV_LINKS = '.nav-link' -const SELECTOR_NAV_ITEMS = '.nav-item' -const SELECTOR_LIST_ITEMS = '.list-group-item' -const SELECTOR_DROPDOWN = '.dropdown' -const SELECTOR_DROPDOWN_ITEMS = '.dropdown-item' +const CLASS_NAME_ACTIVE = 'active' + +const SELECTOR_DATA_SPY = '[data-spy="scroll"]' +const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group' +const SELECTOR_NAV_LINKS = '.nav-link' +const SELECTOR_NAV_ITEMS = '.nav-item' +const SELECTOR_LIST_ITEMS = '.list-group-item' +const SELECTOR_DROPDOWN = '.dropdown' +const SELECTOR_DROPDOWN_ITEMS = '.dropdown-item' const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle' -const METHOD_OFFSET = 'offset' +const METHOD_OFFSET = 'offset' const METHOD_POSITION = 'position' /** @@ -60,18 +60,18 @@ const METHOD_POSITION = 'position' class ScrollSpy { constructor(element, config) { - this._element = element + this._element = element this._scrollElement = element.tagName === 'BODY' ? window : element - this._config = this._getConfig(config) - this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS},` + + this._config = this._getConfig(config) + this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS},` + `${this._config.target} ${SELECTOR_LIST_ITEMS},` + `${this._config.target} ${SELECTOR_DROPDOWN_ITEMS}` - this._offsets = [] - this._targets = [] - this._activeTarget = null - this._scrollHeight = 0 + this._offsets = [] + this._targets = [] + this._activeTarget = null + this._scrollHeight = 0 - $(this._scrollElement).on(EVENT_SCROLL, (event) => this._process(event)) + $(this._scrollElement).on(EVENT_SCROLL, event => this._process(event)) this.refresh() this._process() @@ -90,14 +90,14 @@ class ScrollSpy { // Public refresh() { - const autoMethod = this._scrollElement === this._scrollElement.window - ? METHOD_OFFSET : METHOD_POSITION + const autoMethod = this._scrollElement === this._scrollElement.window ? + METHOD_OFFSET : METHOD_POSITION - const offsetMethod = this._config.method === 'auto' - ? autoMethod : this._config.method + const offsetMethod = this._config.method === 'auto' ? + autoMethod : this._config.method - const offsetBase = offsetMethod === METHOD_POSITION - ? this._getScrollTop() : 0 + const offsetBase = offsetMethod === METHOD_POSITION ? + this._getScrollTop() : 0 this._offsets = [] this._targets = [] @@ -107,7 +107,7 @@ class ScrollSpy { const targets = [].slice.call(document.querySelectorAll(this._selector)) targets - .map((element) => { + .map(element => { let target const targetSelector = Util.getSelectorFromElement(element) @@ -125,11 +125,12 @@ class ScrollSpy { ] } } + return null }) - .filter((item) => item) + .filter(item => item) .sort((a, b) => a[0] - b[0]) - .forEach((item) => { + .forEach(item => { this._offsets.push(item[0]) this._targets.push(item[1]) }) @@ -139,14 +140,14 @@ class ScrollSpy { $.removeData(this._element, DATA_KEY) $(this._scrollElement).off(EVENT_KEY) - this._element = null + this._element = null this._scrollElement = null - this._config = null - this._selector = null - this._offsets = null - this._targets = null - this._activeTarget = null - this._scrollHeight = null + this._config = null + this._selector = null + this._offsets = null + this._targets = null + this._activeTarget = null + this._scrollHeight = null } // Private @@ -154,7 +155,7 @@ class ScrollSpy { _getConfig(config) { config = { ...Default, - ...typeof config === 'object' && config ? config : {} + ...(typeof config === 'object' && config ? config : {}) } if (typeof config.target !== 'string' && Util.isElement(config.target)) { @@ -163,6 +164,7 @@ class ScrollSpy { id = Util.getUID(NAME) $(config.target).attr('id', id) } + config.target = `#${id}` } @@ -172,8 +174,8 @@ class ScrollSpy { } _getScrollTop() { - return this._scrollElement === window - ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop + return this._scrollElement === window ? + this._scrollElement.pageYOffset : this._scrollElement.scrollTop } _getScrollHeight() { @@ -184,14 +186,14 @@ class ScrollSpy { } _getOffsetHeight() { - return this._scrollElement === window - ? window.innerHeight : this._scrollElement.getBoundingClientRect().height + return this._scrollElement === window ? + window.innerHeight : this._scrollElement.getBoundingClientRect().height } _process() { - const scrollTop = this._getScrollTop() + this._config.offset + const scrollTop = this._getScrollTop() + this._config.offset const scrollHeight = this._getScrollHeight() - const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight() + const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight() if (this._scrollHeight !== scrollHeight) { this.refresh() @@ -203,6 +205,7 @@ class ScrollSpy { if (this._activeTarget !== target) { this._activate(target) } + return } @@ -231,7 +234,7 @@ class ScrollSpy { const queries = this._selector .split(',') - .map((selector) => `${selector}[data-target="${target}"],${selector}[href="${target}"]`) + .map(selector => `${selector}[data-target="${target}"],${selector}[href="${target}"]`) const $link = $([].slice.call(document.querySelectorAll(queries.join(',')))) @@ -262,8 +265,8 @@ class ScrollSpy { _clear() { [].slice.call(document.querySelectorAll(this._selector)) - .filter((node) => node.classList.contains(CLASS_NAME_ACTIVE)) - .forEach((node) => node.classList.remove(CLASS_NAME_ACTIVE)) + .filter(node => node.classList.contains(CLASS_NAME_ACTIVE)) + .forEach(node => node.classList.remove(CLASS_NAME_ACTIVE)) } // Static @@ -282,6 +285,7 @@ class ScrollSpy { if (typeof data[config] === 'undefined') { throw new TypeError(`No method named "${config}"`) } + data[config]() } }) |