Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-10-13 15:19:28 +0300
committerGitHub <noreply@github.com>2021-10-13 15:19:28 +0300
commite8f702666f285a3e69866ed1f8d29fa6eaaaeabb (patch)
tree944b2dc894f49f8278d41d096e4388e9ac83157b /js/src/scrollspy.js
parentdb44392bda22f3d5319d2880c992f76d27d2a60c (diff)
JS: minor refactoring (#35183)
* add missing comments * shorten block comments * reorder constants * reorder public/private methods * sort exports alphabetically in util/index.js * fix a couple of typos
Diffstat (limited to 'js/src/scrollspy.js')
-rw-r--r--js/src/scrollspy.js41
1 files changed, 14 insertions, 27 deletions
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js
index bdc22653b6..27bc0cd877 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -17,9 +17,7 @@ import SelectorEngine from './dom/selector-engine'
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'scrollspy'
@@ -27,18 +25,6 @@ const DATA_KEY = 'bs.scrollspy'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
-const Default = {
- offset: 10,
- method: 'auto',
- target: ''
-}
-
-const DefaultType = {
- offset: 'number',
- method: 'string',
- target: '(string|element)'
-}
-
const EVENT_ACTIVATE = `activate${EVENT_KEY}`
const EVENT_SCROLL = `scroll${EVENT_KEY}`
const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
@@ -58,10 +44,20 @@ const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'
const METHOD_OFFSET = 'offset'
const METHOD_POSITION = 'position'
+const Default = {
+ offset: 10,
+ method: 'auto',
+ target: ''
+}
+
+const DefaultType = {
+ offset: 'number',
+ method: 'string',
+ target: '(string|element)'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class ScrollSpy extends BaseComponent {
@@ -81,7 +77,6 @@ class ScrollSpy extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
@@ -91,7 +86,6 @@ class ScrollSpy extends BaseComponent {
}
// Public
-
refresh() {
const autoMethod = this._scrollElement === this._scrollElement.window ?
METHOD_OFFSET :
@@ -141,7 +135,6 @@ class ScrollSpy extends BaseComponent {
}
// Private
-
_getConfig(config) {
config = {
...Default,
@@ -257,7 +250,6 @@ class ScrollSpy extends BaseComponent {
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = ScrollSpy.getOrCreateInstance(this, config)
@@ -276,9 +268,7 @@ class ScrollSpy extends BaseComponent {
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
@@ -288,10 +278,7 @@ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .ScrollSpy to jQuery only if jQuery is present
*/
defineJQueryPlugin(ScrollSpy)