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