release/0.1.2.046 #4

Merged
Ray merged 5 commits from release/0.1.2.046 into master 2023-08-21 18:15:43 +00:00
3 changed files with 65 additions and 23 deletions
Showing only changes of commit 36d99fdbc1 - Show all commits

View File

@ -88,7 +88,7 @@
<p><b>Example Five</b></p> <p><b>Example Five</b></p>
<p>Launch a prompt modal</p> <p>Launch a prompt modal</p>
<div class="alert alert-secondary"> <div class="alert alert-secondary">
let result = await BSDialog.ShowPrompt({<br /> let result = await BSDialog.Prompt({<br />
&nbsp;&nbsp;&nbsp;&nbsp;Title: "Prompt",<br /> &nbsp;&nbsp;&nbsp;&nbsp;Title: "Prompt",<br />
&nbsp;&nbsp;&nbsp;&nbsp;Message: "This is a prompt",<br /> &nbsp;&nbsp;&nbsp;&nbsp;Message: "This is a prompt",<br />
&nbsp;&nbsp;&nbsp;&nbsp;Size: "md",<br /> &nbsp;&nbsp;&nbsp;&nbsp;Size: "md",<br />
@ -138,7 +138,7 @@ $(document).ready(function(){
}); });
$("#button5").on('click', async function(){ $("#button5").on('click', async function(){
let result = await BSDialog.ShowPrompt({ let result = await BSDialog.Prompt({
Title: "Prompt", Title: "Prompt",
Message: "This is a prompt", Message: "This is a prompt",
Size: "md", Size: "md",

View File

@ -4,22 +4,14 @@
*/ */
var BSDialog = { var BSDialog = {
Create: async function (id, title, url, size) { Create: async function (id, title, url, size) {
var a = this; await this.Show({
ID: id,
a.id = id; Title: title,
a.pfx = "bsdia4_"; Message: url,
a.body = document.getElementsByTagName("body")[0]; URL: url,
Size: size,
a.addBackdrop(); Colour: "secondary"
a.addModal(id, title, size); });
if (a.isNullOrWhitespace(url)) {
a.UpdateBody(id, "");
} else if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("/")) {
a.UpdateBodyRemote(id, url);
} else {
await a.UpdateBody(id, url);
}
}, },
Clear: function () { Clear: function () {
this.body.querySelectorAll(".modal").forEach(function(e) { this.body.querySelectorAll(".modal").forEach(function(e) {
@ -132,19 +124,54 @@ var BSDialog = {
Modal: modal Modal: modal
}; };
}, },
ShowToast: function (id, title, message, size) { Show: async function (options) {
const a = this; const a = this;
const _options = Object.assign(a.DefaultShowOptions, options);
a.Create(id, title, null, size); a.id = _options.ID;
a.UpdateBody(id, message); a.pfx = "bsdia4_";
a.body = document.getElementsByTagName("body")[0];
const modal = a.Find(id); a.addBackdrop();
a.addModal(_options.ID, _options.Title, _options.Size);
if (_options.URL == null) {
await a.UpdateBody(_options.ID, _options.Message);
} else {
if (a.isNullOrWhitespace(_options.URL)) {
await a.UpdateBody(_options.ID, _options.URL);
} else {
if (_options.URL.startsWith("http://") || _options.URL.startsWith("https://") || _options.URL.startsWith("/")) {
await a.UpdateBodyRemote(_options.ID, _options.URL);
} else {
await a.UpdateBody(_options.ID, _options.URL);
}
}
}
},
Toast: function (options) {
const a = this;
const _options = Object.assign(a.DefaultToastOptions, options);
a.Create(_options.ID, _options.Title, null, _options.Size);
a.UpdateBody(_options.ID, _options.Message);
const modal = a.Find(_options.ID);
modal.Footer.forEach(function(e) { modal.Footer.forEach(function(e) {
e.parentNode.removeChild(e); e.parentNode.removeChild(e);
}); });
}, },
ShowPrompt: async function (options) { ShowToast: function (id, title, message, size) {
this.Toast({
ID: id,
Title: title,
Message: message,
Size: size
});
},
Prompt: async function (options) {
const a = this; const a = this;
let id = "prompt" + Math.floor(Math.random() * 10000) + 1000; let id = "prompt" + Math.floor(Math.random() * 10000) + 1000;
@ -189,6 +216,20 @@ var BSDialog = {
}); });
}, },
DefaultShowOptions: {
ID: null,
Title: "",
Message: "",
URL: null,
Size: "md",
Colour: "secondary"
},
DefaultToastOptions: {
ID: null,
Title: "",
Message: "",
Size: "md"
},
DefaultPromptOptions: { DefaultPromptOptions: {
Title: "", Title: "",
Message: "", Message: "",

1
bsdialog4.min.js vendored

File diff suppressed because one or more lines are too long