add ability to change yes/no labels

This commit is contained in:
jojo aquino 2025-01-04 11:50:13 +00:00
parent a3d803cdfb
commit c8512b30f4

View File

@ -1,5 +1,5 @@
jfa.components.dialog = (function () {
function _confirm({ message, title, callbackyes, callbackno }) {
function _confirm({ message, title, callbackyes, callbackno, yesLabel, noLabel }) {
const dialogTemplate = jfa.page.getDialogTemplate().content;
let spanTitle = dialogTemplate.querySelector(".modal__title__text");
@ -12,6 +12,9 @@
const modal = bootstrap.Modal.getOrCreateInstance(dialog);
let buttonNo = dialogTemplate.querySelector(".modal__footer__button-no");
if (noLabel) {
buttonNo.textContent = noLabel;
}
buttonNo.addEventListener("click", function () {
buttonNo.blur();
modal.hide();
@ -19,6 +22,9 @@
});
let buttonYes = dialogTemplate.querySelector(".modal__footer__button-yes");
if (yesLabel) {
buttonYes.textContent = yesLabel;
}
buttonYes.addEventListener("click", function () {
buttonYes.blur();
modal.hide();