webcimes-modal 2.0.1 → 2.0.2
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 +16 -16
- package/demo/script_esm.js +3 -3
- package/demo/script_udm.js +2 -2
- package/dist/js/webcimes-modal.esm.d.ts +1 -1
- 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 +1 -1
- package/dist/js/webcimes-modal.udm.js +1 -1
- package/dist/js/webcimes-modal.udm.js.map +1 -1
- package/package.json +1 -1
- package/src/ts/webcimes-modal.d.ts +1 -1
- package/src/ts/webcimes-modal.ts +1 -1
- package/test/script.js +3 -3
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ You can use an importmap to resolve the arbitrary module names to complete paths
|
|
|
36
36
|
Then import javascript module:
|
|
37
37
|
|
|
38
38
|
```javascript
|
|
39
|
-
import {
|
|
39
|
+
import { createWebcimesModal } from 'webcimes-modal';
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Or you can also set the full path directly in the import:
|
|
@@ -47,7 +47,7 @@ Or you can also set the full path directly in the import:
|
|
|
47
47
|
...
|
|
48
48
|
<script type="module">
|
|
49
49
|
// Import webcimes-modal
|
|
50
|
-
import {
|
|
50
|
+
import { createWebcimesModal } from "./node_modules/webcimes-modal/dist/js/webcimes-modal.esm.js";
|
|
51
51
|
...
|
|
52
52
|
</script>
|
|
53
53
|
</head>
|
|
@@ -58,7 +58,7 @@ Or you can also set the full path directly in the import:
|
|
|
58
58
|
Or with JS bundlers (like Webpack) you can call directly the module :
|
|
59
59
|
|
|
60
60
|
```javascript
|
|
61
|
-
import {
|
|
61
|
+
import { createWebcimesModal } from 'webcimes-modal';
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### UDM
|
|
@@ -86,13 +86,13 @@ You can directly load the udm module in the script tag:
|
|
|
86
86
|
|
|
87
87
|
## Usage
|
|
88
88
|
|
|
89
|
-
### Call `
|
|
89
|
+
### Call `createWebcimesModal()` to create modal:
|
|
90
90
|
|
|
91
91
|
```javascript
|
|
92
|
-
// Wait for dom content loaded or call
|
|
92
|
+
// Wait for dom content loaded or call createWebcimesModal before the end of body
|
|
93
93
|
document.addEventListener('DOMContentLoaded', function () {
|
|
94
94
|
// Create modal
|
|
95
|
-
const myModal =
|
|
95
|
+
const myModal = createWebcimesModal({
|
|
96
96
|
setId: null, // set a specific id on the modal. default "null"
|
|
97
97
|
setClass: null, // set a specific class on the modal, default "null"
|
|
98
98
|
width: 'auto', // width (specify unit), default "auto"
|
|
@@ -172,7 +172,7 @@ All parameters are optionnal, but to set the base message on the modal you can u
|
|
|
172
172
|
For these 4 fields you can just directly write the text or define tags, or call html from an element like this :
|
|
173
173
|
|
|
174
174
|
```javascript
|
|
175
|
-
const myModal =
|
|
175
|
+
const myModal = createWebcimesModal({
|
|
176
176
|
titleHtml: "My title <span style='color:red'>with red color</span>", // directly put an html tag or attribute like span and style
|
|
177
177
|
bodyHtml: document.querySelector('#myID').outerHTML, // set html from an HTML element
|
|
178
178
|
buttonCancelHtml: "Cancel <img src='my-url' alt=''>", // put the img tag
|
|
@@ -199,7 +199,7 @@ By default the `height` and `width` are set to `auto`, the modal will also be si
|
|
|
199
199
|
You can also set the determined `height` or `width` by indicating the value with a number and a unit.
|
|
200
200
|
|
|
201
201
|
```javascript
|
|
202
|
-
const myModal =
|
|
202
|
+
const myModal = createWebcimesModal({
|
|
203
203
|
width: '80vm',
|
|
204
204
|
height: '200px',
|
|
205
205
|
});
|
|
@@ -210,7 +210,7 @@ const myModal = CreateWebcimesModal({
|
|
|
210
210
|
Below are the different options for customize the modal behavior.
|
|
211
211
|
|
|
212
212
|
```javascript
|
|
213
|
-
const myModal =
|
|
213
|
+
const myModal = createWebcimesModal({
|
|
214
214
|
closeOnCancelButton: false, // close modal after triggering cancel button, default "true"
|
|
215
215
|
closeOnConfirmButton: false, // close modal after triggering confirm button, default "true"
|
|
216
216
|
showCloseButton: true, // show close button, default "true"
|
|
@@ -229,7 +229,7 @@ const myModal = CreateWebcimesModal({
|
|
|
229
229
|
You can define the style of the modal with `css`, but you can also use the style property which allows to directly add an additional style to the modal.
|
|
230
230
|
|
|
231
231
|
```javascript
|
|
232
|
-
const myModal =
|
|
232
|
+
const myModal = createWebcimesModal({
|
|
233
233
|
style: 'background:black; color:#fff; text-align:center;',
|
|
234
234
|
});
|
|
235
235
|
```
|
|
@@ -245,7 +245,7 @@ For `animationOnDestroy` you can choose between `animDropUp` or `animFadeOut`
|
|
|
245
245
|
And you can set the duration of all animation by setting `animationDuration` with a number in ms.
|
|
246
246
|
|
|
247
247
|
```javascript
|
|
248
|
-
const myModal =
|
|
248
|
+
const myModal = createWebcimesModal({
|
|
249
249
|
animationOnShow: 'animDropDown', // "animDropDown" or "animFadeIn" for show animation, default "animDropDown"
|
|
250
250
|
animationOnDestroy: 'animDropUp', // "animDropUp" or "animFadeOut" for destroy animation, default "animDropUp"
|
|
251
251
|
animationDuration: 500, // anim duration in ms, default "500"
|
|
@@ -258,7 +258,7 @@ You can get the dom element of the current modal like this:
|
|
|
258
258
|
|
|
259
259
|
```javascript
|
|
260
260
|
// Get the instance
|
|
261
|
-
const myModal =
|
|
261
|
+
const myModal = createWebcimesModal(...);
|
|
262
262
|
|
|
263
263
|
// Things
|
|
264
264
|
|
|
@@ -270,7 +270,7 @@ Or you can get the global container of all modals like this:
|
|
|
270
270
|
|
|
271
271
|
```javascript
|
|
272
272
|
// Get the instance
|
|
273
|
-
const myModal =
|
|
273
|
+
const myModal = createWebcimesModal(...);
|
|
274
274
|
|
|
275
275
|
// Things
|
|
276
276
|
|
|
@@ -283,7 +283,7 @@ myModal.modals;
|
|
|
283
283
|
Multiple events exist, which allow to interact with the modal at each step. You can use all events below:
|
|
284
284
|
|
|
285
285
|
```javascript
|
|
286
|
-
const myModal =
|
|
286
|
+
const myModal = createWebcimesModal({
|
|
287
287
|
beforeShow: () => {
|
|
288
288
|
console.log('before show');
|
|
289
289
|
}, // callback before show modal
|
|
@@ -309,7 +309,7 @@ You can also use `addEventListener` for get the events from the instance like th
|
|
|
309
309
|
|
|
310
310
|
```javascript
|
|
311
311
|
// Get the instance
|
|
312
|
-
const myModal =
|
|
312
|
+
const myModal = createWebcimesModal(...);
|
|
313
313
|
|
|
314
314
|
// Create an event on the current modal
|
|
315
315
|
myModal.modal.addEventListener("afterDestroy", () => {
|
|
@@ -331,7 +331,7 @@ To destroy the modal, you have several ways:
|
|
|
331
331
|
|
|
332
332
|
```javascript
|
|
333
333
|
// Get the instance
|
|
334
|
-
const myModal =
|
|
334
|
+
const myModal = createWebcimesModal(...);
|
|
335
335
|
|
|
336
336
|
// Things
|
|
337
337
|
|
package/demo/script_esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Import webcimes-modal
|
|
2
|
-
import {
|
|
2
|
+
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
|
-
const myModal =
|
|
6
|
+
const myModal = createWebcimesModal({
|
|
7
7
|
setId: null, // set specific id to the modal, default "null"
|
|
8
8
|
setClass: null, // set specific class to the modal, default "null"
|
|
9
9
|
width: 'auto', // width (specify the unit), default "auto"
|
|
@@ -46,7 +46,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
46
46
|
}, // callback after trigger confirm button
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
const myModal2 =
|
|
49
|
+
const myModal2 = createWebcimesModal({
|
|
50
50
|
titleHtml: 'My title', // html for title, default "null"
|
|
51
51
|
bodyHtml: document.querySelector('.test').outerHTML, // html for body, default "null"
|
|
52
52
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
package/demo/script_udm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Wait for dom content loaded
|
|
2
2
|
document.addEventListener('DOMContentLoaded', function () {
|
|
3
|
-
const myModal =
|
|
3
|
+
const myModal = createWebcimesModal({
|
|
4
4
|
setId: null, // set specific id to the modal, default "null"
|
|
5
5
|
setClass: null, // set specific class to the modal, default "null"
|
|
6
6
|
width: 'auto', // width (specify the unit), default "auto"
|
|
@@ -43,7 +43,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
43
43
|
}, // callback after trigger confirm button
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const myModal2 =
|
|
46
|
+
const myModal2 = createWebcimesModal({
|
|
47
47
|
titleHtml: 'My title', // html for title, default "null"
|
|
48
48
|
bodyHtml: document.querySelector('.test').outerHTML, // html for body, default "null"
|
|
49
49
|
buttonCancelHtml: 'Cancel', // html for cancel button, default "null"
|
|
@@ -93,5 +93,5 @@ export interface WebcimesModal {
|
|
|
93
93
|
/**
|
|
94
94
|
* Factory function to create a WebcimesModal instance with proper typing
|
|
95
95
|
*/
|
|
96
|
-
export declare function
|
|
96
|
+
export declare function createWebcimesModal(options: Partial<Options>): WebcimesModal;
|
|
97
97
|
//# sourceMappingURL=webcimes-modal.d.ts.map
|
|
@@ -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,{
|
|
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};
|
|
2
2
|
//# sourceMappingURL=webcimes-modal.esm.js.map
|
|
@@ -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AAK6C,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"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,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":""}
|
|
@@ -93,5 +93,5 @@ export interface WebcimesModal {
|
|
|
93
93
|
/**
|
|
94
94
|
* Factory function to create a WebcimesModal instance with proper typing
|
|
95
95
|
*/
|
|
96
|
-
export declare function
|
|
96
|
+
export declare function createWebcimesModal(options: Partial<Options>): WebcimesModal;
|
|
97
97
|
//# sourceMappingURL=webcimes-modal.d.ts.map
|
|
@@ -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,{
|
|
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})()));
|
|
2
2
|
//# sourceMappingURL=webcimes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,IAInEjB,KAAKF,QAAQ6D,gBACZ3D,KAAKF,QAAQ8D,gBACV5D,KAAKF,QAAQ+D,cACb7D,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/universalModuleDefinition","webpack://webcimes-modal/webpack/bootstrap","webpack://webcimes-modal/webpack/runtime/define property getters","webpack://webcimes-modal/webpack/runtime/hasOwnProperty shorthand","webpack://webcimes-modal/webpack/runtime/make namespace object","webpack://webcimes-modal/./src/ts/webcimes-modal.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, () => {\nreturn ","// 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))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\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":["root","factory","exports","module","define","amd","a","i","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","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.udm.js","mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO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AAC,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/universalModuleDefinition","webpack://webcimes-modal/webpack/bootstrap","webpack://webcimes-modal/webpack/runtime/define property getters","webpack://webcimes-modal/webpack/runtime/hasOwnProperty shorthand","webpack://webcimes-modal/webpack/runtime/make namespace object","webpack://webcimes-modal/./src/ts/webcimes-modal.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(self, () => {\nreturn ","// 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))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\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":["root","factory","exports","module","define","amd","a","i","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","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":""}
|
package/package.json
CHANGED
|
@@ -93,5 +93,5 @@ export interface WebcimesModal {
|
|
|
93
93
|
/**
|
|
94
94
|
* Factory function to create a WebcimesModal instance with proper typing
|
|
95
95
|
*/
|
|
96
|
-
export declare function
|
|
96
|
+
export declare function createWebcimesModal(options: Partial<Options>): WebcimesModal;
|
|
97
97
|
//# sourceMappingURL=webcimes-modal.d.ts.map
|
package/src/ts/webcimes-modal.ts
CHANGED
|
@@ -591,6 +591,6 @@ class WebcimesModalImpl implements WebcimesModal {
|
|
|
591
591
|
/**
|
|
592
592
|
* Factory function to create a WebcimesModal instance with proper typing
|
|
593
593
|
*/
|
|
594
|
-
export function
|
|
594
|
+
export function createWebcimesModal(options: Partial<Options>): WebcimesModal {
|
|
595
595
|
return new WebcimesModalImpl(options);
|
|
596
596
|
}
|
package/test/script.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Import webcimes-modal
|
|
2
|
-
import {
|
|
2
|
+
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
|
-
let modal1 =
|
|
6
|
+
let modal1 = createWebcimesModal({
|
|
7
7
|
titleHtml: 'My title',
|
|
8
8
|
bodyHtml: 'My Body',
|
|
9
9
|
afterDestroy: () => {
|
|
@@ -16,7 +16,7 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
|
16
16
|
console.log('event');
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
createWebcimesModal({
|
|
20
20
|
titleHtml: 'My title 2',
|
|
21
21
|
bodyHtml: 'My Body 2',
|
|
22
22
|
afterDestroy: () => {
|