Skip to content

Commit

Permalink
Now making sure closeModal() works on Trongate MX without admin.js or…
Browse files Browse the repository at this point in the history
… app.js being loaded.
  • Loading branch information
David Connelly committed Dec 11, 2024
1 parent 869dadf commit c617f06
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion public/js/trongate-mx.js
Original file line number Diff line number Diff line change
Expand Up @@ -1526,4 +1526,28 @@
};


})(window);
})(window);

// Make sure closeModal() works (identical to app.js version)
const _mxCloseModal = function () {
const modalContainer = document.getElementById("modal-container");
if (modalContainer) {
const openModal = modalContainer.firstChild;
openModal.style.zIndex = TGUI_ADMIN.UI_CONSTANTS.MODAL.Z_INDEX_HIDDEN;
openModal.style.opacity = 0;
openModal.style.marginTop = TGUI_ADMIN.UI_CONSTANTS.MODAL.DEFAULT_MARGIN_TOP;
openModal.style.display = "none";
TGUI_ADMIN.body.appendChild(openModal);
modalContainer.remove();

const overlay = document.getElementById("overlay");
if (overlay) {
overlay.remove();
}

const event = new Event("modalClosed", { bubbles: true, cancelable: true });
document.dispatchEvent(event);
}
};

window.closeModal = window.closeModal || _mxCloseModal;

0 comments on commit c617f06

Please sign in to comment.