동기식 대화상자 다이얼로그 추가

main
이범준 8 months ago
parent 552f7a1e80
commit 5a487640ce

@ -1,3 +1,58 @@
/**************************************************************************
* 동기식 대화상자
**************************************************************************/
async function confirm2(msg){
return await dialog2(msg, "confirm");
}
async function alert2(msg){
return await dialog2(msg, "alert");
}
async function dialog2(msg, type){
var dlgId = "dlg-" + uuid();
var resp = await fetch(wctx.url("/resources/html/dialog.html"));
var template = await resp.text();
var container = "<div class='container-fluid text-center' style='font-size:1.4em;'>{content}</div>";
content = container.replace(/{content}/g, msg);
var backdropID = dlgId + "-backdrop";
var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("","");
tmpl = tmpl.replace("data-bs-backdrop=\"static\"", "data-bs-backdrop=\"static\" data-bs-keyboard=\"false\"");
tmpl = tmpl.replace("text-end hidden","text-end");
tmpl = tmpl.replace("btn-primary","btn-primary btn-ok");
var dlg = $(tmpl).appendTo("body");
if(type == "confirm"){
dlg.find(".modal-footer").append('<button type="button" class="btn btn-primary btn-cancel">취소</button>');
}
dlg.find(".modal-header").remove();
dlg.find(".modal-body").html(content).fadeIn();
dlg.on("hidden.bs.modal", function() {
$("#" + dlgId +",#" + backdropID).remove();
});
dlg.modal("show");
$(".modal-backdrop").each(function() {
var backdrop = $(this);
if (!backdrop.prop("id")){
backdrop.prop("id", backdropID);
}
});
setDialogZindex();
return new Promise(resolve => {
dlg[0].querySelector(".btn-ok").addEventListener("click", () => {
dlg.modal("hide");
resolve(true);
});
if(type == "confirm"){
dlg[0].querySelector(".btn-cancel").addEventListener("click", () => {
dlg.modal("hide");
resolve(false);
});
}
});
}
/**************************************************************************
* 모달창 z-index 초기화
**************************************************************************/
@ -40,18 +95,6 @@ function focusOK() {
});
}
/**************************************************************************
* 파일 다운로드
**************************************************************************/
function downloadFile(filePath, fileName, tempAreaId){
var a = document.createElement("a");
a.href = resp.filePath;
a.download = resp.fileName;
document.getElementById(tempAreaId).appendChild(a);
a.click();
document.getElementById(tempAreaId).removeChild(a);
}
/**************************************************************************
* pdf파일 미리보기
**************************************************************************/

@ -35,10 +35,10 @@ function settingPhotoMain(pageName, crdnIdElementId, carInfoFunc, carLinkFunc){
});
//편집버튼
$("#btnEditPhoto--"+pageName).on('click', () => {
$("#btnEditPhoto--"+pageName).on('click', async() => {
var checked = $("#displayForExist--"+pageName).find("[name='existPhoto']:checked");
if(checked.length < 1){
alert("선택된 사진이 없습니다.");
await alert2("선택된 사진이 없습니다.");
return;
}
@ -50,11 +50,11 @@ function settingPhotoMain(pageName, crdnIdElementId, carInfoFunc, carLinkFunc){
);
});
//삭제버튼
$("#btnDeleteExistPhoto--"+pageName).on('click', () => {
$("#btnDeleteExistPhoto--"+pageName).on('click', async() => {
var checked = $("#displayForExist--"+pageName).find("[name='existPhoto']:checked");
if(checked.length < 1){
alert("선택된 사진이 없습니다.");
await alert2("선택된 사진이 없습니다.");
return;
}

Loading…
Cancel
Save