webcimes-modal 1.0.1 → 1.1.1
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/.eslintrc.json +0 -0
- package/.gitignore +2 -0
- package/LICENSE.md +0 -0
- package/README.md +67 -17
- package/{demo.html → demo/demo_esm.html} +7 -6
- package/demo/demo_udm.html +94 -0
- package/{webcimes-modal.css → dist/css/webcimes-modal.css} +418 -415
- package/dist/css/webcimes-modal.css.map +1 -0
- package/dist/css/webcimes-modal.min.css +2 -0
- package/dist/css/webcimes-modal.min.css.map +1 -0
- package/{images → dist/images}/times.svg +0 -0
- package/{webcimes-modal.js → dist/js/esm/webcimes-modal.esm.js} +151 -108
- package/dist/js/esm/webcimes-modal.esm.js.map +1 -0
- package/dist/js/esm/webcimes-modal.esm.min.js +2 -0
- package/dist/js/esm/webcimes-modal.esm.min.js.map +1 -0
- package/dist/js/udm/webcimes-modal.udm.js +421 -0
- package/dist/js/udm/webcimes-modal.udm.js.map +1 -0
- package/dist/js/udm/webcimes-modal.udm.min.js +2 -0
- package/dist/js/udm/webcimes-modal.udm.min.js.map +1 -0
- package/package.json +16 -4
- package/src/css/webcimes-modal.css +416 -0
- package/src/images/times.svg +1 -0
- package/{webcimes-modal.ts → src/ts/webcimes-modal.ts} +22 -9
- package/tsconfig.json +15 -8
- package/webpack.config.ts +147 -0
- package/demo_test.html +0 -0
- package/webcimes-modal.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcimes-modal",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Simply create and animate modals. It works with vanilla javascript + html + css.",
|
|
5
|
-
"main": "webcimes-modal.js",
|
|
5
|
+
"main": "./dist/js/udm/webcimes-modal.udm.min.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"
|
|
7
|
+
"build": "webpack --config webpack.config.ts --node-env=production",
|
|
8
|
+
"build:dev": "webpack --config webpack.config.ts --node-env=development"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|
|
@@ -24,5 +25,16 @@
|
|
|
24
25
|
"bugs": {
|
|
25
26
|
"url": "https://github.com/WebCimes/webcimes-modal/issues"
|
|
26
27
|
},
|
|
27
|
-
"homepage": "https://github.com/WebCimes/webcimes-modal#readme"
|
|
28
|
+
"homepage": "https://github.com/WebCimes/webcimes-modal#readme",
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"css-loader": "^6.8.1",
|
|
31
|
+
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
32
|
+
"mini-css-extract-plugin": "^2.7.6",
|
|
33
|
+
"remove-files-webpack-plugin": "^1.5.0",
|
|
34
|
+
"ts-loader": "^9.4.4",
|
|
35
|
+
"ts-node": "^10.9.1",
|
|
36
|
+
"typescript": "^5.2.2",
|
|
37
|
+
"webpack": "^5.88.2",
|
|
38
|
+
"webpack-cli": "^5.1.4"
|
|
39
|
+
}
|
|
28
40
|
}
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023 WebCimes - RICHARD Florian (https://webcimes.com)
|
|
3
|
+
* MIT License - https://choosealicense.com/licenses/mit/
|
|
4
|
+
* Date: 2023-03-25
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
-----------------------
|
|
9
|
+
WEBCIMES MODAL
|
|
10
|
+
-----------------------
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
.webcimesModals,
|
|
14
|
+
.webcimesModals *,
|
|
15
|
+
.webcimesModals *::before,
|
|
16
|
+
.webcimesModals *::after
|
|
17
|
+
{
|
|
18
|
+
-webkit-box-sizing: border-box;
|
|
19
|
+
-moz-box-sizing: border-box;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
}
|
|
22
|
+
.webcimesModals
|
|
23
|
+
{
|
|
24
|
+
--webcimes-modals-background: rgba(0,0,0,0.8);
|
|
25
|
+
--webcimes-modals-z-index: 5;
|
|
26
|
+
|
|
27
|
+
position: fixed;
|
|
28
|
+
background: var(--webcimes-modals-background);
|
|
29
|
+
top: 0;
|
|
30
|
+
bottom: 0;
|
|
31
|
+
left: 0;
|
|
32
|
+
right: 0;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
z-index: var(--webcimes-modals-z-index);
|
|
37
|
+
}
|
|
38
|
+
.webcimesModals > .modal
|
|
39
|
+
{
|
|
40
|
+
--modal-color: inherit;
|
|
41
|
+
--modal-background: #fff;
|
|
42
|
+
--modal-border-color: #ddd;
|
|
43
|
+
--modal-box-shadow: 1px 1px 3px 0px #444;
|
|
44
|
+
--modal-title-font-size: 24px;
|
|
45
|
+
--modal-button-cancel-background: rgba(102,102,102,1);
|
|
46
|
+
--modal-button-cancel-background-hover: rgba(102,102,102,0.7);
|
|
47
|
+
--modal-button-cancel-color: #fff;
|
|
48
|
+
--modal-button-cancel-color-hover: #fff;
|
|
49
|
+
--modal-button-confirm-background: rgba(0,0,0,1);
|
|
50
|
+
--modal-button-confirm-background-hover: rgba(0,0,0,0.7);
|
|
51
|
+
--modal-button-confirm-color: #fff;
|
|
52
|
+
--modal-button-confirm-color-hover: #fff;
|
|
53
|
+
|
|
54
|
+
position: absolute;
|
|
55
|
+
border-radius: 5px;
|
|
56
|
+
overflow:auto;
|
|
57
|
+
color: var(--modal-color);
|
|
58
|
+
background: var(--modal-background);
|
|
59
|
+
-webkit-box-shadow: var(--modal-box-shadow);
|
|
60
|
+
-moz-box-shadow: var(--modal-box-shadow);
|
|
61
|
+
-o-box-shadow: var(--modal-box-shadow);
|
|
62
|
+
box-shadow: var(--modal-box-shadow);
|
|
63
|
+
}
|
|
64
|
+
.webcimesModals > .modal button
|
|
65
|
+
{
|
|
66
|
+
font-family: inherit;
|
|
67
|
+
font-size: inherit;
|
|
68
|
+
font-weight: inherit;
|
|
69
|
+
border: none;
|
|
70
|
+
background: none;
|
|
71
|
+
}
|
|
72
|
+
.webcimesModals > .modal > .modalHeader
|
|
73
|
+
{
|
|
74
|
+
position: relative;
|
|
75
|
+
background: var(--modal-background);
|
|
76
|
+
padding: 20px 40px;
|
|
77
|
+
border-bottom: 1px solid var(--modal-border-color);
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
.webcimesModals > .modal > .modalHeader.sticky
|
|
82
|
+
{
|
|
83
|
+
position: sticky;
|
|
84
|
+
top: 0;
|
|
85
|
+
}
|
|
86
|
+
.webcimesModals > .modal > .modalHeader.movable
|
|
87
|
+
{
|
|
88
|
+
cursor: move;
|
|
89
|
+
touch-action: none;
|
|
90
|
+
}
|
|
91
|
+
.webcimesModals > .modal > .modalHeader > .title
|
|
92
|
+
{
|
|
93
|
+
flex: 1;
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
text-overflow: ellipsis;
|
|
96
|
+
font-size: var(--modal-title-font-size);
|
|
97
|
+
}
|
|
98
|
+
.webcimesModals > .modal > .modalHeader > .close
|
|
99
|
+
{
|
|
100
|
+
position: absolute;
|
|
101
|
+
height: 20px;
|
|
102
|
+
width: 12px;
|
|
103
|
+
right: 15px;
|
|
104
|
+
top: 50%;
|
|
105
|
+
margin-top: -10px;
|
|
106
|
+
background-image: url("../images/times.svg");
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
opacity: 1;
|
|
109
|
+
-webkit-transition: opacity 0.6s ease 0s;
|
|
110
|
+
-moz-transition: opacity 0.6s ease 0s;
|
|
111
|
+
-o-transition: opacity 0.6s ease 0s;
|
|
112
|
+
transition: opacity 0.6s ease 0s;
|
|
113
|
+
}
|
|
114
|
+
.webcimesModals > .modal > .modalHeader > .close:hover
|
|
115
|
+
{
|
|
116
|
+
opacity: 0.5;
|
|
117
|
+
}
|
|
118
|
+
.webcimesModals > .modal > .modalBody
|
|
119
|
+
{
|
|
120
|
+
padding: 20px 40px;
|
|
121
|
+
}
|
|
122
|
+
.webcimesModals > .modal > .modalBody.movable
|
|
123
|
+
{
|
|
124
|
+
cursor: move;
|
|
125
|
+
}
|
|
126
|
+
.webcimesModals > .modal > .modalFooter
|
|
127
|
+
{
|
|
128
|
+
background: var(--modal-background);
|
|
129
|
+
padding: 20px 40px;
|
|
130
|
+
border-top: 1px solid var(--modal-border-color);
|
|
131
|
+
display: flex;
|
|
132
|
+
justify-content: flex-end;
|
|
133
|
+
flex-wrap: wrap;
|
|
134
|
+
}
|
|
135
|
+
.webcimesModals > .modal > .modalFooter.sticky
|
|
136
|
+
{
|
|
137
|
+
position: sticky;
|
|
138
|
+
bottom: 0;
|
|
139
|
+
}
|
|
140
|
+
.webcimesModals > .modal > .modalFooter.movable
|
|
141
|
+
{
|
|
142
|
+
cursor: move;
|
|
143
|
+
touch-action: none;
|
|
144
|
+
}
|
|
145
|
+
.webcimesModals > .modal > .modalFooter button
|
|
146
|
+
{
|
|
147
|
+
max-width: 100%;
|
|
148
|
+
flex: 0 0 auto;
|
|
149
|
+
border-radius: 5px;
|
|
150
|
+
padding: 10px 30px;
|
|
151
|
+
margin: 5px;
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
text-overflow: ellipsis;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
-webkit-transition: color 0.6s ease 0s, background 0.6s ease 0s;
|
|
156
|
+
-moz-transition: color 0.6s ease 0s, background 0.6s ease 0s;
|
|
157
|
+
-o-transition: color 0.6s ease 0s, background 0.6s ease 0s;
|
|
158
|
+
transition: color 0.6s ease 0s, background 0.6s ease 0s;
|
|
159
|
+
}
|
|
160
|
+
.webcimesModals > .modal > .modalFooter button.cancel
|
|
161
|
+
{
|
|
162
|
+
background: var(--modal-button-cancel-background);
|
|
163
|
+
color: var(--modal-button-cancel-color);
|
|
164
|
+
}
|
|
165
|
+
.webcimesModals > .modal > .modalFooter button.cancel:hover
|
|
166
|
+
{
|
|
167
|
+
background: var(--modal-button-cancel-background-hover);
|
|
168
|
+
color: var(--modal-button-cancel-color-hover);
|
|
169
|
+
}
|
|
170
|
+
.webcimesModals > .modal > .modalFooter button.confirm
|
|
171
|
+
{
|
|
172
|
+
background: var(--modal-button-confirm-background);
|
|
173
|
+
color: var(--modal-button-confirm-color);
|
|
174
|
+
}
|
|
175
|
+
.webcimesModals > .modal > .modalFooter button.confirm:hover
|
|
176
|
+
{
|
|
177
|
+
background: var(--modal-button-confirm-background-hover);
|
|
178
|
+
color: var(--modal-button-confirm-color-hover);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* ANIMATIONS */
|
|
182
|
+
|
|
183
|
+
@-webkit-keyframes animFadeIn
|
|
184
|
+
{
|
|
185
|
+
0%
|
|
186
|
+
{
|
|
187
|
+
opacity: 0;
|
|
188
|
+
}
|
|
189
|
+
100%
|
|
190
|
+
{
|
|
191
|
+
opacity: 1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
@keyframes animFadeIn
|
|
195
|
+
{
|
|
196
|
+
0%
|
|
197
|
+
{
|
|
198
|
+
opacity:0;
|
|
199
|
+
}
|
|
200
|
+
100%
|
|
201
|
+
{
|
|
202
|
+
opacity:1;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
.animFadeIn
|
|
206
|
+
{
|
|
207
|
+
-webkit-animation-duration: 0.5s;
|
|
208
|
+
animation-duration: 0.5s;
|
|
209
|
+
-webkit-animation-fill-mode: both;
|
|
210
|
+
animation-fill-mode: both;
|
|
211
|
+
-webkit-animation-name: animFadeIn;
|
|
212
|
+
animation-name: animFadeIn;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@-webkit-keyframes animFadeOut
|
|
216
|
+
{
|
|
217
|
+
0%
|
|
218
|
+
{
|
|
219
|
+
opacity: 1;
|
|
220
|
+
}
|
|
221
|
+
100%
|
|
222
|
+
{
|
|
223
|
+
opacity: 0;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
@keyframes animFadeOut
|
|
227
|
+
{
|
|
228
|
+
0%
|
|
229
|
+
{
|
|
230
|
+
opacity: 1;
|
|
231
|
+
}
|
|
232
|
+
100%
|
|
233
|
+
{
|
|
234
|
+
opacity: 0;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
.animFadeOut
|
|
238
|
+
{
|
|
239
|
+
-webkit-animation-duration: 0.5s;
|
|
240
|
+
animation-duration: 0.5s;
|
|
241
|
+
-webkit-animation-fill-mode: both;
|
|
242
|
+
animation-fill-mode: both;
|
|
243
|
+
-webkit-animation-name: animFadeOut;
|
|
244
|
+
animation-name: animFadeOut;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@-webkit-keyframes animDropDown
|
|
248
|
+
{
|
|
249
|
+
0%
|
|
250
|
+
{
|
|
251
|
+
-webkit-transform: translateY(-20vh);
|
|
252
|
+
-moz-transform: translateY(-20vh);
|
|
253
|
+
-ms-transform: translateY(-20vh);
|
|
254
|
+
-o-transform: translateY(-20vh);
|
|
255
|
+
transform: translateY(-20vh);
|
|
256
|
+
opacity: 0;
|
|
257
|
+
}
|
|
258
|
+
100%
|
|
259
|
+
{
|
|
260
|
+
-webkit-transform: translateY(0);
|
|
261
|
+
-moz-transform: translateY(0);
|
|
262
|
+
-ms-transform: translateY(0);
|
|
263
|
+
-o-transform: translateY(0);
|
|
264
|
+
transform: translateY(0);
|
|
265
|
+
opacity: 1;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
@keyframes animDropDown
|
|
270
|
+
{
|
|
271
|
+
0%
|
|
272
|
+
{
|
|
273
|
+
-webkit-transform: translateY(-20vh);
|
|
274
|
+
-moz-transform: translateY(-20vh);
|
|
275
|
+
-ms-transform: translateY(-20vh);
|
|
276
|
+
-o-transform: translateY(-20vh);
|
|
277
|
+
transform: translateY(-20vh);
|
|
278
|
+
opacity: 0;
|
|
279
|
+
}
|
|
280
|
+
100%
|
|
281
|
+
{
|
|
282
|
+
-webkit-transform: translateY(0);
|
|
283
|
+
-moz-transform: translateY(0);
|
|
284
|
+
-ms-transform: translateY(0);
|
|
285
|
+
-o-transform: translateY(0);
|
|
286
|
+
transform: translateY(0);
|
|
287
|
+
opacity: 1;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
.animDropDown
|
|
291
|
+
{
|
|
292
|
+
-webkit-animation-duration: 0.5s;
|
|
293
|
+
animation-duration: 0.5s;
|
|
294
|
+
-webkit-animation-fill-mode: both;
|
|
295
|
+
animation-fill-mode: both;
|
|
296
|
+
-webkit-animation-name: animDropDown;
|
|
297
|
+
animation-name: animDropDown;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@-webkit-keyframes animDropUp
|
|
301
|
+
{
|
|
302
|
+
0%
|
|
303
|
+
{
|
|
304
|
+
-webkit-transform: translateY(0);
|
|
305
|
+
-moz-transform: translateY(0);
|
|
306
|
+
-ms-transform: translateY(0);
|
|
307
|
+
-o-transform: translateY(0);
|
|
308
|
+
transform: translateY(0);
|
|
309
|
+
opacity: 1;
|
|
310
|
+
}
|
|
311
|
+
100%
|
|
312
|
+
{
|
|
313
|
+
-webkit-transform: translateY(-20vh);
|
|
314
|
+
-moz-transform: translateY(-20vh);
|
|
315
|
+
-ms-transform: translateY(-20vh);
|
|
316
|
+
-o-transform: translateY(-20vh);
|
|
317
|
+
transform: translateY(-20vh);
|
|
318
|
+
opacity: 0;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@keyframes animDropUp
|
|
323
|
+
{
|
|
324
|
+
0%
|
|
325
|
+
{
|
|
326
|
+
-webkit-transform: translateY(0);
|
|
327
|
+
-moz-transform: translateY(0);
|
|
328
|
+
-ms-transform: translateY(0);
|
|
329
|
+
-o-transform: translateY(0);
|
|
330
|
+
transform: translateY(0);
|
|
331
|
+
opacity: 1;
|
|
332
|
+
}
|
|
333
|
+
100%
|
|
334
|
+
{
|
|
335
|
+
-webkit-transform: translateY(-20vh);
|
|
336
|
+
-moz-transform: translateY(-20vh);
|
|
337
|
+
-ms-transform: translateY(-20vh);
|
|
338
|
+
-o-transform: translateY(-20vh);
|
|
339
|
+
transform: translateY(-20vh);
|
|
340
|
+
opacity: 0;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
.animDropUp
|
|
344
|
+
{
|
|
345
|
+
-webkit-animation-duration: 0.5s;
|
|
346
|
+
animation-duration: 0.5s;
|
|
347
|
+
-webkit-animation-fill-mode: both;
|
|
348
|
+
animation-fill-mode: both;
|
|
349
|
+
-webkit-animation-name: animDropUp;
|
|
350
|
+
animation-name: animDropUp;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
@-webkit-keyframes animGrowShrink
|
|
354
|
+
{
|
|
355
|
+
0%
|
|
356
|
+
{
|
|
357
|
+
-webkit-transform: scale(1);
|
|
358
|
+
-moz-transform: scale(1);
|
|
359
|
+
-ms-transform: scale(1);
|
|
360
|
+
-o-transform: scale(1);
|
|
361
|
+
transform: scale(1);
|
|
362
|
+
}
|
|
363
|
+
50%
|
|
364
|
+
{
|
|
365
|
+
-webkit-transform: scale(1.2);
|
|
366
|
+
-moz-transform: scale(1.2);
|
|
367
|
+
-ms-transform: scale(1.2);
|
|
368
|
+
-o-transform: scale(1.2);
|
|
369
|
+
transform: scale(1.2);
|
|
370
|
+
}
|
|
371
|
+
100%
|
|
372
|
+
{
|
|
373
|
+
-webkit-transform: scale(1);
|
|
374
|
+
-moz-transform: scale(1);
|
|
375
|
+
-ms-transform: scale(1);
|
|
376
|
+
-o-transform: scale(1);
|
|
377
|
+
transform: scale(1);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
@keyframes animGrowShrink
|
|
382
|
+
{
|
|
383
|
+
0%
|
|
384
|
+
{
|
|
385
|
+
-webkit-transform: scale(1);
|
|
386
|
+
-moz-transform: scale(1);
|
|
387
|
+
-ms-transform: scale(1);
|
|
388
|
+
-o-transform: scale(1);
|
|
389
|
+
transform: scale(1);
|
|
390
|
+
}
|
|
391
|
+
50%
|
|
392
|
+
{
|
|
393
|
+
-webkit-transform: scale(1.1);
|
|
394
|
+
-moz-transform: scale(1.1);
|
|
395
|
+
-ms-transform: scale(1.1);
|
|
396
|
+
-o-transform: scale(1.1);
|
|
397
|
+
transform: scale(1.1);
|
|
398
|
+
}
|
|
399
|
+
100%
|
|
400
|
+
{
|
|
401
|
+
-webkit-transform: scale(1);
|
|
402
|
+
-moz-transform: scale(1);
|
|
403
|
+
-ms-transform: scale(1);
|
|
404
|
+
-o-transform: scale(1);
|
|
405
|
+
transform: scale(1);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
.animGrowShrink
|
|
409
|
+
{
|
|
410
|
+
-webkit-animation-duration: 0.5s;
|
|
411
|
+
animation-duration: 0.5s;
|
|
412
|
+
-webkit-animation-fill-mode: both;
|
|
413
|
+
animation-fill-mode: both;
|
|
414
|
+
-webkit-animation-name: animGrowShrink;
|
|
415
|
+
animation-name: animGrowShrink;
|
|
416
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><path d="M193.94 256L296.5 153.44l21.15-21.15c3.12-3.12 3.12-8.19 0-11.31l-22.63-22.63c-3.12-3.12-8.19-3.12-11.31 0L160 222.06 36.29 98.34c-3.12-3.12-8.19-3.12-11.31 0L2.34 120.97c-3.12 3.12-3.12 8.19 0 11.31L126.06 256 2.34 379.71c-3.12 3.12-3.12 8.19 0 11.31l22.63 22.63c3.12 3.12 8.19 3.12 11.31 0L160 289.94 262.56 392.5l21.15 21.15c3.12 3.12 8.19 3.12 11.31 0l22.63-22.63c3.12-3.12 3.12-8.19 0-11.31L193.94 256z"/></svg>
|
|
@@ -73,8 +73,8 @@ interface Options {
|
|
|
73
73
|
*/
|
|
74
74
|
export class WebcimesModal
|
|
75
75
|
{
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
public webcimesModals: HTMLElement;
|
|
77
|
+
public modal: HTMLElement;
|
|
78
78
|
private options: Options;
|
|
79
79
|
private eventCancelButton: () => void = () => {
|
|
80
80
|
// Callback on cancel button
|
|
@@ -187,6 +187,11 @@ export class WebcimesModal
|
|
|
187
187
|
e.preventDefault();
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
+
private eventResize: () => void = () => {
|
|
191
|
+
this.modal.style.removeProperty("left");
|
|
192
|
+
this.modal.style.removeProperty("top");
|
|
193
|
+
|
|
194
|
+
};
|
|
190
195
|
|
|
191
196
|
/**
|
|
192
197
|
* Create modal
|
|
@@ -284,15 +289,9 @@ export class WebcimesModal
|
|
|
284
289
|
this.webcimesModals = <HTMLElement>document.querySelector(".webcimesModals");
|
|
285
290
|
}
|
|
286
291
|
|
|
287
|
-
// Callback before show modal
|
|
288
|
-
if(typeof this.options.beforeShow === 'function')
|
|
289
|
-
{
|
|
290
|
-
this.options.beforeShow();
|
|
291
|
-
}
|
|
292
|
-
|
|
293
292
|
// Create modal
|
|
294
293
|
this.webcimesModals.insertAdjacentHTML("beforeend",
|
|
295
|
-
`<div class="modal `+(this.options.setClass?this.options.setClass:'')+` `+this.options.animationOnShow+`" `+(this.options.
|
|
294
|
+
`<div class="modal `+(this.options.setClass?this.options.setClass:'')+` `+this.options.animationOnShow+`" `+(this.options.setId?'id="'+this.options.setId+'"':'')+`>
|
|
296
295
|
`+(this.options.titleHtml||this.options.showCloseButton?
|
|
297
296
|
`<div class="modalHeader `+(this.options.stickyHeader?'sticky':'')+` `+(this.options.moveFromHeader?'movable':'')+`">
|
|
298
297
|
`+(this.options.titleHtml?'<div class="title">'+this.options.titleHtml+'</div>':'')+`
|
|
@@ -314,6 +313,15 @@ export class WebcimesModal
|
|
|
314
313
|
);
|
|
315
314
|
this.modal = <HTMLElement>this.webcimesModals.lastElementChild;
|
|
316
315
|
|
|
316
|
+
// Callback before show modal
|
|
317
|
+
if(typeof this.options.beforeShow === 'function')
|
|
318
|
+
{
|
|
319
|
+
// Set a timeout of zero, to wait for some dom to load
|
|
320
|
+
setTimeout(() => {
|
|
321
|
+
this.options.beforeShow();
|
|
322
|
+
}, 0);
|
|
323
|
+
}
|
|
324
|
+
|
|
317
325
|
// Set animation duration for modal
|
|
318
326
|
this.modal.style.setProperty("animation-duration", this.options.animationDuration+"ms");
|
|
319
327
|
|
|
@@ -416,6 +424,9 @@ export class WebcimesModal
|
|
|
416
424
|
|
|
417
425
|
document.addEventListener("selectstart", this.eventPreventSelectText);
|
|
418
426
|
}
|
|
427
|
+
|
|
428
|
+
// When resizing window, reset modal position to center
|
|
429
|
+
window.addEventListener("resize", this.eventResize);
|
|
419
430
|
}
|
|
420
431
|
|
|
421
432
|
/**
|
|
@@ -487,6 +498,8 @@ export class WebcimesModal
|
|
|
487
498
|
document.removeEventListener("selectstart", this.eventPreventSelectText);
|
|
488
499
|
}
|
|
489
500
|
|
|
501
|
+
window.removeEventListener("resize", this.eventResize);
|
|
502
|
+
|
|
490
503
|
// Remove webcimesModals or modal according the number of modal
|
|
491
504
|
(document.querySelectorAll(".modal").length>1?this.modal:this.webcimesModals).remove();
|
|
492
505
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
"module": "ESNext",
|
|
4
|
+
"target": "ESNext",
|
|
5
|
+
"removeComments": false,
|
|
6
|
+
"sourceMap": true,
|
|
7
|
+
"noImplicitAny": true,
|
|
8
|
+
"strictNullChecks": true,
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"esModuleInterop": true
|
|
11
|
+
},
|
|
12
|
+
"ts-node": {
|
|
13
|
+
"compilerOptions": {
|
|
14
|
+
"module": "CommonJS"
|
|
15
|
+
}
|
|
9
16
|
},
|
|
10
17
|
"files": [
|
|
11
|
-
|
|
18
|
+
"src/ts/webcimes-modal.ts",
|
|
12
19
|
]
|
|
13
|
-
|
|
20
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
|
2
|
+
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import webpack from "webpack";
|
|
5
|
+
import TerserPlugin from "terser-webpack-plugin";
|
|
6
|
+
import MiniCssExtractPlugin from "mini-css-extract-plugin";
|
|
7
|
+
import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
8
|
+
import RemovePlugin from "remove-files-webpack-plugin";
|
|
9
|
+
|
|
10
|
+
const isProduction = process.env.NODE_ENV == 'production';
|
|
11
|
+
|
|
12
|
+
// Config UDM
|
|
13
|
+
const configUDM: webpack.Configuration = {
|
|
14
|
+
mode: (isProduction ? "production" : "development"),
|
|
15
|
+
// devtool: (isProduction ? false : "source-map"),
|
|
16
|
+
devtool: "source-map",
|
|
17
|
+
entry: {
|
|
18
|
+
"webcimes-modal.udm": "./src/ts/webcimes-modal.ts",
|
|
19
|
+
"webcimes-modal.udm.min": "./src/ts/webcimes-modal.ts",
|
|
20
|
+
},
|
|
21
|
+
optimization: {
|
|
22
|
+
minimize: true,
|
|
23
|
+
minimizer: [
|
|
24
|
+
new TerserPlugin({
|
|
25
|
+
test: /\.min\.js$/i,
|
|
26
|
+
extractComments: false,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
output: {
|
|
31
|
+
filename: "js/udm/[name].js",
|
|
32
|
+
path: path.resolve(__dirname, "dist"),
|
|
33
|
+
// publicPath: "/dist/",
|
|
34
|
+
libraryTarget: "umd",
|
|
35
|
+
clean: false, // Clean the output directory before emit.
|
|
36
|
+
},
|
|
37
|
+
module: {
|
|
38
|
+
rules: [
|
|
39
|
+
{
|
|
40
|
+
test: /\.(ts)$/i,
|
|
41
|
+
use: "ts-loader",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Config ESM
|
|
48
|
+
const configESM: webpack.Configuration = {
|
|
49
|
+
mode: (isProduction ? "production" : "development"),
|
|
50
|
+
// devtool: (isProduction ? false : "source-map"),
|
|
51
|
+
devtool: "source-map",
|
|
52
|
+
entry: {
|
|
53
|
+
"webcimes-modal.esm": "./src/ts/webcimes-modal.ts",
|
|
54
|
+
"webcimes-modal.esm.min": "./src/ts/webcimes-modal.ts",
|
|
55
|
+
},
|
|
56
|
+
optimization: {
|
|
57
|
+
minimize: true,
|
|
58
|
+
minimizer: [
|
|
59
|
+
new TerserPlugin({
|
|
60
|
+
test: /\.min\.js$/i,
|
|
61
|
+
extractComments: false,
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
experiments: {
|
|
66
|
+
outputModule: true,
|
|
67
|
+
},
|
|
68
|
+
output: {
|
|
69
|
+
filename: "js/esm/[name].js",
|
|
70
|
+
path: path.resolve(__dirname, "dist"),
|
|
71
|
+
// publicPath: "/dist/",
|
|
72
|
+
libraryTarget: "module",
|
|
73
|
+
clean: false, // Clean the output directory before emit.
|
|
74
|
+
},
|
|
75
|
+
module: {
|
|
76
|
+
rules: [
|
|
77
|
+
{
|
|
78
|
+
test: /\.(ts)$/i,
|
|
79
|
+
use: "ts-loader",
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Config CSS + Remove plugin
|
|
86
|
+
const configCSS: webpack.Configuration = {
|
|
87
|
+
mode: (isProduction ? "production" : "development"),
|
|
88
|
+
// devtool: (isProduction ? false : "source-map"),
|
|
89
|
+
devtool: "source-map",
|
|
90
|
+
entry: {
|
|
91
|
+
"webcimes-modal": "./src/css/webcimes-modal.css",
|
|
92
|
+
"webcimes-modal.min": "./src/css/webcimes-modal.css",
|
|
93
|
+
},
|
|
94
|
+
optimization: {
|
|
95
|
+
minimize: true,
|
|
96
|
+
minimizer: [
|
|
97
|
+
new CssMinimizerPlugin({
|
|
98
|
+
test: /\.min\.css$/i,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
output: {
|
|
103
|
+
filename: "css/[name].js",
|
|
104
|
+
path: path.resolve(__dirname, "dist"),
|
|
105
|
+
// publicPath: "/dist/",
|
|
106
|
+
clean: false, // Clean the output directory before emit.
|
|
107
|
+
},
|
|
108
|
+
module: {
|
|
109
|
+
rules: [
|
|
110
|
+
{
|
|
111
|
+
test: /\.css$/i,
|
|
112
|
+
// use: ['style-loader', 'css-loader'],
|
|
113
|
+
use: [MiniCssExtractPlugin.loader, "css-loader"],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
test: /\.(svg|png|jpg|jpeg|gif)$/i,
|
|
117
|
+
type: 'asset/resource',
|
|
118
|
+
generator: {
|
|
119
|
+
filename: 'images/[name][ext][query]', // Correct bug asset/ressource url wrong path with css files subfolder https://github.com/webpack-contrib/mini-css-extract-plugin/issues/1005
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
plugins: [
|
|
125
|
+
new MiniCssExtractPlugin({filename: "css/[name].css"}),
|
|
126
|
+
new RemovePlugin({
|
|
127
|
+
before: {
|
|
128
|
+
include: [
|
|
129
|
+
'./dist' // Delete dist folder before running webpack build
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
after: {
|
|
133
|
+
test: [
|
|
134
|
+
{
|
|
135
|
+
folder: './dist/css',
|
|
136
|
+
method: (absoluteItemPath) => {
|
|
137
|
+
return new RegExp(/(\.js|\.js\.map)$/, 'm').test(absoluteItemPath); // Delete extra empty js file (can't ouput directly css)
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Export
|
|
147
|
+
export default [configUDM, configESM, configCSS];
|
package/demo_test.html
DELETED
|
File without changes
|