2024-02-01 16:34:27 +01:00
|
|
|
// Variables
|
|
|
|
|
var baseid = "snap-lightbox-";
|
|
|
|
|
var imageIndex = 1;
|
|
|
|
|
|
|
|
|
|
// Open the Lightbox
|
|
|
|
|
function openLightbox(id) {
|
2024-01-30 23:21:17 +01:00
|
|
|
document.getElementById(baseid + id).style.display = "block";
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-01 16:34:27 +01:00
|
|
|
// Close the Lightbox
|
|
|
|
|
function closeLightbox(id) {
|
2024-01-30 23:21:17 +01:00
|
|
|
document.getElementById(baseid + id).style.display = "none";
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Next/previous controls
|
2024-02-01 16:34:27 +01:00
|
|
|
function moveLightboxItem(id, n) {
|
|
|
|
|
showLightboxItem(id, imageIndex += n);
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-01 16:34:27 +01:00
|
|
|
// Move lightbox to the specified item
|
|
|
|
|
function openLightboxItem(id, n) {
|
|
|
|
|
showLightboxItem(id, imageIndex = n);
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-01 16:34:27 +01:00
|
|
|
// Make a specific image visible, make others hidden
|
|
|
|
|
function showLightboxItem(id, n) {
|
2024-01-30 12:18:28 +01:00
|
|
|
var i;
|
2024-01-30 23:21:17 +01:00
|
|
|
var lightbox = document.getElementById(baseid + id);
|
2024-02-01 16:34:27 +01:00
|
|
|
var images = lightbox.querySelectorAll(".snap-lightbox-inner");
|
|
|
|
|
if (n > images.length) { imageIndex = 1 }
|
|
|
|
|
if (n < 1) { imageIndex = images.length }
|
|
|
|
|
for (i = 0; i < images.length; i++) {
|
|
|
|
|
images[i].style.display = "none";
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|
2024-02-01 16:34:27 +01:00
|
|
|
images[imageIndex - 1].style.display = "inline-block";
|
2024-01-30 12:18:28 +01:00
|
|
|
}
|