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();
|
this.click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (e.key === "Enter" || e.key === " ") {
|
|
||||||
e.preventDefault();
|
|
||||||
$(this).trigger("click");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Lightbox – track last focused element for focus return
|
// Lightbox – track last focused element for focus return
|
||||||
@@ -92,27 +88,26 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
|
|
||||||
function openLightbox(src) {
|
function openLightbox(src) {
|
||||||
lightboxTrigger = document.activeElement;
|
lightboxTrigger = document.activeElement;
|
||||||
$("#lightboxImg").attr("src", src).attr("alt", "");
|
document.getElementById("lightboxImg").setAttribute("src", src);
|
||||||
$("#lightbox").addClass("open");
|
document.getElementById("lightboxImg").setAttribute("alt", "");
|
||||||
$("body").css("overflow", "hidden");
|
document.getElementById("lightbox").classList.add("open");
|
||||||
|
document.body.style.overflow = "hidden";
|
||||||
// Set focus to close button
|
// Set focus to close button
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$("#lightboxClose").focus();
|
document.getElementById("lightboxClose").focus();
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeLightbox() {
|
function closeLightbox() {
|
||||||
$("#lightbox").removeClass("open");
|
document.getElementById("lightbox").classList.remove("open");
|
||||||
$("body").css("overflow", "");
|
document.body.style.overflow = "";
|
||||||
// Return focus to trigger
|
// Return focus to trigger
|
||||||
if (lightboxTrigger) {
|
if (lightboxTrigger) {
|
||||||
$(lightboxTrigger).focus();
|
lightboxTrigger.focus();
|
||||||
lightboxTrigger = null;
|
lightboxTrigger = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lightbox – gallery grid items
|
|
||||||
|
|
||||||
// Lightbox – gallery grid items
|
// Lightbox – gallery grid items
|
||||||
document.querySelectorAll(".grid-item").forEach(function (item) {
|
document.querySelectorAll(".grid-item").forEach(function (item) {
|
||||||
item.addEventListener("click", function () {
|
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("lightboxClose").addEventListener("click", closeLightbox);
|
||||||
document.getElementById("lightbox").addEventListener("click", function (e) {
|
document.getElementById("lightbox").addEventListener("click", function (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user