diff options
author | Toma Nistor <toma.nistor@gmail.com> | 2018-12-26 09:26:56 +0300 |
---|---|---|
committer | Toma Nistor <toma.nistor@gmail.com> | 2018-12-26 09:26:56 +0300 |
commit | 3f506a5c30cb1431728be6f827fd34611bae7fa6 (patch) | |
tree | b929a956af5b5bbb48f23d681ba96c6ba68ba532 /static | |
parent | 0abb05aabff4891348f593a5bb18f9326e556efc (diff) |
Added ability to close modals with ESC key, added projectDate param to gallery archetype
Diffstat (limited to 'static')
-rw-r--r-- | static/scripts/modal.min.js | 2 | ||||
-rw-r--r-- | static/scripts/src/modal.js | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/static/scripts/modal.min.js b/static/scripts/modal.min.js index cfff854..36c5e68 100644 --- a/static/scripts/modal.min.js +++ b/static/scripts/modal.min.js @@ -1 +1 @@ -!function(){function t(){i.forEach(function(t){t.classList.remove("scale-out-center")})}function e(){i.forEach(function(t){t.classList.add("scale-out-center")})}var c,n=document.querySelector.bind(document),o=document.querySelectorAll.bind(document),i=o(".modal-box"),u=o(".gallery-modal-link"),a=o(".close");u.forEach(function(e){e.onclick=function(e){e.preventDefault(),c=n(e.target.getAttribute("href")),c.classList.add("active"),t()}}),a.forEach(function(t){t.onclick=function(t){t.preventDefault(),e(),setTimeout(function(){c.classList.remove("active")},500)}}),window.onclick=function(t){t.target===c&&(e(),setTimeout(function(){c.classList.remove("active")},500))}}();
\ No newline at end of file +!function(){function t(){i.forEach(function(t){t.classList.remove("scale-out-center")})}function n(){i.forEach(function(t){t.classList.add("scale-out-center"),setTimeout(function(){c.classList.remove("active")},500)})}var c,e=document.querySelector.bind(document),o=document.querySelectorAll.bind(document),i=o(".modal-box"),u=o(".gallery-modal-link"),a=o(".close");u.forEach(function(n){n.onclick=function(n){n.preventDefault(),c=e(n.target.getAttribute("href")),c.classList.add("active"),t()}}),a.forEach(function(t){t.onclick=function(t){t.preventDefault(),n()}}),window.onclick=function(t){t.target===c&&n()},document.onkeydown=function(t){"Escape"===t.key&&n()}}();
\ No newline at end of file diff --git a/static/scripts/src/modal.js b/static/scripts/src/modal.js index 8d8b39b..1994ef6 100644 --- a/static/scripts/src/modal.js +++ b/static/scripts/src/modal.js @@ -23,6 +23,7 @@ function closeModal() { modalBoxes.forEach(function(box) { box.classList.add('scale-out-center') + setTimeout(function() { modal.classList.remove('active') }, 500) }) } @@ -41,7 +42,6 @@ link.onclick = function(e) { e.preventDefault() closeModal() - setTimeout(function() { modal.classList.remove('active') }, 500) } }) @@ -49,7 +49,13 @@ window.onclick = function(event) { if (event.target === modal) { closeModal() - setTimeout(function() { modal.classList.remove('active') }, 500) + } + } + + // Close modal on ESC key press + document.onkeydown = function(e) { + if (e.key === 'Escape') { + closeModal() } } })() |