/** * BSToast5 * @version v0.1.0.001 (2023/08/16 0022) */ var BSToast5 = { Create: async function (options) { var a = this; a.Options = Object.assign(a.DefaultOptions, options); a.pfx = "bstoa5_"; a.id = Math.floor(Math.random() * 100000) + 10000; a.body = document.getElementsByTagName("body")[0]; a.addBackdrop(); a.addToast(a.Options); }, DefaultOptions: { Icon: null, Title: "", Time: "", Message: "", Animation: true, AutoHide: true, Delay: 2500, Position: "top-0 end-0 p-3" }, Clear: function () { this.body.querySelectorAll(".toast").forEach(function(e) { e.parentNode.removeChild(e); }); this.removeBackdrop(); }, Close: function (id) { var a = this; // Close this toast a.body.querySelectorAll("#" + a.pfx + id + ".toast").forEach(function(e) { if (typeof(e.parentNode) == "undefined") { return; } e.parentNode.removeChild(e); }); // Clean-up all closed toasts a.body.querySelectorAll(".toast.hide").forEach(function(e) { if (typeof(e.parentNode) == "undefined") { return; } e.parentNode.removeChild(e); }); if (a.body.querySelectorAll(".toast").length <= 0) { let backdrop = a.body.querySelectorAll(".toast-backdrop")[0]; if (typeof(backdrop) == "undefined") { return; } if (typeof(backdrop.parentNode) == "undefined") { return; } backdrop.parentNode.removeChild(backdrop); } }, addBackdrop: async function () { let a = this; // don't allow duplicates if (a.body.querySelectorAll(".toast-backdrop").length > 0) { return; } a.appendHtml(a.body, '