@@ -29,40 +29,40 @@ define([
29
29
* ------------------------------------------------------------------------
30
30
*/
31
31
32
- const VERSION = '5.1.3'
33
- const NAME = 'collapse'
34
- const DATA_KEY = 'bs.collapse'
35
- const EVENT_KEY = `.${ DATA_KEY } `
36
- const DATA_API_KEY = '.data-api'
32
+ const VERSION = '5.1.3' ;
33
+ const NAME = 'collapse' ;
34
+ const DATA_KEY = 'bs.collapse' ;
35
+ const EVENT_KEY = `.${ DATA_KEY } ` ;
36
+ const DATA_API_KEY = '.data-api' ;
37
37
38
38
const Default = {
39
39
toggle : true ,
40
40
parent : null
41
- }
41
+ } ;
42
42
43
43
const DefaultType = {
44
44
toggle : 'boolean' ,
45
45
parent : '(null|element)'
46
- }
46
+ } ;
47
47
48
- const EVENT_SHOW = `show${ EVENT_KEY } `
49
- const EVENT_SHOWN = `shown${ EVENT_KEY } `
50
- const EVENT_HIDE = `hide${ EVENT_KEY } `
51
- const EVENT_HIDDEN = `hidden${ EVENT_KEY } `
52
- const EVENT_CLICK_DATA_API = `click${ EVENT_KEY } ${ DATA_API_KEY } `
48
+ const EVENT_SHOW = `show${ EVENT_KEY } ` ;
49
+ const EVENT_SHOWN = `shown${ EVENT_KEY } ` ;
50
+ const EVENT_HIDE = `hide${ EVENT_KEY } ` ;
51
+ const EVENT_HIDDEN = `hidden${ EVENT_KEY } ` ;
52
+ const EVENT_CLICK_DATA_API = `click${ EVENT_KEY } ${ DATA_API_KEY } ` ;
53
53
54
- const CLASS_NAME_SHOW = 'show'
55
- const CLASS_NAME_COLLAPSE = 'collapse'
56
- const CLASS_NAME_COLLAPSING = 'collapsing'
57
- const CLASS_NAME_COLLAPSED = 'collapsed'
58
- const CLASS_NAME_DEEPER_CHILDREN = `:scope .${ CLASS_NAME_COLLAPSE } .${ CLASS_NAME_COLLAPSE } `
59
- const CLASS_NAME_HORIZONTAL = 'collapse-horizontal'
54
+ const CLASS_NAME_SHOW = 'show' ;
55
+ const CLASS_NAME_COLLAPSE = 'collapse' ;
56
+ const CLASS_NAME_COLLAPSING = 'collapsing' ;
57
+ const CLASS_NAME_COLLAPSED = 'collapsed' ;
58
+ const CLASS_NAME_DEEPER_CHILDREN = `:scope .${ CLASS_NAME_COLLAPSE } .${ CLASS_NAME_COLLAPSE } ` ;
59
+ const CLASS_NAME_HORIZONTAL = 'collapse-horizontal' ;
60
60
61
- const WIDTH = 'width'
62
- const HEIGHT = 'height'
61
+ const WIDTH = 'width' ;
62
+ const HEIGHT = 'height' ;
63
63
64
- const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'
65
- const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]'
64
+ const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing' ;
65
+ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]' ;
66
66
67
67
/**
68
68
* ------------------------------------------------------------------------
@@ -84,13 +84,13 @@ define([
84
84
this . _config = this . _getConfig ( config )
85
85
this . _triggerArray = [ ]
86
86
87
- const toggleList = SelectorEngine . find ( SELECTOR_DATA_TOGGLE )
87
+ const toggleList = SelectorEngine . find ( SELECTOR_DATA_TOGGLE ) ;
88
88
89
89
for ( let i = 0 , len = toggleList . length ; i < len ; i ++ ) {
90
- const elem = toggleList [ i ]
91
- const selector = getSelectorFromElement ( elem )
90
+ const elem = toggleList [ i ] ;
91
+ const selector = getSelectorFromElement ( elem ) ;
92
92
const filterElement = SelectorEngine . find ( selector )
93
- . filter ( foundElem => foundElem === this . _element )
93
+ . filter ( foundElem => foundElem === this . _element ) ;
94
94
95
95
if ( selector !== null && filterElement . length ) {
96
96
this . _selector = selector
@@ -149,25 +149,25 @@ define([
149
149
return
150
150
}
151
151
152
- let actives = [ ]
153
- let activesData
152
+ let actives = [ ] ;
153
+ let activesData ;
154
154
155
155
if ( this . _config . parent ) {
156
- const children = SelectorEngine . find ( CLASS_NAME_DEEPER_CHILDREN , this . _config . parent )
156
+ const children = SelectorEngine . find ( CLASS_NAME_DEEPER_CHILDREN , this . _config . parent ) ;
157
157
actives = SelectorEngine . find ( SELECTOR_ACTIVES , this . _config . parent ) . filter ( elem => ! children . includes ( elem ) ) // remove children if greater depth
158
158
}
159
159
160
- const container = SelectorEngine . findOne ( this . _selector )
160
+ const container = SelectorEngine . findOne ( this . _selector ) ;
161
161
if ( actives . length ) {
162
- const tempActiveData = actives . find ( elem => container !== elem )
162
+ const tempActiveData = actives . find ( elem => container !== elem ) ;
163
163
activesData = tempActiveData ? Collapse . getInstance ( tempActiveData ) : null
164
164
165
165
if ( activesData && activesData . _isTransitioning ) {
166
166
return
167
167
}
168
168
}
169
169
170
- const startEvent = EventHandler . trigger ( this . _element , EVENT_SHOW )
170
+ const startEvent = EventHandler . trigger ( this . _element , EVENT_SHOW ) ;
171
171
if ( startEvent . defaultPrevented ) {
172
172
return
173
173
}
@@ -182,7 +182,7 @@ define([
182
182
}
183
183
} )
184
184
185
- const dimension = this . _getDimension ( )
185
+ const dimension = this . _getDimension ( ) ;
186
186
187
187
this . _element . classList . remove ( CLASS_NAME_COLLAPSE )
188
188
this . _element . classList . add ( CLASS_NAME_COLLAPSING )
@@ -201,10 +201,10 @@ define([
201
201
this . _element . style [ dimension ] = ''
202
202
203
203
EventHandler . trigger ( this . _element , EVENT_SHOWN )
204
- }
204
+ } ;
205
205
206
- const capitalizedDimension = dimension [ 0 ] . toUpperCase ( ) + dimension . slice ( 1 )
207
- const scrollSize = `scroll${ capitalizedDimension } `
206
+ const capitalizedDimension = dimension [ 0 ] . toUpperCase ( ) + dimension . slice ( 1 ) ;
207
+ const scrollSize = `scroll${ capitalizedDimension } ` ;
208
208
209
209
this . _queueCallback ( complete , this . _element , true )
210
210
this . _element . style [ dimension ] = `${ this . _element [ scrollSize ] } px`
@@ -215,12 +215,12 @@ define([
215
215
return
216
216
}
217
217
218
- const startEvent = EventHandler . trigger ( this . _element , EVENT_HIDE )
218
+ const startEvent = EventHandler . trigger ( this . _element , EVENT_HIDE ) ;
219
219
if ( startEvent . defaultPrevented ) {
220
220
return
221
221
}
222
222
223
- const dimension = this . _getDimension ( )
223
+ const dimension = this . _getDimension ( ) ;
224
224
225
225
this . _element . style [ dimension ] = `${ this . _element . getBoundingClientRect ( ) [ dimension ] } px`
226
226
@@ -229,10 +229,10 @@ define([
229
229
this . _element . classList . add ( CLASS_NAME_COLLAPSING )
230
230
this . _element . classList . remove ( CLASS_NAME_COLLAPSE , CLASS_NAME_SHOW )
231
231
232
- const triggerArrayLength = this . _triggerArray . length
232
+ const triggerArrayLength = this . _triggerArray . length ;
233
233
for ( let i = 0 ; i < triggerArrayLength ; i ++ ) {
234
- const trigger = this . _triggerArray [ i ]
235
- const elem = getElementFromSelector ( trigger )
234
+ const trigger = this . _triggerArray [ i ] ;
235
+ const elem = getElementFromSelector ( trigger ) ;
236
236
237
237
if ( elem && ! this . _isShown ( elem ) ) {
238
238
this . _addAriaAndCollapsedClass ( [ trigger ] , false )
@@ -246,7 +246,7 @@ define([
246
246
this . _element . classList . remove ( CLASS_NAME_COLLAPSING )
247
247
this . _element . classList . add ( CLASS_NAME_COLLAPSE )
248
248
EventHandler . trigger ( this . _element , EVENT_HIDDEN )
249
- }
249
+ } ;
250
250
251
251
this . _element . style [ dimension ] = ''
252
252
@@ -280,10 +280,10 @@ define([
280
280
return
281
281
}
282
282
283
- const children = SelectorEngine . find ( CLASS_NAME_DEEPER_CHILDREN , this . _config . parent )
283
+ const children = SelectorEngine . find ( CLASS_NAME_DEEPER_CHILDREN , this . _config . parent ) ;
284
284
SelectorEngine . find ( SELECTOR_DATA_TOGGLE , this . _config . parent ) . filter ( elem => ! children . includes ( elem ) )
285
285
. forEach ( element => {
286
- const selected = getElementFromSelector ( element )
286
+ const selected = getElementFromSelector ( element ) ;
287
287
288
288
if ( selected ) {
289
289
this . _addAriaAndCollapsedClass ( [ element ] , this . _isShown ( selected ) )
@@ -319,12 +319,12 @@ define([
319
319
320
320
Collapse . jQueryInterface = function ( config ) {
321
321
return this . each ( function ( ) {
322
- const _config = { }
322
+ const _config = { } ;
323
323
if ( typeof config === 'string' && / s h o w | h i d e / . test ( config ) ) {
324
324
_config . toggle = false
325
325
}
326
326
327
- const data = Collapse . getOrCreateInstance ( this , _config )
327
+ const data = Collapse . getOrCreateInstance ( this , _config ) ;
328
328
329
329
if ( typeof config === 'string' ) {
330
330
if ( typeof data [ config ] === 'undefined' ) {
@@ -348,8 +348,8 @@ define([
348
348
event . preventDefault ( )
349
349
}
350
350
351
- const selector = getSelectorFromElement ( this )
352
- const selectorElements = SelectorEngine . find ( selector )
351
+ const selector = getSelectorFromElement ( this ) ;
352
+ const selectorElements = SelectorEngine . find ( selector ) ;
353
353
354
354
selectorElements . forEach ( element => {
355
355
Collapse . getOrCreateInstance ( element , { toggle : false } ) . toggle ( )
0 commit comments