diff --git a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Components/Dialog/_Dialog.js b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Components/Dialog/_Dialog.js new file mode 100644 index 0000000..06c9cc8 --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Components/Dialog/_Dialog.js @@ -0,0 +1,34 @@ +jfa.components.dialog = (function () { + function _confirm({ message, title, callbackyes, callbackno }) { + const dialogTemplate = jfa.page.getDialogTemplate().content; + + let spanTitle = dialogTemplate.querySelector(".modal__title__text"); + spanTitle.textContent = title || "Confirm"; + + let bodyMessage = dialogTemplate.querySelector(".modal__body-message"); + bodyMessage.textContent = message; + + const dialog = dialogTemplate.querySelector("#dialog-container"); + const modal = bootstrap.Modal.getOrCreateInstance(dialog); + + let buttonNo = dialogTemplate.querySelector(".modal__footer__button-no"); + buttonNo.addEventListener("click", function () { + buttonNo.blur(); + modal.hide(); + callbackno?.(); + }); + + let buttonYes = dialogTemplate.querySelector(".modal__footer__button-yes"); + buttonYes.addEventListener("click", function () { + buttonYes.blur(); + modal.hide(); + callbackyes?.(); + }); + + modal.show(); + } + + return { + confirm: _confirm + }; +})(); \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js index 58ae1ba..8e29030 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js +++ b/EnotaryoPH/EnotaryoPH.Web/Assets/js/Page/_Page.js @@ -11,6 +11,14 @@ return window.top.document.querySelector("[name='__RequestVerificationToken']")?.value; } + function _getDialogContainer() { + return document.getElementById("ContainerDialog").cloneNode(true); + } + + function _getDialogTemplate() { + return document.getElementById("DialogTemplate").cloneNode(true); + } + function reload() { window.location.reload(); } @@ -19,6 +27,8 @@ getAlertContainer: _getAlertContainer, getAlertTemplate: _getAlertTemplate, getAntiForgeryToken: _getAntiForgeryToken, + getDialogContainer: _getDialogContainer, + getDialogTemplate: _getDialogTemplate, reload: reload }; })(); \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml index cfb9570..3f390e8 100644 --- a/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml +++ b/EnotaryoPH/EnotaryoPH.Web/Pages/Shared/_Layout.cshtml @@ -19,31 +19,39 @@
-