JS tweaks for showing messages (#60)
This commit is contained in:
@@ -413,6 +413,7 @@ this.Admin = {
|
||||
toast.setAttribute("role", "alert")
|
||||
toast.setAttribute("aria-live", "assertive")
|
||||
toast.setAttribute("aria-atomic", "true")
|
||||
toast.setAttribute("data-mwl-shown", "true")
|
||||
toast.appendChild(toastHead)
|
||||
toast.appendChild(toastBody)
|
||||
|
||||
@@ -430,14 +431,13 @@ this.Admin = {
|
||||
* Initialize any toasts that were pre-rendered from the server
|
||||
*/
|
||||
showPreRenderedMessages() {
|
||||
[...document.querySelectorAll(".toast")].forEach(el => {
|
||||
if (el.getAttribute("data-mwl-shown") !== "true") {
|
||||
[...document.querySelectorAll(".toast")]
|
||||
.filter(el => !el.hasAttribute("data-mwl-shown"))
|
||||
.forEach(el => {
|
||||
const toast = new bootstrap.Toast(el,
|
||||
el.getAttribute("data-bs-autohide") === "false"
|
||||
? { autohide: false } : { delay: 6000, autohide: true })
|
||||
el.getAttribute("data-bs-autohide") === "false" ? { autohide: false } : { delay: 6000, autohide: true })
|
||||
toast.show()
|
||||
el.setAttribute("data-mwl-shown", "true")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user