Comparing version 2.10.0 to 2.11.0
@@ -1,4 +0,4 @@ | ||
> Pull Requests are welcome. But note that v2 of Lightbox is in Maintenance Mode and no new features | ||
> will be added. See the [Roadmap](https://github.com/lokesh/lightbox2/blob/master/ROADMAP.md). | ||
> Pull Requests are welcome. But v2 of Lightbox is in Maintenance Mode. | ||
> No new features are planned. See the [Roadmap](https://github.com/lokesh/lightbox2/blob/master/ROADMAP.md). | ||
> | ||
> PRs submitted will still be reviewed and then kept open for other users to utilize. | ||
> PRs submitted will still be reviewed and kept open for others to utilize. |
@@ -1,8 +0,15 @@ | ||
## How to make a release and deploy | ||
## How to Make a Release | ||
### Build | ||
- **Checkout dev branch.** This will contain work queued up for the next release. | ||
- **Update version number.** Manually update version number in `src/lightbox.js` and `package.json`. Don't use `npm version`. | ||
- **Run `grunt build`.** Make sure you have run `bower install` ahead of this as it will pull down jQuery which is utilized in the build step. | ||
- **`grunt build`.** Make sure you have run `bower install` ahead of this as it will pull down jQuery which is utilized in the build step. | ||
- **Merge to `master`.** Commit changes and push to new branch. Create PR from this branch to `master`. Merge. | ||
- **Create tagged release.** Go to [Github Releases page](https://github.com/lokesh/lightbox2/releases). Draft a new release. Naming convention is `v2.8.1`. | ||
- Run `npm publish` | ||
### Release | ||
- **Create tagged release.** Go to [Github Releases page](https://github.com/lokesh/lightbox2/releases). Draft a new release. Naming convention is `v2.8.1`. Add notes that link to PRs. | ||
- **`npm publish`**. No need to do anything for Bower as it is entirely based on the Github repo. | ||
### Maintenance and Docs | ||
- **GH clean-up.** Close out issues with `[status] pending release`. | ||
- **Lightbox Site.** If there are any changes to the options, don't forget to update the [Lightbox Site](http://localhost:8000/dist/#options). The code lives in a separate repo, [lightbox2-site](https://github.com/lokesh/lightbox2-site/). |
/*! | ||
* Lightbox v2.10.0 | ||
* Lightbox v2.11.0 | ||
* by Lokesh Dhakar | ||
@@ -8,3 +8,3 @@ * | ||
* | ||
* Copyright 2007, 2018 Lokesh Dhakar | ||
* Copyright Lokesh Dhakar | ||
* Released under the MIT license | ||
@@ -103,3 +103,3 @@ * https://github.com/lokesh/lightbox2/blob/master/LICENSE | ||
var self = this; | ||
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body')); | ||
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt=""/><div class="lb-nav"><a class="lb-prev" aria-label="Previous image" href="" ></a><a class="lb-next" aria-label="Next image" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body')); | ||
@@ -139,3 +139,2 @@ // Cache jQuery objects | ||
} | ||
return false; | ||
}); | ||
@@ -207,6 +206,2 @@ | ||
$('select, object, embed').css({ | ||
visibility: 'hidden' | ||
}); | ||
this.sizeOverlay(); | ||
@@ -263,3 +258,3 @@ | ||
if (this.options.disableScrolling) { | ||
$('html').addClass('lb-disable-scrolling'); | ||
$('body').addClass('lb-disable-scrolling'); | ||
} | ||
@@ -273,11 +268,13 @@ | ||
var self = this; | ||
var filename = this.album[imageNumber].link; | ||
var filetype = filename.split('.').slice(-1)[0]; | ||
var $image = this.$lightbox.find('.lb-image'); | ||
// Disable keyboard nav during transitions | ||
this.disableKeyboardNav(); | ||
var $image = this.$lightbox.find('.lb-image'); | ||
// Show loading state | ||
this.$overlay.fadeIn(this.options.fadeDuration); | ||
$('.lb-loader').fadeIn('slow'); | ||
this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); | ||
this.$outerContainer.addClass('animating'); | ||
@@ -298,3 +295,3 @@ | ||
'alt': self.album[imageNumber].alt, | ||
'src': self.album[imageNumber].link | ||
'src': filename | ||
}); | ||
@@ -306,12 +303,28 @@ | ||
$image.height(preloader.height); | ||
windowWidth = $(window).width(); | ||
windowHeight = $(window).height(); | ||
// Calculate the max image dimensions for the current viewport. | ||
// Take into account the border around the image and an additional 10px gutter on each side. | ||
maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; | ||
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - self.options.positionFromTop - 70; | ||
/* | ||
SVGs that don't have width and height attributes specified are reporting width and height | ||
values of 0 in Firefox 47 and IE11 on Windows. To fix, we set the width and height to the max | ||
dimensions for the viewport rather than 0 x 0. | ||
https://github.com/lokesh/lightbox2/issues/552 | ||
*/ | ||
if (filetype === 'svg') { | ||
if ((preloader.width === 0) || preloader.height === 0) { | ||
$image.width(maxImageWidth); | ||
$image.height(maxImageHeight); | ||
} | ||
} | ||
// Fit image inside the viewport. | ||
if (self.options.fitImagesInViewport) { | ||
// Fit image inside the viewport. | ||
// Take into account the border around the image and an additional 10px gutter on each side. | ||
windowWidth = $(window).width(); | ||
windowHeight = $(window).height(); | ||
maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; | ||
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120; | ||
// Check if image size is larger then maxWidth|maxHeight in settings | ||
@@ -344,3 +357,4 @@ if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) { | ||
preloader.src = this.album[imageNumber].link; | ||
// Preload image before showing | ||
preloader.src = this.album[imageNumber].link; | ||
this.currentImageIndex = imageNumber; | ||
@@ -351,8 +365,20 @@ }; | ||
Lightbox.prototype.sizeOverlay = function() { | ||
this.$overlay | ||
.width($(document).width()) | ||
.height($(document).height()); | ||
var self = this; | ||
/* | ||
We use a setTimeout 0 to pause JS execution and let the rendering catch-up. | ||
Why do this? If the `disableScrolling` option is set to true, a class is added to the body | ||
tag that disables scrolling and hides the scrollbar. We want to make sure the scrollbar is | ||
hidden before we measure the document width, as the presence of the scrollbar will affect the | ||
number. | ||
*/ | ||
setTimeout(function() { | ||
self.$overlay | ||
.width($(document).width()) | ||
.height($(document).height()); | ||
}, 0); | ||
}; | ||
// Animate the size of the lightbox to fit the image we are showing | ||
// This method also shows the the image. | ||
Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) { | ||
@@ -446,10 +472,3 @@ var self = this; | ||
} | ||
$caption.fadeIn('fast') | ||
.find('a').on('click', function(event) { | ||
if ($(this).attr('target') !== undefined) { | ||
window.open($(this).attr('href'), $(this).attr('target')); | ||
} else { | ||
location.href = $(this).attr('href'); | ||
} | ||
}); | ||
$caption.fadeIn('fast'); | ||
} | ||
@@ -497,6 +516,5 @@ | ||
var keycode = event.keyCode; | ||
var key = String.fromCharCode(keycode).toLowerCase(); | ||
if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) { | ||
if (keycode === KEYCODE_ESC) { | ||
this.end(); | ||
} else if (key === 'p' || keycode === KEYCODE_LEFTARROW) { | ||
} else if (keycode === KEYCODE_LEFTARROW) { | ||
if (this.currentImageIndex !== 0) { | ||
@@ -507,3 +525,3 @@ this.changeImage(this.currentImageIndex - 1); | ||
} | ||
} else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) { | ||
} else if (keycode === KEYCODE_RIGHTARROW) { | ||
if (this.currentImageIndex !== this.album.length - 1) { | ||
@@ -523,7 +541,5 @@ this.changeImage(this.currentImageIndex + 1); | ||
this.$overlay.fadeOut(this.options.fadeDuration); | ||
$('select, object, embed').css({ | ||
visibility: 'visible' | ||
}); | ||
if (this.options.disableScrolling) { | ||
$('html').removeClass('lb-disable-scrolling'); | ||
$('body').removeClass('lb-disable-scrolling'); | ||
} | ||
@@ -530,0 +546,0 @@ }; |
/*! | ||
* Lightbox v2.10.0 | ||
* Lightbox v2.11.0 | ||
* by Lokesh Dhakar | ||
@@ -8,3 +8,3 @@ * | ||
* | ||
* Copyright 2007, 2018 Lokesh Dhakar | ||
* Copyright Lokesh Dhakar | ||
* Released under the MIT license | ||
@@ -15,3 +15,3 @@ * https://github.com/lokesh/lightbox2/blob/master/LICENSE | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):a.lightbox=b(a.jQuery)}(this,function(a){function b(b){this.album=[],this.currentImageIndex=void 0,this.init(),this.options=a.extend({},this.constructor.defaults),this.option(b)}return b.defaults={albumLabel:"Image %1 of %2",alwaysShowNavOnTouchDevices:!1,fadeDuration:600,fitImagesInViewport:!0,imageFadeDuration:600,positionFromTop:50,resizeDuration:700,showImageNumberLabel:!0,wrapAround:!1,disableScrolling:!1,sanitizeTitle:!1},b.prototype.option=function(b){a.extend(this.options,b)},b.prototype.imageCountLabel=function(a,b){return this.options.albumLabel.replace(/%1/g,a).replace(/%2/g,b)},b.prototype.init=function(){var b=this;a(document).ready(function(){b.enable(),b.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(){if(!(a("#lightbox").length>0)){var b=this;a('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').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.$image=this.$lightbox.find(".lb-image"),this.$nav=this.$lightbox.find(".lb-nav"),this.containerPadding={top:parseInt(this.$container.css("padding-top"),10),right:parseInt(this.$container.css("padding-right"),10),bottom:parseInt(this.$container.css("padding-bottom"),10),left:parseInt(this.$container.css("padding-left"),10)},this.imageBorderWidth={top:parseInt(this.$image.css("border-top-width"),10),right:parseInt(this.$image.css("border-right-width"),10),bottom:parseInt(this.$image.css("border-bottom-width"),10),left:parseInt(this.$image.css("border-left-width"),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 0===b.currentImageIndex?b.changeImage(b.album.length-1):b.changeImage(b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.currentImageIndex===b.album.length-1?b.changeImage(0):b.changeImage(b.currentImageIndex+1),!1}),this.$nav.on("mousedown",function(a){3===a.which&&(b.$nav.css("pointer-events","none"),b.$lightbox.one("contextmenu",function(){setTimeout(function(){this.$nav.css("pointer-events","auto")}.bind(b),0)}))}),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({alt:a.attr("data-alt"),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;i<f.length;i=++i)c(a(f[i])),f[i]===b[0]&&(g=i)}else if("lightbox"===b.attr("rel"))c(b);else{f=a(b.prop("tagName")+'[rel="'+b.attr("rel")+'"]');for(var j=0;j<f.length;j=++j)c(a(f[j])),f[j]===b[0]&&(g=j)}var k=e.scrollTop()+this.options.positionFromTop,l=e.scrollLeft();this.$lightbox.css({top:k+"px",left:l+"px"}).fadeIn(this.options.fadeDuration),this.options.disableScrolling&&a("html").addClass("lb-disable-scrolling"),this.changeImage(g)},b.prototype.changeImage=function(b){var c=this;this.disableKeyboardNav();var d=this.$lightbox.find(".lb-image");this.$overlay.fadeIn(this.options.fadeDuration),a(".lb-loader").fadeIn("slow"),this.$lightbox.find(".lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption").hide(),this.$outerContainer.addClass("animating");var e=new Image;e.onload=function(){var f,g,h,i,j,k;d.attr({alt:c.album[b].alt,src:c.album[b].link}),a(e),d.width(e.width),d.height(e.height),c.options.fitImagesInViewport&&(k=a(window).width(),j=a(window).height(),i=k-c.containerPadding.left-c.containerPadding.right-c.imageBorderWidth.left-c.imageBorderWidth.right-20,h=j-c.containerPadding.top-c.containerPadding.bottom-c.imageBorderWidth.top-c.imageBorderWidth.bottom-120,c.options.maxWidth&&c.options.maxWidth<i&&(i=c.options.maxWidth),c.options.maxHeight&&c.options.maxHeight<i&&(h=c.options.maxHeight),(e.width>i||e.height>h)&&(e.width/i>e.height/h?(g=i,f=parseInt(e.height/(e.width/g),10),d.width(g),d.height(f)):(f=h,g=parseInt(e.width/(e.height/f),10),d.width(g),d.height(f)))),c.sizeContainer(d.width(),d.height())},e.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){this.$overlay.width(a(document).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.containerPadding.left+this.containerPadding.right+this.imageBorderWidth.left+this.imageBorderWidth.right,h=b+this.containerPadding.top+this.containerPadding.bottom+this.imageBorderWidth.top+this.imageBorderWidth.bottom;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").stop(!0).hide(),this.$lightbox.find(".lb-image").fadeIn(this.options.imageFadeDuration),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=!!this.options.alwaysShowNavOnTouchDevices}catch(a){}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.currentImageIndex<this.album.length-1&&(this.$lightbox.find(".lb-next").show(),a&&this.$lightbox.find(".lb-next").css("opacity","1"))))},b.prototype.updateDetails=function(){var b=this;if(void 0!==this.album[this.currentImageIndex].title&&""!==this.album[this.currentImageIndex].title){var c=this.$lightbox.find(".lb-caption");this.options.sanitizeTitle?c.text(this.album[this.currentImageIndex].title):c.html(this.album[this.currentImageIndex].title),c.fadeIn("fast").find("a").on("click",function(b){void 0!==a(this).attr("target")?window.open(a(this).attr("href"),a(this).attr("target")):location.href=a(this).attr("href")})}if(this.album.length>1&&this.options.showImageNumberLabel){var d=this.imageCountLabel(this.currentImageIndex+1,this.album.length);this.$lightbox.find(".lb-number").text(d).fadeIn("fast")}else 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){(new Image).src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){(new Image).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=a.keyCode,c=String.fromCharCode(b).toLowerCase();27===b||c.match(/x|o|c/)?this.end():"p"===c||37===b?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):"n"!==c&&39!==b||(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"}),this.options.disableScrolling&&a("html").removeClass("lb-disable-scrolling")},new b}); | ||
!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?module.exports=b(require("jquery")):a.lightbox=b(a.jQuery)}(this,function(a){function b(b){this.album=[],this.currentImageIndex=void 0,this.init(),this.options=a.extend({},this.constructor.defaults),this.option(b)}return b.defaults={albumLabel:"Image %1 of %2",alwaysShowNavOnTouchDevices:!1,fadeDuration:600,fitImagesInViewport:!0,imageFadeDuration:600,positionFromTop:50,resizeDuration:700,showImageNumberLabel:!0,wrapAround:!1,disableScrolling:!1,sanitizeTitle:!1},b.prototype.option=function(b){a.extend(this.options,b)},b.prototype.imageCountLabel=function(a,b){return this.options.albumLabel.replace(/%1/g,a).replace(/%2/g,b)},b.prototype.init=function(){var b=this;a(document).ready(function(){b.enable(),b.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(){if(!(a("#lightbox").length>0)){var b=this;a('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt=""/><div class="lb-nav"><a class="lb-prev" aria-label="Previous image" href="" ></a><a class="lb-next" aria-label="Next image" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').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.$image=this.$lightbox.find(".lb-image"),this.$nav=this.$lightbox.find(".lb-nav"),this.containerPadding={top:parseInt(this.$container.css("padding-top"),10),right:parseInt(this.$container.css("padding-right"),10),bottom:parseInt(this.$container.css("padding-bottom"),10),left:parseInt(this.$container.css("padding-left"),10)},this.imageBorderWidth={top:parseInt(this.$image.css("border-top-width"),10),right:parseInt(this.$image.css("border-right-width"),10),bottom:parseInt(this.$image.css("border-bottom-width"),10),left:parseInt(this.$image.css("border-left-width"),10)},this.$overlay.hide().on("click",function(){return b.end(),!1}),this.$lightbox.hide().on("click",function(c){"lightbox"===a(c.target).attr("id")&&b.end()}),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 0===b.currentImageIndex?b.changeImage(b.album.length-1):b.changeImage(b.currentImageIndex-1),!1}),this.$lightbox.find(".lb-next").on("click",function(){return b.currentImageIndex===b.album.length-1?b.changeImage(0):b.changeImage(b.currentImageIndex+1),!1}),this.$nav.on("mousedown",function(a){3===a.which&&(b.$nav.css("pointer-events","none"),b.$lightbox.one("contextmenu",function(){setTimeout(function(){this.$nav.css("pointer-events","auto")}.bind(b),0)}))}),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({alt:a.attr("data-alt"),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)),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;i<f.length;i=++i)c(a(f[i])),f[i]===b[0]&&(g=i)}else if("lightbox"===b.attr("rel"))c(b);else{f=a(b.prop("tagName")+'[rel="'+b.attr("rel")+'"]');for(var j=0;j<f.length;j=++j)c(a(f[j])),f[j]===b[0]&&(g=j)}var k=e.scrollTop()+this.options.positionFromTop,l=e.scrollLeft();this.$lightbox.css({top:k+"px",left:l+"px"}).fadeIn(this.options.fadeDuration),this.options.disableScrolling&&a("body").addClass("lb-disable-scrolling"),this.changeImage(g)},b.prototype.changeImage=function(b){var c=this,d=this.album[b].link,e=d.split(".").slice(-1)[0],f=this.$lightbox.find(".lb-image");this.disableKeyboardNav(),this.$overlay.fadeIn(this.options.fadeDuration),a(".lb-loader").fadeIn("slow"),this.$lightbox.find(".lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption").hide(),this.$outerContainer.addClass("animating");var g=new Image;g.onload=function(){var h,i,j,k,l,m;f.attr({alt:c.album[b].alt,src:d}),a(g),f.width(g.width),f.height(g.height),m=a(window).width(),l=a(window).height(),k=m-c.containerPadding.left-c.containerPadding.right-c.imageBorderWidth.left-c.imageBorderWidth.right-20,j=l-c.containerPadding.top-c.containerPadding.bottom-c.imageBorderWidth.top-c.imageBorderWidth.bottom-c.options.positionFromTop-70,"svg"===e&&(0!==g.width&&0!==g.height||(f.width(k),f.height(j))),c.options.fitImagesInViewport&&(c.options.maxWidth&&c.options.maxWidth<k&&(k=c.options.maxWidth),c.options.maxHeight&&c.options.maxHeight<k&&(j=c.options.maxHeight),(g.width>k||g.height>j)&&(g.width/k>g.height/j?(i=k,h=parseInt(g.height/(g.width/i),10),f.width(i),f.height(h)):(h=j,i=parseInt(g.width/(g.height/h),10),f.width(i),f.height(h)))),c.sizeContainer(f.width(),f.height())},g.src=this.album[b].link,this.currentImageIndex=b},b.prototype.sizeOverlay=function(){var b=this;setTimeout(function(){b.$overlay.width(a(document).width()).height(a(document).height())},0)},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.containerPadding.left+this.containerPadding.right+this.imageBorderWidth.left+this.imageBorderWidth.right,h=b+this.containerPadding.top+this.containerPadding.bottom+this.imageBorderWidth.top+this.imageBorderWidth.bottom;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").stop(!0).hide(),this.$lightbox.find(".lb-image").fadeIn(this.options.imageFadeDuration),this.updateNav(),this.updateDetails(),this.preloadNeighboringImages(),this.enableKeyboardNav()},b.prototype.updateNav=function(){var a=!1;try{document.createEvent("TouchEvent"),a=!!this.options.alwaysShowNavOnTouchDevices}catch(a){}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.currentImageIndex<this.album.length-1&&(this.$lightbox.find(".lb-next").show(),a&&this.$lightbox.find(".lb-next").css("opacity","1"))))},b.prototype.updateDetails=function(){var a=this;if(void 0!==this.album[this.currentImageIndex].title&&""!==this.album[this.currentImageIndex].title){var b=this.$lightbox.find(".lb-caption");this.options.sanitizeTitle?b.text(this.album[this.currentImageIndex].title):b.html(this.album[this.currentImageIndex].title),b.fadeIn("fast")}if(this.album.length>1&&this.options.showImageNumberLabel){var c=this.imageCountLabel(this.currentImageIndex+1,this.album.length);this.$lightbox.find(".lb-number").text(c).fadeIn("fast")}else this.$lightbox.find(".lb-number").hide();this.$outerContainer.removeClass("animating"),this.$lightbox.find(".lb-dataContainer").fadeIn(this.options.resizeDuration,function(){return a.sizeOverlay()})},b.prototype.preloadNeighboringImages=function(){if(this.album.length>this.currentImageIndex+1){(new Image).src=this.album[this.currentImageIndex+1].link}if(this.currentImageIndex>0){(new Image).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=a.keyCode;27===b?this.end():37===b?0!==this.currentImageIndex?this.changeImage(this.currentImageIndex-1):this.options.wrapAround&&this.album.length>1&&this.changeImage(this.album.length-1):39===b&&(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),this.options.disableScrolling&&a("body").removeClass("lb-disable-scrolling")},new b}); | ||
//# sourceMappingURL=lightbox.min.map |
{ | ||
"name": "lightbox2", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"author": "Lokesh Dhakar <lokesh.dhakar@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "The original Lightbox script. Uses jQuery.", |
@@ -16,5 +16,16 @@ # Lightbox2 | ||
### Info for Maintainers | ||
## Info for Maintainers | ||
- **Issues and PRs requiring review.** See items tagged with [\[status\] needs review](https://github.com/lokesh/lightbox2/labels/%5Bstatus%5D%20needs%20review) | ||
- **Questions on Stackoverflow.** See Questions tagged with [lightbox2](https://stackoverflow.com/questions/tagged/lightbox2). | ||
- **Release instructions.** See [DEPLOY.md](https://github.com/lokesh/lightbox2/blob/master/DEPLOY.md). | ||
- **Issues and PRs requiring review.** See items tagged with [\[status\] needs review](https://github.com/lokesh/lightbox2/labels/%5Bstatus%5D%20needs%20review) | ||
### Local development | ||
- Install [Bower](https://bower.io/) and [Grunt](https://gruntjs.com/). | ||
- Install jQuery dependency with Bower: `bower install` | ||
- Start local server: `grunt` | ||
- Navigate to `localhost:8000/examples` | ||
- Update `examples/index.html` to load `src/js/lightbox.js` and jQuery. | ||
/*! | ||
* Lightbox v2.10.0 | ||
* Lightbox v2.11.0 | ||
* by Lokesh Dhakar | ||
@@ -8,3 +8,3 @@ * | ||
* | ||
* Copyright 2007, 2018 Lokesh Dhakar | ||
* Copyright Lokesh Dhakar | ||
* Released under the MIT license | ||
@@ -103,3 +103,3 @@ * https://github.com/lokesh/lightbox2/blob/master/LICENSE | ||
var self = this; | ||
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" /><div class="lb-nav"><a class="lb-prev" href="" ></a><a class="lb-next" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body')); | ||
$('<div id="lightboxOverlay" class="lightboxOverlay"></div><div id="lightbox" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt=""/><div class="lb-nav"><a class="lb-prev" aria-label="Previous image" href="" ></a><a class="lb-next" aria-label="Next image" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body')); | ||
@@ -139,3 +139,2 @@ // Cache jQuery objects | ||
} | ||
return false; | ||
}); | ||
@@ -207,6 +206,2 @@ | ||
$('select, object, embed').css({ | ||
visibility: 'hidden' | ||
}); | ||
this.sizeOverlay(); | ||
@@ -263,3 +258,3 @@ | ||
if (this.options.disableScrolling) { | ||
$('html').addClass('lb-disable-scrolling'); | ||
$('body').addClass('lb-disable-scrolling'); | ||
} | ||
@@ -273,11 +268,13 @@ | ||
var self = this; | ||
var filename = this.album[imageNumber].link; | ||
var filetype = filename.split('.').slice(-1)[0]; | ||
var $image = this.$lightbox.find('.lb-image'); | ||
// Disable keyboard nav during transitions | ||
this.disableKeyboardNav(); | ||
var $image = this.$lightbox.find('.lb-image'); | ||
// Show loading state | ||
this.$overlay.fadeIn(this.options.fadeDuration); | ||
$('.lb-loader').fadeIn('slow'); | ||
this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); | ||
this.$outerContainer.addClass('animating'); | ||
@@ -298,3 +295,3 @@ | ||
'alt': self.album[imageNumber].alt, | ||
'src': self.album[imageNumber].link | ||
'src': filename | ||
}); | ||
@@ -306,12 +303,28 @@ | ||
$image.height(preloader.height); | ||
windowWidth = $(window).width(); | ||
windowHeight = $(window).height(); | ||
// Calculate the max image dimensions for the current viewport. | ||
// Take into account the border around the image and an additional 10px gutter on each side. | ||
maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; | ||
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - self.options.positionFromTop - 70; | ||
/* | ||
SVGs that don't have width and height attributes specified are reporting width and height | ||
values of 0 in Firefox 47 and IE11 on Windows. To fix, we set the width and height to the max | ||
dimensions for the viewport rather than 0 x 0. | ||
https://github.com/lokesh/lightbox2/issues/552 | ||
*/ | ||
if (filetype === 'svg') { | ||
if ((preloader.width === 0) || preloader.height === 0) { | ||
$image.width(maxImageWidth); | ||
$image.height(maxImageHeight); | ||
} | ||
} | ||
// Fit image inside the viewport. | ||
if (self.options.fitImagesInViewport) { | ||
// Fit image inside the viewport. | ||
// Take into account the border around the image and an additional 10px gutter on each side. | ||
windowWidth = $(window).width(); | ||
windowHeight = $(window).height(); | ||
maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; | ||
maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - 120; | ||
// Check if image size is larger then maxWidth|maxHeight in settings | ||
@@ -344,3 +357,4 @@ if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) { | ||
preloader.src = this.album[imageNumber].link; | ||
// Preload image before showing | ||
preloader.src = this.album[imageNumber].link; | ||
this.currentImageIndex = imageNumber; | ||
@@ -351,8 +365,20 @@ }; | ||
Lightbox.prototype.sizeOverlay = function() { | ||
this.$overlay | ||
.width($(document).width()) | ||
.height($(document).height()); | ||
var self = this; | ||
/* | ||
We use a setTimeout 0 to pause JS execution and let the rendering catch-up. | ||
Why do this? If the `disableScrolling` option is set to true, a class is added to the body | ||
tag that disables scrolling and hides the scrollbar. We want to make sure the scrollbar is | ||
hidden before we measure the document width, as the presence of the scrollbar will affect the | ||
number. | ||
*/ | ||
setTimeout(function() { | ||
self.$overlay | ||
.width($(document).width()) | ||
.height($(document).height()); | ||
}, 0); | ||
}; | ||
// Animate the size of the lightbox to fit the image we are showing | ||
// This method also shows the the image. | ||
Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) { | ||
@@ -446,10 +472,3 @@ var self = this; | ||
} | ||
$caption.fadeIn('fast') | ||
.find('a').on('click', function(event) { | ||
if ($(this).attr('target') !== undefined) { | ||
window.open($(this).attr('href'), $(this).attr('target')); | ||
} else { | ||
location.href = $(this).attr('href'); | ||
} | ||
}); | ||
$caption.fadeIn('fast'); | ||
} | ||
@@ -497,6 +516,5 @@ | ||
var keycode = event.keyCode; | ||
var key = String.fromCharCode(keycode).toLowerCase(); | ||
if (keycode === KEYCODE_ESC || key.match(/x|o|c/)) { | ||
if (keycode === KEYCODE_ESC) { | ||
this.end(); | ||
} else if (key === 'p' || keycode === KEYCODE_LEFTARROW) { | ||
} else if (keycode === KEYCODE_LEFTARROW) { | ||
if (this.currentImageIndex !== 0) { | ||
@@ -507,3 +525,3 @@ this.changeImage(this.currentImageIndex - 1); | ||
} | ||
} else if (key === 'n' || keycode === KEYCODE_RIGHTARROW) { | ||
} else if (keycode === KEYCODE_RIGHTARROW) { | ||
if (this.currentImageIndex !== this.album.length - 1) { | ||
@@ -523,7 +541,5 @@ this.changeImage(this.currentImageIndex + 1); | ||
this.$overlay.fadeOut(this.options.fadeDuration); | ||
$('select, object, embed').css({ | ||
visibility: 'visible' | ||
}); | ||
if (this.options.disableScrolling) { | ||
$('html').removeClass('lb-disable-scrolling'); | ||
$('body').removeClass('lb-disable-scrolling'); | ||
} | ||
@@ -530,0 +546,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
630650
10624
31