Update texts and add clickable enlarged image lightbox

This commit is contained in:
Kaya Samat
2026-08-07 22:06:27 +03:00
parent a16a1e0f6b
commit 2e81f0f465
4 changed files with 79 additions and 4 deletions
+34
View File
@@ -80,10 +80,44 @@
});
slider.addEventListener("mouseleave", restart);
images.forEach(function (img) {
img.classList.add("clickable");
img.addEventListener("click", function (ev) {
ev.stopPropagation();
openLightbox(img.src);
});
});
show();
restart();
});
// ---- Lightbox ----
var lightbox = document.getElementById("lightbox");
var lightboxImg = lightbox ? lightbox.querySelector("img") : null;
var lightboxClose = lightbox ? lightbox.querySelector(".lightbox-close") : null;
function openLightbox(src) {
if (!lightbox || !lightboxImg) return;
lightboxImg.src = src;
lightbox.classList.add("open");
lightbox.setAttribute("aria-hidden", "false");
}
function closeLightbox() {
if (!lightbox) return;
lightbox.classList.remove("open");
lightbox.setAttribute("aria-hidden", "true");
lightboxImg.src = "";
}
if (lightbox) {
lightbox.addEventListener("click", function (ev) {
if (ev.target === lightbox || ev.target === lightboxClose) closeLightbox();
});
document.addEventListener("keydown", function (ev) {
if (ev.key === "Escape") closeLightbox();
});
}
// ---- Flash mesajları ----
setTimeout(function () {
document.querySelectorAll(".flash").forEach(function (el) {