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>2020-06-12 21:50:30 +0300
committerXhmikosR <xhmikosr@gmail.com>2020-09-10 12:06:30 +0300
commit3be585990cd017736df97a418e135e5cf2382d5a (patch)
tree6c094dd4c9c4610445408ae5e46372198c6492c4 /js/src/collapse.js
parent1c37a2ba77002331376c0b70abb7fc1acf02a70b (diff)
Comply to the new rules
Diffstat (limited to 'js/src/collapse.js')
-rw-r--r--js/src/collapse.js65
1 files changed, 33 insertions, 32 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 9e501e085a..04653b835e 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -14,38 +14,38 @@ import Util from './util'
* ------------------------------------------------------------------------
*/
-const NAME = 'collapse'
-const VERSION = '4.5.2'
-const DATA_KEY = 'bs.collapse'
-const EVENT_KEY = `.${DATA_KEY}`
-const DATA_API_KEY = '.data-api'
-const JQUERY_NO_CONFLICT = $.fn[NAME]
+const NAME = 'collapse'
+const VERSION = '4.5.2'
+const DATA_KEY = 'bs.collapse'
+const EVENT_KEY = `.${DATA_KEY}`
+const DATA_API_KEY = '.data-api'
+const JQUERY_NO_CONFLICT = $.fn[NAME]
const Default = {
- toggle : true,
- parent : ''
+ toggle: true,
+ parent: ''
}
const DefaultType = {
- toggle : 'boolean',
- parent : '(string|element)'
+ toggle: 'boolean',
+ parent: '(string|element)'
}
-const EVENT_SHOW = `show${EVENT_KEY}`
-const EVENT_SHOWN = `shown${EVENT_KEY}`
-const EVENT_HIDE = `hide${EVENT_KEY}`
-const EVENT_HIDDEN = `hidden${EVENT_KEY}`
+const EVENT_SHOW = `show${EVENT_KEY}`
+const EVENT_SHOWN = `shown${EVENT_KEY}`
+const EVENT_HIDE = `hide${EVENT_KEY}`
+const EVENT_HIDDEN = `hidden${EVENT_KEY}`
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`
-const CLASS_NAME_SHOW = 'show'
-const CLASS_NAME_COLLAPSE = 'collapse'
+const CLASS_NAME_SHOW = 'show'
+const CLASS_NAME_COLLAPSE = 'collapse'
const CLASS_NAME_COLLAPSING = 'collapsing'
-const CLASS_NAME_COLLAPSED = 'collapsed'
+const CLASS_NAME_COLLAPSED = 'collapsed'
-const DIMENSION_WIDTH = 'width'
+const DIMENSION_WIDTH = 'width'
const DIMENSION_HEIGHT = 'height'
-const SELECTOR_ACTIVES = '.show, .collapsing'
+const SELECTOR_ACTIVES = '.show, .collapsing'
const SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]'
/**
@@ -57,9 +57,9 @@ const SELECTOR_DATA_TOGGLE = '[data-toggle="collapse"]'
class Collapse {
constructor(element, config) {
this._isTransitioning = false
- this._element = element
- this._config = this._getConfig(config)
- this._triggerArray = [].slice.call(document.querySelectorAll(
+ this._element = element
+ this._config = this._getConfig(config)
+ this._triggerArray = [].slice.call(document.querySelectorAll(
`[data-toggle="collapse"][href="#${element.id}"],` +
`[data-toggle="collapse"][data-target="#${element.id}"]`
))
@@ -69,7 +69,7 @@ class Collapse {
const elem = toggleList[i]
const selector = Util.getSelectorFromElement(elem)
const filterElement = [].slice.call(document.querySelectorAll(selector))
- .filter((foundElem) => foundElem === element)
+ .filter(foundElem => foundElem === element)
if (selector !== null && filterElement.length > 0) {
this._selector = selector
@@ -119,7 +119,7 @@ class Collapse {
if (this._parent) {
actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES))
- .filter((elem) => {
+ .filter(elem => {
if (typeof this._config.parent === 'string') {
return elem.getAttribute('data-parent') === this._config.parent
}
@@ -254,10 +254,10 @@ class Collapse {
dispose() {
$.removeData(this._element, DATA_KEY)
- this._config = null
- this._parent = null
- this._element = null
- this._triggerArray = null
+ this._config = null
+ this._parent = null
+ this._element = null
+ this._triggerArray = null
this._isTransitioning = null
}
@@ -324,8 +324,8 @@ class Collapse {
static _jQueryInterface(config) {
return this.each(function () {
- const $this = $(this)
- let data = $this.data(DATA_KEY)
+ const $this = $(this)
+ let data = $this.data(DATA_KEY)
const _config = {
...Default,
...$this.data(),
@@ -345,6 +345,7 @@ class Collapse {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
+
data[config]()
}
})
@@ -369,8 +370,8 @@ $(document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
$(selectors).each(function () {
const $target = $(this)
- const data = $target.data(DATA_KEY)
- const config = data ? 'toggle' : $trigger.data()
+ const data = $target.data(DATA_KEY)
+ const config = data ? 'toggle' : $trigger.data()
Collapse._jQueryInterface.call($target, config)
})
})