diff --git a/2021/04/bsdialog4-v0.1.0.002.js b/2021/04/bsdialog4-v0.1.0.002.js new file mode 100644 index 0000000..4659887 --- /dev/null +++ b/2021/04/bsdialog4-v0.1.0.002.js @@ -0,0 +1,191 @@ +/** + * BSDialog4 + * @version v0.1.0.002 (2021/04/25 1713) + */ +var BSDialog = { + Create: function (id, title, url, size) { + var a = this; + + a.id = id; + a.title = title; + a.url = url; + + if (typeof (size) == "undefined") { + a.size = "md"; + } else if (size === true) { + a.size = "lg"; + } else if (size === false) { + a.size = "md"; + } else { + a.size = size; + } + + if (!a.Exists(id)) { + a.renderContent(null); + } + + if (url != null) { + $.ajax({ + url: url, + cache: false, + xhrFields: { + withCredentials:true + }, + timeout: 30000, + success: function (result, status, xhr) { + if ((xhr.status == 200) || (xhr.status == 302) || (xhr.status == 301)) { + a.updateContentBody(id, result); + } else { + a.updateContentBody(id, xhr.statusText + " (" + xhr.status + ")"); + } + }, + error: function (xhr) { + a.updateContentBody(id, xhr.statusText + " (" + xhr.status + ")"); + }, + complete: function (xhr, status) { + // do nothing yet + } + }); + } + + a.initialiseComponents(); + }, + Close: function (id) { + $("#dlg" + id).modal('hide'); + }, + Clear: function () { + $("body > div[class~='modal'][role='dialog']").remove(); + $("body > div[class~='modal-backdrop']").remove(); + $("body").removeClass("modal-open"); + }, + ShowToast: function (id, title, message, size) { + var a = this; + + if (a.Exists(id)) { + return; + } + + a.id = id; + a.title = title; + a.url = null; + a.size = ((typeof (size) == "undefined") ? "md" : size); + + a.renderContent(message); + a.initialiseComponents(); + }, + Exists: function (id) { + return ($("body > div[id='dlg" + id + "']").length > 0); + }, + generateModalHtml: function (message) { + var a = this; + + var html = ""; + html += "