diff options
Diffstat (limited to 'js/dist/scrollspy.js')
-rw-r--r-- | js/dist/scrollspy.js | 106 |
1 files changed, 75 insertions, 31 deletions
diff --git a/js/dist/scrollspy.js b/js/dist/scrollspy.js index 4e4e2466db..1f048cb43c 100644 --- a/js/dist/scrollspy.js +++ b/js/dist/scrollspy.js @@ -5,7 +5,7 @@ */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) : + typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine)); }(this, (function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict'; @@ -102,8 +102,6 @@ } }; - function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } @@ -113,8 +111,55 @@ * ------------------------------------------------------------------------ */ - var NAME = 'scrollspy'; var VERSION = '5.0.0-alpha3'; + + var BaseComponent = /*#__PURE__*/function () { + function BaseComponent(element) { + if (!element) { + return; + } + + this._element = element; + Data__default['default'].setData(element, this.constructor.DATA_KEY, this); + } + + var _proto = BaseComponent.prototype; + + _proto.dispose = function dispose() { + Data__default['default'].removeData(this._element, this.constructor.DATA_KEY); + this._element = null; + } + /** Static */ + ; + + BaseComponent.getInstance = function getInstance(element) { + return Data__default['default'].getData(element, this.DATA_KEY); + }; + + _createClass(BaseComponent, null, [{ + key: "VERSION", + get: function get() { + return VERSION; + } + }]); + + return BaseComponent; + }(); + + function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } + + function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'scrollspy'; var DATA_KEY = 'bs.scrollspy'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -148,26 +193,29 @@ * ------------------------------------------------------------------------ */ - var ScrollSpy = /*#__PURE__*/function () { - function ScrollSpy(element, config) { - var _this = this; + var ScrollSpy = /*#__PURE__*/function (_BaseComponent) { + _inheritsLoose(ScrollSpy, _BaseComponent); - 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 + " ." + CLASS_NAME_DROPDOWN_ITEM; - this._offsets = []; - this._targets = []; - this._activeTarget = null; - this._scrollHeight = 0; - EventHandler__default['default'].on(this._scrollElement, EVENT_SCROLL, function (event) { + function ScrollSpy(element, config) { + var _this; + + _this = _BaseComponent.call(this, element) || this; + _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 + " ." + CLASS_NAME_DROPDOWN_ITEM; + _this._offsets = []; + _this._targets = []; + _this._activeTarget = null; + _this._scrollHeight = 0; + EventHandler__default['default'].on(_this._scrollElement, EVENT_SCROLL, function (event) { return _this._process(event); }); - this.refresh(); - this._process(); + _this.refresh(); + + _this._process(); - Data__default['default'].setData(element, DATA_KEY, this); + return _this; } // Getters @@ -209,9 +257,9 @@ }; _proto.dispose = function dispose() { - Data__default['default'].removeData(this._element, DATA_KEY); + _BaseComponent.prototype.dispose.call(this); + EventHandler__default['default'].off(this._scrollElement, EVENT_KEY); - this._element = null; this._scrollElement = null; this._config = null; this._selector = null; @@ -356,24 +404,20 @@ }); }; - ScrollSpy.getInstance = function getInstance(element) { - return Data__default['default'].getData(element, DATA_KEY); - }; - - _createClass(ScrollSpy, null, [{ - key: "VERSION", + _createClass$1(ScrollSpy, null, [{ + key: "Default", get: function get() { - return VERSION; + return Default; } }, { - key: "Default", + key: "DATA_KEY", get: function get() { - return Default; + return DATA_KEY; } }]); return ScrollSpy; - }(); + }(BaseComponent); /** * ------------------------------------------------------------------------ * Data Api implementation |