Skip to content

Commit 1c9faa2

Browse files
committed
Compile files for release
1 parent 792cca2 commit 1c9faa2

18 files changed

+140
-66
lines changed

dist/js/joomla-alert-es5.js

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ function _getPrototypeOf(o) {
187187
this.appendCloseButton();
188188
}
189189

190+
if (this.hasAttribute('auto-dismiss')) {
191+
this.autoDismiss();
192+
}
193+
190194
this.dispatchCustomEvent('joomla.alert.show');
191195
}
192196
/* Lifecycle, element removed from the DOM */
@@ -232,6 +236,10 @@ function _getPrototypeOf(o) {
232236

233237
break;
234238

239+
case 'auto-dismiss':
240+
this.autoDismiss();
241+
break;
242+
235243
case 'href':
236244
if (!newValue || newValue === '') {
237245
this.removeCloseButton();
@@ -252,11 +260,16 @@ function _getPrototypeOf(o) {
252260
value: function close() {
253261
var _this = this;
254262

263+
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
255264
this.dispatchCustomEvent('joomla.alert.close');
256265
this.addEventListener('transitionend', function () {
257266
_this.dispatchCustomEvent('joomla.alert.closed');
258267

259-
_this.parentNode.removeChild(_this);
268+
if (element) {
269+
element.remove();
270+
} else {
271+
_this.remove();
272+
}
260273
}, false);
261274
this.classList.remove('joomla-alert--show');
262275
}
@@ -324,18 +337,22 @@ function _getPrototypeOf(o) {
324337
});
325338
}
326339
}
340+
}
341+
/* Method to auto-dismiss */
327342

328-
if (this.hasAttribute('auto-dismiss')) {
329-
setTimeout(function () {
330-
self.dispatchCustomEvent('joomla.alert.buttonClicked');
343+
}, {
344+
key: "autoDismiss",
345+
value: function autoDismiss() {
346+
var self = this;
347+
setTimeout(function () {
348+
self.dispatchCustomEvent('joomla.alert.buttonClicked');
331349

332-
if (self.hasAttribute('data-callback')) {
333-
window[self.getAttribute('data-callback')]();
334-
} else {
335-
self.close();
336-
}
337-
}, parseInt(self.getAttribute('auto-dismiss'), 10) ? self.getAttribute('auto-dismiss') : 3000);
338-
}
350+
if (self.hasAttribute('data-callback')) {
351+
window[self.getAttribute('data-callback')]();
352+
} else {
353+
self.close(self);
354+
}
355+
}, parseInt(self.getAttribute('auto-dismiss'), 10) ? self.getAttribute('auto-dismiss') : 3000);
339356
}
340357
/* Method to remove the close button */
341358

@@ -346,7 +363,7 @@ function _getPrototypeOf(o) {
346363

347364
if (button) {
348365
button.removeEventListener('click', this);
349-
button.parentNode.removeChild(button);
366+
button.remove();
350367
}
351368
}
352369
/* Method to get the translated text */
@@ -380,6 +397,11 @@ function _getPrototypeOf(o) {
380397
get: function get() {
381398
return this.getAttribute('dismiss');
382399
}
400+
}, {
401+
key: "autodismiss",
402+
get: function get() {
403+
return this.getAttribute('auto-dismiss');
404+
}
383405
}, {
384406
key: "acknowledge",
385407
get: function get() {

dist/js/joomla-alert-es5.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/joomla-alert.js

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
get dismiss() { return this.getAttribute('dismiss'); }
1515

16+
get autodismiss() { return this.getAttribute('auto-dismiss'); }
17+
1618
get acknowledge() { return this.getAttribute('acknowledge'); }
1719

1820
get href() { return this.getAttribute('href'); }
@@ -35,6 +37,10 @@
3537
this.appendCloseButton();
3638
}
3739

40+
if (this.hasAttribute('auto-dismiss')) {
41+
this.autoDismiss();
42+
}
43+
3844
this.dispatchCustomEvent('joomla.alert.show');
3945
}
4046

@@ -70,6 +76,9 @@
7076
this.removeCloseButton();
7177
}
7278
break;
79+
case 'auto-dismiss':
80+
this.autoDismiss();
81+
break;
7382
case 'href':
7483
if (!newValue || newValue === '') {
7584
this.removeCloseButton();
@@ -83,11 +92,15 @@
8392
}
8493

8594
/* Method to close the alert */
86-
close() {
95+
close(element = null) {
8796
this.dispatchCustomEvent('joomla.alert.close');
8897
this.addEventListener('transitionend', () => {
8998
this.dispatchCustomEvent('joomla.alert.closed');
90-
this.parentNode.removeChild(this);
99+
if (element) {
100+
element.remove();
101+
} else {
102+
this.remove();
103+
}
91104
}, false);
92105
this.classList.remove('joomla-alert--show');
93106
}
@@ -148,25 +161,27 @@
148161
});
149162
}
150163
}
164+
}
151165

152-
if (this.hasAttribute('auto-dismiss')) {
153-
setTimeout(() => {
154-
self.dispatchCustomEvent('joomla.alert.buttonClicked');
155-
if (self.hasAttribute('data-callback')) {
156-
window[self.getAttribute('data-callback')]();
157-
} else {
158-
self.close();
159-
}
160-
}, parseInt(self.getAttribute('auto-dismiss'), 10) ? self.getAttribute('auto-dismiss') : 3000);
161-
}
166+
/* Method to auto-dismiss */
167+
autoDismiss() {
168+
const self = this;
169+
setTimeout(() => {
170+
self.dispatchCustomEvent('joomla.alert.buttonClicked');
171+
if (self.hasAttribute('data-callback')) {
172+
window[self.getAttribute('data-callback')]();
173+
} else {
174+
self.close(self);
175+
}
176+
}, parseInt(self.getAttribute('auto-dismiss'), 10) ? self.getAttribute('auto-dismiss') : 3000);
162177
}
163178

164179
/* Method to remove the close button */
165180
removeCloseButton() {
166181
const button = this.querySelector('button');
167182
if (button) {
168183
button.removeEventListener('click', this);
169-
button.parentNode.removeChild(button);
184+
button.remove();
170185
}
171186
}
172187

0 commit comments

Comments
 (0)