@creative-web-solution/front-library 7.1.54 → 7.1.55
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 +4 -0
- package/Modules/Popin/Popin.ts +291 -320
- package/Modules/Popin/PopinAccessibility.ts +74 -36
- package/Modules/Popin/PopinBackground.ts +26 -31
- package/Modules/Popin/PopinController.ts +82 -92
- package/Modules/Popin/Tools.ts +53 -59
- package/README.md +1 -1
- package/package.json +1 -1
|
@@ -1,67 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { FOCUSABLE_ELEMENTS_SELECTOR } from "./Tools";
|
|
3
2
|
|
|
4
3
|
export default class PopinAccessibility {
|
|
5
|
-
|
|
6
|
-
#$
|
|
7
|
-
#$
|
|
8
|
-
#$
|
|
9
|
-
#$
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
#$elements: HTMLElement[] | undefined;
|
|
5
|
+
#$firstElement: HTMLElement | undefined;
|
|
6
|
+
#$lastElement: HTMLElement | undefined;
|
|
7
|
+
#$startSentinel: HTMLElement | null = null;
|
|
8
|
+
#$endSentinel: HTMLElement | null = null;
|
|
9
|
+
#$popin: HTMLElement;
|
|
10
|
+
#isFocusBackHandled: boolean = false;
|
|
11
|
+
|
|
12
|
+
constructor($popin: HTMLElement) {
|
|
13
13
|
this.#$popin = $popin;
|
|
14
14
|
|
|
15
15
|
this.refresh();
|
|
16
|
-
this.toggleTabIndexNavigation( false );
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
18
|
focusFirstElement(): void {
|
|
22
|
-
if (
|
|
19
|
+
if (!this.#$firstElement) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
22
|
this.#$firstElement.focus();
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if ( !this.#$elements?.length || !this.#$firstElement ) {
|
|
31
|
-
e.preventDefault();
|
|
25
|
+
focusLastElement(): void {
|
|
26
|
+
if (!this.#$lastElement) {
|
|
32
27
|
return;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
this.#$lastElement?.focus();
|
|
37
|
-
}
|
|
29
|
+
this.#$lastElement.focus();
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if ( !this.#$elements?.length || !this.#$lastElement ) {
|
|
32
|
+
handleBackwardTab(e: Event): void {
|
|
33
|
+
if (document.activeElement === this.#$firstElement) {
|
|
43
34
|
e.preventDefault();
|
|
44
|
-
|
|
35
|
+
this.focusLastElement();
|
|
45
36
|
}
|
|
46
|
-
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
handleForwardTab(e: Event): void {
|
|
40
|
+
if (document.activeElement === this.#$lastElement) {
|
|
47
41
|
e.preventDefault();
|
|
48
|
-
this
|
|
42
|
+
this.focusFirstElement();
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
45
|
|
|
46
|
+
refresh(): void {
|
|
47
|
+
this.#addSentinels();
|
|
48
|
+
this.#handleFocusBackInDocument();
|
|
49
|
+
|
|
50
|
+
this.#$elements = Array.from(
|
|
51
|
+
this.#$popin.querySelectorAll<HTMLElement>(
|
|
52
|
+
FOCUSABLE_ELEMENTS_SELECTOR,
|
|
53
|
+
),
|
|
54
|
+
).filter(($element) => $element.offsetParent !== null);
|
|
55
|
+
this.#$firstElement = this.#$elements[0] ?? this.#$popin;
|
|
56
|
+
this.#$lastElement = this.#$elements[this.#$elements.length - 1];
|
|
57
|
+
}
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
#addSentinels(): void {
|
|
60
|
+
if (this.#$startSentinel) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.#$startSentinel = document.createElement("div");
|
|
64
|
+
this.#$endSentinel = document.createElement("div");
|
|
65
|
+
[this.#$startSentinel, this.#$endSentinel].forEach(($sentinel) => {
|
|
66
|
+
$sentinel.tabIndex = 0;
|
|
67
|
+
$sentinel.setAttribute("aria-hidden", "true");
|
|
68
|
+
$sentinel.style.cssText =
|
|
69
|
+
"position:fixed;width:1px;height:1px;overflow:hidden;";
|
|
70
|
+
});
|
|
71
|
+
this.#$popin.prepend(this.#$startSentinel);
|
|
72
|
+
this.#$popin.append(this.#$endSentinel);
|
|
73
|
+
this.#$startSentinel.addEventListener("focus", () =>
|
|
74
|
+
this.focusLastElement(),
|
|
75
|
+
);
|
|
76
|
+
this.#$endSentinel.addEventListener("focus", () =>
|
|
77
|
+
this.focusFirstElement(),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
55
80
|
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
#handleFocusBackInDocument(): void {
|
|
82
|
+
if (this.#isFocusBackHandled) {
|
|
83
|
+
return;
|
|
58
84
|
}
|
|
85
|
+
this.#isFocusBackHandled = true;
|
|
86
|
+
document.addEventListener("focusin", this.#onFocusBackInDocument);
|
|
59
87
|
}
|
|
60
88
|
|
|
89
|
+
#onFocusBackInDocument = (e: FocusEvent): void => {
|
|
90
|
+
if (!this.#$popin.contains(e.target as Node)) {
|
|
91
|
+
this.focusFirstElement();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
clean(): void {
|
|
96
|
+
document.removeEventListener("focusin", this.#onFocusBackInDocument);
|
|
97
|
+
this.#isFocusBackHandled = false;
|
|
61
98
|
|
|
62
|
-
|
|
63
|
-
this.#$
|
|
64
|
-
|
|
65
|
-
this.#$
|
|
99
|
+
this.#$startSentinel?.remove();
|
|
100
|
+
this.#$endSentinel?.remove();
|
|
101
|
+
|
|
102
|
+
this.#$startSentinel = null;
|
|
103
|
+
this.#$endSentinel = null;
|
|
66
104
|
}
|
|
67
105
|
}
|
|
@@ -1,68 +1,63 @@
|
|
|
1
|
-
import { strToDOM }
|
|
2
|
-
import PopinController
|
|
3
|
-
import Popin
|
|
4
|
-
import { CLICK_EVENT_NAME } from
|
|
5
|
-
|
|
1
|
+
import { strToDOM } from "../../DOM/StrToDOM";
|
|
2
|
+
import PopinController from "./PopinController";
|
|
3
|
+
import Popin from "./Popin";
|
|
4
|
+
import { CLICK_EVENT_NAME } from "./Tools";
|
|
6
5
|
|
|
7
6
|
export default class PopinBackground implements FLib.Popin.Background {
|
|
8
|
-
|
|
9
7
|
#$bgLayer: HTMLElement;
|
|
10
8
|
#isOpened: boolean;
|
|
11
|
-
#options:
|
|
12
|
-
#popin:
|
|
13
|
-
|
|
9
|
+
#options: FLib.Popin.Options;
|
|
10
|
+
#popin: Popin | PopinController;
|
|
14
11
|
|
|
15
12
|
get isOpened(): boolean {
|
|
16
13
|
return this.#isOpened;
|
|
17
14
|
}
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
constructor( popin: Popin | PopinController, options: FLib.Popin.Options ) {
|
|
16
|
+
constructor(popin: Popin | PopinController, options: FLib.Popin.Options) {
|
|
21
17
|
this.#isOpened = false;
|
|
22
|
-
this.#popin
|
|
23
|
-
this.#options
|
|
24
|
-
this.#$bgLayer = strToDOM(
|
|
18
|
+
this.#popin = popin;
|
|
19
|
+
this.#options = options;
|
|
20
|
+
this.#$bgLayer = strToDOM(options.templates.bgLayer) as HTMLElement;
|
|
25
21
|
|
|
26
|
-
document.body.appendChild(
|
|
22
|
+
document.body.appendChild(this.#$bgLayer);
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
25
|
open(): Promise<any> {
|
|
31
|
-
if (
|
|
26
|
+
if (this.#isOpened) {
|
|
32
27
|
return Promise.resolve();
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
if (
|
|
36
|
-
this.#$bgLayer.addEventListener(
|
|
30
|
+
if (!this.#options.modal) {
|
|
31
|
+
this.#$bgLayer.addEventListener(CLICK_EVENT_NAME, this.#onBgClick);
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
return this.#options.animations.openBg(
|
|
34
|
+
return this.#options.animations.openBg(this.#$bgLayer).then(() => {
|
|
40
35
|
this.#isOpened = true;
|
|
41
|
-
}
|
|
36
|
+
});
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
|
|
45
39
|
close(): Promise<any> {
|
|
46
|
-
if (
|
|
40
|
+
if (!this.#isOpened) {
|
|
47
41
|
return Promise.resolve();
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
if (
|
|
51
|
-
this.#$bgLayer.removeEventListener(
|
|
44
|
+
if (!this.#options.modal) {
|
|
45
|
+
this.#$bgLayer.removeEventListener(
|
|
46
|
+
CLICK_EVENT_NAME,
|
|
47
|
+
this.#onBgClick,
|
|
48
|
+
);
|
|
52
49
|
}
|
|
53
50
|
|
|
54
|
-
return this.#options.animations.closeBg(
|
|
51
|
+
return this.#options.animations.closeBg(this.#$bgLayer).then(() => {
|
|
55
52
|
this.#isOpened = false;
|
|
56
|
-
}
|
|
53
|
+
});
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
56
|
#onBgClick = (): void => {
|
|
61
57
|
this.#popin.close();
|
|
62
|
-
}
|
|
63
|
-
|
|
58
|
+
};
|
|
64
59
|
|
|
65
60
|
destroy(): void {
|
|
66
|
-
this.#$bgLayer.removeEventListener(
|
|
61
|
+
this.#$bgLayer.removeEventListener(CLICK_EVENT_NAME, this.#onBgClick);
|
|
67
62
|
}
|
|
68
63
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { on, off }
|
|
2
|
-
import { extend }
|
|
3
|
-
import Popin
|
|
4
|
-
import PopinBackground
|
|
5
|
-
import { CLICK_EVENT_NAME, defaultOptions
|
|
6
|
-
|
|
1
|
+
import { on, off } from "../../Events/EventsManager";
|
|
2
|
+
import { extend } from "../../Helpers/Extend";
|
|
3
|
+
import Popin from "./Popin";
|
|
4
|
+
import PopinBackground from "./PopinBackground";
|
|
5
|
+
import { CLICK_EVENT_NAME, defaultOptions } from "./Tools";
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Create a controller tha manage all popin in the page
|
|
@@ -15,138 +14,136 @@ import { CLICK_EVENT_NAME, defaultOptions, toggleTabIndex } from './Tools';
|
|
|
15
14
|
* popin.loadForm( $form );
|
|
16
15
|
*/
|
|
17
16
|
export default class PopinController implements FLib.Popin.Controller {
|
|
18
|
-
#options:
|
|
19
|
-
#selectors:
|
|
17
|
+
#options: FLib.Popin.Options;
|
|
18
|
+
#selectors: FLib.Popin.SelectorsOptions;
|
|
20
19
|
#background: PopinBackground;
|
|
21
|
-
#popin:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
#popin: Popin;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
userOptions: FLib.Popin.OptionsInit = {},
|
|
24
|
+
$popin?: HTMLElement,
|
|
25
|
+
) {
|
|
26
|
+
if (!("AbortController" in window)) {
|
|
27
|
+
throw "This plugin uses fecth and AbortController. You may need to add a polyfill for this browser.";
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
this.#options = extend(
|
|
30
|
+
this.#options = extend(defaultOptions, userOptions);
|
|
31
31
|
|
|
32
32
|
this.#selectors = this.#options.selectors;
|
|
33
33
|
|
|
34
34
|
// global var, only one background for all popin
|
|
35
|
-
this.#background = new PopinBackground(
|
|
36
|
-
|
|
37
|
-
this.#popin = new Popin( {
|
|
38
|
-
...this.#options
|
|
39
|
-
},
|
|
40
|
-
$popin,
|
|
41
|
-
{
|
|
42
|
-
"controller": this,
|
|
43
|
-
"background": this.#background
|
|
44
|
-
} );
|
|
35
|
+
this.#background = new PopinBackground(this, this.#options);
|
|
45
36
|
|
|
37
|
+
this.#popin = new Popin(
|
|
38
|
+
{
|
|
39
|
+
...this.#options,
|
|
40
|
+
},
|
|
41
|
+
$popin,
|
|
42
|
+
{
|
|
43
|
+
controller: this,
|
|
44
|
+
background: this.#background,
|
|
45
|
+
},
|
|
46
|
+
);
|
|
46
47
|
|
|
47
48
|
// ------------------- BINDING
|
|
48
49
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"selector": `a[href="#${ $popin.id }"]`,
|
|
56
|
-
"callback": this.#openPopinHandler
|
|
57
|
-
} );
|
|
50
|
+
if ($popin) {
|
|
51
|
+
on(document.body, {
|
|
52
|
+
eventsName: CLICK_EVENT_NAME,
|
|
53
|
+
selector: `a[href="#${$popin.id}"]`,
|
|
54
|
+
callback: this.#openPopinHandler,
|
|
55
|
+
});
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
on(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const $triggerOnLoadPopin = document.querySelector( `[${ this.#selectors.openOnLoadAttribute }]` );
|
|
59
|
+
on(document.body, {
|
|
60
|
+
eventsName: CLICK_EVENT_NAME,
|
|
61
|
+
selector: this.#selectors.links,
|
|
62
|
+
callback: this.#openPopinHandler,
|
|
63
|
+
});
|
|
64
|
+
on(document.body, {
|
|
65
|
+
eventsName: "submit",
|
|
66
|
+
selector: this.#selectors.forms,
|
|
67
|
+
callback: this.#openPopinHandler,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const $triggerOnLoadPopin = document.querySelector(
|
|
71
|
+
`[${this.#selectors.openOnLoadAttribute}]`,
|
|
72
|
+
);
|
|
77
73
|
|
|
78
|
-
if (
|
|
74
|
+
if ($triggerOnLoadPopin) {
|
|
79
75
|
this.#parseElement(
|
|
80
76
|
$triggerOnLoadPopin as HTMLElement,
|
|
81
|
-
$triggerOnLoadPopin.getAttribute(
|
|
77
|
+
$triggerOnLoadPopin.getAttribute(
|
|
78
|
+
this.#selectors.openOnLoadAttribute,
|
|
79
|
+
),
|
|
82
80
|
);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
#parseElement = (
|
|
85
|
+
$dom: HTMLElement,
|
|
86
|
+
customUrl?: string | null,
|
|
87
|
+
): Promise<void> => {
|
|
88
|
+
if (customUrl) {
|
|
89
|
+
return this.#popin.load(customUrl);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
if (
|
|
93
|
-
return this.#popin.loadForm(
|
|
92
|
+
if ($dom.nodeName === "FORM") {
|
|
93
|
+
return this.#popin.loadForm($dom as HTMLFormElement);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
const anchor = $dom.getAttribute(
|
|
96
|
+
const anchor = $dom.getAttribute("href");
|
|
97
97
|
|
|
98
|
-
if (
|
|
98
|
+
if (anchor && anchor.indexOf("#") === 0) {
|
|
99
99
|
return this.#popin.open();
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
return this.#popin.loadLink(
|
|
103
|
-
}
|
|
104
|
-
|
|
102
|
+
return this.#popin.loadLink($dom as HTMLAnchorElement);
|
|
103
|
+
};
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
#openPopinHandler = ( e: Event, $target: HTMLElement): void => {
|
|
105
|
+
#openPopinHandler = (e: Event, $target: HTMLElement): void => {
|
|
108
106
|
e.preventDefault();
|
|
109
107
|
|
|
110
|
-
this.#parseElement(
|
|
111
|
-
}
|
|
112
|
-
|
|
108
|
+
this.#parseElement($target);
|
|
109
|
+
};
|
|
113
110
|
|
|
114
111
|
/**
|
|
115
112
|
* Load a file and display it in the popin
|
|
116
113
|
*
|
|
117
114
|
* @param data - All parameters available for window.fetch
|
|
118
115
|
*/
|
|
119
|
-
load(
|
|
120
|
-
|
|
116
|
+
load(
|
|
117
|
+
url: string,
|
|
118
|
+
data: RequestInit,
|
|
119
|
+
type?: FLib.Popin.ResponseType,
|
|
120
|
+
): Promise<void> {
|
|
121
|
+
return this.#popin.load(url, data, type);
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
124
|
/**
|
|
125
125
|
* Send a form and display the result it in the popin
|
|
126
126
|
*/
|
|
127
|
-
loadForm(
|
|
128
|
-
return this.#popin.loadForm(
|
|
127
|
+
loadForm($form: HTMLFormElement): Promise<void> {
|
|
128
|
+
return this.#popin.loadForm($form);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
132
131
|
/**
|
|
133
132
|
* Load a page from a link and display the result it in the popin
|
|
134
133
|
*/
|
|
135
|
-
loadLink(
|
|
136
|
-
return this.#popin.loadLink(
|
|
134
|
+
loadLink($link: HTMLAnchorElement): Promise<void> {
|
|
135
|
+
return this.#popin.loadLink($link);
|
|
137
136
|
}
|
|
138
137
|
|
|
139
|
-
|
|
140
138
|
/**
|
|
141
139
|
* Insert some html in the popin and open it
|
|
142
140
|
*
|
|
143
141
|
* @param openFirst - Open the popin THEN insert the html
|
|
144
142
|
*/
|
|
145
|
-
set(
|
|
146
|
-
return this.#popin.set(
|
|
143
|
+
set(html: string, openFirst?: boolean): Promise<void> {
|
|
144
|
+
return this.#popin.set(html, openFirst);
|
|
147
145
|
}
|
|
148
146
|
|
|
149
|
-
|
|
150
147
|
/**
|
|
151
148
|
* Remove the content of the popin
|
|
152
149
|
*/
|
|
@@ -154,7 +151,6 @@ export default class PopinController implements FLib.Popin.Controller {
|
|
|
154
151
|
return this.#popin.clear();
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
|
|
158
154
|
/**
|
|
159
155
|
* Close the popin
|
|
160
156
|
*/
|
|
@@ -162,7 +158,6 @@ export default class PopinController implements FLib.Popin.Controller {
|
|
|
162
158
|
return this.#popin.close();
|
|
163
159
|
}
|
|
164
160
|
|
|
165
|
-
|
|
166
161
|
/**
|
|
167
162
|
* Open the popin
|
|
168
163
|
*/
|
|
@@ -170,7 +165,6 @@ export default class PopinController implements FLib.Popin.Controller {
|
|
|
170
165
|
return this.#popin.open();
|
|
171
166
|
}
|
|
172
167
|
|
|
173
|
-
|
|
174
168
|
/**
|
|
175
169
|
* Remove all events, css class or inline styles
|
|
176
170
|
*/
|
|
@@ -178,15 +172,11 @@ export default class PopinController implements FLib.Popin.Controller {
|
|
|
178
172
|
this.#background.destroy();
|
|
179
173
|
this.#popin.destroy();
|
|
180
174
|
|
|
181
|
-
off(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
"callback": this.#openPopinHandler
|
|
186
|
-
}
|
|
187
|
-
);
|
|
175
|
+
off(document.body, {
|
|
176
|
+
eventsName: `${CLICK_EVENT_NAME} submit`,
|
|
177
|
+
callback: this.#openPopinHandler,
|
|
178
|
+
});
|
|
188
179
|
|
|
189
180
|
return this;
|
|
190
181
|
}
|
|
191
|
-
|
|
192
182
|
}
|
package/Modules/Popin/Tools.ts
CHANGED
|
@@ -1,86 +1,80 @@
|
|
|
1
|
+
export const FOCUSABLE_ELEMENTS_SELECTOR =
|
|
2
|
+
'a[href],button:not([disabled]),textarea,input,select,[tabindex]:not([tabindex="-1"])';
|
|
1
3
|
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
$elements = $elements || $popin.querySelectorAll( FOCUSABLE_ELEMENTS_SELECTOR );
|
|
6
|
-
const tabIndex = activate ? '0' : '-1';
|
|
7
|
-
$elements.forEach( e => e.setAttribute( 'tabindex', tabIndex ) );
|
|
8
|
-
$popin.setAttribute( 'tabindex', tabIndex );
|
|
9
|
-
$popin.setAttribute( 'aria-hidden', activate ? 'false' : 'true' );
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const CLICK_EVENT_NAME = window.matchMedia( '(hover: none)' ).matches ? 'touchend' : 'click';
|
|
4
|
+
export const CLICK_EVENT_NAME = window.matchMedia("(hover: none)").matches
|
|
5
|
+
? "touchend"
|
|
6
|
+
: "click";
|
|
13
7
|
|
|
14
8
|
export const defaultOptions = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
modal: false,
|
|
10
|
+
errorMessage: "Error while loading...",
|
|
11
|
+
marginHeight: 20,
|
|
12
|
+
autoResize: false,
|
|
13
|
+
enableKeyboard: true,
|
|
14
|
+
isBackgroundAside: true,
|
|
15
|
+
onLoad: (): Promise<any> => {
|
|
22
16
|
return Promise.resolve();
|
|
23
17
|
},
|
|
24
|
-
|
|
25
|
-
return
|
|
18
|
+
setLinkResponseType: (): string => {
|
|
19
|
+
return "text";
|
|
26
20
|
},
|
|
27
|
-
|
|
28
|
-
return
|
|
21
|
+
setFormResponseType: (): string => {
|
|
22
|
+
return "text";
|
|
29
23
|
},
|
|
30
|
-
|
|
24
|
+
checkValidity: (): boolean => {
|
|
31
25
|
return true;
|
|
32
26
|
},
|
|
33
|
-
|
|
27
|
+
normalize: <V>(body: V): { success: boolean; data: V } => {
|
|
34
28
|
return {
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
success: true,
|
|
30
|
+
data: body,
|
|
37
31
|
};
|
|
38
32
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
autoHandleAjaxError: true,
|
|
34
|
+
templates: {
|
|
35
|
+
popinLoader: '<div class="popin-loader"></div>',
|
|
36
|
+
popin: '<div class="popin"><div class="popin-content"></div></div>',
|
|
37
|
+
bgLayer: '<div class="bg-popin"></div>',
|
|
38
|
+
errorMessage: '<div class="error">{{ message }}</div>',
|
|
45
39
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
selectors: {
|
|
41
|
+
popin: ".popin",
|
|
42
|
+
popinBody: ".popin",
|
|
43
|
+
popinContent: ".popin-content",
|
|
44
|
+
links: "a[data-popin]",
|
|
45
|
+
forms: "form[data-popin]",
|
|
46
|
+
btClosePopin: "button[data-close-popin]",
|
|
47
|
+
openOnLoadAttribute: "data-onload-popin",
|
|
54
48
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
$bg.style.display =
|
|
49
|
+
animations: {
|
|
50
|
+
openBg: ($bg: HTMLElement): Promise<any> => {
|
|
51
|
+
$bg.style.display = "block";
|
|
58
52
|
return Promise.resolve();
|
|
59
53
|
},
|
|
60
|
-
|
|
61
|
-
$bg.style.display =
|
|
54
|
+
closeBg: ($bg: HTMLElement): Promise<any> => {
|
|
55
|
+
$bg.style.display = "none";
|
|
62
56
|
return Promise.resolve();
|
|
63
57
|
},
|
|
64
|
-
|
|
65
|
-
$popin.style.display =
|
|
66
|
-
$popin.style.opacity =
|
|
58
|
+
initOpenPopin: ($popin: HTMLElement): Promise<any> => {
|
|
59
|
+
$popin.style.display = "block";
|
|
60
|
+
$popin.style.opacity = "0";
|
|
67
61
|
return Promise.resolve();
|
|
68
62
|
},
|
|
69
|
-
|
|
70
|
-
$popin.style.opacity =
|
|
63
|
+
openPopin: ($popin: HTMLElement): Promise<any> => {
|
|
64
|
+
$popin.style.opacity = "1";
|
|
71
65
|
return Promise.resolve();
|
|
72
66
|
},
|
|
73
|
-
|
|
74
|
-
$popin.style.display =
|
|
67
|
+
closePopin: ($popin: HTMLElement): Promise<any> => {
|
|
68
|
+
$popin.style.display = "none";
|
|
75
69
|
return Promise.resolve();
|
|
76
70
|
},
|
|
77
|
-
|
|
78
|
-
$loader.style.display =
|
|
71
|
+
openLoader: ($loader: HTMLElement): Promise<any> => {
|
|
72
|
+
$loader.style.display = "block";
|
|
79
73
|
return Promise.resolve();
|
|
80
74
|
},
|
|
81
|
-
|
|
82
|
-
$loader.style.display =
|
|
75
|
+
closeLoader: ($loader: HTMLElement): Promise<any> => {
|
|
76
|
+
$loader.style.display = "none";
|
|
83
77
|
return Promise.resolve();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@creative-web-solution/front-library",
|
|
3
3
|
"title": "Frontend library",
|
|
4
4
|
"description": "Frontend functions and modules",
|
|
5
|
-
"version": "7.1.
|
|
5
|
+
"version": "7.1.55",
|
|
6
6
|
"homepage": "https://github.com/creative-web-solution/front-library",
|
|
7
7
|
"author": "Creative Web Solution <contact@cws-studio.com> (https://www.cws-studio.com)",
|
|
8
8
|
"keywords": [],
|