From 535f2305003e28a44437fc8a2b71b46150e00b2c Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Wed, 4 Jun 2025 16:32:16 +0900 Subject: [PATCH] =?UTF-8?q?dialog=20=ED=8F=AC=EC=BB=A4=EC=8A=A4=20?= =?UTF-8?q?=EC=A0=9C=EC=96=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/resources/js/base/base.js | 30 ++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/resources/js/base/base.js b/src/main/webapp/resources/js/base/base.js index b2a1eef..4052364 100644 --- a/src/main/webapp/resources/js/base/base.js +++ b/src/main/webapp/resources/js/base/base.js @@ -115,12 +115,21 @@ var dialog = { }); } }, + getLast: function() { + let modals = $("div.modal.show"); + return modals.last()[0]; + }, + refocus: function() { + let last = dialog.getLast(); + if (last) + last.focus(); + }, close:function(id) { $("#close" + id).click(); }, create:function(conf) { let last = { - dlg: $("div.modal.show").last()[0], + dlg: dialog.getLast(), setZIndex: (obj, offset) => { if (!last.dlg) return; @@ -144,11 +153,18 @@ var dialog = { dlg.find(".modal-body").html(conf.content || "").fadeIn(); - dlg.on("hidden.bs.modal", function() {// on dialog close + dlg.on("shown.bs.modal", function() {// after dialog show + dialog.refocus(); + dlg.find("[autofocus]").first().focus(); + if (conf.init) + conf.init(); + }) + .on("hidden.bs.modal", function() {// on dialog close $("#" + id +",#" + backdropID).remove(); // removes the dialog and its backdrop if (conf.onClose) conf.onClose(); - }); + dialog.refocus(); + }); if (conf.onOK) { let footer = dlg.find(".modal-footer"); @@ -179,9 +195,11 @@ var dialog = { if (!backdrop.prop("id")) backdrop.prop("id", backdropID); }); - - if (conf.init) - conf.init(); +/* setTimeout(function(){ + if (conf.init) + conf.init(); + }, 100); +*/ }, alert:function(conf) { var container = "
{content}
";