neptune/core/static/modal.js

45 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-08-10 21:40:54 +00:00
// var modal = document.querySelector('.modal'); // assuming you have only 1
2022-08-11 18:36:34 +00:00
var modal = document.getElementById("modal");
var html = document.querySelector('html');
2022-08-03 06:20:30 +00:00
2022-08-09 06:20:30 +00:00
var disableModal = function() {
modal.classList.remove('is-active');
html.classList.remove('is-clipped');
var modal_refresh = document.getElementsByClassName("modal-refresh");
for(var i = 0; i < modal_refresh.length; i++) {
modal_refresh[i].remove();
}
}
2022-08-03 06:20:30 +00:00
var elements = document.querySelectorAll('.modal-background');
for(var i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', function(e) {
// elements[i].preventDefault();
2022-08-09 06:20:30 +00:00
disableModal();
2022-08-03 06:20:30 +00:00
});
}
var elements = document.querySelectorAll('.modal-close');
for(var i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', function(e) {
// elements[i].preventDefault();
2022-08-09 06:20:30 +00:00
disableModal();
2022-08-03 06:20:30 +00:00
});
}
function activateButtons() {
var elements = document.querySelectorAll('.modal-close-button');
for(var i = 0; i < elements.length; i++) {
elements[i].addEventListener('click', function(e) {
// elements[i].preventDefault();
2022-08-09 06:20:30 +00:00
disableModal();
2022-08-03 06:20:30 +00:00
});
}
}
activateButtons();
// modal.querySelector('.modal-close-button').addEventListener('click', function(e) {
// e.preventDefault();
// modal.classList.remove('is-active');
// html.classList.remove('is-clipped');
2022-08-10 21:40:54 +00:00
// });