Add lightbox feature for album images
This commit is contained in:
parent
6495cc68c1
commit
858fec7ec1
|
@ -1,3 +1,5 @@
|
|||
var lightboxImages = [];
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#btn_refresh").click(function() { refreshAlbums() });
|
||||
$("#btn_album_0").click(function() { showAlbum($(this)) });
|
||||
|
@ -25,10 +27,12 @@ function getAlbumInfo() {
|
|||
url: 'ajax/getalbuminfo.php',
|
||||
dataType: 'json',
|
||||
success: function(data, stat, jqo) {
|
||||
lightboxImages = [];
|
||||
if ( data.currentalbum == 0 ) {
|
||||
$("#albumdetails").addClass("hidden");
|
||||
} else {
|
||||
$("#albumdetails").removeClass("hidden");
|
||||
lightboxImages = data.images;
|
||||
}
|
||||
$("#albumtitle").html(data.albumtitle);
|
||||
$("#albumdescription").html(data.albumdescription);
|
||||
|
@ -40,6 +44,7 @@ function getAlbumInfo() {
|
|||
showImage($(this));
|
||||
}
|
||||
});
|
||||
console.log(lightboxImages);
|
||||
},
|
||||
error: function(jqp, status, error) {
|
||||
toastr.error("Error retrieving album info!\n" + error, "Server Error");
|
||||
|
@ -49,7 +54,24 @@ function getAlbumInfo() {
|
|||
|
||||
function showImage(clickedElement) {
|
||||
var imageid = clickedElement.attr("id").substring(clickedElement.attr("id").lastIndexOf("_") + 1);
|
||||
console.log(imageid);
|
||||
var startIndex = 0;
|
||||
var images = [];
|
||||
var captions = [];
|
||||
lightboxImages.forEach(function(image, index) {
|
||||
if ( image.id == imageid ) startIndex = index;
|
||||
images.push(image.imageurl);
|
||||
captions.push(image.description);
|
||||
});
|
||||
/*
|
||||
images.forEach(function(image, index) {
|
||||
if ( basename(image, "/") == basename(clickedElement.attr("src"), "/") ) startIndex = index;
|
||||
});
|
||||
*/
|
||||
SimpleLightbox.open({
|
||||
items: images,
|
||||
captions: captions,
|
||||
startAt: startIndex
|
||||
});
|
||||
}
|
||||
|
||||
function showAlbum(clickedElement) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user