aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/dist/scrollspy.js
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/scrollspy.js')
-rw-r--r--vendor/twbs/bootstrap/js/dist/scrollspy.js92
1 files changed, 39 insertions, 53 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/scrollspy.js b/vendor/twbs/bootstrap/js/dist/scrollspy.js
index 067ca0c59..c73fa002a 100644
--- a/vendor/twbs/bootstrap/js/dist/scrollspy.js
+++ b/vendor/twbs/bootstrap/js/dist/scrollspy.js
@@ -1,6 +1,6 @@
/*!
- * Bootstrap scrollspy.js v4.4.1 (https://getbootstrap.com/)
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Bootstrap scrollspy.js v4.5.0 (https://getbootstrap.com/)
+ * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
(function (global, factory) {
@@ -9,8 +9,8 @@
(global = global || self, global.ScrollSpy = factory(global.jQuery, global.Util));
}(this, (function ($, Util) { 'use strict';
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
+ $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
+ Util = Util && Object.prototype.hasOwnProperty.call(Util, 'default') ? Util['default'] : Util;
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
@@ -84,7 +84,7 @@
*/
var NAME = 'scrollspy';
- var VERSION = '4.4.1';
+ var VERSION = '4.5.0';
var DATA_KEY = 'bs.scrollspy';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -99,52 +99,40 @@
method: 'string',
target: '(string|element)'
};
- var Event = {
- ACTIVATE: "activate" + EVENT_KEY,
- SCROLL: "scroll" + EVENT_KEY,
- LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY
- };
- var ClassName = {
- DROPDOWN_ITEM: 'dropdown-item',
- DROPDOWN_MENU: 'dropdown-menu',
- ACTIVE: 'active'
- };
- var Selector = {
- DATA_SPY: '[data-spy="scroll"]',
- ACTIVE: '.active',
- NAV_LIST_GROUP: '.nav, .list-group',
- NAV_LINKS: '.nav-link',
- NAV_ITEMS: '.nav-item',
- LIST_ITEMS: '.list-group-item',
- DROPDOWN: '.dropdown',
- DROPDOWN_ITEMS: '.dropdown-item',
- DROPDOWN_TOGGLE: '.dropdown-toggle'
- };
- var OffsetMethod = {
- OFFSET: 'offset',
- POSITION: 'position'
- };
+ var EVENT_ACTIVATE = "activate" + EVENT_KEY;
+ var EVENT_SCROLL = "scroll" + EVENT_KEY;
+ var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
+ var CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item';
+ var CLASS_NAME_ACTIVE = 'active';
+ var SELECTOR_DATA_SPY = '[data-spy="scroll"]';
+ var SELECTOR_NAV_LIST_GROUP = '.nav, .list-group';
+ var SELECTOR_NAV_LINKS = '.nav-link';
+ var SELECTOR_NAV_ITEMS = '.nav-item';
+ var SELECTOR_LIST_ITEMS = '.list-group-item';
+ var SELECTOR_DROPDOWN = '.dropdown';
+ var SELECTOR_DROPDOWN_ITEMS = '.dropdown-item';
+ var SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
+ var METHOD_OFFSET = 'offset';
+ var METHOD_POSITION = 'position';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
- var ScrollSpy =
- /*#__PURE__*/
- function () {
+ var ScrollSpy = /*#__PURE__*/function () {
function ScrollSpy(element, config) {
var _this = this;
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.target + " " + Selector.LIST_ITEMS + ",") + (this._config.target + " " + Selector.DROPDOWN_ITEMS);
+ 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._scrollElement).on(Event.SCROLL, function (event) {
+ $(this._scrollElement).on(EVENT_SCROLL, function (event) {
return _this._process(event);
});
this.refresh();
@@ -159,9 +147,9 @@
_proto.refresh = function refresh() {
var _this2 = this;
- var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
+ var autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION;
var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
- var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
+ var offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0;
this._offsets = [];
this._targets = [];
this._scrollHeight = this._getScrollHeight();
@@ -210,9 +198,9 @@
;
_proto._getConfig = function _getConfig(config) {
- config = _objectSpread2({}, Default, {}, typeof config === 'object' && config ? config : {});
+ config = _objectSpread2(_objectSpread2({}, Default), typeof config === 'object' && config ? config : {});
- if (typeof config.target !== 'string') {
+ if (typeof config.target !== 'string' && Util.isElement(config.target)) {
var id = $(config.target).attr('id');
if (!id) {
@@ -268,9 +256,7 @@
return;
}
- var offsetLength = this._offsets.length;
-
- for (var i = offsetLength; i--;) {
+ for (var i = this._offsets.length; i--;) {
var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
if (isActiveTarget) {
@@ -290,29 +276,29 @@
var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
- if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
- $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
- $link.addClass(ClassName.ACTIVE);
+ if ($link.hasClass(CLASS_NAME_DROPDOWN_ITEM)) {
+ $link.closest(SELECTOR_DROPDOWN).find(SELECTOR_DROPDOWN_TOGGLE).addClass(CLASS_NAME_ACTIVE);
+ $link.addClass(CLASS_NAME_ACTIVE);
} else {
// Set triggered link as active
- $link.addClass(ClassName.ACTIVE); // Set triggered links parents as active
+ $link.addClass(CLASS_NAME_ACTIVE); // Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
- $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_LINKS + ", " + Selector.LIST_ITEMS).addClass(ClassName.ACTIVE); // Handle special case when .nav-link is inside .nav-item
+ $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_LINKS + ", " + SELECTOR_LIST_ITEMS).addClass(CLASS_NAME_ACTIVE); // Handle special case when .nav-link is inside .nav-item
- $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
+ $link.parents(SELECTOR_NAV_LIST_GROUP).prev(SELECTOR_NAV_ITEMS).children(SELECTOR_NAV_LINKS).addClass(CLASS_NAME_ACTIVE);
}
- $(this._scrollElement).trigger(Event.ACTIVATE, {
+ $(this._scrollElement).trigger(EVENT_ACTIVATE, {
relatedTarget: target
});
};
_proto._clear = function _clear() {
[].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
- return node.classList.contains(ClassName.ACTIVE);
+ return node.classList.contains(CLASS_NAME_ACTIVE);
}).forEach(function (node) {
- return node.classList.remove(ClassName.ACTIVE);
+ return node.classList.remove(CLASS_NAME_ACTIVE);
});
} // Static
;
@@ -359,8 +345,8 @@
*/
- $(window).on(Event.LOAD_DATA_API, function () {
- var scrollSpys = [].slice.call(document.querySelectorAll(Selector.DATA_SPY));
+ $(window).on(EVENT_LOAD_DATA_API, function () {
+ var scrollSpys = [].slice.call(document.querySelectorAll(SELECTOR_DATA_SPY));
var scrollSpysLength = scrollSpys.length;
for (var i = scrollSpysLength; i--;) {