From 87af005b072c89238a964d8f819fcfaaadf01430 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 17:09:34 -0500 Subject: [PATCH 01/11] Update lightbox to have autorotation and configurable options. --- js/lightbox.js | 101 +++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index 5f4b8af2..a3ec2c59 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -7,32 +7,24 @@ * - Attribution requires leaving author name, author link, and the license info intact */ +var LightboxOptions = { + fadeDuration: 500, + fitImagesInViewport: true, + resizeDuration: 700, + positionFromTop: 50, + showImageNumberLabel: true, + alwaysShowNavOnTouchDevices: false, + wrapAround: false, + autoRotate: false +}; + (function() { // Use local alias var $ = jQuery; - var LightboxOptions = (function() { - function LightboxOptions() { - this.fadeDuration = 500; - this.fitImagesInViewport = true; - this.resizeDuration = 700; - this.positionFromTop = 50; - this.showImageNumberLabel = true; - this.alwaysShowNavOnTouchDevices = false; - this.wrapAround = false; - } - - // Change to localize to non-english language - LightboxOptions.prototype.albumLabel = function(curImageNum, albumSize) { - return "Image " + curImageNum + " of " + albumSize; - }; - - return LightboxOptions; - })(); - - var Lightbox = (function() { function Lightbox(options) { + console.log(options); this.options = options; this.album = []; this.currentImageIndex = void 0; @@ -93,20 +85,12 @@ }); this.$lightbox.find('.lb-prev').on('click', function() { - if (self.currentImageIndex === 0) { - self.changeImage(self.album.length - 1); - } else { - self.changeImage(self.currentImageIndex - 1); - } + self.prev(true); return false; }); this.$lightbox.find('.lb-next').on('click', function() { - if (self.currentImageIndex === self.album.length - 1) { - self.changeImage(0); - } else { - self.changeImage(self.currentImageIndex + 1); - } + self.next(true); return false; }); @@ -176,6 +160,10 @@ }).fadeIn(this.options.fadeDuration); this.changeImage(imageNumber); + + if (this.options.autoRotate) { + this.autoSlide(); + } }; // Hide most UI elements in preparation for the animated resizing of the lightbox. @@ -234,6 +222,47 @@ this.currentImageIndex = imageNumber; }; + // Go to the next slide. + // 1 param indicates that this transition was intialized by input from the + // user, as opposed to autorotation. + Lightbox.prototype.next = function(userInput) { + userInput = userInput ? userInput : false; + if (userInput) { + this.options.autoRotate = false; + clearTimeout(this.autoInterval); + } + if (this.currentImageIndex !== this.album.length - 1) { + this.changeImage(this.currentImageIndex + 1); + } else if (this.options.wrapAround && this.album.length > 1) { + this.changeImage(0); + } + } + + // Go to the previous slide. + Lightbox.prototype.prev = function(userInput) { + userInput = userInput ? userInput : false; + if (userInput) { + this.options.autoRotate = false; + clearTimeout(this.autoInterval); + } + if (this.currentImageIndex !== 0) { + this.changeImage(this.currentImageIndex - 1); + } else if (this.options.wrapAround && this.album.length > 1) { + this.changeImage(this.album.length - 1); + } + } + + Lightbox.prototype.autoSlide = function() { + if (!this.options.autoRotate) { + return; + } + var self = this; + self.autoInterval = setTimeout(function() { + self.next(); + self.autoSlide(); + }, this.options.autoRotate); + } + // Stretch overlay to fit the viewport Lightbox.prototype.sizeOverlay = function() { this.$overlay @@ -374,17 +403,9 @@ if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) { this.end(); } else if (key === 'p' || keycode === KEYCODE_LEFTARROW) { - if (this.currentImageIndex !== 0) { - this.changeImage(this.currentImageIndex - 1); - } else if (this.options.wrapAround && this.album.length > 1) { - this.changeImage(this.album.length - 1); - } + this.prev(true); } else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) { - if (this.currentImageIndex !== this.album.length - 1) { - this.changeImage(this.currentImageIndex + 1); - } else if (this.options.wrapAround && this.album.length > 1) { - this.changeImage(0); - } + this.next(true); } }; From ad90ac4471607c3e33d07bac4fa80aeb9961d211 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 17:23:13 -0500 Subject: [PATCH 02/11] Update minified js --- js/lightbox.min.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 25cf95e8..ce4d06bf 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,5 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -(function(){var a=jQuery,b=function(){function a(){this.fadeDuration=500,this.fitImagesInViewport=!0,this.resizeDuration=700,this.positionFromTop=50,this.showImageNumberLabel=!0,this.alwaysShowNavOnTouchDevices=!1,this.wrapAround=!1}return a.prototype.albumLabel=function(a,b){return"Image "+a+" of "+b},a}(),c=function(){function b(a){this.options=a,this.album=[],this.currentImageIndex=void 0,this.init()}return b.prototype.init=function(){this.enable(),this.build()},b.prototype.enable=function(){var b=this;a("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(c){return b.start(a(c.currentTarget)),!1})},b.prototype.build=function(){var b=this;a("
").appendTo(a("body")),this.$lightbox=a("#lightbox"),this.$overlay=a("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return b.end(),!1}),this.$lightbox.hide().on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$outerContainer.on("click",function(c){return"lightbox"===a(c.target).attr("id")&&b.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return b.changeImage(0===b.currentImageIndex?b.album.length-1:b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.changeImage(b.currentImageIndex===b.album.length-1?0:b.currentImageIndex+1),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return b.end(),!1})},b.prototype.start=function(b){function c(a){d.album.push({link:a.attr("href"),title:a.attr("data-title")||a.attr("title")})}var d=this,e=a(window);e.on("resize",a.proxy(this.sizeOverlay,this)),a("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var f,g=0,h=b.attr("data-lightbox");if(h){f=a(b.prop("tagName")+'[data-lightbox="'+h+'"]');for(var i=0;ij||e.height>i)&&(e.width/j>e.height/i?(h=j,g=parseInt(e.height/(e.width/h),10),d.width(h),d.height(g)):(g=i,h=parseInt(e.width/(e.height/g),10),d.width(h),d.height(g)))),c.sizeContainer(d.width(),d.height())},e.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){this.$overlay.width(a(window).width()).height(a(document).height())},b.prototype.sizeContainer=function(a,b){function c(){d.$lightbox.find(".lb-dataContainer").width(g),d.$lightbox.find(".lb-prevLink").height(h),d.$lightbox.find(".lb-nextLink").height(h),d.showImage()}var d=this,e=this.$outerContainer.outerWidth(),f=this.$outerContainer.outerHeight(),g=a+this.containerLeftPadding+this.containerRightPadding,h=b+this.containerTopPadding+this.containerBottomPadding;e!==g||f!==h?this.$outerContainer.animate({width:g,height:h},this.options.resizeDuration,"swing",function(){c()}):c()},b.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(b){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(a&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),a&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return b.sizeOverlay()})},b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var a=new Image;a.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var b=new Image;b.src=this.album[this.currentImageIndex-1].link}},b.prototype.enableKeyboardNav=function(){a(document).on("keyup.keyboard",a.proxy(this.keyboardAction,this))},b.prototype.disableKeyboardNav=function(){a(document).off(".keyboard")},b.prototype.keyboardAction=function(a){var b=27,c=37,d=39,e=a.keyCode,f=String.fromCharCode(e).toLowerCase();e===b||f.match(/x|o|c/)?this.end():"p"===f||e===c?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):("n"===f||e===d)&&(this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0))},b.prototype.end=function(){this.disableKeyboardNav(),a(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),a("select, object, embed").css({visibility:"visible"})},b}();a(function(){{var a=new b;new c(a)}})}).call(this); -//# sourceMappingURL=lightbox.min.map \ No newline at end of file +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){{var t=new LightboxOptions;new i(t)}})}).call(this); From 8bce704d46ee282b976e99ef5fb321be0379bff3 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 17:27:58 -0500 Subject: [PATCH 03/11] Fix some js issue. --- js/lightbox.js | 1 - js/lightbox.min.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index a3ec2c59..c4073f0d 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -425,7 +425,6 @@ var LightboxOptions = { })(); $(function() { - var options = new LightboxOptions(); var lightbox = new Lightbox(options); }); diff --git a/js/lightbox.min.js b/js/lightbox.min.js index ce4d06bf..92d40ab5 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){{var t=new LightboxOptions;new i(t)}})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){{new i(LightboxOptions)}})}).call(this); From 98d1151b90cc1cf61219cb86f465af1e7a932b9a Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 17:39:11 -0500 Subject: [PATCH 04/11] Fix a js error introduced by one of my changes. --- js/lightbox.js | 5 ++++- js/lightbox.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index c4073f0d..0ea9cc33 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -15,7 +15,10 @@ var LightboxOptions = { showImageNumberLabel: true, alwaysShowNavOnTouchDevices: false, wrapAround: false, - autoRotate: false + autoRotate: false, + albumLabel: function(curImageNum, albumSize) { + return "Image " + curImageNum + " of " + albumSize; + } }; (function() { diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 92d40ab5..670a4e07 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){{new i(LightboxOptions)}})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); From a316156b1f272d5a89395e951767347575f0cd36 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 18:27:40 -0500 Subject: [PATCH 05/11] Fix options passage. --- js/lightbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/lightbox.js b/js/lightbox.js index 0ea9cc33..bc0afc48 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -428,7 +428,7 @@ var LightboxOptions = { })(); $(function() { - var lightbox = new Lightbox(options); + var lightbox = new Lightbox(LightboxOptions); }); }).call(this); From 86c463fad1951269ce6b5e881894ec801bf300bc Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 18:36:33 -0500 Subject: [PATCH 06/11] Add a slideshow stop button. --- js/lightbox.js | 9 +++++++-- js/lightbox.min.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index bc0afc48..cc445ff7 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -15,7 +15,7 @@ var LightboxOptions = { showImageNumberLabel: true, alwaysShowNavOnTouchDevices: false, wrapAround: false, - autoRotate: false, + autoRotate: 5000, albumLabel: function(curImageNum, albumSize) { return "Image " + curImageNum + " of " + albumSize; } @@ -53,7 +53,7 @@ var LightboxOptions = { // Attach event handlers to the new DOM elements. click click click Lightbox.prototype.build = function() { var self = this; - $("
").appendTo($('body')); + $("
").appendTo($('body')); // Cache jQuery objects this.$lightbox = $('#lightbox'); @@ -165,7 +165,12 @@ var LightboxOptions = { this.changeImage(imageNumber); if (this.options.autoRotate) { + $('.slideshow-stop a').text('Stop Slideshow'); this.autoSlide(); + $('.slideshow-stop a').bind('click.lightbox2', function() { + self.options.autoRotate = false; + clearTimeout(self.autoInterval); + }) } }; diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 670a4e07..93f3c94b 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:!1,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); From 68a81940dc3b90ea4b1a58f30ac06149d6f1deec Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 18:41:47 -0500 Subject: [PATCH 07/11] Fix stop slideshow button. --- js/lightbox.js | 6 +++--- js/lightbox.min.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index cc445ff7..ee81c907 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -53,7 +53,7 @@ var LightboxOptions = { // Attach event handlers to the new DOM elements. click click click Lightbox.prototype.build = function() { var self = this; - $("
").appendTo($('body')); + $("
").appendTo($('body')); // Cache jQuery objects this.$lightbox = $('#lightbox'); @@ -165,9 +165,9 @@ var LightboxOptions = { this.changeImage(imageNumber); if (this.options.autoRotate) { - $('.slideshow-stop a').text('Stop Slideshow'); + $('.slideshow-stop').text('Stop Slideshow'); this.autoSlide(); - $('.slideshow-stop a').bind('click.lightbox2', function() { + $('.slideshow-stop').bind('click.lightbox2', function() { self.options.autoRotate = false; clearTimeout(self.autoInterval); }) diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 93f3c94b..f93dce6a 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); From 139b051602c2e690d2c8f07579ece6423fc46f52 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Mon, 8 Dec 2014 18:43:36 -0500 Subject: [PATCH 08/11] Remove debug code. --- js/lightbox.js | 1 - js/lightbox.min.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index ee81c907..8f7f7901 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -27,7 +27,6 @@ var LightboxOptions = { var Lightbox = (function() { function Lightbox(options) { - console.log(options); this.options = options; this.album = []; this.currentImageIndex = void 0; diff --git a/js/lightbox.min.js b/js/lightbox.min.js index f93dce6a..c4526355 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){console.log(t),this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); From b38245d6016a7672ab75aa1feb27cbc48a16d8cd Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Wed, 10 Dec 2014 12:06:24 -0500 Subject: [PATCH 09/11] Code refinments. --- js/lightbox.js | 4 +--- js/lightbox.min.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index 8f7f7901..a0067103 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -167,7 +167,6 @@ var LightboxOptions = { $('.slideshow-stop').text('Stop Slideshow'); this.autoSlide(); $('.slideshow-stop').bind('click.lightbox2', function() { - self.options.autoRotate = false; clearTimeout(self.autoInterval); }) } @@ -235,7 +234,6 @@ var LightboxOptions = { Lightbox.prototype.next = function(userInput) { userInput = userInput ? userInput : false; if (userInput) { - this.options.autoRotate = false; clearTimeout(this.autoInterval); } if (this.currentImageIndex !== this.album.length - 1) { @@ -249,7 +247,6 @@ var LightboxOptions = { Lightbox.prototype.prev = function(userInput) { userInput = userInput ? userInput : false; if (userInput) { - this.options.autoRotate = false; clearTimeout(this.autoInterval); } if (this.currentImageIndex !== 0) { @@ -425,6 +422,7 @@ var LightboxOptions = { $('select, object, embed').css({ visibility: "visible" }); + clearTimeout(this.autoInterval); }; return Lightbox; diff --git a/js/lightbox.min.js b/js/lightbox.min.js index c4526355..115b0c6a 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&(this.options.autoRotate=!1,clearTimeout(this.autoInterval)),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"})},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"}),clearTimeout(this.autoInterval)},i}();t(function(){new i(LightboxOptions)})}).call(this); From ab12282867cee75a14232dc72892ecfa624ed8f8 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Wed, 10 Dec 2014 16:06:12 -0500 Subject: [PATCH 10/11] Add a start/stop toggle. --- js/lightbox.js | 9 +++++++-- js/lightbox.min.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index a0067103..c5026639 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -14,7 +14,7 @@ var LightboxOptions = { positionFromTop: 50, showImageNumberLabel: true, alwaysShowNavOnTouchDevices: false, - wrapAround: false, + wrapAround: true, autoRotate: 5000, albumLabel: function(curImageNum, albumSize) { return "Image " + curImageNum + " of " + albumSize; @@ -166,8 +166,13 @@ var LightboxOptions = { if (this.options.autoRotate) { $('.slideshow-stop').text('Stop Slideshow'); this.autoSlide(); - $('.slideshow-stop').bind('click.lightbox2', function() { + $('.slideshow-stop').toggle(function() { + $('.slideshow-stop').text('Start Slideshow'); clearTimeout(self.autoInterval); + }, + function() { + $('.slideshow-stop').text('Stop Slideshow'); + self.autoSlide(); }) } }; diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 115b0c6a..401cd81a 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!1,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"}),clearTimeout(this.autoInterval)},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!0,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"}),clearTimeout(this.autoInterval)},i}();t(function(){new i(LightboxOptions)})}).call(this); From 8fdbba347e1abdb66de9c0219c46408fd6875c87 Mon Sep 17 00:00:00 2001 From: Mike DeWolf Date: Thu, 18 Dec 2014 10:35:47 -0500 Subject: [PATCH 11/11] Update lightbox to have stop auto on input option. --- js/lightbox.js | 5 +++-- js/lightbox.min.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/lightbox.js b/js/lightbox.js index c5026639..07511267 100644 --- a/js/lightbox.js +++ b/js/lightbox.js @@ -16,6 +16,7 @@ var LightboxOptions = { alwaysShowNavOnTouchDevices: false, wrapAround: true, autoRotate: 5000, + stopAutoOnInput: false, albumLabel: function(curImageNum, albumSize) { return "Image " + curImageNum + " of " + albumSize; } @@ -238,7 +239,7 @@ var LightboxOptions = { // user, as opposed to autorotation. Lightbox.prototype.next = function(userInput) { userInput = userInput ? userInput : false; - if (userInput) { + if (userInput && this.options.stopAutoOnInput) { clearTimeout(this.autoInterval); } if (this.currentImageIndex !== this.album.length - 1) { @@ -251,7 +252,7 @@ var LightboxOptions = { // Go to the previous slide. Lightbox.prototype.prev = function(userInput) { userInput = userInput ? userInput : false; - if (userInput) { + if (userInput && this.options.stopAutoOnInput) { clearTimeout(this.autoInterval); } if (this.currentImageIndex !== 0) { diff --git a/js/lightbox.min.js b/js/lightbox.min.js index 401cd81a..bb37bf2e 100644 --- a/js/lightbox.min.js +++ b/js/lightbox.min.js @@ -6,4 +6,4 @@ * - Free for use in both personal and commercial projects * - Attribution requires leaving author name, author link, and the license info intact */ -var LightboxOptions={fadeDuration:500,fitImagesInViewport:!0,resizeDuration:700,positionFromTop:50,showImageNumberLabel:!0,alwaysShowNavOnTouchDevices:!1,wrapAround:!0,autoRotate:5e3,albumLabel:function(t,i){return"Image "+t+" of "+i}};(function(){var t=jQuery,i=function(){function i(t){this.options=t,this.album=[],this.currentImageIndex=void 0,this.init()}return i.prototype.init=function(){this.enable(),this.build()},i.prototype.enable=function(){var i=this;t("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(e){return i.start(t(e.currentTarget)),!1})},i.prototype.build=function(){var i=this;t("
").appendTo(t("body")),this.$lightbox=t("#lightbox"),this.$overlay=t("#lightboxOverlay"),this.$outerContainer=this.$lightbox.find(".lb-outerContainer"),this.$container=this.$lightbox.find(".lb-container"),this.containerTopPadding=parseInt(this.$container.css("padding-top"),10),this.containerRightPadding=parseInt(this.$container.css("padding-right"),10),this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10),this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10),this.$overlay.hide().on("click",function(){return i.end(),!1}),this.$lightbox.hide().on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$outerContainer.on("click",function(e){return"lightbox"===t(e.target).attr("id")&&i.end(),!1}),this.$lightbox.find(".lb-prev").on("click",function(){return i.prev(!0),!1}),this.$lightbox.find(".lb-next").on("click",function(){return i.next(!0),!1}),this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){return i.end(),!1})},i.prototype.start=function(i){function e(t){n.album.push({link:t.attr("href"),title:t.attr("data-title")||t.attr("title")})}var n=this,o=t(window);o.on("resize",t.proxy(this.sizeOverlay,this)),t("select, object, embed").css({visibility:"hidden"}),this.sizeOverlay(),this.album=[];var a,s=0,h=i.attr("data-lightbox");if(h){a=t(i.prop("tagName")+'[data-lightbox="'+h+'"]');for(var r=0;rl||o.height>r)&&(o.width/l>o.height/r?(h=l,s=parseInt(o.height/(o.width/h),10),n.width(h),n.height(s)):(s=r,h=parseInt(o.width/(o.height/s),10),n.width(h),n.height(s)))),e.sizeContainer(n.width(),n.height())},o.src=this.album[i].link,this.currentImageIndex=i},i.prototype.next=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),this.currentImageIndex!==this.album.length-1?this.changeImage(this.currentImageIndex+1):this.options.wrapAround&&this.album.length>1&&this.changeImage(0)},i.prototype.prev=function(t){t=t?t:!1,t&&clearTimeout(this.autoInterval),0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1)},i.prototype.autoSlide=function(){if(this.options.autoRotate){var t=this;t.autoInterval=setTimeout(function(){t.next(),t.autoSlide()},this.options.autoRotate)}},i.prototype.sizeOverlay=function(){this.$overlay.width(t(window).width()).height(t(document).height())},i.prototype.sizeContainer=function(t,i){function e(){n.$lightbox.find(".lb-dataContainer").width(s),n.$lightbox.find(".lb-prevLink").height(h),n.$lightbox.find(".lb-nextLink").height(h),n.showImage()}var n=this,o=this.$outerContainer.outerWidth(),a=this.$outerContainer.outerHeight(),s=t+this.containerLeftPadding+this.containerRightPadding,h=i+this.containerTopPadding+this.containerBottomPadding;o!==s||a!==h?this.$outerContainer.animate({width:s,height:h},this.options.resizeDuration,"swing",function(){e()}):e()},i.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide(),this.$lightbox.find(".lb-image").fadeIn("slow"),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},i.prototype.updateNav=function(){var t=!1;try{document.createEvent("TouchEvent"),t=this.options.alwaysShowNavOnTouchDevices?!0:!1}catch(i){}this.$lightbox.find(".lb-nav").show(),this.album.length>1&&(this.options.wrapAround?(t&&this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1"),this.$lightbox.find(".lb-prev, .lb-next").show()):(this.currentImageIndex>0&&(this.$lightbox.find(".lb-prev").show(),t&&this.$lightbox.find(".lb-prev").css("opacity","1")),this.currentImageIndex1&&this.options.showImageNumberLabel?this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast"):this.$lightbox.find(".lb-number").hide(),this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return i.sizeOverlay()})},i.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var t=new Image;t.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var i=new Image;i.src=this.album[this.currentImageIndex-1].link}},i.prototype.enableKeyboardNav=function(){t(document).on("keyup.keyboard",t.proxy(this.keyboardAction,this))},i.prototype.disableKeyboardNav=function(){t(document).off(".keyboard")},i.prototype.keyboardAction=function(t){var i=27,e=37,n=39,o=t.keyCode,a=String.fromCharCode(o).toLowerCase();o===i||a.match(/x|o|c/)?this.end():"p"===a||o===e?this.prev(!0):("n"===a||o===n)&&this.next(!0)},i.prototype.end=function(){this.disableKeyboardNav(),t(window).off("resize",this.sizeOverlay),this.$lightbox.fadeOut(this.options.fadeDuration),this.$overlay.fadeOut(this.options.fadeDuration),t("select, object, embed").css({visibility:"visible"}),clearTimeout(this.autoInterval)},i}();t(function(){new i(LightboxOptions)})}).call(this); +var LightboxOptions={fadeDuration:500,fitImagesInViewport:true,resizeDuration:700,positionFromTop:50,showImageNumberLabel:true,alwaysShowNavOnTouchDevices:false,wrapAround:true,autoRotate:5e3,stopAutoOnInput:false,albumLabel:function(e,t){return"Image "+e+" of "+t}};(function(){var e=jQuery;var t=function(){function t(e){this.options=e;this.album=[];this.currentImageIndex=void 0;this.init()}t.prototype.init=function(){this.enable();this.build()};t.prototype.enable=function(){var t=this;e("body").on("click","a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]",function(n){t.start(e(n.currentTarget));return false})};t.prototype.build=function(){var t=this;e("
").appendTo(e("body"));this.$lightbox=e("#lightbox");this.$overlay=e("#lightboxOverlay");this.$outerContainer=this.$lightbox.find(".lb-outerContainer");this.$container=this.$lightbox.find(".lb-container");this.containerTopPadding=parseInt(this.$container.css("padding-top"),10);this.containerRightPadding=parseInt(this.$container.css("padding-right"),10);this.containerBottomPadding=parseInt(this.$container.css("padding-bottom"),10);this.containerLeftPadding=parseInt(this.$container.css("padding-left"),10);this.$overlay.hide().on("click",function(){t.end();return false});this.$lightbox.hide().on("click",function(n){if(e(n.target).attr("id")==="lightbox"){t.end()}return false});this.$outerContainer.on("click",function(n){if(e(n.target).attr("id")==="lightbox"){t.end()}return false});this.$lightbox.find(".lb-prev").on("click",function(){t.prev(true);return false});this.$lightbox.find(".lb-next").on("click",function(){t.next(true);return false});this.$lightbox.find(".lb-loader, .lb-close").on("click",function(){t.end();return false})};t.prototype.start=function(t){function s(e){n.album.push({link:e.attr("href"),title:e.attr("data-title")||e.attr("title")})}var n=this;var r=e(window);r.on("resize",e.proxy(this.sizeOverlay,this));e("select, object, embed").css({visibility:"hidden"});this.sizeOverlay();this.album=[];var i=0;var o=t.attr("data-lightbox");var u;if(o){u=e(t.prop("tagName")+'[data-lightbox="'+o+'"]');for(var a=0;af||i.height>a){if(i.width/f>i.height/a){u=f;o=parseInt(i.height/(i.width/u),10);r.width(u);r.height(o)}else{o=a;u=parseInt(i.width/(i.height/o),10);r.width(u);r.height(o)}}}n.sizeContainer(r.width(),r.height())};i.src=this.album[t].link;this.currentImageIndex=t};t.prototype.next=function(e){e=e?e:false;if(e&&this.options.stopAutoOnInput){clearTimeout(this.autoInterval)}if(this.currentImageIndex!==this.album.length-1){this.changeImage(this.currentImageIndex+1)}else if(this.options.wrapAround&&this.album.length>1){this.changeImage(0)}};t.prototype.prev=function(e){e=e?e:false;if(e&&this.options.stopAutoOnInput){clearTimeout(this.autoInterval)}if(this.currentImageIndex!==0){this.changeImage(this.currentImageIndex-1)}else if(this.options.wrapAround&&this.album.length>1){this.changeImage(this.album.length-1)}};t.prototype.autoSlide=function(){if(!this.options.autoRotate){return}var e=this;e.autoInterval=setTimeout(function(){e.next();e.autoSlide()},this.options.autoRotate)};t.prototype.sizeOverlay=function(){this.$overlay.width(e(window).width()).height(e(document).height())};t.prototype.sizeContainer=function(e,t){function u(){n.$lightbox.find(".lb-dataContainer").width(s);n.$lightbox.find(".lb-prevLink").height(o);n.$lightbox.find(".lb-nextLink").height(o);n.showImage()}var n=this;var r=this.$outerContainer.outerWidth();var i=this.$outerContainer.outerHeight();var s=e+this.containerLeftPadding+this.containerRightPadding;var o=t+this.containerTopPadding+this.containerBottomPadding;if(r!==s||i!==o){this.$outerContainer.animate({width:s,height:o},this.options.resizeDuration,"swing",function(){u()})}else{u()}};t.prototype.showImage=function(){this.$lightbox.find(".lb-loader").hide();this.$lightbox.find(".lb-image").fadeIn("slow");this.updateNav();this.updateDetails();this.preloadNeighboringImages();this.enableKeyboardNav()};t.prototype.updateNav=function(){var e=false;try{document.createEvent("TouchEvent");e=this.options.alwaysShowNavOnTouchDevices?true:false}catch(t){}this.$lightbox.find(".lb-nav").show();if(this.album.length>1){if(this.options.wrapAround){if(e){this.$lightbox.find(".lb-prev, .lb-next").css("opacity","1")}this.$lightbox.find(".lb-prev, .lb-next").show()}else{if(this.currentImageIndex>0){this.$lightbox.find(".lb-prev").show();if(e){this.$lightbox.find(".lb-prev").css("opacity","1")}}if(this.currentImageIndex1&&this.options.showImageNumberLabel){this.$lightbox.find(".lb-number").text(this.options.albumLabel(this.currentImageIndex+1,this.album.length)).fadeIn("fast")}else{this.$lightbox.find(".lb-number").hide()}this.$outerContainer.removeClass("animating");this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return t.sizeOverlay()})};t.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){var e=new Image;e.src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){var t=new Image;t.src=this.album[this.currentImageIndex-1].link}};t.prototype.enableKeyboardNav=function(){e(document).on("keyup.keyboard",e.proxy(this.keyboardAction,this))};t.prototype.disableKeyboardNav=function(){e(document).off(".keyboard")};t.prototype.keyboardAction=function(e){var t=27;var n=37;var r=39;var i=e.keyCode;var s=String.fromCharCode(i).toLowerCase();if(i===t||s.match(/x|o|c/)){this.end()}else if(s==="p"||i===n){this.prev(true)}else if(s==="n"||i===r){this.next(true)}};t.prototype.end=function(){this.disableKeyboardNav();e(window).off("resize",this.sizeOverlay);this.$lightbox.fadeOut(this.options.fadeDuration);this.$overlay.fadeOut(this.options.fadeDuration);e("select, object, embed").css({visibility:"visible"});clearTimeout(this.autoInterval)};return t}();e(function(){var e=new t(LightboxOptions)})}).call(this)