diff options
author | XhmikosR <xhmikosr@gmail.com> | 2018-11-13 09:41:12 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2018-11-13 09:47:32 +0300 |
commit | fceee8d09310ae1c49a38ed66dab77dc53120ca7 (patch) | |
tree | 34fcec8e4e60e881f55d43d119051ed36329d4f7 /js/dist/scrollspy.js | |
parent | 220baef0d9f97b21748e51ec634d7171a267999b (diff) |
Dist
Diffstat (limited to 'js/dist/scrollspy.js')
-rw-r--r-- | js/dist/scrollspy.js | 492 |
1 files changed, 247 insertions, 245 deletions
diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js index 177369bb26..9394a79be5 100644 --- a/js/dist/scrollspy.js +++ b/js/dist/scrollspy.js @@ -1,3 +1,8 @@ +/*! + * Bootstrap scrollspy.js v4.1.3 (https://getbootstrap.com/) + * Copyright 2011-2018 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) : @@ -64,314 +69,311 @@ * -------------------------------------------------------------------------- */ - var ScrollSpy = function ($$$1) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + 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 = $.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; + return; + } - this._clear(); + if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { + this._activeTarget = null; - return; - } + this._clear(); - var offsetLength = this._offsets.length; + return; + } - 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 offsetLength = this._offsets.length; - if (isActiveTarget) { - this._activate(this._targets[i]); - } - } - }; + 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]); - _proto._activate = function _activate(target) { - this._activeTarget = target; + if (isActiveTarget) { + this._activate(this._targets[i]); + } + } + }; - this._clear(); + _proto._activate = function _activate(target) { + this._activeTarget = target; - var queries = this._selector.split(','); // eslint-disable-next-line arrow-body-style + this._clear(); + var queries = this._selector.split(','); // eslint-disable-next-line arrow-body-style - queries = queries.map(function (selector) { - return selector + "[data-target=\"" + target + "\"]," + (selector + "[href=\"" + target + "\"]"); - }); - var $link = $$$1([].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); - } 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 + queries = queries.map(function (selector) { + return selector + "[data-target=\"" + target + "\"]," + (selector + "[href=\"" + target + "\"]"); + }); + var $link = $([].slice.call(document.querySelectorAll(queries.join(',')))); - $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 + 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 - $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_LINKS + ", " + Selector.LIST_ITEMS).addClass(ClassName.ACTIVE); // Handle special case when .nav-link is inside .nav-item - $$$1(this._scrollElement).trigger(Event.ACTIVATE, { - relatedTarget: target - }); - }; + $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE); + } - _proto._clear = function _clear() { - var nodes = [].slice.call(document.querySelectorAll(this._selector)); - $$$1(nodes).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE); - }; // Static + $(this._scrollElement).trigger(Event.ACTIVATE, { + relatedTarget: target + }); + }; + _proto._clear = function _clear() { + var nodes = [].slice.call(document.querySelectorAll(this._selector)); + $(nodes).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + }; // Static - ScrollSpy._jQueryInterface = function _jQueryInterface(config) { - return this.each(function () { - var data = $$$1(this).data(DATA_KEY); - 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; |