From 6fe5d626d05859cd3bcaebc23097e07aa4e0c1d4 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 7 Nov 2011 15:51:12 +0530 Subject: [PATCH] image gallery next prev --- itf/static/js/insidepage.js | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/itf/static/js/insidepage.js b/itf/static/js/insidepage.js index ce01440..5610487 100755 --- a/itf/static/js/insidepage.js +++ b/itf/static/js/insidepage.js @@ -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 = $('').attr("src", bigImage); showLightbox($img); var title = $(this).hasAttr("title") ? $(this).attr("title") : ''; + var $c = $('#lightboxContent'); if (title != '') { - var $caption = $('
').addClass("lightboxCaption").text(title).appendTo($('#lightboxContent')); + var $caption = $('
').addClass("lightboxCaption").text(title).appendTo($c); } + if (hasNext) { + var $next = $('
').addClass("lightboxNext").text("NEXT").data("image", nextImage).appendTo($c); + } + if (hasPrev) { + var $prev = $('
').addClass("lightboxPrev").text("PREV").data("image", prevImage).appendTo($c); + } + }); function hideLightbox() { @@ -54,7 +81,9 @@ function hideLightbox() { } function showLightbox($content) { - $('#lightbox, #lightboxPanel').fadeIn(400); + if (!$('#lightbox').is("visible")) { + $('#lightbox, #lightboxPanel').fadeIn(400); + } $('#lightboxContent').empty().append($content); }