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.js504
1 files changed, 250 insertions, 254 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/scrollspy.js b/vendor/twbs/bootstrap/js/dist/scrollspy.js
index 177369bb2..7949b9f33 100644
--- a/vendor/twbs/bootstrap/js/dist/scrollspy.js
+++ b/vendor/twbs/bootstrap/js/dist/scrollspy.js
@@ -1,8 +1,13 @@
+/*!
+ * Bootstrap scrollspy.js v4.3.1 (https://getbootstrap.com/)
+ * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
- (global.ScrollSpy = factory(global.jQuery,global.Util));
-}(this, (function ($,Util) { 'use strict';
+ (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;
@@ -58,322 +63,313 @@
}
/**
- * --------------------------------------------------------------------------
- * Bootstrap (v4.1.3): scrollspy.js
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * --------------------------------------------------------------------------
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
*/
- var ScrollSpy = function ($$$1) {
+ var NAME = 'scrollspy';
+ var VERSION = '4.3.1';
+ var DATA_KEY = 'bs.scrollspy';
+ var EVENT_KEY = "." + DATA_KEY;
+ var DATA_API_KEY = '.data-api';
+ var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var Default = {
+ offset: 10,
+ method: 'auto',
+ target: ''
+ };
+ var DefaultType = {
+ offset: 'number',
+ 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'
/**
* ------------------------------------------------------------------------
- * Constants
+ * Class Definition
* ------------------------------------------------------------------------
*/
- var NAME = 'scrollspy';
- var VERSION = '4.1.3';
- var DATA_KEY = 'bs.scrollspy';
- var EVENT_KEY = "." + DATA_KEY;
- var DATA_API_KEY = '.data-api';
- var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
- var Default = {
- offset: 10,
- method: 'auto',
- target: ''
- };
- var DefaultType = {
- offset: 'number',
- 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'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
- };
-
- 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._offsets = [];
- this._targets = [];
- this._activeTarget = null;
- this._scrollHeight = 0;
- $$$1(this._scrollElement).on(Event.SCROLL, function (event) {
- return _this._process(event);
- });
- this.refresh();
+ };
+
+ 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._offsets = [];
+ this._targets = [];
+ this._activeTarget = null;
+ this._scrollHeight = 0;
+ $(this._scrollElement).on(Event.SCROLL, function (event) {
+ return _this._process(event);
+ });
+ this.refresh();
- this._process();
- } // Getters
+ this._process();
+ } // Getters
- var _proto = ScrollSpy.prototype;
+ var _proto = ScrollSpy.prototype;
- // Public
- _proto.refresh = function refresh() {
- var _this2 = this;
+ // Public
+ _proto.refresh = function refresh() {
+ var _this2 = this;
- var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
- var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
- var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
- this._offsets = [];
- this._targets = [];
- this._scrollHeight = this._getScrollHeight();
- var targets = [].slice.call(document.querySelectorAll(this._selector));
- targets.map(function (element) {
- var target;
- var targetSelector = Util.getSelectorFromElement(element);
+ var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
+ var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
+ var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
+ this._offsets = [];
+ this._targets = [];
+ this._scrollHeight = this._getScrollHeight();
+ var targets = [].slice.call(document.querySelectorAll(this._selector));
+ targets.map(function (element) {
+ var target;
+ var targetSelector = Util.getSelectorFromElement(element);
- if (targetSelector) {
- target = document.querySelector(targetSelector);
- }
+ if (targetSelector) {
+ target = document.querySelector(targetSelector);
+ }
- if (target) {
- var targetBCR = target.getBoundingClientRect();
+ if (target) {
+ var targetBCR = target.getBoundingClientRect();
- if (targetBCR.width || targetBCR.height) {
- // TODO (fat): remove sketch reliance on jQuery position/offset
- return [$$$1(target)[offsetMethod]().top + offsetBase, targetSelector];
- }
+ if (targetBCR.width || targetBCR.height) {
+ // TODO (fat): remove sketch reliance on jQuery position/offset
+ return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
}
+ }
- return null;
- }).filter(function (item) {
- return item;
- }).sort(function (a, b) {
- return a[0] - b[0];
- }).forEach(function (item) {
- _this2._offsets.push(item[0]);
-
- _this2._targets.push(item[1]);
- });
- };
-
- _proto.dispose = function dispose() {
- $$$1.removeData(this._element, DATA_KEY);
- $$$1(this._scrollElement).off(EVENT_KEY);
- this._element = null;
- this._scrollElement = null;
- this._config = null;
- this._selector = null;
- this._offsets = null;
- this._targets = null;
- this._activeTarget = null;
- this._scrollHeight = null;
- }; // Private
-
-
- _proto._getConfig = function _getConfig(config) {
- config = _objectSpread({}, Default, typeof config === 'object' && config ? config : {});
-
- if (typeof config.target !== 'string') {
- var id = $$$1(config.target).attr('id');
+ return null;
+ }).filter(function (item) {
+ return item;
+ }).sort(function (a, b) {
+ return a[0] - b[0];
+ }).forEach(function (item) {
+ _this2._offsets.push(item[0]);
- if (!id) {
- id = Util.getUID(NAME);
- $$$1(config.target).attr('id', id);
- }
+ _this2._targets.push(item[1]);
+ });
+ };
- config.target = "#" + id;
+ _proto.dispose = function dispose() {
+ $.removeData(this._element, DATA_KEY);
+ $(this._scrollElement).off(EVENT_KEY);
+ this._element = null;
+ this._scrollElement = null;
+ this._config = null;
+ this._selector = null;
+ this._offsets = null;
+ this._targets = null;
+ this._activeTarget = null;
+ this._scrollHeight = null;
+ } // Private
+ ;
+
+ _proto._getConfig = function _getConfig(config) {
+ config = _objectSpread({}, Default, typeof config === 'object' && config ? config : {});
+
+ if (typeof config.target !== 'string') {
+ var id = $(config.target).attr('id');
+
+ if (!id) {
+ id = Util.getUID(NAME);
+ $(config.target).attr('id', id);
}
- Util.typeCheckConfig(NAME, config, DefaultType);
- return config;
- };
+ config.target = "#" + id;
+ }
- _proto._getScrollTop = function _getScrollTop() {
- return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
- };
+ Util.typeCheckConfig(NAME, config, DefaultType);
+ return config;
+ };
- _proto._getScrollHeight = function _getScrollHeight() {
- return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
- };
+ _proto._getScrollTop = function _getScrollTop() {
+ return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
+ };
- _proto._getOffsetHeight = function _getOffsetHeight() {
- return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
- };
+ _proto._getScrollHeight = function _getScrollHeight() {
+ return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
+ };
- _proto._process = function _process() {
- var scrollTop = this._getScrollTop() + this._config.offset;
+ _proto._getOffsetHeight = function _getOffsetHeight() {
+ return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
+ };
- var scrollHeight = this._getScrollHeight();
+ _proto._process = function _process() {
+ var scrollTop = this._getScrollTop() + this._config.offset;
- var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
+ var scrollHeight = this._getScrollHeight();
- if (this._scrollHeight !== scrollHeight) {
- this.refresh();
- }
+ var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
- if (scrollTop >= maxScroll) {
- var target = this._targets[this._targets.length - 1];
+ if (this._scrollHeight !== scrollHeight) {
+ this.refresh();
+ }
- if (this._activeTarget !== target) {
- this._activate(target);
- }
+ if (scrollTop >= maxScroll) {
+ var target = this._targets[this._targets.length - 1];
- return;
+ if (this._activeTarget !== target) {
+ this._activate(target);
}
- if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
- this._activeTarget = null;
-
- this._clear();
-
- return;
- }
+ return;
+ }
- var offsetLength = this._offsets.length;
+ if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
+ this._activeTarget = null;
- for (var i = offsetLength; i--;) {
- var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
+ this._clear();
- if (isActiveTarget) {
- this._activate(this._targets[i]);
- }
- }
- };
+ return;
+ }
- _proto._activate = function _activate(target) {
- this._activeTarget = target;
+ var offsetLength = this._offsets.length;
- this._clear();
+ for (var i = offsetLength; i--;) {
+ var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
- var queries = this._selector.split(','); // eslint-disable-next-line arrow-body-style
+ if (isActiveTarget) {
+ this._activate(this._targets[i]);
+ }
+ }
+ };
+ _proto._activate = function _activate(target) {
+ this._activeTarget = target;
- queries = queries.map(function (selector) {
- return selector + "[data-target=\"" + target + "\"]," + (selector + "[href=\"" + target + "\"]");
- });
- var $link = $$$1([].slice.call(document.querySelectorAll(queries.join(','))));
+ this._clear();
- if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
- $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
- $link.addClass(ClassName.ACTIVE);
- } else {
- // Set triggered link as active
- $link.addClass(ClassName.ACTIVE); // Set triggered links parents as active
- // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
+ var queries = this._selector.split(',').map(function (selector) {
+ return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
+ });
- $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
+ var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
- $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
- }
+ if ($link.hasClass(ClassName.DROPDOWN_ITEM)) {
+ $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE);
+ $link.addClass(ClassName.ACTIVE);
+ } else {
+ // Set triggered link as active
+ $link.addClass(ClassName.ACTIVE); // Set triggered links parents as active
+ // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
- $$$1(this._scrollElement).trigger(Event.ACTIVATE, {
- relatedTarget: target
- });
- };
+ $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
- _proto._clear = function _clear() {
- var nodes = [].slice.call(document.querySelectorAll(this._selector));
- $$$1(nodes).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
- }; // Static
+ $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
+ }
+ $(this._scrollElement).trigger(Event.ACTIVATE, {
+ relatedTarget: target
+ });
+ };
- ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
- return this.each(function () {
- var data = $$$1(this).data(DATA_KEY);
+ _proto._clear = function _clear() {
+ [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
+ return node.classList.contains(ClassName.ACTIVE);
+ }).forEach(function (node) {
+ return node.classList.remove(ClassName.ACTIVE);
+ });
+ } // Static
+ ;
- var _config = typeof config === 'object' && config;
+ ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
+ return this.each(function () {
+ var data = $(this).data(DATA_KEY);
- if (!data) {
- data = new ScrollSpy(this, _config);
- $$$1(this).data(DATA_KEY, data);
- }
+ var _config = typeof config === 'object' && config;
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new TypeError("No method named \"" + config + "\"");
- }
+ if (!data) {
+ data = new ScrollSpy(this, _config);
+ $(this).data(DATA_KEY, data);
+ }
- data[config]();
+ if (typeof config === 'string') {
+ if (typeof data[config] === 'undefined') {
+ throw new TypeError("No method named \"" + config + "\"");
}
- });
- };
- _createClass(ScrollSpy, null, [{
- key: "VERSION",
- get: function get() {
- return VERSION;
+ data[config]();
}
- }, {
- key: "Default",
- get: function get() {
- return Default;
- }
- }]);
+ });
+ };
- return ScrollSpy;
- }();
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
+ _createClass(ScrollSpy, null, [{
+ key: "VERSION",
+ get: function get() {
+ return VERSION;
+ }
+ }, {
+ key: "Default",
+ get: function get() {
+ return Default;
+ }
+ }]);
+ return ScrollSpy;
+ }();
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
- $$$1(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--;) {
- var $spy = $$$1(scrollSpys[i]);
+ $(window).on(Event.LOAD_DATA_API, function () {
+ var scrollSpys = [].slice.call(document.querySelectorAll(Selector.DATA_SPY));
+ var scrollSpysLength = scrollSpys.length;
- ScrollSpy._jQueryInterface.call($spy, $spy.data());
- }
- });
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
+ for (var i = scrollSpysLength; i--;) {
+ var $spy = $(scrollSpys[i]);
- $$$1.fn[NAME] = ScrollSpy._jQueryInterface;
- $$$1.fn[NAME].Constructor = ScrollSpy;
+ ScrollSpy._jQueryInterface.call($spy, $spy.data());
+ }
+ });
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
- $$$1.fn[NAME].noConflict = function () {
- $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
- return ScrollSpy._jQueryInterface;
- };
+ $.fn[NAME] = ScrollSpy._jQueryInterface;
+ $.fn[NAME].Constructor = ScrollSpy;
- return ScrollSpy;
- }($);
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return ScrollSpy._jQueryInterface;
+ };
return ScrollSpy;
-})));
+}));
//# sourceMappingURL=scrollspy.js.map