@massimo-cassandro/minimo 1.5.7 → 1.5.9
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/package.json
CHANGED
|
@@ -3,9 +3,10 @@ export const defaults = {
|
|
|
3
3
|
// settings to be applied to all dialog types
|
|
4
4
|
// can be reassigned on single types
|
|
5
5
|
globals: {
|
|
6
|
+
extra_class: null,
|
|
6
7
|
onOpen: null,
|
|
7
8
|
onClose: null,
|
|
8
|
-
cssFile: null, // css file to be automatically loaded
|
|
9
|
+
cssFile: null, // css file to be automatically loaded // TODO remove
|
|
9
10
|
animation: true,
|
|
10
11
|
showMarks: true,
|
|
11
12
|
callback: null,
|
|
@@ -65,7 +65,7 @@ export default function (params, custom_defaults = {}, marks = default_marks) {
|
|
|
65
65
|
const closedByAny = ['success', 'info'].indexOf(params.type) !== -1? ' closedBy="any"' : '';
|
|
66
66
|
|
|
67
67
|
document.body.insertAdjacentHTML('beforeend',
|
|
68
|
-
`<dialog class="modal-alert modal-alert-${params.type}${params.animation? ' modal-alert-animated' : ''}"${closedByAny}>
|
|
68
|
+
`<dialog class="modal-alert modal-alert-${params.type}${params.animation? ' modal-alert-animated' : ''} ${params.extra_class??''}"${closedByAny}>
|
|
69
69
|
<div class="malert-inner">
|
|
70
70
|
${params.showMarks? `<div class="malert-mark">${icon}</div>` : ''}
|
|
71
71
|
<div class="malert-body">
|
|
@@ -11,11 +11,11 @@ import * as styles from './modal-popup.module.css';
|
|
|
11
11
|
|
|
12
12
|
let dialogEl, dialogContentEl;
|
|
13
13
|
|
|
14
|
-
function closeDialog() {
|
|
15
|
-
|
|
14
|
+
function closeDialog(el) {
|
|
15
|
+
el.classList.remove(styles.on);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
el.addEventListener('transitionend', () => {
|
|
18
|
+
el.close();
|
|
19
19
|
}, { once: true });
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -165,39 +165,41 @@ export function modalPopup({
|
|
|
165
165
|
}
|
|
166
166
|
], document.body);
|
|
167
167
|
|
|
168
|
+
// snapshot: dialogEl potrebbe essere sovrascritto da una seconda chiamata a modalPopup
|
|
169
|
+
const thisDialog = dialogEl;
|
|
168
170
|
|
|
169
171
|
// listener sul pulsante di chiusura
|
|
170
|
-
|
|
171
|
-
closeDialog();
|
|
172
|
+
thisDialog.querySelector(`.${styles.closeButton}`).addEventListener('click', () => {
|
|
173
|
+
closeDialog(thisDialog);
|
|
172
174
|
}, false);
|
|
173
175
|
|
|
174
176
|
// // Esc e clic sul backdrop
|
|
175
|
-
//
|
|
177
|
+
// thisDialog.addEventListener('cancel', (e) => {
|
|
176
178
|
// e.preventDefault();
|
|
177
|
-
// closeDialog();
|
|
179
|
+
// closeDialog(thisDialog);
|
|
178
180
|
// }, false);
|
|
179
181
|
|
|
180
182
|
|
|
181
183
|
|
|
182
|
-
|
|
184
|
+
thisDialog.addEventListener('close', () => {
|
|
183
185
|
|
|
184
186
|
document.body.classList.remove('overflow-hidden');
|
|
185
187
|
|
|
186
188
|
if(closeCallback) {
|
|
187
|
-
closeCallback(
|
|
189
|
+
closeCallback(thisDialog);
|
|
188
190
|
}
|
|
189
|
-
|
|
191
|
+
thisDialog.remove();
|
|
190
192
|
|
|
191
193
|
}, false);
|
|
192
194
|
|
|
193
195
|
|
|
194
196
|
document.body.classList.add('overflow-hidden');
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
thisDialog.showModal();
|
|
198
|
+
thisDialog.focus();
|
|
197
199
|
|
|
198
|
-
|
|
200
|
+
thisDialog.classList.add(styles.on);
|
|
199
201
|
|
|
200
202
|
|
|
201
|
-
return
|
|
203
|
+
return thisDialog;
|
|
202
204
|
|
|
203
205
|
}
|