rename JS functions to make them more clear
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
// Open the Modal
|
||||
function openModal(id) {
|
||||
// Variables
|
||||
var baseid = "snap-lightbox-";
|
||||
var imageIndex = 1;
|
||||
|
||||
// Open the Lightbox
|
||||
function openLightbox(id) {
|
||||
document.getElementById(baseid + id).style.display = "block";
|
||||
}
|
||||
|
||||
// Close the Modal
|
||||
function closeModal(id) {
|
||||
// Close the Lightbox
|
||||
function closeLightbox(id) {
|
||||
document.getElementById(baseid + id).style.display = "none";
|
||||
}
|
||||
|
||||
var baseid = "snap-lightbox-";
|
||||
var slideIndex = 1;
|
||||
showSlides(slideIndex);
|
||||
|
||||
|
||||
// Next/previous controls
|
||||
function plusSlides(id, n) {
|
||||
showSlides(id, slideIndex += n);
|
||||
function moveLightboxItem(id, n) {
|
||||
showLightboxItem(id, imageIndex += n);
|
||||
}
|
||||
|
||||
// Thumbnail image controls
|
||||
function currentSlide(id, n) {
|
||||
showSlides(id, slideIndex = n);
|
||||
// Move lightbox to the specified item
|
||||
function openLightboxItem(id, n) {
|
||||
showLightboxItem(id, imageIndex = n);
|
||||
}
|
||||
|
||||
function showSlides(id, n) {
|
||||
// Make a specific image visible, make others hidden
|
||||
function showLightboxItem(id, n) {
|
||||
var i;
|
||||
var lightbox = document.getElementById(baseid + id);
|
||||
var slides = lightbox.querySelectorAll(".snap-lightbox-inner");
|
||||
if (n > slides.length) { slideIndex = 1 }
|
||||
if (n < 1) { slideIndex = slides.length }
|
||||
for (i = 0; i < slides.length; i++) {
|
||||
slides[i].style.display = "none";
|
||||
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";
|
||||
}
|
||||
slides[slideIndex - 1].style.display = "inline-block";
|
||||
images[imageIndex - 1].style.display = "inline-block";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user