image gallery next prev

This commit is contained in:
Sanj 2011-11-07 15:51:12 +05:30
parent 3d7d35fee5
commit 6fe5d626d0

View File

@ -36,17 +36,44 @@ $('#listLeft ul li a').live("click", function() {
return false;
});
$('.lightboxNext').live("click", function(e) {
$(this).data("image").click();
});
$('.lightboxPrev').live("click", function(e) {
$(this).data("image").click();
});
$('.thumbsDetails').live("click", function(e) {
// alert($(this).attr("data-bigimage"));
var that = this;
var totalImages = $(this).parent().find(".thumbsDetails").length;
var thisIndex = $(this).index();
if (thisIndex < (totalImages - 1)) {
var hasNext = true;
var nextImage = $(this).parent().find(".thumbsDetail").eq(thisIndex + 1);
}
if (thisIndex > 0 && totalImages > 1) {
var hasPrev = true;
var prevImage = $(this).parent().find(".thumbsDetail").eq(thisIndex - 1);
}
var bigImage = $(this).attr("data-bigimage");
var $img = $('<img />').attr("src", bigImage);
showLightbox($img);
var title = $(this).hasAttr("title") ? $(this).attr("title") : '';
var $c = $('#lightboxContent');
if (title != '') {
var $caption = $('<div />').addClass("lightboxCaption").text(title).appendTo($('#lightboxContent'));
var $caption = $('<div />').addClass("lightboxCaption").text(title).appendTo($c);
}
if (hasNext) {
var $next = $('<div />').addClass("lightboxNext").text("NEXT").data("image", nextImage).appendTo($c);
}
if (hasPrev) {
var $prev = $('<div />').addClass("lightboxPrev").text("PREV").data("image", prevImage).appendTo($c);
}
});
function hideLightbox() {
@ -54,7 +81,9 @@ function hideLightbox() {
}
function showLightbox($content) {
if (!$('#lightbox').is("visible")) {
$('#lightbox, #lightboxPanel').fadeIn(400);
}
$('#lightboxContent').empty().append($content);
}