-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoasts.js
More file actions
23 lines (22 loc) · 851 Bytes
/
Copy pathtoasts.js
File metadata and controls
23 lines (22 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function getToastHtml(title, content) {
return `
<div class="toast position-absolute top-0 start-50 translate-middle-x border-over mt-2 z-7">
<div class="toast-header">
<img src="img/warning.ico" class="size-16">
<strong class="ms-2 me-auto">${title}</strong>
<button class="btn-close" data-bs-dismiss="toast"></button>
</div>
<div class="toast-body">
${content}
</div>
</div>
`;
}
function showToast(title, content) {
const html = getToastHtml(title, content);
let element = parseElement(html);
document.body.firstElementChild.append(element);
const toast = new bootstrap.Toast(element, {"delay": 3000});
element.addEventListener('hidden.bs.toast', () => element.remove());
toast.show();
}