Refactor resizing

This commit is contained in:
Ray 2023-08-30 01:02:45 +01:00
parent 46cda4fbf1
commit 0d3df02449

View File

@ -35,7 +35,6 @@ var BSDialog = {
const _options = Object.assign(a.Default().PromptOptions, options); const _options = Object.assign(a.Default().PromptOptions, options);
return await new Promise((resolve, reject) => { return await new Promise((resolve, reject) => {
a.Create(id, _options.Title, _options.Message, _options.Size); a.Create(id, _options.Title, _options.Message, _options.Size);
let html = ''; let html = '';
@ -138,10 +137,17 @@ var BSDialog = {
if (!this.isNullOrWhitespace(_options.Size)) { if (!this.isNullOrWhitespace(_options.Size)) {
modal.Modal[0].querySelectorAll(".modal-dialog").forEach(function(e) { modal.Modal[0].querySelectorAll(".modal-dialog").forEach(function(e) {
e.classList.remove("modal-sm");
e.classList.remove("modal-md"); e.classList.forEach(function(e2) {
e.classList.remove("modal-lg"); if (e2 == "modal-dialog") {
e.classList.remove("modal-xl"); return;
}
if (e2.startsWith("modal-")) {
e.classList.remove(e2);
}
});
e.classList.add("modal-" + _options.Size); e.classList.add("modal-" + _options.Size);
}); });
} }
@ -367,30 +373,19 @@ var BSDialog = {
let modalDialog = modal.Modal[0].querySelectorAll(".modal-dialog")[0]; let modalDialog = modal.Modal[0].querySelectorAll(".modal-dialog")[0];
if (modalDialog.classList.contains('modal-sm')) { if (modalDialog.classList.contains('modal-sm')) {
modalDialog.classList.remove("modal-sm"); a.Update({ ID: a.id, Size: "md" });
modalDialog.classList.add("modal-md");
} else if (modalDialog.classList.contains('modal-md')) { } else if (modalDialog.classList.contains('modal-md')) {
modalDialog.classList.remove("modal-md"); a.Update({ ID: a.id, Size: "lg" });
modalDialog.classList.add("modal-lg");
} else if (modalDialog.classList.contains('modal-lg')) { } else if (modalDialog.classList.contains('modal-lg')) {
modalDialog.classList.remove("modal-lg"); a.Update({ ID: a.id, Size: "xl" });
modalDialog.classList.add("modal-xl");
} else if (modalDialog.classList.contains('modal-xl')) { } else if (modalDialog.classList.contains('modal-xl')) {
modalDialog.classList.remove("modal-xl"); a.Update({ ID: a.id, Size: "sm" });
modalDialog.classList.add("modal-sm");
} else { } else {
modalDialog.classList.remove("modal-sm"); a.Update({ ID: a.id, Size: "md" });
modalDialog.classList.remove("modal-md");
modalDialog.classList.remove("modal-lg");
modalDialog.classList.remove("modal-xl");
modalDialog.classList.add("modal-md");
} }
}, },
// //
// deprecated/legacy -support // deprecated/legacy-support
// DefaultShowOptions: this.Default().ShowOptions,
// DefaultToastOptions: this.Default().ToastOptions,
// DefaultPromptOptions: this.Default().PromptOptions,
Create: async function (id, title, url, size) { Create: async function (id, title, url, size) {
await this.Show({ await this.Show({
ID: id, ID: id,