Fixed formatting in toastHandler
This commit is contained in:
parent
a8b0374d5e
commit
37649ec98e
@ -8,11 +8,11 @@ currentToasts = [];
|
||||
* @param {Boolean} autoReload Should the page reload after the toast is hidden, default is true (for compatibility with old code)
|
||||
* @returns {String} The id of the created toast, format: toast-<number>
|
||||
*/
|
||||
function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload = true){
|
||||
function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload = true) {
|
||||
const targetContainer = document.getElementById('toastMainController');
|
||||
const masterToast = document.getElementById('masterToast');
|
||||
const newToast = masterToast.cloneNode(true);
|
||||
newToast.classList.add(colorSelector)
|
||||
newToast.classList.add(colorSelector);
|
||||
newToast.id = `toast-${currentToasts.length}`;
|
||||
console.log(newToast.childNodes[1]);
|
||||
newToast.childNodes[1].childNodes[1].innerHTML = message;
|
||||
@ -21,7 +21,7 @@ function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload
|
||||
$(newToast).toast('show');
|
||||
setTimeout(() => {
|
||||
destroyToast(newToast.id);
|
||||
if(autoReload){
|
||||
if (autoReload) {
|
||||
location.reload();
|
||||
}
|
||||
}, autoHideTime);
|
||||
@ -32,7 +32,7 @@ function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload
|
||||
* Generic function to destroy a toast
|
||||
* @param {String} id The id of the toast to destroy
|
||||
*/
|
||||
function destroyToast(id){
|
||||
function destroyToast(id) {
|
||||
const targetContainer = document.getElementById('toastMainController');
|
||||
const targetToast = document.getElementById(id);
|
||||
targetContainer.removeChild(targetToast);
|
||||
@ -40,8 +40,8 @@ function destroyToast(id){
|
||||
}
|
||||
|
||||
// Moved here
|
||||
function normalizeToast(){
|
||||
console.warn("Something is using the deprecated function normalizeToast(). Please use createNewToast() instead.")
|
||||
function normalizeToast() {
|
||||
console.warn('Something is using the deprecated function normalizeToast(). Please use createNewToast() instead.');
|
||||
$('#generalToast').removeClass('text-bg-primary');
|
||||
$('#generalToast').removeClass('text-bg-success');
|
||||
$('#generalToast').removeClass('text-bg-danger');
|
||||
|
Loading…
Reference in New Issue
Block a user