2024-04-07 01:50:31 +02:00
|
|
|
const modal = document.getElementById('modal');
|
|
|
|
const modalImg = document.getElementById("modal-content");
|
|
|
|
const captionText = document.getElementById("modal-caption");
|
2022-01-24 16:12:31 +01:00
|
|
|
|
|
|
|
document.addEventListener('click', function (e) {
|
|
|
|
if (e.target.className.indexOf('modal-target') !== -1) {
|
2024-04-07 01:50:31 +02:00
|
|
|
// Open modal
|
|
|
|
const img = e.target;
|
2022-01-24 16:12:31 +01:00
|
|
|
modal.style.display = "block";
|
2024-04-07 01:50:31 +02:00
|
|
|
modalImg.src = img.dataset.fullsrc;
|
2022-01-24 16:12:31 +01:00
|
|
|
captionText.innerHTML = img.alt;
|
2022-01-25 15:04:00 +01:00
|
|
|
} else if (modal.style.display != "none") {
|
2024-04-07 01:50:31 +02:00
|
|
|
// Close modal
|
2022-01-25 15:04:00 +01:00
|
|
|
modal.style.display = "none";
|
2024-04-07 01:50:31 +02:00
|
|
|
modalImg.src = "";
|
2022-01-24 16:12:31 +01:00
|
|
|
}
|
|
|
|
});
|