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