diff options
author | Simone Bortolin <simonebortolin@users.noreply.github.com> | 2022-08-05 06:59:56 +0200 |
---|---|---|
committer | Simone Bortolin <simonebortolin@users.noreply.github.com> | 2022-12-19 22:55:58 +0100 |
commit | 04e593565d0f69ec54923fb66a167eecc48f6e50 (patch) | |
tree | a770cf7b174d3ba9c235d412b0449a40481394af /assets/js/modal.js | |
parent | add images (diff) | |
download | hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar.gz hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar.bz2 hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar.lz hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar.xz hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.tar.zst hack-gpon.github.io-04e593565d0f69ec54923fb66a167eecc48f6e50.zip |
Diffstat (limited to 'assets/js/modal.js')
-rw-r--r-- | assets/js/modal.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/assets/js/modal.js b/assets/js/modal.js new file mode 100644 index 0000000..2cae945 --- /dev/null +++ b/assets/js/modal.js @@ -0,0 +1,26 @@ +var modals = document.querySelectorAll("[data-modal]"); +var modalToogles = document.querySelectorAll("[data-toogle=modal]"); + + +[...modals].forEach(modal => { + var closeBtns = modal.getElementsByClassName("close"); + [...closeBtns].forEach(closeBtn => { + closeBtn.addEventListener("click", (event) => { + modal.style.display = "none"; + }); + }) +}); + +[...modalToogles].forEach(toogle => { + toogle.addEventListener("click", (event) => { + var modal = document.querySelector(toogle.getAttribute('data-target')); + modal.style.display = "block"; + }); +}); + +window.addEventListener("click", function(event) { + if ([...modals].includes(event.target)) { + event.target.style.display = "none"; + } +}); + |