@creative-web-solution/front-library 7.0.7 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/DOM/Class.ts +10 -12
- package/DOM/DocumentSize.ts +3 -1
- package/DOM/Filter.ts +0 -2
- package/DOM/Index.ts +1 -3
- package/DOM/Manipulation.ts +0 -3
- package/DOM/Matrix.ts +12 -12
- package/DOM/Offset.ts +4 -5
- package/DOM/OuterSize.ts +12 -12
- package/DOM/PageToDOM.ts +2 -2
- package/DOM/Position.ts +3 -3
- package/DOM/Size.ts +3 -7
- package/DOM/StrToDOM.ts +0 -1
- package/DOM/Styles.ts +3 -12
- package/DOM/Traversing.ts +0 -6
- package/DOM/WindowScroll.ts +3 -1
- package/DOM/WindowSize.ts +3 -1
- package/DOM/Wrap.ts +0 -1
- package/Events/DeviceOrientation.ts +27 -31
- package/Events/EventsManager.ts +10 -25
- package/Events/Gesture.ts +36 -37
- package/Events/HistoryController.ts +11 -17
- package/Events/ImageLoad.ts +35 -19
- package/Events/IntersectObserver.ts +15 -19
- package/Events/KeyboardHandler.ts +10 -8
- package/Events/MediaQueriesEvents.ts +53 -51
- package/Events/OnAnimationEnd.ts +2 -3
- package/Events/OnTransitionEnd.ts +3 -3
- package/Events/PubSub.ts +5 -8
- package/Events/TouchHover.ts +18 -21
- package/Events/WindowEvents.ts +26 -30
- package/Helpers/Colors.ts +7 -23
- package/Helpers/Cookie.ts +5 -12
- package/Helpers/Coordinates.ts +0 -7
- package/Helpers/Debounce.ts +3 -7
- package/Helpers/Defer.ts +1 -1
- package/Helpers/GetValue.ts +0 -2
- package/Helpers/Insert.ts +0 -1
- package/Helpers/Sequential.ts +0 -2
- package/Helpers/Slice.ts +0 -3
- package/Helpers/Throttle.ts +0 -1
- package/Helpers/TransitionHelpers.ts +8 -6
- package/Helpers/Type.ts +1 -14
- package/Helpers/Unique.ts +3 -3
- package/Helpers/UrlParser.ts +13 -22
- package/Helpers/Wait.ts +1 -1
- package/Modules/Accordion/Tab.ts +18 -16
- package/Modules/Accordion/index.ts +24 -16
- package/Modules/Autocomplete.ts +95 -101
- package/Modules/DragSlider.ts +72 -63
- package/Modules/GlobalState.ts +60 -53
- package/Modules/LoadGMap.ts +4 -7
- package/Modules/Notifications/Notification.ts +28 -32
- package/Modules/Notifications/index.ts +43 -36
- package/Modules/Popin/Popin.ts +100 -110
- package/Modules/Popin/PopinAccessibility.ts +8 -8
- package/Modules/Popin/PopinBackground.ts +11 -11
- package/Modules/Popin/PopinController.ts +23 -29
- package/Modules/Popin/Tools.ts +18 -19
- package/Modules/QuickTemplate.ts +4 -6
- package/Modules/ScrollSnap.ts +110 -104
- package/Modules/SkinCheckbox.ts +51 -37
- package/Modules/SkinFile.ts +62 -52
- package/Modules/SkinRadio.ts +62 -42
- package/Modules/SkinSelect.ts +116 -100
- package/Modules/Slider/Slide.ts +49 -52
- package/Modules/Slider/Slider.ts +100 -136
- package/Modules/Slider/SliderControls.ts +60 -59
- package/Modules/Tabs/Tab.ts +27 -23
- package/Modules/Tabs/index.ts +35 -25
- package/Modules/Validator/Date.ts +2 -1
- package/Modules/Validator/Equals.ts +1 -1
- package/Modules/Validator/Internal/Input.ts +370 -0
- package/Modules/Validator/Internal/InputValidator.ts +99 -0
- package/Modules/Validator/Internal/ValidatorFunctionsController.ts +58 -0
- package/Modules/Validator/Max.ts +1 -1
- package/Modules/Validator/Min.ts +1 -1
- package/Modules/Validator/MultiRequired.ts +5 -5
- package/Modules/Validator/Number.ts +1 -0
- package/Modules/Validator/Pattern.ts +1 -1
- package/Modules/Validator/Recaptcha.ts +1 -0
- package/Modules/Validator/Required.ts +3 -2
- package/Modules/Validator/ServerCheck.ts +23 -15
- package/Modules/Validator/Tools/GetQueryFromForm.ts +1 -6
- package/Modules/Validator/Tools/IsDate.ts +2 -3
- package/Modules/Validator/Tools/IsEmail.ts +2 -5
- package/Modules/Validator/Tools/IsEmpty.ts +0 -2
- package/Modules/Validator/Tools/IsNumber.ts +0 -2
- package/Modules/Validator/Tools/IsUrl.ts +1 -3
- package/Modules/Validator/Tools/Label.ts +5 -15
- package/Modules/Validator/Tools/RadioButton.ts +4 -10
- package/Modules/Validator/Url.ts +1 -0
- package/Modules/Validator/index.ts +36 -36
- package/Modules/YouTubePlayer.ts +18 -16
- package/README.md +1 -1
- package/Types/Accordion.d.ts +36 -0
- package/Types/Autocomplete.d.ts +95 -0
- package/Types/DOM.d.ts +69 -0
- package/Types/DragSlider.d.ts +56 -0
- package/Types/EventsHelpers.d.ts +390 -0
- package/Types/GLImageTransition.d.ts +47 -43
- package/Types/GlobalState.d.ts +9 -0
- package/Types/Helpers.d.ts +30 -0
- package/Types/Notifications.d.ts +48 -44
- package/Types/Popin.d.ts +95 -0
- package/Types/ScrollSnap.d.ts +66 -0
- package/Types/SkinCheckbox.d.ts +26 -0
- package/Types/SkinFile.d.ts +38 -0
- package/Types/SkinRadio.d.ts +28 -0
- package/Types/SkinSelect.d.ts +59 -0
- package/Types/Slider.d.ts +106 -0
- package/Types/Tabs.d.ts +26 -0
- package/Types/Validator.d.ts +72 -0
- package/Types/YouTubePlayer.d.ts +27 -0
- package/Types/index.d.ts +22 -21
- package/WebGL/GLImageTransition/GLImageTransition.ts +83 -80
- package/WebGL/GLImageTransition/Presets/Cellular.ts +11 -11
- package/WebGL/GLImageTransition/Presets/Fade.ts +2 -3
- package/WebGL/GLImageTransition/Presets/HorizontalMovingGrid.ts +9 -9
- package/WebGL/GLImageTransition/Presets/PresetSample.ts +11 -9
- package/WebGL/GLImageTransition/Presets/Solarisation.ts +7 -12
- package/package.json +1 -1
- package/Modules/Template.ts +0 -209
- package/Types/AccordionTypes.d.ts +0 -29
- package/Types/AutocompleteTypes.d.ts +0 -85
- package/Types/DOMTypes.d.ts +0 -62
- package/Types/DragSliderTypes.d.ts +0 -52
- package/Types/EventsHelpersTypes.d.ts +0 -370
- package/Types/GlobalStateTypes.d.ts +0 -5
- package/Types/HelpersTypes.d.ts +0 -23
- package/Types/MediaPreloaderTypes.d.ts +0 -12
- package/Types/PopinTypes.d.ts +0 -83
- package/Types/ScrollSnapTypes.d.ts +0 -62
- package/Types/SkinCheckboxTypes.d.ts +0 -23
- package/Types/SkinFileTypes.d.ts +0 -34
- package/Types/SkinRadioTypes.d.ts +0 -24
- package/Types/SkinSelectTypes.d.ts +0 -48
- package/Types/SliderTypes.d.ts +0 -97
- package/Types/TabsTypes.d.ts +0 -22
- package/Types/ValidatorTypes.d.ts +0 -61
- package/Types/YouTubePlayerTypes.d.ts +0 -23
package/Helpers/Type.ts
CHANGED
|
@@ -6,9 +6,6 @@ const CORE_HAS_OWN = CLASS_TO_TYPE.hasOwnProperty;
|
|
|
6
6
|
/**
|
|
7
7
|
* Check the type of an object
|
|
8
8
|
*
|
|
9
|
-
* @param obj
|
|
10
|
-
* @param type
|
|
11
|
-
*
|
|
12
9
|
* @example
|
|
13
10
|
* boolean = isType( obj, 'String' )
|
|
14
11
|
*
|
|
@@ -22,8 +19,6 @@ export function isType( obj: any, type: string ): boolean {
|
|
|
22
19
|
/**
|
|
23
20
|
* Return true if the objec is an Array
|
|
24
21
|
*
|
|
25
|
-
* @param obj
|
|
26
|
-
*
|
|
27
22
|
* @example
|
|
28
23
|
* boolean = isArray( obj )
|
|
29
24
|
*/
|
|
@@ -35,8 +30,6 @@ export function isArray( obj: any ): boolean {
|
|
|
35
30
|
/**
|
|
36
31
|
* Return true if the object is a Function
|
|
37
32
|
*
|
|
38
|
-
* @param obj
|
|
39
|
-
*
|
|
40
33
|
* @example
|
|
41
34
|
* boolean = isFunction( obj )
|
|
42
35
|
*/
|
|
@@ -48,8 +41,6 @@ export function isFunction( obj: any ): boolean {
|
|
|
48
41
|
/**
|
|
49
42
|
* Return true if the object is a String
|
|
50
43
|
*
|
|
51
|
-
* @param obj
|
|
52
|
-
*
|
|
53
44
|
* @example
|
|
54
45
|
* boolean = isString( obj )
|
|
55
46
|
*/
|
|
@@ -61,8 +52,6 @@ export function isString( obj: any ): boolean {
|
|
|
61
52
|
/**
|
|
62
53
|
* Return true if the object is a Number
|
|
63
54
|
*
|
|
64
|
-
* @param obj
|
|
65
|
-
*
|
|
66
55
|
* @example
|
|
67
56
|
* boolean = isNumber( obj )
|
|
68
57
|
*/
|
|
@@ -82,9 +71,7 @@ export function isNumber( obj: any ): boolean {
|
|
|
82
71
|
|
|
83
72
|
|
|
84
73
|
/**
|
|
85
|
-
* Return true if obj is {} or an object created with "new Object"
|
|
86
|
-
*
|
|
87
|
-
* @param obj
|
|
74
|
+
* Return true if obj is `{}` or an object created with "new Object"
|
|
88
75
|
*/
|
|
89
76
|
export function isPlainObject( obj: any ): boolean {
|
|
90
77
|
// Detect obvious negatives
|
package/Helpers/Unique.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove all duplicate from a list. Doesn't change the original list.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param filter - Optionnal, (currentItem, returnArray) => { should return true or false }
|
|
4
|
+
* @param filter - Optionnal, (currentItem, returnArray) => `{` should return true or false `}`
|
|
6
5
|
*
|
|
7
6
|
* @example
|
|
7
|
+
* ```ts
|
|
8
8
|
* // Using the native includes function
|
|
9
9
|
* modifiedArray = unique( array )
|
|
10
10
|
*
|
|
11
|
-
* @example
|
|
12
11
|
* // With custom function (here, same as default behaviour)
|
|
13
12
|
* modifiedArray = unique( array, (currentValue, returnArray) => { return !returnArray.includes(currentValue) } )
|
|
13
|
+
* ```
|
|
14
14
|
*
|
|
15
15
|
* @returns Filtered list
|
|
16
16
|
*/
|
package/Helpers/UrlParser.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parse an URL
|
|
3
3
|
*
|
|
4
|
-
* @param url
|
|
5
|
-
*
|
|
6
4
|
* @example
|
|
5
|
+
* ```ts
|
|
7
6
|
* let url = new UrlParser( 'https://username:password@demo.domain.com:1337/section/page.html?param=1¶m=2#anchor' );
|
|
8
7
|
*
|
|
9
8
|
* // Update the anchor and regenerate url
|
|
@@ -32,6 +31,7 @@
|
|
|
32
31
|
*
|
|
33
32
|
* // Remove all query param
|
|
34
33
|
* url.removeAll()
|
|
34
|
+
* ```
|
|
35
35
|
*/
|
|
36
36
|
export class UrlParser {
|
|
37
37
|
/** Complete url without userInfo and anchor. Ex: https://demo.domain.com:1337/section/page.html?param=2 */
|
|
@@ -40,7 +40,7 @@ export class UrlParser {
|
|
|
40
40
|
absolute2 = '';
|
|
41
41
|
/** Ex: anchor */
|
|
42
42
|
anchor = '';
|
|
43
|
-
/** Ex: username:password
|
|
43
|
+
/** Ex: username:password\@demo.domain.com:1337 */
|
|
44
44
|
authority = '';
|
|
45
45
|
/** Ex: /section/ */
|
|
46
46
|
directory = '';
|
|
@@ -63,8 +63,8 @@ export class UrlParser {
|
|
|
63
63
|
protocol = '';
|
|
64
64
|
/** Ex: param=2 */
|
|
65
65
|
query = '';
|
|
66
|
-
/** Ex: { "param": "2" } */
|
|
67
|
-
queryKey:
|
|
66
|
+
/** Ex: `{` "param": "2" `}` */
|
|
67
|
+
queryKey: Record<string, string> = {};
|
|
68
68
|
/** Ex: Url without host, credential and anchor */
|
|
69
69
|
relative = '';
|
|
70
70
|
/** Ex: Url without host, credential but with anchor */
|
|
@@ -89,7 +89,7 @@ export class UrlParser {
|
|
|
89
89
|
/*
|
|
90
90
|
Rebuild the complete url
|
|
91
91
|
*/
|
|
92
|
-
|
|
92
|
+
#rebuild = (): void => {
|
|
93
93
|
let portToAdd, queryToAdd;
|
|
94
94
|
|
|
95
95
|
queryToAdd = '';
|
|
@@ -162,7 +162,7 @@ export class UrlParser {
|
|
|
162
162
|
/**
|
|
163
163
|
* Init
|
|
164
164
|
*/
|
|
165
|
-
init( url: string ) {
|
|
165
|
+
init( url: string ): void {
|
|
166
166
|
let location, result;
|
|
167
167
|
|
|
168
168
|
const parseUri = function( str: string ) {
|
|
@@ -240,19 +240,17 @@ export class UrlParser {
|
|
|
240
240
|
this[ key ] = result[ key ];
|
|
241
241
|
} );
|
|
242
242
|
|
|
243
|
-
this
|
|
243
|
+
this.#rebuild();
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
/**
|
|
248
248
|
* Change the anchor
|
|
249
|
-
*
|
|
250
|
-
* @param anchor
|
|
251
249
|
*/
|
|
252
250
|
setAnchor( anchor: string ): this {
|
|
253
251
|
this.anchor = anchor;
|
|
254
252
|
|
|
255
|
-
this
|
|
253
|
+
this.#rebuild();
|
|
256
254
|
|
|
257
255
|
return this;
|
|
258
256
|
}
|
|
@@ -261,8 +259,6 @@ export class UrlParser {
|
|
|
261
259
|
/**
|
|
262
260
|
* Get the value of a query param
|
|
263
261
|
*
|
|
264
|
-
* @param key
|
|
265
|
-
*
|
|
266
262
|
* @returns The parameter value or undefined
|
|
267
263
|
*/
|
|
268
264
|
getParam( key: string ): string {
|
|
@@ -276,11 +272,8 @@ export class UrlParser {
|
|
|
276
272
|
|
|
277
273
|
/**
|
|
278
274
|
* Add/modify one or several query param
|
|
279
|
-
*
|
|
280
|
-
* @param keys
|
|
281
|
-
* @param value
|
|
282
275
|
*/
|
|
283
|
-
setParam( keys: string |
|
|
276
|
+
setParam( keys: string | Record<string, string>, value?: string ): this {
|
|
284
277
|
if ( !this.queryKey ) {
|
|
285
278
|
this.queryKey = {};
|
|
286
279
|
}
|
|
@@ -294,7 +287,7 @@ export class UrlParser {
|
|
|
294
287
|
} );
|
|
295
288
|
}
|
|
296
289
|
|
|
297
|
-
this
|
|
290
|
+
this.#rebuild();
|
|
298
291
|
|
|
299
292
|
return this;
|
|
300
293
|
}
|
|
@@ -302,8 +295,6 @@ export class UrlParser {
|
|
|
302
295
|
|
|
303
296
|
/**
|
|
304
297
|
* Remove one or several query param
|
|
305
|
-
*
|
|
306
|
-
* @param keys
|
|
307
298
|
*/
|
|
308
299
|
removeParam( keys: string | string[] ): this {
|
|
309
300
|
if ( !this.queryKey ) {
|
|
@@ -319,7 +310,7 @@ export class UrlParser {
|
|
|
319
310
|
} );
|
|
320
311
|
}
|
|
321
312
|
|
|
322
|
-
this
|
|
313
|
+
this.#rebuild();
|
|
323
314
|
|
|
324
315
|
return this;
|
|
325
316
|
}
|
|
@@ -331,7 +322,7 @@ export class UrlParser {
|
|
|
331
322
|
removeAll(): this {
|
|
332
323
|
this.queryKey = {};
|
|
333
324
|
|
|
334
|
-
this
|
|
325
|
+
this.#rebuild();
|
|
335
326
|
|
|
336
327
|
return this;
|
|
337
328
|
}
|
package/Helpers/Wait.ts
CHANGED
package/Modules/Accordion/Tab.ts
CHANGED
|
@@ -13,7 +13,7 @@ export default class Tab {
|
|
|
13
13
|
#$TAB;
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
constructor( $TAB: HTMLElement, options:
|
|
16
|
+
constructor( $TAB: HTMLElement, options: FLib.Accordion.TabOptions ) {
|
|
17
17
|
this.#options = options;
|
|
18
18
|
this.#$TAB = $TAB ;
|
|
19
19
|
|
|
@@ -28,17 +28,17 @@ export default class Tab {
|
|
|
28
28
|
} );
|
|
29
29
|
|
|
30
30
|
if ( this.#isOpen ) {
|
|
31
|
-
this
|
|
31
|
+
this.#openTab( true );
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
#changeTabState = (): void => {
|
|
37
37
|
this.#$TAB.setAttribute( 'aria-expanded', this.#isOpen ? 'true' : 'false' );
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
#openTab = ( isOpenAtStart?: boolean ): void => {
|
|
42
42
|
this.#options.animations
|
|
43
43
|
.open( this.#$TAB, this.#$TAB_PANNEL )
|
|
44
44
|
.then( () => {
|
|
@@ -55,11 +55,11 @@ export default class Tab {
|
|
|
55
55
|
this.#options.onOpenTab( this );
|
|
56
56
|
}
|
|
57
57
|
this.#isOpen = true;
|
|
58
|
-
this
|
|
58
|
+
this.#changeTabState();
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
#closeTab = ( autoClose?: boolean ): void => {
|
|
63
63
|
this.#options.animations
|
|
64
64
|
.close( this.#$TAB, this.#$TAB_PANNEL )
|
|
65
65
|
.then( () => {
|
|
@@ -69,32 +69,32 @@ export default class Tab {
|
|
|
69
69
|
} );
|
|
70
70
|
|
|
71
71
|
this.#isOpen = false;
|
|
72
|
-
this
|
|
72
|
+
this.#changeTabState();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
#toggleTab = ( e: Event ) => {
|
|
76
|
+
#toggleTab = ( e: Event ): void => {
|
|
77
77
|
e.preventDefault();
|
|
78
78
|
|
|
79
79
|
if( this.#isOpen && ( !this.#options.atLeastOneOpen || this.#options.allowMultipleTab ) ) {
|
|
80
|
-
this
|
|
80
|
+
this.#closeTab();
|
|
81
81
|
}
|
|
82
82
|
else if( !this.#isOpen ) {
|
|
83
|
-
this
|
|
83
|
+
this.#openTab();
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
close( autoClose?: boolean ) {
|
|
89
|
-
if(
|
|
90
|
-
|
|
88
|
+
close( autoClose?: boolean ): this {
|
|
89
|
+
if( this.#isOpen ) {
|
|
90
|
+
this.#closeTab( autoClose );
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
this
|
|
93
|
+
return this;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
destroy() {
|
|
97
|
+
destroy(): this {
|
|
98
98
|
this.#options.animations.destroy( this.#$TAB, this.#$TAB_PANNEL );
|
|
99
99
|
|
|
100
100
|
off( this.#$TAB, {
|
|
@@ -103,5 +103,7 @@ export default class Tab {
|
|
|
103
103
|
} );
|
|
104
104
|
|
|
105
105
|
this.#$TAB.setAttribute( 'aria-expanded', this.#originalOpenedState ? 'true' : 'false' );
|
|
106
|
-
|
|
106
|
+
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
107
109
|
}
|
|
@@ -3,7 +3,7 @@ import { extend } from '../../Helpers/Extend';
|
|
|
3
3
|
import Tab from './Tab';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
const DEFAULT_OPTIONS
|
|
6
|
+
const DEFAULT_OPTIONS = {
|
|
7
7
|
"tabSelector": "button[aria-expanded]",
|
|
8
8
|
"allowMultipleTab": false,
|
|
9
9
|
"atLeastOneOpen": false,
|
|
@@ -31,6 +31,7 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
|
|
|
31
31
|
* Accordion
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
+
* ```ts
|
|
34
35
|
* new Accordion( document.querySelector( '.accordion' ), {
|
|
35
36
|
* "tabSelector": ".tab",
|
|
36
37
|
* "allowMultipleTab": false,
|
|
@@ -62,9 +63,11 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
|
|
|
62
63
|
* console.log( 'close: ', $tab, $panel );
|
|
63
64
|
* }
|
|
64
65
|
* } );
|
|
66
|
+
* ```
|
|
65
67
|
*
|
|
66
68
|
* HTML:
|
|
67
69
|
*
|
|
70
|
+
* ```html
|
|
68
71
|
* <div class="accordion">
|
|
69
72
|
* <button aria-expanded="true" class="tab" aria-controls="panel-1">Button name</button>
|
|
70
73
|
* <div id="panel-1" class="panel">
|
|
@@ -76,12 +79,13 @@ const DEFAULT_OPTIONS: AccordionOptionsType = {
|
|
|
76
79
|
* <p>Content</p>
|
|
77
80
|
* </div>
|
|
78
81
|
* </div>
|
|
82
|
+
* ```
|
|
79
83
|
*
|
|
80
84
|
* Set aria-expanded to "true" on the tab you want open at start
|
|
81
85
|
*/
|
|
82
86
|
export default class Accordion {
|
|
83
|
-
#options:
|
|
84
|
-
#$tabs:
|
|
87
|
+
#options: FLib.Accordion.Options;
|
|
88
|
+
#$tabs: NodeListOf<HTMLElement>;
|
|
85
89
|
#tablist: Tab[];
|
|
86
90
|
#status: string;
|
|
87
91
|
#lastOpenedTab: Tab | null = null;
|
|
@@ -91,7 +95,7 @@ export default class Accordion {
|
|
|
91
95
|
#STATUS_OFF = 'STATUS_OFF';
|
|
92
96
|
|
|
93
97
|
|
|
94
|
-
constructor( $accordionWrapper: HTMLElement, userOptions:
|
|
98
|
+
constructor( $accordionWrapper: HTMLElement, userOptions: FLib.Accordion.OptionsInit ) {
|
|
95
99
|
|
|
96
100
|
this.#options = extend( DEFAULT_OPTIONS, userOptions );
|
|
97
101
|
|
|
@@ -99,11 +103,11 @@ export default class Accordion {
|
|
|
99
103
|
this.#tablist = [];
|
|
100
104
|
this.#status = this.#STATUS_OFF;
|
|
101
105
|
|
|
102
|
-
this
|
|
106
|
+
this.#on();
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
|
|
106
|
-
#onOpenTab = ( tab: Tab ) => {
|
|
110
|
+
#onOpenTab = ( tab: Tab ): void => {
|
|
107
111
|
if ( this.#lastOpenedTab ) {
|
|
108
112
|
this.#lastOpenedTab.close( true );
|
|
109
113
|
}
|
|
@@ -112,7 +116,7 @@ export default class Accordion {
|
|
|
112
116
|
}
|
|
113
117
|
|
|
114
118
|
|
|
115
|
-
|
|
119
|
+
#on = (): void => {
|
|
116
120
|
if( this.#status === this.#STATUS_ON ){
|
|
117
121
|
return;
|
|
118
122
|
}
|
|
@@ -120,7 +124,7 @@ export default class Accordion {
|
|
|
120
124
|
this.#status = this.#STATUS_ON;
|
|
121
125
|
|
|
122
126
|
this.#$tabs.forEach( ( $tab, index ) => {
|
|
123
|
-
this.#tablist.push( new Tab( $tab
|
|
127
|
+
this.#tablist.push( new Tab( $tab, {
|
|
124
128
|
...this.#options,
|
|
125
129
|
index,
|
|
126
130
|
"onOpenTab": this.#options.allowMultipleTab ? null : this.#onOpenTab
|
|
@@ -129,7 +133,7 @@ export default class Accordion {
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
|
|
132
|
-
|
|
136
|
+
#off = (): void => {
|
|
133
137
|
if( this.#status === this.#STATUS_OFF ){
|
|
134
138
|
return;
|
|
135
139
|
}
|
|
@@ -147,16 +151,20 @@ export default class Accordion {
|
|
|
147
151
|
/**
|
|
148
152
|
* Remove all events, css class, ...
|
|
149
153
|
*/
|
|
150
|
-
destroy() {
|
|
151
|
-
this
|
|
152
|
-
|
|
154
|
+
destroy(): this {
|
|
155
|
+
this.#off();
|
|
156
|
+
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
153
159
|
|
|
154
160
|
|
|
155
161
|
/**
|
|
156
162
|
* Restart the module
|
|
157
163
|
*/
|
|
158
|
-
update() {
|
|
159
|
-
this
|
|
160
|
-
this
|
|
161
|
-
|
|
164
|
+
update(): this {
|
|
165
|
+
this.#off();
|
|
166
|
+
this.#on();
|
|
167
|
+
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
162
170
|
}
|