Compare commits

...

2 Commits

Author SHA1 Message Date
Ray
57b8a3ce0b Merge pull request 'Added Pop() to close top-most modal' (#10) from release/0.1.6.015 into master
Reviewed-on: #10
2024-01-20 23:23:57 +00:00
Ray
ecd6dd156d Added Pop() to close top-most modal
Fixed stacking modal causes scrolling and focus failure
2023-12-08 22:19:39 +00:00
2 changed files with 26 additions and 28 deletions

View File

@ -1,6 +1,6 @@
/** /**
* BSDialog4 * BSDialog4
* @version v0.1.5.038 (2023/11/18 19:40) * @version v0.1.6.015 (2023/12/08 22:04)
*/ */
class BSDialog4 { class BSDialog4 {
constructor() { constructor() {
@ -102,15 +102,15 @@ class BSDialog4 {
} }
} }
Clear() { async Clear() {
const a = this; const a = this;
document.querySelectorAll('.modal').forEach(function(e) { document.querySelectorAll('.modal').forEach(async function(e) {
$(e).modal('hide'); await a.Close(e.getAttribute("id"));
}); });
} }
Close(id) { async Close(id) {
const a = this; const a = this;
if (id.toString().startsWith(a.#prefix)) { if (id.toString().startsWith(a.#prefix)) {
@ -120,10 +120,28 @@ class BSDialog4 {
const node = document.getElementById(a.#prefix + id); const node = document.getElementById(a.#prefix + id);
if (node) { if (node) {
$(node).modal('hide'); await $(node).modal('hide');
node.parentNode.removeChild(node); node.parentNode.removeChild(node);
} }
if (document.querySelectorAll('.modal').length > 0) {
if (!a.#body.classList.contains("modal-open")) {
a.#body.classList.add("modal-open");
a.#body.style.paddingRight = "17px";
}
}
}
async Pop() {
const a = this;
if (document.querySelectorAll('.modal').length > 0) {
const id = document.querySelectorAll('.modal')[0].getAttribute("id");
await a.Close(id);
}
} }
async Update(options) { async Update(options) {
@ -419,26 +437,6 @@ class BSDialog4 {
return (e.trim().length <= 0); return (e.trim().length <= 0);
} }
#removeBackdrop() {
const a = this;
if (a.#body.querySelectorAll(".modal-backdrop").length <= 0) {
return;
}
if (a.#body.querySelectorAll(".modal").length > 0) {
return;
}
a.#body.querySelectorAll(".modal-backdrop").forEach(function(e){
e.parentNode.removeChild(e);
});
// unlock background
a.#body.classList.remove("modal-open");
a.#body.style.overflow = null;
}
async #retrieveURL(url) { async #retrieveURL(url) {
return await new Promise(async (resolve) => { return await new Promise(async (resolve) => {
await fetch(url, { await fetch(url, {

4
bsdialog4.min.js vendored

File diff suppressed because one or more lines are too long