30 lines
841 B
JavaScript
30 lines
841 B
JavaScript
'use srict';
|
|
|
|
(function() {
|
|
const imageModal = document.querySelector('#image-modal');
|
|
const imageModalContents = document.querySelector('#image-modal-contents');
|
|
|
|
imageModal.querySelector('.close-x').addEventListener('click', function(e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
imageModal.hidden = true;
|
|
});
|
|
|
|
const images = document.querySelectorAll('img');
|
|
images.forEach(function(img) {
|
|
const name = img.src.split('/').pop();
|
|
|
|
if(name.match(/^th_/)) {
|
|
img.addEventListener('click', function(e) {
|
|
e.stopPropagation();
|
|
e.preventDefault();
|
|
|
|
imageModal.hidden = undefined;
|
|
const fullImage = document.createElement('img');
|
|
fullImage.src = `./images/${name.replace(/^th_/, '')}`;
|
|
imageModalContents.replaceChildren(fullImage);
|
|
});
|
|
}
|
|
});
|
|
})();
|