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/collapse.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/collapse.js')
-rw-r--r--js/src/collapse.js37
1 files changed, 12 insertions, 25 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index b32ce01862..39093c7a2a 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -20,9 +20,7 @@ import SelectorEngine from './dom/selector-engine'
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'collapse'
@@ -30,16 +28,6 @@ const DATA_KEY = 'bs.collapse'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
-const Default = {
- toggle: true,
- parent: null
-}
-
-const DefaultType = {
- toggle: 'boolean',
- parent: '(null|element)'
-}
-
const EVENT_SHOW = `show${EVENT_KEY}`
const EVENT_SHOWN = `shown${EVENT_KEY}`
const EVENT_HIDE = `hide${EVENT_KEY}`
@@ -59,10 +47,18 @@ const HEIGHT = 'height'
const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]'
+const Default = {
+ toggle: true,
+ parent: null
+}
+
+const DefaultType = {
+ toggle: 'boolean',
+ parent: '(null|element)'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Collapse extends BaseComponent {
@@ -98,7 +94,6 @@ class Collapse extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
@@ -108,7 +103,6 @@ class Collapse extends BaseComponent {
}
// Public
-
toggle() {
if (this._isShown()) {
this.hide()
@@ -230,7 +224,6 @@ class Collapse extends BaseComponent {
}
// Private
-
_getConfig(config) {
config = {
...Default,
@@ -281,7 +274,6 @@ class Collapse extends BaseComponent {
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const _config = {}
@@ -303,9 +295,7 @@ class Collapse extends BaseComponent {
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
@@ -323,10 +313,7 @@ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Collapse to jQuery only if jQuery is present
*/
defineJQueryPlugin(Collapse)