Merge pull request 'fix: JavaScript doppelte Funktionen & toter Code (#39)' (#40) from feature/39-js-duplicate-functions-fix into main
Reviewed-on: #40
This commit is contained in:
@@ -81,10 +81,6 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
this.click();
|
||||
}
|
||||
});
|
||||
if (e.key === "Enter" || e.key === " ") {
|
||||
e.preventDefault();
|
||||
$(this).trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
// Lightbox – track last focused element for focus return
|
||||
@@ -92,27 +88,26 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
function openLightbox(src) {
|
||||
lightboxTrigger = document.activeElement;
|
||||
$("#lightboxImg").attr("src", src).attr("alt", "");
|
||||
$("#lightbox").addClass("open");
|
||||
$("body").css("overflow", "hidden");
|
||||
document.getElementById("lightboxImg").setAttribute("src", src);
|
||||
document.getElementById("lightboxImg").setAttribute("alt", "");
|
||||
document.getElementById("lightbox").classList.add("open");
|
||||
document.body.style.overflow = "hidden";
|
||||
// Set focus to close button
|
||||
setTimeout(function () {
|
||||
$("#lightboxClose").focus();
|
||||
document.getElementById("lightboxClose").focus();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
$("#lightbox").removeClass("open");
|
||||
$("body").css("overflow", "");
|
||||
document.getElementById("lightbox").classList.remove("open");
|
||||
document.body.style.overflow = "";
|
||||
// Return focus to trigger
|
||||
if (lightboxTrigger) {
|
||||
$(lightboxTrigger).focus();
|
||||
lightboxTrigger.focus();
|
||||
lightboxTrigger = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Lightbox – gallery grid items
|
||||
|
||||
// Lightbox – gallery grid items
|
||||
document.querySelectorAll(".grid-item").forEach(function (item) {
|
||||
item.addEventListener("click", function () {
|
||||
@@ -139,26 +134,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
});
|
||||
|
||||
function openLightbox(src) {
|
||||
lightboxTrigger = document.activeElement;
|
||||
document.getElementById("lightboxImg").setAttribute("src", src);
|
||||
document.getElementById("lightbox").classList.add("open");
|
||||
document.body.style.overflow = "hidden";
|
||||
// Focus close button
|
||||
setTimeout(function () {
|
||||
document.getElementById("lightboxClose").focus();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
document.getElementById("lightbox").classList.remove("open");
|
||||
document.body.style.overflow = "";
|
||||
// Return focus to trigger
|
||||
if (lightboxTrigger) {
|
||||
lightboxTrigger.focus();
|
||||
lightboxTrigger = null;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("lightboxClose").addEventListener("click", closeLightbox);
|
||||
document.getElementById("lightbox").addEventListener("click", function (e) {
|
||||
|
||||
Reference in New Issue
Block a user