- added method to force disable reload

This commit is contained in:
Sören Oesterwind 2023-07-07 14:02:54 +02:00
parent f4d6ed4d8f
commit 90924aa30d

View File

@ -1,5 +1,5 @@
currentToasts = []; currentToasts = [];
var forceSkipReload = false;
/** /**
* Generic function to create a new toast * Generic function to create a new toast
* @param {String} message The message to be displayed * @param {String} message The message to be displayed
@ -8,7 +8,7 @@ currentToasts = [];
* @param {Boolean} autoReload Should the page reload after the toast is hidden, default is true (for compatibility with old code) * @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> * @returns {String} The id of the created toast, format: toast-<number>
*/ */
function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload = true) { function createNewToast(message, colorSelector, autoHideTime = 1500, autoReload = true) {
const targetContainer = document.getElementById('toastMainController'); const targetContainer = document.getElementById('toastMainController');
const masterToast = document.getElementById('masterToast'); const masterToast = document.getElementById('masterToast');
const newToast = masterToast.cloneNode(true); const newToast = masterToast.cloneNode(true);
@ -21,7 +21,7 @@ function createNewToast(message, colorSelector, autoHideTime = 3000, autoReload
$(newToast).toast('show'); $(newToast).toast('show');
setTimeout(() => { setTimeout(() => {
destroyToast(newToast.id); destroyToast(newToast.id);
if (autoReload) { if (autoReload && !forceSkipReload) {
location.reload(); location.reload();
} }
}, autoHideTime); }, autoHideTime);