'+
'
' +
'
'+
'
' +
@@ -45,7 +47,7 @@
'
'
);
- plugin.lightbox = $("#lightbox");
+ plugin.lightbox = $("."+plugin.selector);
}
if (plugin.items.length > 1 && opts.nav) {
@@ -191,7 +193,7 @@
close: function () {
$(document).off('keydown'); // Unbind all key events each time the lightbox is closed
- $('#lightbox').fadeOut('fast');
+ $(plugin.lightbox).fadeOut('fast');
$('body').removeClass('blurred');
}
};
diff --git a/jquery.lightbox.min.js b/jquery.lightbox.min.js
index aff3184..9fb59cf 100644
--- a/jquery.lightbox.min.js
+++ b/jquery.lightbox.min.js
@@ -10,4 +10,16 @@
* minSize - int - default 0. Min window width or height to open lightbox. Below threshold will open image in a new tab.
*
*/
-(function(i){"use strict";i.fn.lightbox=function(t){var e={margin:50,nav:!0,blur:!0,minSize:0},n={items:[],lightbox:null,image:null,current:null,locked:!1,init:function(t){n.items=t,n.lightbox||(i("body").append('
'),n.lightbox=i("#lightbox")),n.items.length>1&&e.nav?i(".lightbox-nav",n.lightbox).show():i(".lightbox-nav",n.lightbox).hide(),n.bindEvents()},loadImage:function(){e.blur&&i("body").addClass("blurred"),i("img",n.lightbox).remove(),n.lightbox.fadeIn("fast").append('
');var t=i('
.attr()
');i(t).load(function(){i(".lightbox-loading").remove(),n.lightbox.append(t),n.image=i("img",n.lightbox).hide(),n.resizeImage()})},resizeImage:function(){var t,o,l,r,g;o=i(window).height()-e.margin,l=i(window).outerWidth(!0)-e.margin,n.image.width("").height(""),r=n.image.height(),g=n.image.width(),g>l&&(t=l/g,g=l,r=Math.round(r*t)),r>o&&(t=o/r,r=o,g=Math.round(g*t)),n.image.width(g).height(r).css({top:(i(window).height()-n.image.outerHeight())/2+"px",left:(i(window).width()-n.image.outerWidth())/2+"px"}).show(),n.locked=!1},getCurrentIndex:function(){return i.inArray(n.current,n.items)},next:function(){return n.locked?!1:(n.locked=!0,n.getCurrentIndex()>=n.items.length-1?i(n.items[0]).click():i(n.items[n.getCurrentIndex()+1]).click(),void 0)},previous:function(){return n.locked?!1:(n.locked=!0,0>=n.getCurrentIndex()?i(n.items[n.items.length-1]).click():i(n.items[n.getCurrentIndex()-1]).click(),void 0)},bindEvents:function(){i(n.items).click(function(t){if(!i("#lightbox").is(":visible")&&(i(window).width()
'+''+'"+"");r.lightbox=e("."+r.selector)}if(r.items.length>1&&n.nav){e(".lightbox-nav",r.lightbox).show()}else{e(".lightbox-nav",r.lightbox).hide()}r.bindEvents()},loadImage:function(){if(n.blur){e("body").addClass("blurred")}e("img",r.lightbox).remove();r.lightbox.fadeIn("fast").append('
');e(t).load(function(){e(".lightbox-loading").remove();r.lightbox.append(t);r.image=e("img",r.lightbox).hide();r.resizeImage()})},resizeImage:function(){var t,i,s,o,u;i=e(window).height()-n.margin;s=e(window).outerWidth(true)-n.margin;r.image.width("").height("");o=r.image.height();u=r.image.width();if(u>s){t=s/u;u=s;o=Math.round(o*t)}if(o>i){t=i/o;o=i;u=Math.round(u*t)}r.image.width(u).height(o).css({top:(e(window).height()-r.image.outerHeight())/2+"px",left:(e(window).width()-r.image.outerWidth())/2+"px"}).show();r.locked=false},getCurrentIndex:function(){return e.inArray(r.current,r.items)},next:function(){if(r.locked){return false}r.locked=true;if(r.getCurrentIndex()>=r.items.length-1){e(r.items[0]).click()}else{e(r.items[r.getCurrentIndex()+1]).click()}},previous:function(){if(r.locked){return false}r.locked=true;if(r.getCurrentIndex()<=0){e(r.items[r.items.length-1]).click()}else{e(r.items[r.getCurrentIndex()-1]).click()}},bindEvents:function(){e(r.items).click(function(t){if(!e("#lightbox").is(":visible")&&(e(window).width()