MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / initModal

Function initModal

popup/helpers/modal.js:6–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4const modalBody = modal.querySelector(".body");
5
6function initModal() {
7 // When the user clicks on <span> (x), close the modal
8 closeModalBtn.onclick = function () {
9 toggleModal(false);
10 };
11
12 // When the user clicks anywhere outside of the modal, close it
13 window.addEventListener("click", function (event) {
14 if (event.target == modal) {
15 toggleModal(false);
16 }
17 });
18}
19
20export function toggleModal(show = true) {
21 modal.classList.toggle("hide", !show);

Callers 1

modal.jsFile · 0.85

Calls 1

toggleModalFunction · 0.85

Tested by

no test coverage detected