58 lines
1.7 KiB
JavaScript
58 lines
1.7 KiB
JavaScript
// Variables
|
|
var lightbox_baseid = "snap-lightbox-";
|
|
var slideshow_baseid = "snap-slideshow-";
|
|
//var imageIndex = {1: 1, 2: 1, 3: 1};
|
|
var imageIndex = {}
|
|
|
|
// Open the Lightbox
|
|
function openLightbox(id) {
|
|
document.getElementById(lightbox_baseid + id).style.display = "block";
|
|
}
|
|
|
|
// Close the Lightbox
|
|
function closeLightbox(id) {
|
|
document.getElementById(lightbox_baseid + id).style.display = "none";
|
|
}
|
|
|
|
// Next/previous controls for lightbox
|
|
function moveLightboxItem(id, n) {
|
|
showLightboxItem(id, imageIndex[id] += n);
|
|
}
|
|
|
|
// Next/previous controls for slideshow
|
|
function moveSlideshowItem(id, n) {
|
|
showSlideshowItem(id, imageIndex[id] += n);
|
|
}
|
|
|
|
// Move lightbox to the specified item
|
|
function openLightboxItem(id, n) {
|
|
showLightboxItem(id, imageIndex[id] = n);
|
|
}
|
|
|
|
// TODO: Unify these functions
|
|
// In the lightbox, make a specific image visible, make others hidden
|
|
function showLightboxItem(id, n) {
|
|
var i;
|
|
var lightbox = document.getElementById(lightbox_baseid + id);
|
|
var images = lightbox.querySelectorAll(".snap-lightbox-inner");
|
|
if (n > images.length) { imageIndex[id] = 1 }
|
|
if (n < 1) { imageIndex[id] = images.length }
|
|
for (i = 0; i < images.length; i++) {
|
|
images[i].style.display = "none";
|
|
}
|
|
images[imageIndex[id] - 1].style.display = "inline-block";
|
|
}
|
|
|
|
// In the slideshow, make a specific image visible, make others hidden
|
|
function showSlideshowItem(id, n) {
|
|
var i;
|
|
var slideshow = document.getElementById(slideshow_baseid + id);
|
|
var images = slideshow.querySelectorAll(".snap-image");
|
|
if (n > images.length) { imageIndex[id] = 1 }
|
|
if (n < 1) { imageIndex[id] = images.length }
|
|
for (i = 0; i < images.length; i++) {
|
|
images[i].style.display = "none";
|
|
}
|
|
images[imageIndex[id] - 1].style.display = "block";
|
|
}
|