-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathui-toasts.js
39 lines (35 loc) · 1.27 KB
/
ui-toasts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* UI Toasts
*/
'use strict';
(function () {
// Bootstrap toasts example
// --------------------------------------------------------------------
const toastPlacementExample = document.querySelector('.toast-placement-ex'),
toastPlacementBtn = document.querySelector('#showToastPlacement');
let selectedType, selectedPlacement, toastPlacement;
// Dispose toast when open another
function toastDispose(toast) {
if (toast && toast._element !== null) {
if (toastPlacementExample) {
toastPlacementExample.classList.remove(selectedType);
DOMTokenList.prototype.remove.apply(toastPlacementExample.classList, selectedPlacement);
}
toast.dispose();
}
}
// Placement Button click
if (toastPlacementBtn) {
toastPlacementBtn.onclick = function () {
if (toastPlacement) {
toastDispose(toastPlacement);
}
selectedType = document.querySelector('#selectTypeOpt').value;
selectedPlacement = document.querySelector('#selectPlacement').value.split(' ');
toastPlacementExample.classList.add(selectedType);
DOMTokenList.prototype.add.apply(toastPlacementExample.classList, selectedPlacement);
toastPlacement = new bootstrap.Toast(toastPlacementExample);
toastPlacement.show();
};
}
})();