diff --git a/htdocs/js/SetMaker/setmaker.js b/htdocs/js/SetMaker/setmaker.js index 566774c053..8987d2e958 100644 --- a/htdocs/js/SetMaker/setmaker.js +++ b/htdocs/js/SetMaker/setmaker.js @@ -19,16 +19,37 @@ 'p-3' ); toastContainer.style.zIndex = 20; - toastContainer.innerHTML = - ''; + + const toast = document.createElement('div'); + toast.classList.add('toast', 'bg-white'); + toast.setAttribute('role', 'alert'); + toast.setAttribute('aria-live', 'assertive'); + toast.setAttribute('aria-atomic', 'true'); + toastContainer.append(toast); + + const toastHeader = document.createElement('div'); + toastHeader.classList.add('toast-header'); + toast.append(toastHeader); + + const toastTitle = document.createElement('strong'); + toastTitle.classList.add('me-auto'); + toastTitle.textContent = title; + + const closeButton = document.createElement('button'); + closeButton.classList.add('btn-close'); + closeButton.type = 'button'; + closeButton.dataset.bsDismiss = 'toast'; + closeButton.setAttribute('aria-label', 'close'); + + toastHeader.append(toastTitle, closeButton); + + const toastBody = document.createElement('div'); + toastBody.classList.add('toast-body', 'alert', good ? 'alert-success' : 'alert-danger', 'mb-0', 'text-center'); + toastBody.textContent = msg; + toast.append(toastBody); + document.body.prepend(toastContainer); - const bsToast = new bootstrap.Toast(toastContainer.firstElementChild); + const bsToast = new bootstrap.Toast(toast); toastContainer.addEventListener('hidden.bs.toast', () => { bsToast.dispose(); toastContainer.remove();