|
|
@ -9,12 +9,21 @@ async function alert2(msg){
|
|
|
|
return await dialog2(msg, "alert");
|
|
|
|
return await dialog2(msg, "alert");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function prompt2(msg){
|
|
|
|
|
|
|
|
return await dialog2(msg, "prompt");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function dialog2(msg, type, buttons){
|
|
|
|
async function dialog2(msg, type, buttons){
|
|
|
|
var dlgId = "dlg-" + uuid();
|
|
|
|
var dlgId = "dlg-" + uuid();
|
|
|
|
var resp = await fetch(wctx.url("/resources/html/dialog.html"));
|
|
|
|
var resp = await fetch(wctx.url("/resources/html/dialog.html"));
|
|
|
|
var template = await resp.text();
|
|
|
|
var template = await resp.text();
|
|
|
|
var container = "<div class='container-fluid text-center' style='font-size:1.4em;'>{content}</div>";
|
|
|
|
var container = "<div class='container-fluid text-center' style='font-size:1.4em;'>{content}</div>";
|
|
|
|
|
|
|
|
if(type == "prompt"){
|
|
|
|
|
|
|
|
var rsn = '<br/><input type="text" id="rsn" class="form-control w-100" />';
|
|
|
|
|
|
|
|
content = container.replace(/{content}/g, msg + rsn);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
content = container.replace(/{content}/g, msg);
|
|
|
|
content = container.replace(/{content}/g, msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
var backdropID = dlgId + "-backdrop";
|
|
|
|
var backdropID = dlgId + "-backdrop";
|
|
|
|
var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("","");
|
|
|
|
var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("","");
|
|
|
|
tmpl = tmpl.replace("modal-dialog", "modal-dialog-centered modal-dialog");
|
|
|
|
tmpl = tmpl.replace("modal-dialog", "modal-dialog-centered modal-dialog");
|
|
|
@ -22,8 +31,8 @@ async function dialog2(msg, type, buttons){
|
|
|
|
tmpl = tmpl.replace("text-end hidden","text-end");
|
|
|
|
tmpl = tmpl.replace("text-end hidden","text-end");
|
|
|
|
tmpl = tmpl.replace("btn-primary","btn-primary btn-ok");
|
|
|
|
tmpl = tmpl.replace("btn-primary","btn-primary btn-ok");
|
|
|
|
var dlg = $(tmpl).appendTo("body");
|
|
|
|
var dlg = $(tmpl).appendTo("body");
|
|
|
|
if(type == "confirm" || type == "alert"){
|
|
|
|
if(type == "confirm" || type == "alert" || type == "prompt"){
|
|
|
|
if(type == "confirm"){
|
|
|
|
if(type == "confirm" || type == "prompt"){
|
|
|
|
dlg.find(".modal-footer").append('<button type="button" class="btn btn-primary btn-cancel">취소</button>');
|
|
|
|
dlg.find(".modal-footer").append('<button type="button" class="btn btn-primary btn-cancel">취소</button>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -54,17 +63,31 @@ async function dialog2(msg, type, buttons){
|
|
|
|
setDialogZindex();
|
|
|
|
setDialogZindex();
|
|
|
|
|
|
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
return new Promise(resolve => {
|
|
|
|
if(type == "confirm" || type == "alert"){
|
|
|
|
if(type == "confirm" || type == "alert" || type == "prompt"){
|
|
|
|
|
|
|
|
if(type == "prompt"){
|
|
|
|
|
|
|
|
dlg[0].querySelector(".btn-ok").addEventListener("click", () => {
|
|
|
|
|
|
|
|
dlg.modal("hide");
|
|
|
|
|
|
|
|
resolve($("#rsn").val());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dlg[0].querySelector(".btn-ok").addEventListener("click", () => {
|
|
|
|
dlg[0].querySelector(".btn-ok").addEventListener("click", () => {
|
|
|
|
dlg.modal("hide");
|
|
|
|
dlg.modal("hide");
|
|
|
|
resolve(true);
|
|
|
|
resolve(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(type == "confirm"){
|
|
|
|
if(type == "confirm"){
|
|
|
|
dlg[0].querySelector(".btn-cancel").addEventListener("click", () => {
|
|
|
|
dlg[0].querySelector(".btn-cancel").addEventListener("click", () => {
|
|
|
|
dlg.modal("hide");
|
|
|
|
dlg.modal("hide");
|
|
|
|
resolve(false);
|
|
|
|
resolve(false);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(type == "prompt"){
|
|
|
|
|
|
|
|
dlg[0].querySelector(".btn-cancel").addEventListener("click", () => {
|
|
|
|
|
|
|
|
dlg.modal("hide");
|
|
|
|
|
|
|
|
resolve(null);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
dlg.find(".btn-custom").each(function(){
|
|
|
|
dlg.find(".btn-custom").each(function(){
|
|
|
|
this.addEventListener("click", () => {
|
|
|
|
this.addEventListener("click", () => {
|
|
|
|