Close popup when clicking outside
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
@@ -243,6 +243,23 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
</main>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
|
document.addEventListener('keydown', function(event) {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
document.querySelectorAll('.modal.show').forEach(modal => {
|
||||||
|
modal.classList.remove('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('click', function(event) {
|
||||||
|
const modal = event.target.closest('.modal');
|
||||||
|
if (!modal && document.querySelectorAll('.modal.show').length > 0 && !event.target.closest('.more-link')) {
|
||||||
|
document.querySelectorAll('.modal.show').forEach(modal => {
|
||||||
|
modal.classList.remove('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
[...document.querySelectorAll('.more-link')].forEach(more => {
|
[...document.querySelectorAll('.more-link')].forEach(more => {
|
||||||
const toggleModal = function(event) {
|
const toggleModal = function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user