webcimes-modal 2.0.2 → 2.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/README.md +54 -8
- package/demo/script_esm.js +49 -1
- package/demo/script_udm.js +49 -1
- package/dist/js/webcimes-modal.esm.d.ts +8 -4
- package/dist/js/webcimes-modal.esm.js +1 -1
- package/dist/js/webcimes-modal.esm.js.map +1 -1
- package/dist/js/webcimes-modal.udm.d.ts +8 -4
- package/dist/js/webcimes-modal.udm.js +1 -1
- package/dist/js/webcimes-modal.udm.js.map +1 -1
- package/package.json +42 -42
- package/src/ts/webcimes-modal.d.ts +8 -4
- package/src/ts/webcimes-modal.d.ts.map +1 -1
- package/src/ts/webcimes-modal.ts +201 -85
- package/test/script.js +31 -2
package/README.md
CHANGED
|
@@ -97,8 +97,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
97
97
|
setClass: null, // set a specific class on the modal, default "null"
|
|
98
98
|
width: 'auto', // width (specify unit), default "auto"
|
|
99
99
|
height: 'auto', // height (specify unit), default "auto"
|
|
100
|
+
headerHtml: null, // html for header (overrides titleHtml), default "null"
|
|
100
101
|
titleHtml: 'My title', // html for title, default "null"
|
|
101
102
|
bodyHtml: 'My Body', // html for body, default "null"
|
|
103
|
+
footerHtml: null, // html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default "null"
|
|
102
104
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
103
105
|
buttonConfirmHtml: 'Confirm', // html for confirm button, default "null"
|
|
104
106
|
closeOnCancelButton: false, // close modal after trigger cancel button, default "true"
|
|
@@ -169,28 +171,72 @@ After a creating a modal, the basic html structure look like this:
|
|
|
169
171
|
|
|
170
172
|
All parameters are optionnal, but to set the base message on the modal you can use `titleHtml` to create the title, `bodyHtml` contain the main message of the modal, and `buttonCancelHtml` & `buttonConfirmHtml` contain the html for each button.
|
|
171
173
|
|
|
172
|
-
For these
|
|
174
|
+
For these fields you can provide:
|
|
175
|
+
|
|
176
|
+
- **String**: Plain text or HTML tags
|
|
177
|
+
- **HTMLElement**: A DOM element
|
|
178
|
+
- **Function**: A function that returns an HTMLElement (useful for dynamic content or lazy loading)
|
|
173
179
|
|
|
174
180
|
```javascript
|
|
175
181
|
const myModal = createWebcimesModal({
|
|
176
182
|
titleHtml: "My title <span style='color:red'>with red color</span>", // directly put an html tag or attribute like span and style
|
|
177
|
-
bodyHtml: document.querySelector('#myID')
|
|
178
|
-
buttonCancelHtml:
|
|
183
|
+
bodyHtml: document.querySelector('#myID'), // set HTMLElement directly
|
|
184
|
+
buttonCancelHtml: () => {
|
|
185
|
+
const btn = document.createElement('span');
|
|
186
|
+
btn.textContent = 'Cancel';
|
|
187
|
+
btn.style.fontWeight = 'bold';
|
|
188
|
+
return btn;
|
|
189
|
+
}, // use a function that returns an HTMLElement
|
|
179
190
|
buttonConfirmHtml: 'Confirm', // or just text
|
|
180
191
|
});
|
|
181
192
|
```
|
|
182
193
|
|
|
183
|
-
|
|
194
|
+
### Advanced: Full control with headerHtml and footerHtml
|
|
195
|
+
|
|
196
|
+
For complete customization, you can use `headerHtml` and `footerHtml` which override their respective simple options:
|
|
197
|
+
|
|
198
|
+
- `headerHtml` overrides `titleHtml`
|
|
199
|
+
- `footerHtml` overrides `buttonCancelHtml` and `buttonConfirmHtml`
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
const myModal = createWebcimesModal({
|
|
203
|
+
headerHtml: () => {
|
|
204
|
+
const header = document.createElement('div');
|
|
205
|
+
header.innerHTML = '<h2>Custom Header</h2><p>Subtitle here</p>';
|
|
206
|
+
return header;
|
|
207
|
+
},
|
|
208
|
+
showCloseButton: true, // Close button will still be added
|
|
209
|
+
footerHtml: () => {
|
|
210
|
+
const footer = document.createElement('div');
|
|
211
|
+
footer.innerHTML = '<button class="webcimes-modal__close">Custom Close</button>';
|
|
212
|
+
return footer;
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Note**: Any element with the class `webcimes-modal__close` will automatically close the modal when clicked.
|
|
218
|
+
|
|
219
|
+
if any of these fields is set to null (the default), it will not appear on the modal
|
|
184
220
|
|
|
185
221
|
### Remove specific structure of the modal:
|
|
186
222
|
|
|
187
|
-
|
|
223
|
+
Modal sections are automatically hidden when all their content properties are empty or disabled:
|
|
224
|
+
|
|
225
|
+
**To remove `webcimes-modal__header`:** set `headerHtml` to `null`, `titleHtml` to `null` and `showCloseButton` to `false`
|
|
226
|
+
|
|
227
|
+
**To remove `webcimes-modal__body`:** set `bodyHtml` to `null`
|
|
188
228
|
|
|
189
|
-
To remove `webcimes-
|
|
229
|
+
**To remove `webcimes-modal__footer`:** set `footerHtml` to `null`, `buttonCancelHtml` to `null` and `buttonConfirmHtml` to `null`
|
|
190
230
|
|
|
191
|
-
|
|
231
|
+
Example:
|
|
192
232
|
|
|
193
|
-
|
|
233
|
+
```javascript
|
|
234
|
+
const myModal = createWebcimesModal({
|
|
235
|
+
bodyHtml: 'My message', // Only body will be displayed
|
|
236
|
+
// header is removed (all null/false)
|
|
237
|
+
// footer is removed (all null)
|
|
238
|
+
});
|
|
239
|
+
```
|
|
194
240
|
|
|
195
241
|
### Scale the modal:
|
|
196
242
|
|
package/demo/script_esm.js
CHANGED
|
@@ -3,13 +3,16 @@ import { createWebcimesModal } from '../dist/js/webcimes-modal.esm.js';
|
|
|
3
3
|
|
|
4
4
|
// Wait for dom content loaded
|
|
5
5
|
document.addEventListener('DOMContentLoaded', function () {
|
|
6
|
+
// Example 1: Full options with string content
|
|
6
7
|
const myModal = createWebcimesModal({
|
|
7
8
|
setId: null, // set specific id to the modal, default "null"
|
|
8
9
|
setClass: null, // set specific class to the modal, default "null"
|
|
9
10
|
width: 'auto', // width (specify the unit), default "auto"
|
|
10
11
|
height: 'auto', // height (specify the unit), default "auto"
|
|
12
|
+
headerHtml: null, // html for header (overrides titleHtml), default "null"
|
|
11
13
|
titleHtml: 'My title', // html for title, default "null"
|
|
12
14
|
bodyHtml: 'My Body', // html for body, default "null"
|
|
15
|
+
footerHtml: null, // html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default "null"
|
|
13
16
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
14
17
|
buttonConfirmHtml: 'Confirm', // html for confirm button, default "null"
|
|
15
18
|
closeOnCancelButton: true, // close the modal after trigger cancel button, default "true"
|
|
@@ -46,9 +49,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
46
49
|
}, // callback after trigger confirm button
|
|
47
50
|
});
|
|
48
51
|
|
|
52
|
+
// Example 2: Modal with HTMLElement from DOM
|
|
49
53
|
const myModal2 = createWebcimesModal({
|
|
50
54
|
titleHtml: 'My title', // html for title, default "null"
|
|
51
|
-
bodyHtml: document.querySelector('.test')
|
|
55
|
+
bodyHtml: document.querySelector('.test'), // pass HTMLElement directly
|
|
52
56
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
53
57
|
buttonConfirmHtml: 'Confirm', // html for confirm button, default "null"
|
|
54
58
|
closeOnConfirmButton: false, // close the modal after trigger confirm button, default "true"
|
|
@@ -60,4 +64,48 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
60
64
|
myModal2.destroy();
|
|
61
65
|
}, // callback after trigger confirm button
|
|
62
66
|
});
|
|
67
|
+
|
|
68
|
+
// Example 3: Modal with custom header and footer using functions
|
|
69
|
+
createWebcimesModal({
|
|
70
|
+
headerHtml: () => {
|
|
71
|
+
const header = document.createElement('div');
|
|
72
|
+
header.innerHTML =
|
|
73
|
+
'<h2 style="margin: 0; color: #333;">Custom Header</h2><p style="margin: 5px 0 0; font-size: 14px; color: #666;">With dynamic content</p>';
|
|
74
|
+
return header;
|
|
75
|
+
},
|
|
76
|
+
bodyHtml: () => {
|
|
77
|
+
const body = document.createElement('div');
|
|
78
|
+
body.innerHTML =
|
|
79
|
+
'<p>This modal demonstrates custom header and footer.</p><p>The close button is automatically added after the header content.</p>';
|
|
80
|
+
return body;
|
|
81
|
+
},
|
|
82
|
+
footerHtml: () => {
|
|
83
|
+
const footer = document.createElement('div');
|
|
84
|
+
footer.style.display = 'flex';
|
|
85
|
+
footer.style.gap = '10px';
|
|
86
|
+
footer.style.justifyContent = 'flex-end';
|
|
87
|
+
|
|
88
|
+
const cancelBtn = document.createElement('button');
|
|
89
|
+
cancelBtn.textContent = 'Custom Cancel';
|
|
90
|
+
cancelBtn.className = 'webcimes-modal__close';
|
|
91
|
+
cancelBtn.style.padding = '8px 16px';
|
|
92
|
+
cancelBtn.style.cursor = 'pointer';
|
|
93
|
+
|
|
94
|
+
const confirmBtn = document.createElement('button');
|
|
95
|
+
confirmBtn.textContent = 'Custom Confirm';
|
|
96
|
+
confirmBtn.className = 'webcimes-modal__close';
|
|
97
|
+
confirmBtn.style.padding = '8px 16px';
|
|
98
|
+
confirmBtn.style.cursor = 'pointer';
|
|
99
|
+
confirmBtn.style.background = '#007bff';
|
|
100
|
+
confirmBtn.style.color = 'white';
|
|
101
|
+
confirmBtn.style.border = 'none';
|
|
102
|
+
confirmBtn.style.borderRadius = '4px';
|
|
103
|
+
|
|
104
|
+
footer.appendChild(cancelBtn);
|
|
105
|
+
footer.appendChild(confirmBtn);
|
|
106
|
+
return footer;
|
|
107
|
+
},
|
|
108
|
+
showCloseButton: true, // Close button will be added after headerHtml content
|
|
109
|
+
allowCloseOutside: true,
|
|
110
|
+
});
|
|
63
111
|
});
|
package/demo/script_udm.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
// Wait for dom content loaded
|
|
2
2
|
document.addEventListener('DOMContentLoaded', function () {
|
|
3
|
+
// Example 1: Full options with string content
|
|
3
4
|
const myModal = createWebcimesModal({
|
|
4
5
|
setId: null, // set specific id to the modal, default "null"
|
|
5
6
|
setClass: null, // set specific class to the modal, default "null"
|
|
6
7
|
width: 'auto', // width (specify the unit), default "auto"
|
|
7
8
|
height: 'auto', // height (specify the unit), default "auto"
|
|
9
|
+
headerHtml: null, // html for header (overrides titleHtml), default "null"
|
|
8
10
|
titleHtml: 'My title', // html for title, default "null"
|
|
9
11
|
bodyHtml: 'My Body', // html for body, default "null"
|
|
12
|
+
footerHtml: null, // html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default "null"
|
|
10
13
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
11
14
|
buttonConfirmHtml: 'Confirm', // html for confirm button, default "null"
|
|
12
15
|
closeOnCancelButton: true, // close the modal after trigger cancel button, default "true"
|
|
@@ -43,9 +46,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
43
46
|
}, // callback after trigger confirm button
|
|
44
47
|
});
|
|
45
48
|
|
|
49
|
+
// Example 2: Modal with HTMLElement from DOM
|
|
46
50
|
const myModal2 = createWebcimesModal({
|
|
47
51
|
titleHtml: 'My title', // html for title, default "null"
|
|
48
|
-
bodyHtml: document.querySelector('.test')
|
|
52
|
+
bodyHtml: document.querySelector('.test'), // pass HTMLElement directly
|
|
49
53
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
50
54
|
buttonConfirmHtml: 'Confirm', // html for confirm button, default "null"
|
|
51
55
|
closeOnConfirmButton: false, // close the modal after trigger confirm button, default "true"
|
|
@@ -57,4 +61,48 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
57
61
|
myModal2.destroy();
|
|
58
62
|
}, // callback after trigger confirm button
|
|
59
63
|
});
|
|
64
|
+
|
|
65
|
+
// Example 3: Modal with custom header and footer using functions
|
|
66
|
+
createWebcimesModal({
|
|
67
|
+
headerHtml: () => {
|
|
68
|
+
const header = document.createElement('div');
|
|
69
|
+
header.innerHTML =
|
|
70
|
+
'<h2 style="margin: 0; color: #333;">Custom Header</h2><p style="margin: 5px 0 0; font-size: 14px; color: #666;">With dynamic content</p>';
|
|
71
|
+
return header;
|
|
72
|
+
},
|
|
73
|
+
bodyHtml: () => {
|
|
74
|
+
const body = document.createElement('div');
|
|
75
|
+
body.innerHTML =
|
|
76
|
+
'<p>This modal demonstrates custom header and footer.</p><p>The close button is automatically added after the header content.</p>';
|
|
77
|
+
return body;
|
|
78
|
+
},
|
|
79
|
+
footerHtml: () => {
|
|
80
|
+
const footer = document.createElement('div');
|
|
81
|
+
footer.style.display = 'flex';
|
|
82
|
+
footer.style.gap = '10px';
|
|
83
|
+
footer.style.justifyContent = 'flex-end';
|
|
84
|
+
|
|
85
|
+
const cancelBtn = document.createElement('button');
|
|
86
|
+
cancelBtn.textContent = 'Custom Cancel';
|
|
87
|
+
cancelBtn.className = 'webcimes-modal__close';
|
|
88
|
+
cancelBtn.style.padding = '8px 16px';
|
|
89
|
+
cancelBtn.style.cursor = 'pointer';
|
|
90
|
+
|
|
91
|
+
const confirmBtn = document.createElement('button');
|
|
92
|
+
confirmBtn.textContent = 'Custom Confirm';
|
|
93
|
+
confirmBtn.className = 'webcimes-modal__close';
|
|
94
|
+
confirmBtn.style.padding = '8px 16px';
|
|
95
|
+
confirmBtn.style.cursor = 'pointer';
|
|
96
|
+
confirmBtn.style.background = '#007bff';
|
|
97
|
+
confirmBtn.style.color = 'white';
|
|
98
|
+
confirmBtn.style.border = 'none';
|
|
99
|
+
confirmBtn.style.borderRadius = '4px';
|
|
100
|
+
|
|
101
|
+
footer.appendChild(cancelBtn);
|
|
102
|
+
footer.appendChild(confirmBtn);
|
|
103
|
+
return footer;
|
|
104
|
+
},
|
|
105
|
+
showCloseButton: true, // Close button will be added after headerHtml content
|
|
106
|
+
allowCloseOutside: true,
|
|
107
|
+
});
|
|
60
108
|
});
|
|
@@ -29,14 +29,18 @@ export interface Options {
|
|
|
29
29
|
width: string;
|
|
30
30
|
/** height (specify unit), default "auto" */
|
|
31
31
|
height: string;
|
|
32
|
+
/** html for header (overrides titleHtml), default "null" */
|
|
33
|
+
headerHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
32
34
|
/** html for title, default "null" */
|
|
33
|
-
titleHtml: string | null;
|
|
35
|
+
titleHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
34
36
|
/** html for body, default "null" */
|
|
35
|
-
bodyHtml: string | null;
|
|
37
|
+
bodyHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
38
|
+
/** html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default "null" */
|
|
39
|
+
footerHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
36
40
|
/** html for cancel button, default "null" */
|
|
37
|
-
buttonCancelHtml: string | null;
|
|
41
|
+
buttonCancelHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
38
42
|
/** html for confirm button, default "null" */
|
|
39
|
-
buttonConfirmHtml: string | null;
|
|
43
|
+
buttonConfirmHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
40
44
|
/** close modal after trigger cancel button, default "true" */
|
|
41
45
|
closeOnCancelButton: boolean;
|
|
42
46
|
/** close modal after trigger confirm button, default "true" */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t={d:(o,e)=>{for(var s in e)t.o(e,s)&&!t.o(o,s)&&Object.defineProperty(o,s,{enumerable:!0,get:e[s]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o)},o={};t.d(o,{H:()=>s});class e{modals;modal;options;eventCancelButton=()=>{this.modal.dispatchEvent(new CustomEvent("onCancelButton")),"function"==typeof this.options.onCancelButton&&this.options.onCancelButton()};eventConfirmButton=()=>{this.modal.dispatchEvent(new CustomEvent("onConfirmButton")),"function"==typeof this.options.onConfirmButton&&this.options.onConfirmButton()};eventClickOutside=t=>{t.target==this.modals&&(this.options.allowCloseOutside?this.destroy():(this.modal.classList.add("animGrowShrink"),setTimeout((()=>{this.modal.classList.remove("animGrowShrink")}),this.options.animationDuration)))};eventClickCloseButton=()=>{this.destroy()};eventDragModalOnTop=t=>{if(!t.target.closest(".webcimes-modal__close")&&document.querySelectorAll(".webcimes-modal").length>1&&null!==this.modal.nextElementSibling){let t=this.modal.scrollTop;this.modals.insertAdjacentElement("beforeend",this.modal),this.modal.scrollTop=t}};position;offset;isDragging=!1;moveFromElements=[];eventDragStart=t=>{t.target.closest(".webcimes-modal__button")||(this.isDragging=!0,t.clientX?this.offset={x:this.modal.offsetLeft-t.clientX,y:this.modal.offsetTop-t.clientY}:t.touches&&(this.offset={x:this.modal.offsetLeft-t.touches[0].clientX,y:this.modal.offsetTop-t.touches[0].clientY}))};eventMove=t=>{this.isDragging&&(t.clientX?this.position={x:t.clientX,y:t.clientY}:t.touches&&(this.position={x:t.touches[0].clientX,y:t.touches[0].clientY}),this.modal.style.left=this.position.x+this.offset.x+"px",this.modal.style.top=this.position.y+this.offset.y+"px")};eventDragStop=()=>{this.isDragging=!1};eventPreventSelectText=t=>{this.isDragging&&t.preventDefault()};eventResize=()=>{this.modal.style.removeProperty("left"),this.modal.style.removeProperty("top")};constructor(t){this.options={setId:null,setClass:null,width:"auto",height:"auto",titleHtml:null,bodyHtml:null,buttonCancelHtml:null,buttonConfirmHtml:null,closeOnCancelButton:!0,closeOnConfirmButton:!0,showCloseButton:!0,allowCloseOutside:!0,allowMovement:!0,moveFromHeader:!0,moveFromBody:!1,moveFromFooter:!0,stickyHeader:!0,stickyFooter:!0,style:null,animationOnShow:"animDropDown",animationOnDestroy:"animDropUp",animationDuration:500,beforeShow:()=>{},afterShow:()=>{},beforeDestroy:()=>{},afterDestroy:()=>{},onCancelButton:()=>{},onConfirmButton:()=>{},...t},this.init()}init(){if(document.querySelector(".webcimes-modals")?(this.modals=document.querySelector(".webcimes-modals"),this.modals.classList.remove("animFadeOut")):(document.body.insertAdjacentHTML("beforeend",'<div class="webcimes-modals animFadeIn"></div>'),this.modals=document.querySelector(".webcimes-modals"),this.modals.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modals.classList.remove("animFadeIn")}),this.options.animationDuration)),this.modals.insertAdjacentHTML("beforeend",'<div class="webcimes-modal '+(this.options.setClass?this.options.setClass:"")+" "+this.options.animationOnShow+'" '+(this.options.setId?'id="'+this.options.setId+'"':"")+">\n\t\t\t\t"+(this.options.titleHtml||this.options.showCloseButton?'<div class="webcimes-modal__header '+(this.options.stickyHeader?"webcimes-modal__header--is-sticky":"")+" "+(this.options.moveFromHeader?"webcimes-modal__header--is-movable":"")+'">\n\t\t\t\t\t\t'+(this.options.titleHtml?'<div class="webcimes-modal__title">'+this.options.titleHtml+"</div>":"")+"\n\t\t\t\t\t\t"+(this.options.showCloseButton?'<button class="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close"></button>':"")+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t\t"+(this.options.bodyHtml?'<div class="webcimes-modal__body '+(this.options.moveFromBody?".webcimes-modal__body--is-movable":"")+'">\n\t\t\t\t\t\t'+this.options.bodyHtml+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t\t"+(this.options.buttonCancelHtml||this.options.buttonConfirmHtml?'<div class="webcimes-modal__footer '+(this.options.stickyFooter?".webcimes-modal__footer--is-sticky":"")+" "+(this.options.moveFromFooter?"webcimes-modal__footer--is-movable":"")+'">\n\t\t\t\t\t\t'+(this.options.buttonCancelHtml?'<button class="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel '+(this.options.closeOnCancelButton?"webcimes-modal__close":"")+'">'+this.options.buttonCancelHtml+"</button>":"")+"\n\t\t\t\t\t\t"+(this.options.buttonConfirmHtml?'<button class="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm '+(this.options.closeOnConfirmButton?"webcimes-modal__close":"")+'">'+this.options.buttonConfirmHtml+"</button>":"")+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t</div>"),this.modal=this.modals.lastElementChild,setTimeout((()=>{this.modal.dispatchEvent(new CustomEvent("beforeShow")),"function"==typeof this.options.beforeShow&&this.options.beforeShow()}),0),this.modal.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modal.classList.remove(this.options.animationOnShow),this.modal.dispatchEvent(new CustomEvent("afterShow")),"function"==typeof this.options.afterShow&&this.options.afterShow()}),this.options.animationDuration),this.modal.style.setProperty("max-width","90%"),"auto"!=this.options.width&&this.options.width?this.modal.style.setProperty("width",this.options.width):this.modal.style.setProperty("width","max-content"),this.modal.style.setProperty("max-height","90%"),"auto"!=this.options.height&&this.options.height?this.modal.style.setProperty("height",this.options.height):this.modal.style.setProperty("height","max-content"),this.options.style){let t=this.modal.getAttribute("style")??"";this.modal.setAttribute("style",t+this.options.style)}this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.addEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.addEventListener("click",this.eventConfirmButton),this.modals.addEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.addEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.addEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(this.options.moveFromHeader&&this.modal.querySelector(".webcimes-modal__header")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__header")),this.options.moveFromBody&&this.modal.querySelector(".webcimes-modal__body")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__body")),this.options.moveFromFooter&&this.modal.querySelector(".webcimes-modal__footer")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__footer")),["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((o=>{o.addEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.addEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.addEventListener(t,this.eventDragStop)})),document.addEventListener("selectstart",this.eventPreventSelectText)),window.addEventListener("resize",this.eventResize)}destroy(){this.modal.getAttribute("data-destroying")||(this.modal.dispatchEvent(new CustomEvent("beforeDestroy")),"function"==typeof this.options.beforeDestroy&&this.options.beforeDestroy(),1==document.querySelectorAll(".webcimes-modal:not([data-destroying])").length&&this.modals.classList.add("animFadeOut"),this.modal.setAttribute("data-destroying","1"),this.modal.classList.add(this.options.animationOnDestroy),setTimeout((()=>{void 0!==this.modal&&(this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.removeEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.removeEventListener("click",this.eventConfirmButton),this.modals.removeEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.removeEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.removeEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((o=>{o.removeEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.removeEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.removeEventListener(t,this.eventDragStop)})),document.removeEventListener("selectstart",this.eventPreventSelectText)),window.removeEventListener("resize",this.eventResize),(document.querySelectorAll(".webcimes-modal").length>1?this.modal:this.modals).remove()),this.modal.dispatchEvent(new CustomEvent("afterDestroy")),"function"==typeof this.options.afterDestroy&&this.options.afterDestroy()}),this.options.animationDuration))}}function s(t){return new e(t)}var i=o.H;export{i as createWebcimesModal};
|
|
1
|
+
var t={d:(e,o)=>{for(var s in o)t.o(o,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:o[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{H:()=>s});class o{modals;modal;options;eventCancelButton=()=>{this.modal.dispatchEvent(new CustomEvent("onCancelButton")),"function"==typeof this.options.onCancelButton&&this.options.onCancelButton()};eventConfirmButton=()=>{this.modal.dispatchEvent(new CustomEvent("onConfirmButton")),"function"==typeof this.options.onConfirmButton&&this.options.onConfirmButton()};eventClickOutside=t=>{t.target==this.modals&&(this.options.allowCloseOutside?this.destroy():(this.modal.classList.add("animGrowShrink"),setTimeout((()=>{this.modal.classList.remove("animGrowShrink")}),this.options.animationDuration)))};eventClickCloseButton=()=>{this.destroy()};eventDragModalOnTop=t=>{if(!t.target.closest(".webcimes-modal__close")&&document.querySelectorAll(".webcimes-modal").length>1&&null!==this.modal.nextElementSibling){let t=this.modal.scrollTop;this.modals.insertAdjacentElement("beforeend",this.modal),this.modal.scrollTop=t}};position;offset;isDragging=!1;moveFromElements=[];eventDragStart=t=>{t.target.closest(".webcimes-modal__button")||(this.isDragging=!0,t.clientX?this.offset={x:this.modal.offsetLeft-t.clientX,y:this.modal.offsetTop-t.clientY}:t.touches&&(this.offset={x:this.modal.offsetLeft-t.touches[0].clientX,y:this.modal.offsetTop-t.touches[0].clientY}))};eventMove=t=>{this.isDragging&&(t.clientX?this.position={x:t.clientX,y:t.clientY}:t.touches&&(this.position={x:t.touches[0].clientX,y:t.touches[0].clientY}),this.modal.style.left=this.position.x+this.offset.x+"px",this.modal.style.top=this.position.y+this.offset.y+"px")};eventDragStop=()=>{this.isDragging=!1};eventPreventSelectText=t=>{this.isDragging&&t.preventDefault()};eventResize=()=>{this.modal.style.removeProperty("left"),this.modal.style.removeProperty("top")};setElementContent(t,e){"string"==typeof e?t.innerHTML=e:"function"==typeof e?t.appendChild(e()):t.appendChild(e)}buildHeader(){if(!this.options.headerHtml&&!this.options.titleHtml&&!this.options.showCloseButton)return null;const t=document.createElement("div");if(t.className="webcimes-modal__header",this.options.stickyHeader&&t.classList.add("webcimes-modal__header--is-sticky"),this.options.moveFromHeader&&t.classList.add("webcimes-modal__header--is-movable"),this.options.headerHtml){if(this.setElementContent(t,this.options.headerHtml),this.options.showCloseButton){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close",e.setAttribute("aria-label","Close modal"),t.appendChild(e)}return t}if(this.options.titleHtml){const e=document.createElement("div");e.className="webcimes-modal__title",this.setElementContent(e,this.options.titleHtml),t.appendChild(e)}if(this.options.showCloseButton){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close",e.setAttribute("aria-label","Close modal"),t.appendChild(e)}return t}buildBody(){if(!this.options.bodyHtml)return null;const t=document.createElement("div");return t.className="webcimes-modal__body",this.options.moveFromBody&&t.classList.add("webcimes-modal__body--is-movable"),this.setElementContent(t,this.options.bodyHtml),t}buildFooter(){if(!this.options.footerHtml&&!this.options.buttonCancelHtml&&!this.options.buttonConfirmHtml)return null;const t=document.createElement("div");if(t.className="webcimes-modal__footer",this.options.stickyFooter&&t.classList.add("webcimes-modal__footer--is-sticky"),this.options.moveFromFooter&&t.classList.add("webcimes-modal__footer--is-movable"),this.options.footerHtml)return this.setElementContent(t,this.options.footerHtml),t;if(this.options.buttonCancelHtml){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel",this.options.closeOnCancelButton&&e.classList.add("webcimes-modal__close"),this.setElementContent(e,this.options.buttonCancelHtml),t.appendChild(e)}if(this.options.buttonConfirmHtml){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm",this.options.closeOnConfirmButton&&e.classList.add("webcimes-modal__close"),this.setElementContent(e,this.options.buttonConfirmHtml),t.appendChild(e)}return t}buildModal(){const t=document.createElement("div");t.className=`webcimes-modal ${this.options.animationOnShow}`,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.options.setClass&&t.classList.add(this.options.setClass),this.options.setId&&(t.id=this.options.setId);const e=this.buildHeader();e&&t.appendChild(e);const o=this.buildBody();o&&t.appendChild(o);const s=this.buildFooter();return s&&t.appendChild(s),t}constructor(t){this.options={setId:null,setClass:null,width:"auto",height:"auto",headerHtml:null,titleHtml:null,bodyHtml:null,footerHtml:null,buttonCancelHtml:null,buttonConfirmHtml:null,closeOnCancelButton:!0,closeOnConfirmButton:!0,showCloseButton:!0,allowCloseOutside:!0,allowMovement:!0,moveFromHeader:!0,moveFromBody:!1,moveFromFooter:!0,stickyHeader:!0,stickyFooter:!0,style:null,animationOnShow:"animDropDown",animationOnDestroy:"animDropUp",animationDuration:500,beforeShow:()=>{},afterShow:()=>{},beforeDestroy:()=>{},afterDestroy:()=>{},onCancelButton:()=>{},onConfirmButton:()=>{},...t},this.init()}init(){if(document.querySelector(".webcimes-modals")?(this.modals=document.querySelector(".webcimes-modals"),this.modals.classList.remove("animFadeOut")):(this.modals=document.createElement("div"),this.modals.className="webcimes-modals animFadeIn",this.modals.style.setProperty("animation-duration",this.options.animationDuration+"ms"),document.body.appendChild(this.modals),setTimeout((()=>{this.modals.classList.remove("animFadeIn")}),this.options.animationDuration)),this.modal=this.buildModal(),this.modals.appendChild(this.modal),setTimeout((()=>{this.modal.dispatchEvent(new CustomEvent("beforeShow")),"function"==typeof this.options.beforeShow&&this.options.beforeShow()}),0),this.modal.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modal.classList.remove(this.options.animationOnShow),this.modal.dispatchEvent(new CustomEvent("afterShow")),"function"==typeof this.options.afterShow&&this.options.afterShow()}),this.options.animationDuration),this.modal.style.setProperty("max-width","90%"),"auto"!=this.options.width&&this.options.width?this.modal.style.setProperty("width",this.options.width):this.modal.style.setProperty("width","max-content"),this.modal.style.setProperty("max-height","90%"),"auto"!=this.options.height&&this.options.height?this.modal.style.setProperty("height",this.options.height):this.modal.style.setProperty("height","max-content"),this.options.style){let t=this.modal.getAttribute("style")??"";this.modal.setAttribute("style",t+this.options.style)}this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.addEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.addEventListener("click",this.eventConfirmButton),this.modals.addEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.addEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.addEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(this.options.moveFromHeader&&this.modal.querySelector(".webcimes-modal__header")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__header")),this.options.moveFromBody&&this.modal.querySelector(".webcimes-modal__body")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__body")),this.options.moveFromFooter&&this.modal.querySelector(".webcimes-modal__footer")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__footer")),["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.addEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.addEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.addEventListener(t,this.eventDragStop)})),document.addEventListener("selectstart",this.eventPreventSelectText)),window.addEventListener("resize",this.eventResize)}destroy(){this.modal.getAttribute("data-destroying")||(this.modal.dispatchEvent(new CustomEvent("beforeDestroy")),"function"==typeof this.options.beforeDestroy&&this.options.beforeDestroy(),1==document.querySelectorAll(".webcimes-modal:not([data-destroying])").length&&this.modals.classList.add("animFadeOut"),this.modal.setAttribute("data-destroying","1"),this.modal.classList.add(this.options.animationOnDestroy),setTimeout((()=>{void 0!==this.modal&&(this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.removeEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.removeEventListener("click",this.eventConfirmButton),this.modals.removeEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.removeEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.removeEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.removeEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.removeEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.removeEventListener(t,this.eventDragStop)})),document.removeEventListener("selectstart",this.eventPreventSelectText)),window.removeEventListener("resize",this.eventResize),(document.querySelectorAll(".webcimes-modal").length>1?this.modal:this.modals).remove()),this.modal.dispatchEvent(new CustomEvent("afterDestroy")),"function"==typeof this.options.afterDestroy&&this.options.afterDestroy()}),this.options.animationDuration))}}function s(t){return new o(t)}var i=e.H;export{i as createWebcimesModal};
|
|
2
2
|
//# sourceMappingURL=webcimes-modal.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"js/webcimes-modal.esm.js","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,sBCqGlF,MAAMI,EAEKC,OAGAC,MAGCC,QAEAC,kBAAgC,KAEpCC,KAAKH,MAAMI,cAAc,IAAIC,YAAY,mBACE,mBAAhCF,KAAKF,QAAQK,gBACpBH,KAAKF,QAAQK,gB,EAIbC,mBAAiC,KAErCJ,KAAKH,MAAMI,cAAc,IAAIC,YAAY,oBACG,mBAAjCF,KAAKF,QAAQO,iBACpBL,KAAKF,QAAQO,iB,EAIbC,kBAAyCC,IACzCA,EAAEC,QAAUR,KAAKJ,SACbI,KAAKF,QAAQW,kBAEbT,KAAKU,WAGLV,KAAKH,MAAMc,UAAUC,IAAI,kBAGzBC,YAAW,KACPb,KAAKH,MAAMc,UAAUG,OAAO,iBAAiB,GAC9Cd,KAAKF,QAAQiB,oB,EAKpBC,sBAAoC,KAExChB,KAAKU,SAAS,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b7D,KAAKF,QAAQgE,kBAEjB,CAAC,YAAa,cAAcmB,SAASE,IACjCnF,KAAK6B,iBAAiBoD,SAASC,IAC3BA,EAAGI,oBAAoBH,EAAWnF,KAAK8B,eAAe,GACxD,IAGN,CAAC,YAAa,aAAamD,SAASE,IAChChE,SAASmE,oBAAoBH,EAAWnF,KAAKsC,UAAU,IAG3D,CAAC,UAAW,YAAY2C,SAASE,IAC7BhE,SAASmE,oBAAoBH,EAAWnF,KAAK0C,cAAc,IAG/DvB,SAASmE,oBAAoB,cAAetF,KAAK2C,yBAGrD0C,OAAOC,oBAAoB,SAAUtF,KAAK6C,cAGzC1B,SAASC,iBAAiB,mBAAmBC,OAAS,EACjDrB,KAAKH,MACLG,KAAKJ,QACTkB,UAINd,KAAKH,MAAMI,cAAc,IAAIC,YAAY,iBACA,mBAA9BF,KAAKF,QAAQwE,cACpBtE,KAAKF,QAAQwE,c,GAElBtE,KAAKF,QAAQiB,mBAExB,EAMG,SAASwE,EAAoBzF,GAChC,OAAO,IAAIH,EAAkBG,EACjC,C","sources":["webpack://webcimes-modal/webpack/bootstrap","webpack://webcimes-modal/webpack/runtime/define property getters","webpack://webcimes-modal/webpack/runtime/hasOwnProperty shorthand","webpack://webcimes-modal/./src/ts/webcimes-modal.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","/**\r\n * Copyright (c) 2023 WebCimes - RICHARD Florian (https://webcimes.com)\r\n * MIT License - https://choosealicense.com/licenses/mit/\r\n * Date: 2023-03-25\r\n */\r\n\r\n'use strict';\r\n\r\n/**\r\n * Global\r\n */\r\ndeclare global {\r\n /** Events */\r\n interface GlobalEventHandlersEventMap {\r\n beforeShow: CustomEvent;\r\n afterShow: CustomEvent;\r\n beforeDestroy: CustomEvent;\r\n afterDestroy: CustomEvent;\r\n onCancelButton: CustomEvent;\r\n onConfirmButton: CustomEvent;\r\n }\r\n}\r\n\r\n/**\r\n * Options\r\n */\r\nexport interface Options {\r\n /** set a specific id on the modal. default \"null\" */\r\n setId: string | null;\r\n /** set a specific class on the modal, default \"null\" */\r\n setClass: string | null;\r\n /** width (specify unit), default \"auto\" */\r\n width: string;\r\n /** height (specify unit), default \"auto\" */\r\n height: string;\r\n /** html for title, default \"null\" */\r\n titleHtml: string | null;\r\n /** html for body, default \"null\" */\r\n bodyHtml: string | null;\r\n /** html for cancel button, default \"null\" */\r\n buttonCancelHtml: string | null;\r\n /** html for confirm button, default \"null\" */\r\n buttonConfirmHtml: string | null;\r\n /** close modal after trigger cancel button, default \"true\" */\r\n closeOnCancelButton: boolean;\r\n /** close modal after trigger confirm button, default \"true\" */\r\n closeOnConfirmButton: boolean;\r\n /** show close button, default \"true\" */\r\n showCloseButton: boolean;\r\n /** allow the modal to close when clicked outside, default \"true\" */\r\n allowCloseOutside: boolean;\r\n /** ability to move modal, default \"true\" */\r\n allowMovement: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from header, default \"true\" */\r\n moveFromHeader: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from body, default \"false\" */\r\n moveFromBody: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from footer, default \"true\" */\r\n moveFromFooter: boolean;\r\n /** keep header sticky (visible) when scrolling, default \"true\" */\r\n stickyHeader: boolean;\r\n /** keep footer sticky (visible) when scrolling, default \"true\" */\r\n stickyFooter: boolean;\r\n /** add extra css style to modal, default null */\r\n style: string | null;\r\n /** \"animDropDown\" or \"animFadeIn\" for show animation, default \"animDropDown\" */\r\n animationOnShow: 'animDropDown' | 'animFadeIn';\r\n /** \"animDropUp\" or \"animFadeOut\" for destroy animation, default \"animDropUp\" */\r\n animationOnDestroy: 'animDropUp' | 'animFadeOut';\r\n /** animation duration in ms, default \"500\" */\r\n animationDuration: number;\r\n /** callback before show modal */\r\n beforeShow: () => void;\r\n /** callback after show modal */\r\n afterShow: () => void;\r\n /** callback before destroy modal */\r\n beforeDestroy: () => void;\r\n /** callback after destroy modal */\r\n afterDestroy: () => void;\r\n /** callback after triggering cancel button */\r\n onCancelButton: () => void;\r\n /** callback after triggering confirm button */\r\n onConfirmButton: () => void;\r\n}\r\n\r\n/**\r\n * Public interface for WebcimesModal instances\r\n * This represents the actual accessible members of the instance\r\n */\r\nexport interface WebcimesModal {\r\n /** Get the dom element containing all modals */\r\n modals: HTMLElement;\r\n /** Get the dom element of the current modal */\r\n modal: HTMLElement;\r\n /** Destroy the current modal */\r\n destroy(): void;\r\n}\r\n\r\n/**\r\n * WebcimesModal implementation class\r\n */\r\nclass WebcimesModalImpl implements WebcimesModal {\r\n /** Get the dom element containing all modals */\r\n public modals: HTMLElement;\r\n\r\n /** Get the dom element of the current modal */\r\n public modal: HTMLElement;\r\n\r\n /** Options of the current modal */\r\n private options: Options;\r\n\r\n private eventCancelButton: () => void = () => {\r\n // Callback on cancel button\r\n this.modal.dispatchEvent(new CustomEvent('onCancelButton'));\r\n if (typeof this.options.onCancelButton === 'function') {\r\n this.options.onCancelButton();\r\n }\r\n };\r\n\r\n private eventConfirmButton: () => void = () => {\r\n // Callback on confirm button\r\n this.modal.dispatchEvent(new CustomEvent('onConfirmButton'));\r\n if (typeof this.options.onConfirmButton === 'function') {\r\n this.options.onConfirmButton();\r\n }\r\n };\r\n\r\n private eventClickOutside: (e: Event) => void = (e) => {\r\n if (e.target == this.modals) {\r\n if (this.options.allowCloseOutside) {\r\n // Destroy modal\r\n this.destroy();\r\n } else {\r\n // Add animation for show modal who can't be close\r\n this.modal.classList.add('animGrowShrink');\r\n\r\n // Delete animation after the animation delay\r\n setTimeout(() => {\r\n this.modal.classList.remove('animGrowShrink');\r\n }, this.options.animationDuration);\r\n }\r\n }\r\n };\r\n\r\n private eventClickCloseButton: () => void = () => {\r\n // Destroy modal\r\n this.destroy();\r\n };\r\n\r\n private eventDragModalOnTop: (e: Event) => void = (e) => {\r\n // Only if target is not close button (for bug in chrome)\r\n if (!(<HTMLElement>e.target).closest('.webcimes-modal__close')) {\r\n // If multiple modal, and modal not already on top (no next sibling), we place the current modal on the top\r\n if (\r\n document.querySelectorAll('.webcimes-modal').length > 1 &&\r\n this.modal.nextElementSibling !== null\r\n ) {\r\n let oldScrollTop = this.modal.scrollTop;\r\n this.modals.insertAdjacentElement('beforeend', this.modal);\r\n this.modal.scrollTop = oldScrollTop;\r\n }\r\n }\r\n };\r\n\r\n private position: { x: number; y: number };\r\n\r\n private offset: { x: number; y: number };\r\n\r\n private isDragging: boolean = false;\r\n\r\n private moveFromElements: HTMLElement[] = [];\r\n\r\n private eventDragStart: (e: Event) => void = (e) => {\r\n // Start drag only if it's not a button\r\n if (!(<HTMLElement>e.target).closest('.webcimes-modal__button')) {\r\n this.isDragging = true;\r\n\r\n // Mouse\r\n if ((<MouseEvent>e).clientX) {\r\n this.offset = {\r\n x: this.modal.offsetLeft - (<MouseEvent>e).clientX,\r\n y: this.modal.offsetTop - (<MouseEvent>e).clientY,\r\n };\r\n }\r\n // Touch device (use the first touch only)\r\n else if ((<TouchEvent>e).touches) {\r\n this.offset = {\r\n x: this.modal.offsetLeft - (<TouchEvent>e).touches[0].clientX,\r\n y: this.modal.offsetTop - (<TouchEvent>e).touches[0].clientY,\r\n };\r\n }\r\n }\r\n };\r\n\r\n private eventMove: (e: Event) => void = (e) => {\r\n if (this.isDragging) {\r\n // Mouse\r\n if ((<MouseEvent>e).clientX) {\r\n this.position = {\r\n x: (<MouseEvent>e).clientX,\r\n y: (<MouseEvent>e).clientY,\r\n };\r\n }\r\n // Touch device (use the first touch only)\r\n else if ((<TouchEvent>e).touches) {\r\n this.position = {\r\n x: (<TouchEvent>e).touches[0].clientX,\r\n y: (<TouchEvent>e).touches[0].clientY,\r\n };\r\n }\r\n this.modal.style.left = this.position.x + this.offset.x + 'px';\r\n this.modal.style.top = this.position.y + this.offset.y + 'px';\r\n }\r\n };\r\n\r\n private eventDragStop: () => void = () => {\r\n this.isDragging = false;\r\n };\r\n\r\n private eventPreventSelectText: (e: Event) => void = (e) => {\r\n if (this.isDragging) {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n private eventResize: () => void = () => {\r\n this.modal.style.removeProperty('left');\r\n this.modal.style.removeProperty('top');\r\n };\r\n\r\n /**\r\n * Create modal\r\n */\r\n constructor(options: Partial<Options>) {\r\n // Defaults\r\n const defaults: Options = {\r\n setId: null,\r\n setClass: null,\r\n width: 'auto',\r\n height: 'auto',\r\n titleHtml: null,\r\n bodyHtml: null,\r\n buttonCancelHtml: null,\r\n buttonConfirmHtml: null,\r\n closeOnCancelButton: true,\r\n closeOnConfirmButton: true,\r\n showCloseButton: true,\r\n allowCloseOutside: true,\r\n allowMovement: true,\r\n moveFromHeader: true,\r\n moveFromBody: false,\r\n moveFromFooter: true,\r\n stickyHeader: true,\r\n stickyFooter: true,\r\n style: null,\r\n animationOnShow: 'animDropDown',\r\n animationOnDestroy: 'animDropUp',\r\n animationDuration: 500,\r\n beforeShow: () => {},\r\n afterShow: () => {},\r\n beforeDestroy: () => {},\r\n afterDestroy: () => {},\r\n onCancelButton: () => {},\r\n onConfirmButton: () => {},\r\n };\r\n this.options = { ...defaults, ...options };\r\n\r\n // Call init method\r\n this.init();\r\n }\r\n\r\n /**\r\n * Initialization of the current modal\r\n */\r\n private init() {\r\n // Create modals\r\n if (!document.querySelector('.webcimes-modals')) {\r\n // Create modals\r\n document.body.insertAdjacentHTML(\r\n 'beforeend',\r\n '<div class=\"webcimes-modals animFadeIn\"></div>',\r\n );\r\n this.modals = <HTMLElement>document.querySelector('.webcimes-modals');\r\n\r\n // Set animation duration for modals\r\n this.modals.style.setProperty(\r\n 'animation-duration',\r\n this.options.animationDuration + 'ms',\r\n );\r\n\r\n // Delete enter animation after animation delay\r\n setTimeout(() => {\r\n this.modals.classList.remove('animFadeIn');\r\n }, this.options.animationDuration);\r\n } else {\r\n // Get modals\r\n this.modals = <HTMLElement>document.querySelector('.webcimes-modals');\r\n\r\n // Remove animFadeOut in case of create new modal after destroy the last one before (during animation duration)\r\n this.modals.classList.remove('animFadeOut');\r\n }\r\n\r\n // Create modal\r\n this.modals.insertAdjacentHTML(\r\n 'beforeend',\r\n `<div class=\"webcimes-modal ` +\r\n (this.options.setClass ? this.options.setClass : '') +\r\n ` ` +\r\n this.options.animationOnShow +\r\n `\" ` +\r\n (this.options.setId ? 'id=\"' + this.options.setId + '\"' : '') +\r\n `>\r\n\t\t\t\t` +\r\n (this.options.titleHtml || this.options.showCloseButton\r\n ? `<div class=\"webcimes-modal__header ` +\r\n (this.options.stickyHeader ? 'webcimes-modal__header--is-sticky' : '') +\r\n ` ` +\r\n (this.options.moveFromHeader ? 'webcimes-modal__header--is-movable' : '') +\r\n `\">\r\n\t\t\t\t\t\t` +\r\n (this.options.titleHtml\r\n ? '<div class=\"webcimes-modal__title\">' +\r\n this.options.titleHtml +\r\n '</div>'\r\n : '') +\r\n `\r\n\t\t\t\t\t\t` +\r\n (this.options.showCloseButton\r\n ? '<button class=\"webcimes-modal__button webcimes-modal__header-close webcimes-modal__close\"></button>'\r\n : '') +\r\n `\r\n\t\t\t\t\t</div>`\r\n : '') +\r\n `\r\n\t\t\t\t` +\r\n (this.options.bodyHtml\r\n ? `<div class=\"webcimes-modal__body ` +\r\n (this.options.moveFromBody ? '.webcimes-modal__body--is-movable' : '') +\r\n `\">\r\n\t\t\t\t\t\t` +\r\n this.options.bodyHtml +\r\n `\r\n\t\t\t\t\t</div>`\r\n : '') +\r\n `\r\n\t\t\t\t` +\r\n (this.options.buttonCancelHtml || this.options.buttonConfirmHtml\r\n ? `<div class=\"webcimes-modal__footer ` +\r\n (this.options.stickyFooter ? '.webcimes-modal__footer--is-sticky' : '') +\r\n ` ` +\r\n (this.options.moveFromFooter ? 'webcimes-modal__footer--is-movable' : '') +\r\n `\">\r\n\t\t\t\t\t\t` +\r\n (this.options.buttonCancelHtml\r\n ? '<button class=\"webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel ' +\r\n (this.options.closeOnCancelButton ? 'webcimes-modal__close' : '') +\r\n '\">' +\r\n this.options.buttonCancelHtml +\r\n '</button>'\r\n : '') +\r\n `\r\n\t\t\t\t\t\t` +\r\n (this.options.buttonConfirmHtml\r\n ? '<button class=\"webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm ' +\r\n (this.options.closeOnConfirmButton ? 'webcimes-modal__close' : '') +\r\n '\">' +\r\n this.options.buttonConfirmHtml +\r\n '</button>'\r\n : '') +\r\n `\r\n\t\t\t\t\t</div>`\r\n : '') +\r\n `\r\n\t\t\t</div>`,\r\n );\r\n this.modal = <HTMLElement>this.modals.lastElementChild;\r\n\r\n // Callback before show modal (set a timeout of zero, to wait for some dom to load)\r\n setTimeout(() => {\r\n this.modal.dispatchEvent(new CustomEvent('beforeShow'));\r\n if (typeof this.options.beforeShow === 'function') {\r\n this.options.beforeShow();\r\n }\r\n }, 0);\r\n\r\n // Set animation duration for modal\r\n this.modal.style.setProperty('animation-duration', this.options.animationDuration + 'ms');\r\n\r\n // Delete animation of enter after the animation delay\r\n setTimeout(() => {\r\n this.modal.classList.remove(this.options.animationOnShow);\r\n\r\n // Callback after show modal\r\n this.modal.dispatchEvent(new CustomEvent('afterShow'));\r\n if (typeof this.options.afterShow === 'function') {\r\n this.options.afterShow();\r\n }\r\n }, this.options.animationDuration);\r\n\r\n // Width of modal\r\n this.modal.style.setProperty('max-width', '90%');\r\n if (this.options.width != 'auto' && this.options.width) {\r\n this.modal.style.setProperty('width', this.options.width);\r\n } else {\r\n // \"max-content\" is for keep size in \"auto\" and for maximum to max-width\r\n this.modal.style.setProperty('width', 'max-content');\r\n }\r\n\r\n // Height of modal\r\n this.modal.style.setProperty('max-height', '90%');\r\n if (this.options.height != 'auto' && this.options.height) {\r\n this.modal.style.setProperty('height', this.options.height);\r\n } else {\r\n // \"max-content\" is for keep size in \"auto\" and for maximum to max-height\r\n this.modal.style.setProperty('height', 'max-content');\r\n }\r\n\r\n // Style\r\n if (this.options.style) {\r\n let oldStyle = this.modal.getAttribute('style') ?? '';\r\n this.modal.setAttribute('style', oldStyle + this.options.style);\r\n }\r\n\r\n // Event on cancel button\r\n if (this.options.buttonCancelHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--cancel')\r\n ?.addEventListener('click', this.eventCancelButton);\r\n }\r\n\r\n // Event on confirm button\r\n if (this.options.buttonConfirmHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--confirm')\r\n ?.addEventListener('click', this.eventConfirmButton);\r\n }\r\n\r\n // Event click outside (on modals)\r\n this.modals.addEventListener('click', this.eventClickOutside);\r\n\r\n // Event close modal when click on close button\r\n this.modal.querySelectorAll('.webcimes-modal__close').forEach((el) => {\r\n el.addEventListener('click', this.eventClickCloseButton);\r\n });\r\n\r\n // Place selected modal on top\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.modal.addEventListener(typeEvent, this.eventDragModalOnTop);\r\n });\r\n\r\n // Move modal\r\n if (\r\n this.options.allowMovement &&\r\n (this.options.moveFromHeader ||\r\n this.options.moveFromBody ||\r\n this.options.moveFromFooter)\r\n ) {\r\n if (\r\n this.options.moveFromHeader &&\r\n this.modal.querySelector('.webcimes-modal__header')\r\n ) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__header'),\r\n );\r\n }\r\n if (this.options.moveFromBody && this.modal.querySelector('.webcimes-modal__body')) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__body'),\r\n );\r\n }\r\n if (\r\n this.options.moveFromFooter &&\r\n this.modal.querySelector('.webcimes-modal__footer')\r\n ) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__footer'),\r\n );\r\n }\r\n\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.moveFromElements.forEach((el) => {\r\n el.addEventListener(typeEvent, this.eventDragStart);\r\n });\r\n });\r\n\r\n ['mousemove', 'touchmove'].forEach((typeEvent) => {\r\n document.addEventListener(typeEvent, this.eventMove);\r\n });\r\n\r\n ['mouseup', 'touchend'].forEach((typeEvent) => {\r\n document.addEventListener(typeEvent, this.eventDragStop);\r\n });\r\n\r\n document.addEventListener('selectstart', this.eventPreventSelectText);\r\n }\r\n\r\n // When resizing window, reset modal position to center\r\n window.addEventListener('resize', this.eventResize);\r\n }\r\n\r\n /**\r\n * Destroy current modal\r\n */\r\n public destroy() {\r\n // If modal is not already destroying\r\n if (!this.modal.getAttribute('data-destroying')) {\r\n // Callback before destroy modal\r\n this.modal.dispatchEvent(new CustomEvent('beforeDestroy'));\r\n if (typeof this.options.beforeDestroy === 'function') {\r\n this.options.beforeDestroy();\r\n }\r\n\r\n // Close modals (according the number of modal not already destroying)\r\n if (document.querySelectorAll('.webcimes-modal:not([data-destroying])').length == 1) {\r\n this.modals.classList.add('animFadeOut');\r\n }\r\n\r\n // Close modal\r\n this.modal.setAttribute('data-destroying', '1');\r\n this.modal.classList.add(this.options.animationOnDestroy);\r\n\r\n // Destroy all events from modal and remove modals or modal after animation duration\r\n setTimeout(() => {\r\n if (typeof this.modal !== 'undefined') {\r\n // Destroy all events from modal\r\n\r\n if (this.options.buttonCancelHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--cancel')\r\n ?.removeEventListener('click', this.eventCancelButton);\r\n }\r\n\r\n if (this.options.buttonConfirmHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--confirm')\r\n ?.removeEventListener('click', this.eventConfirmButton);\r\n }\r\n\r\n this.modals.removeEventListener('click', this.eventClickOutside);\r\n\r\n this.modal.querySelectorAll('.webcimes-modal__close').forEach((el) => {\r\n el.removeEventListener('click', this.eventClickCloseButton);\r\n });\r\n\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.modal.removeEventListener(typeEvent, this.eventDragModalOnTop);\r\n });\r\n\r\n if (\r\n this.options.allowMovement &&\r\n (this.options.moveFromHeader ||\r\n this.options.moveFromBody ||\r\n this.options.moveFromFooter)\r\n ) {\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.moveFromElements.forEach((el) => {\r\n el.removeEventListener(typeEvent, this.eventDragStart);\r\n });\r\n });\r\n\r\n ['mousemove', 'touchmove'].forEach((typeEvent) => {\r\n document.removeEventListener(typeEvent, this.eventMove);\r\n });\r\n\r\n ['mouseup', 'touchend'].forEach((typeEvent) => {\r\n document.removeEventListener(typeEvent, this.eventDragStop);\r\n });\r\n\r\n document.removeEventListener('selectstart', this.eventPreventSelectText);\r\n }\r\n\r\n window.removeEventListener('resize', this.eventResize);\r\n\r\n // Remove modals or modal according the number of modal\r\n (document.querySelectorAll('.webcimes-modal').length > 1\r\n ? this.modal\r\n : this.modals\r\n ).remove();\r\n }\r\n\r\n // Callback after destroy modal\r\n this.modal.dispatchEvent(new CustomEvent('afterDestroy'));\r\n if (typeof this.options.afterDestroy === 'function') {\r\n this.options.afterDestroy();\r\n }\r\n }, this.options.animationDuration);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a WebcimesModal instance with proper typing\r\n */\r\nexport function createWebcimesModal(options: Partial<Options>): WebcimesModal {\r\n return new WebcimesModalImpl(options);\r\n}\r\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","WebcimesModalImpl","modals","modal","options","eventCancelButton","this","dispatchEvent","CustomEvent","onCancelButton","eventConfirmButton","onConfirmButton","eventClickOutside","e","target","allowCloseOutside","destroy","classList","add","setTimeout","remove","animationDuration","eventClickCloseButton","eventDragModalOnTop","closest","document","querySelectorAll","length","nextElementSibling","oldScrollTop","scrollTop","insertAdjacentElement","position","offset","isDragging","moveFromElements","eventDragStart","clientX","x","offsetLeft","y","offsetTop","clientY","touches","eventMove","style","left","top","eventDragStop","eventPreventSelectText","preventDefault","eventResize","removeProperty","constructor","setId","setClass","width","height","titleHtml","bodyHtml","buttonCancelHtml","buttonConfirmHtml","closeOnCancelButton","closeOnConfirmButton","showCloseButton","allowMovement","moveFromHeader","moveFromBody","moveFromFooter","stickyHeader","stickyFooter","animationOnShow","animationOnDestroy","beforeShow","afterShow","beforeDestroy","afterDestroy","init","querySelector","body","insertAdjacentHTML","setProperty","lastElementChild","oldStyle","getAttribute","setAttribute","addEventListener","forEach","el","typeEvent","push","window","removeEventListener","createWebcimesModal"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"js/webcimes-modal.esm.js","mappings":"AACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,sBCyGlF,MAAMI,EAEKC,OAGAC,MAGCC,QAEAC,kBAAgC,KAEpCC,KAAKH,MAAMI,cAAc,IAAIC,YAAY,mBACE,mBAAhCF,KAAKF,QAAQK,gBACpBH,KAAKF,QAAQK,gB,EAIbC,mBAAiC,KAErCJ,KAAKH,MAAMI,cAAc,IAAIC,YAAY,oBACG,mBAAjCF,KAAKF,QAAQO,iBACpBL,KAAKF,QAAQO,iB,EAIbC,kBAAyCC,IACzCA,EAAEC,QAAUR,KAAKJ,SACbI,KAAKF,QAAQW,kBAEbT,KAAKU,WAGLV,KAAKH,MAAMc,UAAUC,IAAI,kBAGzBC,YAAW,KACPb,KAAKH,MAAMc,UAAUG,OAAO,iBAAiB,GAC9Cd,KAAKF,QAAQiB,oB,EAKpBC,sBAAoC,KAExChB,KAAKU,SAAS,EA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KAAKH,MACAiG,cAAc,2CACbU,oBAAoB,QAASxG,KAAKD,mBAGxCC,KAAKF,QAAQyE,mBACbvE,KAAKH,MACAiG,cAAc,4CACbU,oBAAoB,QAASxG,KAAKI,oBAG5CJ,KAAKJ,OAAO4G,oBAAoB,QAASxG,KAAKM,mBAE9CN,KAAKH,MAAMuB,iBAAiB,0BAA0B+E,SAASC,IAC3DA,EAAGI,oBAAoB,QAASxG,KAAKgB,sBAAsB,IAG/D,CAAC,YAAa,cAAcmF,SAASE,IACjCrG,KAAKH,MAAM2G,oBAAoBH,EAAWrG,KAAKiB,oBAAoB,IAInEjB,KAAKF,QAAQyF,gBACZvF,KAAKF,QAAQ8D,gBACV5D,KAAKF,QAAQqE,cACbnE,KAAKF,QAAQ4E,kBAEjB,CAAC,YAAa,cAAcyB,SAASE,IACjCrG,KAAK6B,iBAAiBsE,SAASC,IAC3BA,EAAGI,oBAAoBH,EAAWrG,KAAK8B,eAAe,GACxD,IAGN,CAAC,YAAa,aAAaqE,SAASE,IAChClF,SAASqF,oBAAoBH,EAAWrG,KAAKsC,UAAU,IAG3D,CAAC,UAAW,YAAY6D,SAASE,IAC7BlF,SAASqF,oBAAoBH,EAAWrG,KAAK0C,cAAc,IAG/DvB,SAASqF,oBAAoB,cAAexG,KAAK2C,yBAGrD4D,OAAOC,oBAAoB,SAAUxG,KAAK6C,cAGzC1B,SAASC,iBAAiB,mBAAmBC,OAAS,EACjDrB,KAAKH,MACLG,KAAKJ,QACTkB,UAINd,KAAKH,MAAMI,cAAc,IAAIC,YAAY,iBACA,mBAA9BF,KAAKF,QAAQ8F,cACpB5F,KAAKF,QAAQ8F,c,GAElB5F,KAAKF,QAAQiB,mBAExB,EAMG,SAAS0F,EAAoB3G,GAChC,OAAO,IAAIH,EAAkBG,EACjC,C","sources":["webpack://webcimes-modal/webpack/bootstrap","webpack://webcimes-modal/webpack/runtime/define property getters","webpack://webcimes-modal/webpack/runtime/hasOwnProperty shorthand","webpack://webcimes-modal/./src/ts/webcimes-modal.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","/**\r\n * Copyright (c) 2023 WebCimes - RICHARD Florian (https://webcimes.com)\r\n * MIT License - https://choosealicense.com/licenses/mit/\r\n * Date: 2023-03-25\r\n */\r\n\r\n'use strict';\r\n\r\n/**\r\n * Global\r\n */\r\ndeclare global {\r\n /** Events */\r\n interface GlobalEventHandlersEventMap {\r\n beforeShow: CustomEvent;\r\n afterShow: CustomEvent;\r\n beforeDestroy: CustomEvent;\r\n afterDestroy: CustomEvent;\r\n onCancelButton: CustomEvent;\r\n onConfirmButton: CustomEvent;\r\n }\r\n}\r\n\r\n/**\r\n * Options\r\n */\r\nexport interface Options {\r\n /** set a specific id on the modal. default \"null\" */\r\n setId: string | null;\r\n /** set a specific class on the modal, default \"null\" */\r\n setClass: string | null;\r\n /** width (specify unit), default \"auto\" */\r\n width: string;\r\n /** height (specify unit), default \"auto\" */\r\n height: string;\r\n /** html for header (overrides titleHtml), default \"null\" */\r\n headerHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** html for title, default \"null\" */\r\n titleHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** html for body, default \"null\" */\r\n bodyHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default \"null\" */\r\n footerHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** html for cancel button, default \"null\" */\r\n buttonCancelHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** html for confirm button, default \"null\" */\r\n buttonConfirmHtml: string | HTMLElement | (() => HTMLElement) | null;\r\n /** close modal after trigger cancel button, default \"true\" */\r\n closeOnCancelButton: boolean;\r\n /** close modal after trigger confirm button, default \"true\" */\r\n closeOnConfirmButton: boolean;\r\n /** show close button, default \"true\" */\r\n showCloseButton: boolean;\r\n /** allow the modal to close when clicked outside, default \"true\" */\r\n allowCloseOutside: boolean;\r\n /** ability to move modal, default \"true\" */\r\n allowMovement: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from header, default \"true\" */\r\n moveFromHeader: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from body, default \"false\" */\r\n moveFromBody: boolean;\r\n /** if allowMovement is set to \"true\", ability to move modal from footer, default \"true\" */\r\n moveFromFooter: boolean;\r\n /** keep header sticky (visible) when scrolling, default \"true\" */\r\n stickyHeader: boolean;\r\n /** keep footer sticky (visible) when scrolling, default \"true\" */\r\n stickyFooter: boolean;\r\n /** add extra css style to modal, default null */\r\n style: string | null;\r\n /** \"animDropDown\" or \"animFadeIn\" for show animation, default \"animDropDown\" */\r\n animationOnShow: 'animDropDown' | 'animFadeIn';\r\n /** \"animDropUp\" or \"animFadeOut\" for destroy animation, default \"animDropUp\" */\r\n animationOnDestroy: 'animDropUp' | 'animFadeOut';\r\n /** animation duration in ms, default \"500\" */\r\n animationDuration: number;\r\n /** callback before show modal */\r\n beforeShow: () => void;\r\n /** callback after show modal */\r\n afterShow: () => void;\r\n /** callback before destroy modal */\r\n beforeDestroy: () => void;\r\n /** callback after destroy modal */\r\n afterDestroy: () => void;\r\n /** callback after triggering cancel button */\r\n onCancelButton: () => void;\r\n /** callback after triggering confirm button */\r\n onConfirmButton: () => void;\r\n}\r\n\r\n/**\r\n * Public interface for WebcimesModal instances\r\n * This represents the actual accessible members of the instance\r\n */\r\nexport interface WebcimesModal {\r\n /** Get the dom element containing all modals */\r\n modals: HTMLElement;\r\n /** Get the dom element of the current modal */\r\n modal: HTMLElement;\r\n /** Destroy the current modal */\r\n destroy(): void;\r\n}\r\n\r\n/**\r\n * WebcimesModal implementation class\r\n */\r\nclass WebcimesModalImpl implements WebcimesModal {\r\n /** Get the dom element containing all modals */\r\n public modals: HTMLElement;\r\n\r\n /** Get the dom element of the current modal */\r\n public modal: HTMLElement;\r\n\r\n /** Options of the current modal */\r\n private options: Options;\r\n\r\n private eventCancelButton: () => void = () => {\r\n // Callback on cancel button\r\n this.modal.dispatchEvent(new CustomEvent('onCancelButton'));\r\n if (typeof this.options.onCancelButton === 'function') {\r\n this.options.onCancelButton();\r\n }\r\n };\r\n\r\n private eventConfirmButton: () => void = () => {\r\n // Callback on confirm button\r\n this.modal.dispatchEvent(new CustomEvent('onConfirmButton'));\r\n if (typeof this.options.onConfirmButton === 'function') {\r\n this.options.onConfirmButton();\r\n }\r\n };\r\n\r\n private eventClickOutside: (e: Event) => void = (e) => {\r\n if (e.target == this.modals) {\r\n if (this.options.allowCloseOutside) {\r\n // Destroy modal\r\n this.destroy();\r\n } else {\r\n // Add animation for show modal who can't be close\r\n this.modal.classList.add('animGrowShrink');\r\n\r\n // Delete animation after the animation delay\r\n setTimeout(() => {\r\n this.modal.classList.remove('animGrowShrink');\r\n }, this.options.animationDuration);\r\n }\r\n }\r\n };\r\n\r\n private eventClickCloseButton: () => void = () => {\r\n // Destroy modal\r\n this.destroy();\r\n };\r\n\r\n private eventDragModalOnTop: (e: Event) => void = (e) => {\r\n // Only if target is not close button (for bug in chrome)\r\n if (!(<HTMLElement>e.target).closest('.webcimes-modal__close')) {\r\n // If multiple modal, and modal not already on top (no next sibling), we place the current modal on the top\r\n if (\r\n document.querySelectorAll('.webcimes-modal').length > 1 &&\r\n this.modal.nextElementSibling !== null\r\n ) {\r\n let oldScrollTop = this.modal.scrollTop;\r\n this.modals.insertAdjacentElement('beforeend', this.modal);\r\n this.modal.scrollTop = oldScrollTop;\r\n }\r\n }\r\n };\r\n\r\n private position: { x: number; y: number };\r\n\r\n private offset: { x: number; y: number };\r\n\r\n private isDragging: boolean = false;\r\n\r\n private moveFromElements: HTMLElement[] = [];\r\n\r\n private eventDragStart: (e: Event) => void = (e) => {\r\n // Start drag only if it's not a button\r\n if (!(<HTMLElement>e.target).closest('.webcimes-modal__button')) {\r\n this.isDragging = true;\r\n\r\n // Mouse\r\n if ((<MouseEvent>e).clientX) {\r\n this.offset = {\r\n x: this.modal.offsetLeft - (<MouseEvent>e).clientX,\r\n y: this.modal.offsetTop - (<MouseEvent>e).clientY,\r\n };\r\n }\r\n // Touch device (use the first touch only)\r\n else if ((<TouchEvent>e).touches) {\r\n this.offset = {\r\n x: this.modal.offsetLeft - (<TouchEvent>e).touches[0].clientX,\r\n y: this.modal.offsetTop - (<TouchEvent>e).touches[0].clientY,\r\n };\r\n }\r\n }\r\n };\r\n\r\n private eventMove: (e: Event) => void = (e) => {\r\n if (this.isDragging) {\r\n // Mouse\r\n if ((<MouseEvent>e).clientX) {\r\n this.position = {\r\n x: (<MouseEvent>e).clientX,\r\n y: (<MouseEvent>e).clientY,\r\n };\r\n }\r\n // Touch device (use the first touch only)\r\n else if ((<TouchEvent>e).touches) {\r\n this.position = {\r\n x: (<TouchEvent>e).touches[0].clientX,\r\n y: (<TouchEvent>e).touches[0].clientY,\r\n };\r\n }\r\n this.modal.style.left = this.position.x + this.offset.x + 'px';\r\n this.modal.style.top = this.position.y + this.offset.y + 'px';\r\n }\r\n };\r\n\r\n private eventDragStop: () => void = () => {\r\n this.isDragging = false;\r\n };\r\n\r\n private eventPreventSelectText: (e: Event) => void = (e) => {\r\n if (this.isDragging) {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n private eventResize: () => void = () => {\r\n this.modal.style.removeProperty('left');\r\n this.modal.style.removeProperty('top');\r\n };\r\n\r\n /**\r\n * Helper method to set content on an element (string, HTMLElement, or function)\r\n */\r\n private setElementContent(\r\n element: HTMLElement,\r\n content: string | HTMLElement | (() => HTMLElement),\r\n ): void {\r\n if (typeof content === 'string') {\r\n element.innerHTML = content;\r\n } else if (typeof content === 'function') {\r\n element.appendChild(content());\r\n } else {\r\n element.appendChild(content);\r\n }\r\n }\r\n\r\n /**\r\n * Build modal header with content\r\n */\r\n private buildHeader(): HTMLElement | null {\r\n // Check if header should be created\r\n if (!this.options.headerHtml && !this.options.titleHtml && !this.options.showCloseButton) {\r\n return null;\r\n }\r\n\r\n // Create header element with common classes\r\n const header = document.createElement('div');\r\n header.className = 'webcimes-modal__header';\r\n\r\n if (this.options.stickyHeader) {\r\n header.classList.add('webcimes-modal__header--is-sticky');\r\n }\r\n if (this.options.moveFromHeader) {\r\n header.classList.add('webcimes-modal__header--is-movable');\r\n }\r\n\r\n // If headerHtml is provided, use it directly (full control)\r\n if (this.options.headerHtml) {\r\n this.setElementContent(header, this.options.headerHtml);\r\n\r\n // Add close button if requested\r\n if (this.options.showCloseButton) {\r\n const closeButton = document.createElement('button');\r\n closeButton.className =\r\n 'webcimes-modal__button webcimes-modal__header-close webcimes-modal__close';\r\n closeButton.setAttribute('aria-label', 'Close modal');\r\n header.appendChild(closeButton);\r\n }\r\n\r\n return header;\r\n }\r\n\r\n // Otherwise, create title and/or close button\r\n if (this.options.titleHtml) {\r\n const title = document.createElement('div');\r\n title.className = 'webcimes-modal__title';\r\n this.setElementContent(title, this.options.titleHtml);\r\n header.appendChild(title);\r\n }\r\n\r\n if (this.options.showCloseButton) {\r\n const closeButton = document.createElement('button');\r\n closeButton.className =\r\n 'webcimes-modal__button webcimes-modal__header-close webcimes-modal__close';\r\n closeButton.setAttribute('aria-label', 'Close modal');\r\n header.appendChild(closeButton);\r\n }\r\n\r\n return header;\r\n }\r\n\r\n /**\r\n * Build modal body with content\r\n */\r\n private buildBody(): HTMLElement | null {\r\n if (!this.options.bodyHtml) {\r\n return null;\r\n }\r\n\r\n const body = document.createElement('div');\r\n body.className = 'webcimes-modal__body';\r\n\r\n if (this.options.moveFromBody) {\r\n body.classList.add('webcimes-modal__body--is-movable');\r\n }\r\n\r\n this.setElementContent(body, this.options.bodyHtml);\r\n\r\n return body;\r\n }\r\n\r\n /**\r\n * Build modal footer with content\r\n */\r\n private buildFooter(): HTMLElement | null {\r\n // Check if footer should be created\r\n if (\r\n !this.options.footerHtml &&\r\n !this.options.buttonCancelHtml &&\r\n !this.options.buttonConfirmHtml\r\n ) {\r\n return null;\r\n }\r\n\r\n // Create footer element with common classes\r\n const footer = document.createElement('div');\r\n footer.className = 'webcimes-modal__footer';\r\n\r\n if (this.options.stickyFooter) {\r\n footer.classList.add('webcimes-modal__footer--is-sticky');\r\n }\r\n if (this.options.moveFromFooter) {\r\n footer.classList.add('webcimes-modal__footer--is-movable');\r\n }\r\n\r\n // If footerHtml is provided, use it directly (full control)\r\n if (this.options.footerHtml) {\r\n this.setElementContent(footer, this.options.footerHtml);\r\n return footer;\r\n }\r\n\r\n // Otherwise, create buttons\r\n if (this.options.buttonCancelHtml) {\r\n const cancelButton = document.createElement('button');\r\n cancelButton.className =\r\n 'webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel';\r\n if (this.options.closeOnCancelButton) {\r\n cancelButton.classList.add('webcimes-modal__close');\r\n }\r\n this.setElementContent(cancelButton, this.options.buttonCancelHtml);\r\n footer.appendChild(cancelButton);\r\n }\r\n\r\n if (this.options.buttonConfirmHtml) {\r\n const confirmButton = document.createElement('button');\r\n confirmButton.className =\r\n 'webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm';\r\n if (this.options.closeOnConfirmButton) {\r\n confirmButton.classList.add('webcimes-modal__close');\r\n }\r\n this.setElementContent(confirmButton, this.options.buttonConfirmHtml);\r\n footer.appendChild(confirmButton);\r\n }\r\n\r\n return footer;\r\n }\r\n\r\n /**\r\n * Build complete modal with content\r\n */\r\n private buildModal(): HTMLElement {\r\n const modal = document.createElement('div');\r\n modal.className = `webcimes-modal ${this.options.animationOnShow}`;\r\n\r\n // ARIA attributes for accessibility\r\n modal.setAttribute('role', 'dialog');\r\n modal.setAttribute('aria-modal', 'true');\r\n\r\n if (this.options.setClass) {\r\n modal.classList.add(this.options.setClass);\r\n }\r\n if (this.options.setId) {\r\n modal.id = this.options.setId;\r\n }\r\n\r\n const header = this.buildHeader();\r\n if (header) {\r\n modal.appendChild(header);\r\n }\r\n\r\n const body = this.buildBody();\r\n if (body) {\r\n modal.appendChild(body);\r\n }\r\n\r\n const footer = this.buildFooter();\r\n if (footer) {\r\n modal.appendChild(footer);\r\n }\r\n\r\n return modal;\r\n }\r\n\r\n /**\r\n * Create modal\r\n */\r\n constructor(options: Partial<Options>) {\r\n // Defaults\r\n const defaults: Options = {\r\n setId: null,\r\n setClass: null,\r\n width: 'auto',\r\n height: 'auto',\r\n headerHtml: null,\r\n titleHtml: null,\r\n bodyHtml: null,\r\n footerHtml: null,\r\n buttonCancelHtml: null,\r\n buttonConfirmHtml: null,\r\n closeOnCancelButton: true,\r\n closeOnConfirmButton: true,\r\n showCloseButton: true,\r\n allowCloseOutside: true,\r\n allowMovement: true,\r\n moveFromHeader: true,\r\n moveFromBody: false,\r\n moveFromFooter: true,\r\n stickyHeader: true,\r\n stickyFooter: true,\r\n style: null,\r\n animationOnShow: 'animDropDown',\r\n animationOnDestroy: 'animDropUp',\r\n animationDuration: 500,\r\n beforeShow: () => {},\r\n afterShow: () => {},\r\n beforeDestroy: () => {},\r\n afterDestroy: () => {},\r\n onCancelButton: () => {},\r\n onConfirmButton: () => {},\r\n };\r\n this.options = { ...defaults, ...options };\r\n\r\n // Call init method\r\n this.init();\r\n }\r\n\r\n /**\r\n * Initialization of the current modal\r\n */\r\n private init() {\r\n // Create modals container\r\n if (!document.querySelector('.webcimes-modals')) {\r\n this.modals = document.createElement('div');\r\n this.modals.className = 'webcimes-modals animFadeIn';\r\n\r\n // Set animation duration for modals\r\n this.modals.style.setProperty(\r\n 'animation-duration',\r\n this.options.animationDuration + 'ms',\r\n );\r\n\r\n document.body.appendChild(this.modals);\r\n\r\n // Delete enter animation after animation delay\r\n setTimeout(() => {\r\n this.modals.classList.remove('animFadeIn');\r\n }, this.options.animationDuration);\r\n } else {\r\n // Get modals\r\n this.modals = <HTMLElement>document.querySelector('.webcimes-modals');\r\n\r\n // Remove animFadeOut in case of create new modal after destroy the last one before (during animation duration)\r\n this.modals.classList.remove('animFadeOut');\r\n }\r\n\r\n // Create modal with content\r\n this.modal = this.buildModal();\r\n this.modals.appendChild(this.modal);\r\n\r\n // Callback before show modal (set a timeout of zero, to wait for some dom to load)\r\n setTimeout(() => {\r\n this.modal.dispatchEvent(new CustomEvent('beforeShow'));\r\n if (typeof this.options.beforeShow === 'function') {\r\n this.options.beforeShow();\r\n }\r\n }, 0);\r\n\r\n // Set animation duration for modal\r\n this.modal.style.setProperty('animation-duration', this.options.animationDuration + 'ms');\r\n\r\n // Delete animation of enter after the animation delay\r\n setTimeout(() => {\r\n this.modal.classList.remove(this.options.animationOnShow);\r\n\r\n // Callback after show modal\r\n this.modal.dispatchEvent(new CustomEvent('afterShow'));\r\n if (typeof this.options.afterShow === 'function') {\r\n this.options.afterShow();\r\n }\r\n }, this.options.animationDuration);\r\n\r\n // Width of modal\r\n this.modal.style.setProperty('max-width', '90%');\r\n if (this.options.width != 'auto' && this.options.width) {\r\n this.modal.style.setProperty('width', this.options.width);\r\n } else {\r\n // \"max-content\" is for keep size in \"auto\" and for maximum to max-width\r\n this.modal.style.setProperty('width', 'max-content');\r\n }\r\n\r\n // Height of modal\r\n this.modal.style.setProperty('max-height', '90%');\r\n if (this.options.height != 'auto' && this.options.height) {\r\n this.modal.style.setProperty('height', this.options.height);\r\n } else {\r\n // \"max-content\" is for keep size in \"auto\" and for maximum to max-height\r\n this.modal.style.setProperty('height', 'max-content');\r\n }\r\n\r\n // Style\r\n if (this.options.style) {\r\n let oldStyle = this.modal.getAttribute('style') ?? '';\r\n this.modal.setAttribute('style', oldStyle + this.options.style);\r\n }\r\n\r\n // Event on cancel button\r\n if (this.options.buttonCancelHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--cancel')\r\n ?.addEventListener('click', this.eventCancelButton);\r\n }\r\n\r\n // Event on confirm button\r\n if (this.options.buttonConfirmHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--confirm')\r\n ?.addEventListener('click', this.eventConfirmButton);\r\n }\r\n\r\n // Event click outside (on modals)\r\n this.modals.addEventListener('click', this.eventClickOutside);\r\n\r\n // Event close modal when click on close button\r\n this.modal.querySelectorAll('.webcimes-modal__close').forEach((el) => {\r\n el.addEventListener('click', this.eventClickCloseButton);\r\n });\r\n\r\n // Place selected modal on top\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.modal.addEventListener(typeEvent, this.eventDragModalOnTop);\r\n });\r\n\r\n // Move modal\r\n if (\r\n this.options.allowMovement &&\r\n (this.options.moveFromHeader ||\r\n this.options.moveFromBody ||\r\n this.options.moveFromFooter)\r\n ) {\r\n if (\r\n this.options.moveFromHeader &&\r\n this.modal.querySelector('.webcimes-modal__header')\r\n ) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__header'),\r\n );\r\n }\r\n if (this.options.moveFromBody && this.modal.querySelector('.webcimes-modal__body')) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__body'),\r\n );\r\n }\r\n if (\r\n this.options.moveFromFooter &&\r\n this.modal.querySelector('.webcimes-modal__footer')\r\n ) {\r\n this.moveFromElements.push(\r\n <HTMLElement>this.modal.querySelector('.webcimes-modal__footer'),\r\n );\r\n }\r\n\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.moveFromElements.forEach((el) => {\r\n el.addEventListener(typeEvent, this.eventDragStart);\r\n });\r\n });\r\n\r\n ['mousemove', 'touchmove'].forEach((typeEvent) => {\r\n document.addEventListener(typeEvent, this.eventMove);\r\n });\r\n\r\n ['mouseup', 'touchend'].forEach((typeEvent) => {\r\n document.addEventListener(typeEvent, this.eventDragStop);\r\n });\r\n\r\n document.addEventListener('selectstart', this.eventPreventSelectText);\r\n }\r\n\r\n // When resizing window, reset modal position to center\r\n window.addEventListener('resize', this.eventResize);\r\n }\r\n\r\n /**\r\n * Destroy current modal\r\n */\r\n public destroy() {\r\n // If modal is not already destroying\r\n if (!this.modal.getAttribute('data-destroying')) {\r\n // Callback before destroy modal\r\n this.modal.dispatchEvent(new CustomEvent('beforeDestroy'));\r\n if (typeof this.options.beforeDestroy === 'function') {\r\n this.options.beforeDestroy();\r\n }\r\n\r\n // Close modals (according the number of modal not already destroying)\r\n if (document.querySelectorAll('.webcimes-modal:not([data-destroying])').length == 1) {\r\n this.modals.classList.add('animFadeOut');\r\n }\r\n\r\n // Close modal\r\n this.modal.setAttribute('data-destroying', '1');\r\n this.modal.classList.add(this.options.animationOnDestroy);\r\n\r\n // Destroy all events from modal and remove modals or modal after animation duration\r\n setTimeout(() => {\r\n if (typeof this.modal !== 'undefined') {\r\n // Destroy all events from modal\r\n\r\n if (this.options.buttonCancelHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--cancel')\r\n ?.removeEventListener('click', this.eventCancelButton);\r\n }\r\n\r\n if (this.options.buttonConfirmHtml) {\r\n this.modal\r\n .querySelector('.webcimes-modal__footer-button--confirm')\r\n ?.removeEventListener('click', this.eventConfirmButton);\r\n }\r\n\r\n this.modals.removeEventListener('click', this.eventClickOutside);\r\n\r\n this.modal.querySelectorAll('.webcimes-modal__close').forEach((el) => {\r\n el.removeEventListener('click', this.eventClickCloseButton);\r\n });\r\n\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.modal.removeEventListener(typeEvent, this.eventDragModalOnTop);\r\n });\r\n\r\n if (\r\n this.options.allowMovement &&\r\n (this.options.moveFromHeader ||\r\n this.options.moveFromBody ||\r\n this.options.moveFromFooter)\r\n ) {\r\n ['mousedown', 'touchstart'].forEach((typeEvent) => {\r\n this.moveFromElements.forEach((el) => {\r\n el.removeEventListener(typeEvent, this.eventDragStart);\r\n });\r\n });\r\n\r\n ['mousemove', 'touchmove'].forEach((typeEvent) => {\r\n document.removeEventListener(typeEvent, this.eventMove);\r\n });\r\n\r\n ['mouseup', 'touchend'].forEach((typeEvent) => {\r\n document.removeEventListener(typeEvent, this.eventDragStop);\r\n });\r\n\r\n document.removeEventListener('selectstart', this.eventPreventSelectText);\r\n }\r\n\r\n window.removeEventListener('resize', this.eventResize);\r\n\r\n // Remove modals or modal according the number of modal\r\n (document.querySelectorAll('.webcimes-modal').length > 1\r\n ? this.modal\r\n : this.modals\r\n ).remove();\r\n }\r\n\r\n // Callback after destroy modal\r\n this.modal.dispatchEvent(new CustomEvent('afterDestroy'));\r\n if (typeof this.options.afterDestroy === 'function') {\r\n this.options.afterDestroy();\r\n }\r\n }, this.options.animationDuration);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Factory function to create a WebcimesModal instance with proper typing\r\n */\r\nexport function createWebcimesModal(options: Partial<Options>): WebcimesModal {\r\n return new WebcimesModalImpl(options);\r\n}\r\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","WebcimesModalImpl","modals","modal","options","eventCancelButton","this","dispatchEvent","CustomEvent","onCancelButton","eventConfirmButton","onConfirmButton","eventClickOutside","e","target","allowCloseOutside","destroy","classList","add","setTimeout","remove","animationDuration","eventClickCloseButton","eventDragModalOnTop","closest","document","querySelectorAll","length","nextElementSibling","oldScrollTop","scrollTop","insertAdjacentElement","position","offset","isDragging","moveFromElements","eventDragStart","clientX","x","offsetLeft","y","offsetTop","clientY","touches","eventMove","style","left","top","eventDragStop","eventPreventSelectText","preventDefault","eventResize","removeProperty","setElementContent","element","content","innerHTML","appendChild","buildHeader","headerHtml","titleHtml","showCloseButton","header","createElement","className","stickyHeader","moveFromHeader","closeButton","setAttribute","title","buildBody","bodyHtml","body","moveFromBody","buildFooter","footerHtml","buttonCancelHtml","buttonConfirmHtml","footer","stickyFooter","moveFromFooter","cancelButton","closeOnCancelButton","confirmButton","closeOnConfirmButton","buildModal","animationOnShow","setClass","setId","id","constructor","width","height","allowMovement","animationOnDestroy","beforeShow","afterShow","beforeDestroy","afterDestroy","init","querySelector","setProperty","oldStyle","getAttribute","addEventListener","forEach","el","typeEvent","push","window","removeEventListener","createWebcimesModal"],"sourceRoot":""}
|
|
@@ -29,14 +29,18 @@ export interface Options {
|
|
|
29
29
|
width: string;
|
|
30
30
|
/** height (specify unit), default "auto" */
|
|
31
31
|
height: string;
|
|
32
|
+
/** html for header (overrides titleHtml), default "null" */
|
|
33
|
+
headerHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
32
34
|
/** html for title, default "null" */
|
|
33
|
-
titleHtml: string | null;
|
|
35
|
+
titleHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
34
36
|
/** html for body, default "null" */
|
|
35
|
-
bodyHtml: string | null;
|
|
37
|
+
bodyHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
38
|
+
/** html for footer (overrides buttonCancelHtml and buttonConfirmHtml), default "null" */
|
|
39
|
+
footerHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
36
40
|
/** html for cancel button, default "null" */
|
|
37
|
-
buttonCancelHtml: string | null;
|
|
41
|
+
buttonCancelHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
38
42
|
/** html for confirm button, default "null" */
|
|
39
|
-
buttonConfirmHtml: string | null;
|
|
43
|
+
buttonConfirmHtml: string | HTMLElement | (() => HTMLElement) | null;
|
|
40
44
|
/** close modal after trigger cancel button, default "true" */
|
|
41
45
|
closeOnCancelButton: boolean;
|
|
42
46
|
/** close modal after trigger confirm button, default "true" */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(self,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var s in o)t.o(o,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:o[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{createWebcimesModal:()=>s});class o{modals;modal;options;eventCancelButton=()=>{this.modal.dispatchEvent(new CustomEvent("onCancelButton")),"function"==typeof this.options.onCancelButton&&this.options.onCancelButton()};eventConfirmButton=()=>{this.modal.dispatchEvent(new CustomEvent("onConfirmButton")),"function"==typeof this.options.onConfirmButton&&this.options.onConfirmButton()};eventClickOutside=t=>{t.target==this.modals&&(this.options.allowCloseOutside?this.destroy():(this.modal.classList.add("animGrowShrink"),setTimeout((()=>{this.modal.classList.remove("animGrowShrink")}),this.options.animationDuration)))};eventClickCloseButton=()=>{this.destroy()};eventDragModalOnTop=t=>{if(!t.target.closest(".webcimes-modal__close")&&document.querySelectorAll(".webcimes-modal").length>1&&null!==this.modal.nextElementSibling){let t=this.modal.scrollTop;this.modals.insertAdjacentElement("beforeend",this.modal),this.modal.scrollTop=t}};position;offset;isDragging=!1;moveFromElements=[];eventDragStart=t=>{t.target.closest(".webcimes-modal__button")||(this.isDragging=!0,t.clientX?this.offset={x:this.modal.offsetLeft-t.clientX,y:this.modal.offsetTop-t.clientY}:t.touches&&(this.offset={x:this.modal.offsetLeft-t.touches[0].clientX,y:this.modal.offsetTop-t.touches[0].clientY}))};eventMove=t=>{this.isDragging&&(t.clientX?this.position={x:t.clientX,y:t.clientY}:t.touches&&(this.position={x:t.touches[0].clientX,y:t.touches[0].clientY}),this.modal.style.left=this.position.x+this.offset.x+"px",this.modal.style.top=this.position.y+this.offset.y+"px")};eventDragStop=()=>{this.isDragging=!1};eventPreventSelectText=t=>{this.isDragging&&t.preventDefault()};eventResize=()=>{this.modal.style.removeProperty("left"),this.modal.style.removeProperty("top")};constructor(t){this.options={setId:null,setClass:null,width:"auto",height:"auto",titleHtml:null,bodyHtml:null,buttonCancelHtml:null,buttonConfirmHtml:null,closeOnCancelButton:!0,closeOnConfirmButton:!0,showCloseButton:!0,allowCloseOutside:!0,allowMovement:!0,moveFromHeader:!0,moveFromBody:!1,moveFromFooter:!0,stickyHeader:!0,stickyFooter:!0,style:null,animationOnShow:"animDropDown",animationOnDestroy:"animDropUp",animationDuration:500,beforeShow:()=>{},afterShow:()=>{},beforeDestroy:()=>{},afterDestroy:()=>{},onCancelButton:()=>{},onConfirmButton:()=>{},...t},this.init()}init(){if(document.querySelector(".webcimes-modals")?(this.modals=document.querySelector(".webcimes-modals"),this.modals.classList.remove("animFadeOut")):(document.body.insertAdjacentHTML("beforeend",'<div class="webcimes-modals animFadeIn"></div>'),this.modals=document.querySelector(".webcimes-modals"),this.modals.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modals.classList.remove("animFadeIn")}),this.options.animationDuration)),this.modals.insertAdjacentHTML("beforeend",'<div class="webcimes-modal '+(this.options.setClass?this.options.setClass:"")+" "+this.options.animationOnShow+'" '+(this.options.setId?'id="'+this.options.setId+'"':"")+">\n\t\t\t\t"+(this.options.titleHtml||this.options.showCloseButton?'<div class="webcimes-modal__header '+(this.options.stickyHeader?"webcimes-modal__header--is-sticky":"")+" "+(this.options.moveFromHeader?"webcimes-modal__header--is-movable":"")+'">\n\t\t\t\t\t\t'+(this.options.titleHtml?'<div class="webcimes-modal__title">'+this.options.titleHtml+"</div>":"")+"\n\t\t\t\t\t\t"+(this.options.showCloseButton?'<button class="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close"></button>':"")+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t\t"+(this.options.bodyHtml?'<div class="webcimes-modal__body '+(this.options.moveFromBody?".webcimes-modal__body--is-movable":"")+'">\n\t\t\t\t\t\t'+this.options.bodyHtml+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t\t"+(this.options.buttonCancelHtml||this.options.buttonConfirmHtml?'<div class="webcimes-modal__footer '+(this.options.stickyFooter?".webcimes-modal__footer--is-sticky":"")+" "+(this.options.moveFromFooter?"webcimes-modal__footer--is-movable":"")+'">\n\t\t\t\t\t\t'+(this.options.buttonCancelHtml?'<button class="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel '+(this.options.closeOnCancelButton?"webcimes-modal__close":"")+'">'+this.options.buttonCancelHtml+"</button>":"")+"\n\t\t\t\t\t\t"+(this.options.buttonConfirmHtml?'<button class="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm '+(this.options.closeOnConfirmButton?"webcimes-modal__close":"")+'">'+this.options.buttonConfirmHtml+"</button>":"")+"\n\t\t\t\t\t</div>":"")+"\n\t\t\t</div>"),this.modal=this.modals.lastElementChild,setTimeout((()=>{this.modal.dispatchEvent(new CustomEvent("beforeShow")),"function"==typeof this.options.beforeShow&&this.options.beforeShow()}),0),this.modal.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modal.classList.remove(this.options.animationOnShow),this.modal.dispatchEvent(new CustomEvent("afterShow")),"function"==typeof this.options.afterShow&&this.options.afterShow()}),this.options.animationDuration),this.modal.style.setProperty("max-width","90%"),"auto"!=this.options.width&&this.options.width?this.modal.style.setProperty("width",this.options.width):this.modal.style.setProperty("width","max-content"),this.modal.style.setProperty("max-height","90%"),"auto"!=this.options.height&&this.options.height?this.modal.style.setProperty("height",this.options.height):this.modal.style.setProperty("height","max-content"),this.options.style){let t=this.modal.getAttribute("style")??"";this.modal.setAttribute("style",t+this.options.style)}this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.addEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.addEventListener("click",this.eventConfirmButton),this.modals.addEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.addEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.addEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(this.options.moveFromHeader&&this.modal.querySelector(".webcimes-modal__header")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__header")),this.options.moveFromBody&&this.modal.querySelector(".webcimes-modal__body")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__body")),this.options.moveFromFooter&&this.modal.querySelector(".webcimes-modal__footer")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__footer")),["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.addEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.addEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.addEventListener(t,this.eventDragStop)})),document.addEventListener("selectstart",this.eventPreventSelectText)),window.addEventListener("resize",this.eventResize)}destroy(){this.modal.getAttribute("data-destroying")||(this.modal.dispatchEvent(new CustomEvent("beforeDestroy")),"function"==typeof this.options.beforeDestroy&&this.options.beforeDestroy(),1==document.querySelectorAll(".webcimes-modal:not([data-destroying])").length&&this.modals.classList.add("animFadeOut"),this.modal.setAttribute("data-destroying","1"),this.modal.classList.add(this.options.animationOnDestroy),setTimeout((()=>{void 0!==this.modal&&(this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.removeEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.removeEventListener("click",this.eventConfirmButton),this.modals.removeEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.removeEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.removeEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.removeEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.removeEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.removeEventListener(t,this.eventDragStop)})),document.removeEventListener("selectstart",this.eventPreventSelectText)),window.removeEventListener("resize",this.eventResize),(document.querySelectorAll(".webcimes-modal").length>1?this.modal:this.modals).remove()),this.modal.dispatchEvent(new CustomEvent("afterDestroy")),"function"==typeof this.options.afterDestroy&&this.options.afterDestroy()}),this.options.animationDuration))}}function s(t){return new o(t)}return e})()));
|
|
1
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(self,(()=>(()=>{"use strict";var t={d:(e,o)=>{for(var s in o)t.o(o,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:o[s]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{createWebcimesModal:()=>s});class o{modals;modal;options;eventCancelButton=()=>{this.modal.dispatchEvent(new CustomEvent("onCancelButton")),"function"==typeof this.options.onCancelButton&&this.options.onCancelButton()};eventConfirmButton=()=>{this.modal.dispatchEvent(new CustomEvent("onConfirmButton")),"function"==typeof this.options.onConfirmButton&&this.options.onConfirmButton()};eventClickOutside=t=>{t.target==this.modals&&(this.options.allowCloseOutside?this.destroy():(this.modal.classList.add("animGrowShrink"),setTimeout((()=>{this.modal.classList.remove("animGrowShrink")}),this.options.animationDuration)))};eventClickCloseButton=()=>{this.destroy()};eventDragModalOnTop=t=>{if(!t.target.closest(".webcimes-modal__close")&&document.querySelectorAll(".webcimes-modal").length>1&&null!==this.modal.nextElementSibling){let t=this.modal.scrollTop;this.modals.insertAdjacentElement("beforeend",this.modal),this.modal.scrollTop=t}};position;offset;isDragging=!1;moveFromElements=[];eventDragStart=t=>{t.target.closest(".webcimes-modal__button")||(this.isDragging=!0,t.clientX?this.offset={x:this.modal.offsetLeft-t.clientX,y:this.modal.offsetTop-t.clientY}:t.touches&&(this.offset={x:this.modal.offsetLeft-t.touches[0].clientX,y:this.modal.offsetTop-t.touches[0].clientY}))};eventMove=t=>{this.isDragging&&(t.clientX?this.position={x:t.clientX,y:t.clientY}:t.touches&&(this.position={x:t.touches[0].clientX,y:t.touches[0].clientY}),this.modal.style.left=this.position.x+this.offset.x+"px",this.modal.style.top=this.position.y+this.offset.y+"px")};eventDragStop=()=>{this.isDragging=!1};eventPreventSelectText=t=>{this.isDragging&&t.preventDefault()};eventResize=()=>{this.modal.style.removeProperty("left"),this.modal.style.removeProperty("top")};setElementContent(t,e){"string"==typeof e?t.innerHTML=e:"function"==typeof e?t.appendChild(e()):t.appendChild(e)}buildHeader(){if(!this.options.headerHtml&&!this.options.titleHtml&&!this.options.showCloseButton)return null;const t=document.createElement("div");if(t.className="webcimes-modal__header",this.options.stickyHeader&&t.classList.add("webcimes-modal__header--is-sticky"),this.options.moveFromHeader&&t.classList.add("webcimes-modal__header--is-movable"),this.options.headerHtml){if(this.setElementContent(t,this.options.headerHtml),this.options.showCloseButton){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close",e.setAttribute("aria-label","Close modal"),t.appendChild(e)}return t}if(this.options.titleHtml){const e=document.createElement("div");e.className="webcimes-modal__title",this.setElementContent(e,this.options.titleHtml),t.appendChild(e)}if(this.options.showCloseButton){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__header-close webcimes-modal__close",e.setAttribute("aria-label","Close modal"),t.appendChild(e)}return t}buildBody(){if(!this.options.bodyHtml)return null;const t=document.createElement("div");return t.className="webcimes-modal__body",this.options.moveFromBody&&t.classList.add("webcimes-modal__body--is-movable"),this.setElementContent(t,this.options.bodyHtml),t}buildFooter(){if(!this.options.footerHtml&&!this.options.buttonCancelHtml&&!this.options.buttonConfirmHtml)return null;const t=document.createElement("div");if(t.className="webcimes-modal__footer",this.options.stickyFooter&&t.classList.add("webcimes-modal__footer--is-sticky"),this.options.moveFromFooter&&t.classList.add("webcimes-modal__footer--is-movable"),this.options.footerHtml)return this.setElementContent(t,this.options.footerHtml),t;if(this.options.buttonCancelHtml){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--cancel",this.options.closeOnCancelButton&&e.classList.add("webcimes-modal__close"),this.setElementContent(e,this.options.buttonCancelHtml),t.appendChild(e)}if(this.options.buttonConfirmHtml){const e=document.createElement("button");e.className="webcimes-modal__button webcimes-modal__footer-button webcimes-modal__footer-button--confirm",this.options.closeOnConfirmButton&&e.classList.add("webcimes-modal__close"),this.setElementContent(e,this.options.buttonConfirmHtml),t.appendChild(e)}return t}buildModal(){const t=document.createElement("div");t.className=`webcimes-modal ${this.options.animationOnShow}`,t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),this.options.setClass&&t.classList.add(this.options.setClass),this.options.setId&&(t.id=this.options.setId);const e=this.buildHeader();e&&t.appendChild(e);const o=this.buildBody();o&&t.appendChild(o);const s=this.buildFooter();return s&&t.appendChild(s),t}constructor(t){this.options={setId:null,setClass:null,width:"auto",height:"auto",headerHtml:null,titleHtml:null,bodyHtml:null,footerHtml:null,buttonCancelHtml:null,buttonConfirmHtml:null,closeOnCancelButton:!0,closeOnConfirmButton:!0,showCloseButton:!0,allowCloseOutside:!0,allowMovement:!0,moveFromHeader:!0,moveFromBody:!1,moveFromFooter:!0,stickyHeader:!0,stickyFooter:!0,style:null,animationOnShow:"animDropDown",animationOnDestroy:"animDropUp",animationDuration:500,beforeShow:()=>{},afterShow:()=>{},beforeDestroy:()=>{},afterDestroy:()=>{},onCancelButton:()=>{},onConfirmButton:()=>{},...t},this.init()}init(){if(document.querySelector(".webcimes-modals")?(this.modals=document.querySelector(".webcimes-modals"),this.modals.classList.remove("animFadeOut")):(this.modals=document.createElement("div"),this.modals.className="webcimes-modals animFadeIn",this.modals.style.setProperty("animation-duration",this.options.animationDuration+"ms"),document.body.appendChild(this.modals),setTimeout((()=>{this.modals.classList.remove("animFadeIn")}),this.options.animationDuration)),this.modal=this.buildModal(),this.modals.appendChild(this.modal),setTimeout((()=>{this.modal.dispatchEvent(new CustomEvent("beforeShow")),"function"==typeof this.options.beforeShow&&this.options.beforeShow()}),0),this.modal.style.setProperty("animation-duration",this.options.animationDuration+"ms"),setTimeout((()=>{this.modal.classList.remove(this.options.animationOnShow),this.modal.dispatchEvent(new CustomEvent("afterShow")),"function"==typeof this.options.afterShow&&this.options.afterShow()}),this.options.animationDuration),this.modal.style.setProperty("max-width","90%"),"auto"!=this.options.width&&this.options.width?this.modal.style.setProperty("width",this.options.width):this.modal.style.setProperty("width","max-content"),this.modal.style.setProperty("max-height","90%"),"auto"!=this.options.height&&this.options.height?this.modal.style.setProperty("height",this.options.height):this.modal.style.setProperty("height","max-content"),this.options.style){let t=this.modal.getAttribute("style")??"";this.modal.setAttribute("style",t+this.options.style)}this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.addEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.addEventListener("click",this.eventConfirmButton),this.modals.addEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.addEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.addEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(this.options.moveFromHeader&&this.modal.querySelector(".webcimes-modal__header")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__header")),this.options.moveFromBody&&this.modal.querySelector(".webcimes-modal__body")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__body")),this.options.moveFromFooter&&this.modal.querySelector(".webcimes-modal__footer")&&this.moveFromElements.push(this.modal.querySelector(".webcimes-modal__footer")),["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.addEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.addEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.addEventListener(t,this.eventDragStop)})),document.addEventListener("selectstart",this.eventPreventSelectText)),window.addEventListener("resize",this.eventResize)}destroy(){this.modal.getAttribute("data-destroying")||(this.modal.dispatchEvent(new CustomEvent("beforeDestroy")),"function"==typeof this.options.beforeDestroy&&this.options.beforeDestroy(),1==document.querySelectorAll(".webcimes-modal:not([data-destroying])").length&&this.modals.classList.add("animFadeOut"),this.modal.setAttribute("data-destroying","1"),this.modal.classList.add(this.options.animationOnDestroy),setTimeout((()=>{void 0!==this.modal&&(this.options.buttonCancelHtml&&this.modal.querySelector(".webcimes-modal__footer-button--cancel")?.removeEventListener("click",this.eventCancelButton),this.options.buttonConfirmHtml&&this.modal.querySelector(".webcimes-modal__footer-button--confirm")?.removeEventListener("click",this.eventConfirmButton),this.modals.removeEventListener("click",this.eventClickOutside),this.modal.querySelectorAll(".webcimes-modal__close").forEach((t=>{t.removeEventListener("click",this.eventClickCloseButton)})),["mousedown","touchstart"].forEach((t=>{this.modal.removeEventListener(t,this.eventDragModalOnTop)})),this.options.allowMovement&&(this.options.moveFromHeader||this.options.moveFromBody||this.options.moveFromFooter)&&(["mousedown","touchstart"].forEach((t=>{this.moveFromElements.forEach((e=>{e.removeEventListener(t,this.eventDragStart)}))})),["mousemove","touchmove"].forEach((t=>{document.removeEventListener(t,this.eventMove)})),["mouseup","touchend"].forEach((t=>{document.removeEventListener(t,this.eventDragStop)})),document.removeEventListener("selectstart",this.eventPreventSelectText)),window.removeEventListener("resize",this.eventResize),(document.querySelectorAll(".webcimes-modal").length>1?this.modal:this.modals).remove()),this.modal.dispatchEvent(new CustomEvent("afterDestroy")),"function"==typeof this.options.afterDestroy&&this.options.afterDestroy()}),this.options.animationDuration))}}function s(t){return new o(t)}return e})()));
|
|
2
2
|
//# sourceMappingURL=webcimes-modal.udm.js.map
|