@@ -9210,7 +9210,7 @@ return jQuery;
92109210} ) ) ;
92119211
92129212/*!
9213- * Lightbox v2.8.2
9213+ * Lightbox v2.9.0
92149214 * by Lokesh Dhakar
92159215 *
92169216 * More info:
@@ -9252,15 +9252,25 @@ return jQuery;
92529252 Lightbox . defaults = {
92539253 albumLabel : 'Image %1 of %2' ,
92549254 alwaysShowNavOnTouchDevices : false ,
9255- fadeDuration : 500 ,
9255+ fadeDuration : 600 ,
92569256 fitImagesInViewport : true ,
9257+ imageFadeDuration : 600 ,
92579258 // maxWidth: 800,
92589259 // maxHeight: 600,
92599260 positionFromTop : 50 ,
92609261 resizeDuration : 700 ,
92619262 showImageNumberLabel : true ,
92629263 wrapAround : false ,
9263- disableScrolling : false
9264+ disableScrolling : false ,
9265+ /*
9266+ Sanitize Title
9267+ If the caption data is trusted, for example you are hardcoding it in, then leave this to false.
9268+ This will free you to add html tags, such as links, in the caption.
9269+
9270+ If the caption data is user submitted or from some other untrusted source, then set this to true
9271+ to prevent xss and other injection attacks.
9272+ */
9273+ sanitizeTitle : false
92649274 } ;
92659275
92669276 Lightbox . prototype . option = function ( options ) {
@@ -9272,8 +9282,12 @@ return jQuery;
92729282 } ;
92739283
92749284 Lightbox . prototype . init = function ( ) {
9275- this . enable ( ) ;
9276- this . build ( ) ;
9285+ var self = this ;
9286+ // Both enable and build methods require the body tag to be in the DOM.
9287+ $ ( document ) . ready ( function ( ) {
9288+ self . enable ( ) ;
9289+ self . build ( ) ;
9290+ } ) ;
92779291 } ;
92789292
92799293 // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
@@ -9297,12 +9311,23 @@ return jQuery;
92979311 this . $overlay = $ ( '#lightboxOverlay' ) ;
92989312 this . $outerContainer = this . $lightbox . find ( '.lb-outerContainer' ) ;
92999313 this . $container = this . $lightbox . find ( '.lb-container' ) ;
9314+ this . $image = this . $lightbox . find ( '.lb-image' ) ;
9315+ this . $nav = this . $lightbox . find ( '.lb-nav' ) ;
93009316
93019317 // Store css values for future lookup
9302- this . containerTopPadding = parseInt ( this . $container . css ( 'padding-top' ) , 10 ) ;
9303- this . containerRightPadding = parseInt ( this . $container . css ( 'padding-right' ) , 10 ) ;
9304- this . containerBottomPadding = parseInt ( this . $container . css ( 'padding-bottom' ) , 10 ) ;
9305- this . containerLeftPadding = parseInt ( this . $container . css ( 'padding-left' ) , 10 ) ;
9318+ this . containerPadding = {
9319+ top : parseInt ( this . $container . css ( 'padding-top' ) , 10 ) ,
9320+ right : parseInt ( this . $container . css ( 'padding-right' ) , 10 ) ,
9321+ bottom : parseInt ( this . $container . css ( 'padding-bottom' ) , 10 ) ,
9322+ left : parseInt ( this . $container . css ( 'padding-left' ) , 10 )
9323+ } ;
9324+
9325+ this . imageBorderWidth = {
9326+ top : parseInt ( this . $image . css ( 'border-top-width' ) , 10 ) ,
9327+ right : parseInt ( this . $image . css ( 'border-right-width' ) , 10 ) ,
9328+ bottom : parseInt ( this . $image . css ( 'border-bottom-width' ) , 10 ) ,
9329+ left : parseInt ( this . $image . css ( 'border-left-width' ) , 10 )
9330+ } ;
93069331
93079332 // Attach event handlers to the newly minted DOM elements
93089333 this . $overlay . hide ( ) . on ( 'click' , function ( ) {
@@ -9342,6 +9367,32 @@ return jQuery;
93429367 return false ;
93439368 } ) ;
93449369
9370+ /*
9371+ Show context menu for image on right-click
9372+
9373+ There is a div containing the navigation that spans the entire image and lives above of it. If
9374+ you right-click, you are right clicking this div and not the image. This prevents users from
9375+ saving the image or using other context menu actions with the image.
9376+
9377+ To fix this, when we detect the right mouse button is pressed down, but not yet clicked, we
9378+ set pointer-events to none on the nav div. This is so that the upcoming right-click event on
9379+ the next mouseup will bubble down to the image. Once the right-click/contextmenu event occurs
9380+ we set the pointer events back to auto for the nav div so it can capture hover and left-click
9381+ events as usual.
9382+ */
9383+ this . $nav . on ( 'mousedown' , function ( event ) {
9384+ if ( event . which === 3 ) {
9385+ self . $nav . css ( 'pointer-events' , 'none' ) ;
9386+
9387+ self . $lightbox . one ( 'contextmenu' , function ( ) {
9388+ setTimeout ( function ( ) {
9389+ this . $nav . css ( 'pointer-events' , 'auto' ) ;
9390+ } . bind ( self ) , 0 ) ;
9391+ } ) ;
9392+ }
9393+ } ) ;
9394+
9395+
93459396 this . $lightbox . find ( '.lb-loader, .lb-close' ) . on ( 'click' , function ( ) {
93469397 self . end ( ) ;
93479398 return false ;
@@ -9453,8 +9504,8 @@ return jQuery;
94539504
94549505 windowWidth = $ ( window ) . width ( ) ;
94559506 windowHeight = $ ( window ) . height ( ) ;
9456- maxImageWidth = windowWidth - self . containerLeftPadding - self . containerRightPadding - 20 ;
9457- maxImageHeight = windowHeight - self . containerTopPadding - self . containerBottomPadding - 120 ;
9507+ maxImageWidth = windowWidth - self . containerPadding . left - self . containerPadding . right - self . imageBorderWidth . left - self . imageBorderWidth . right - 20 ;
9508+ maxImageHeight = windowHeight - self . containerPadding . top - self . containerPadding . bottom - self . imageBorderWidth . top - self . imageBorderWidth . bottom - 120 ;
94589509
94599510 // Check if image size is larger then maxWidth|maxHeight in settings
94609511 if ( self . options . maxWidth && self . options . maxWidth < maxImageWidth ) {
@@ -9499,8 +9550,8 @@ return jQuery;
94999550
95009551 var oldWidth = this . $outerContainer . outerWidth ( ) ;
95019552 var oldHeight = this . $outerContainer . outerHeight ( ) ;
9502- var newWidth = imageWidth + this . containerLeftPadding + this . containerRightPadding ;
9503- var newHeight = imageHeight + this . containerTopPadding + this . containerBottomPadding ;
9553+ var newWidth = imageWidth + this . containerPadding . left + this . containerPadding . right + this . imageBorderWidth . left + this . imageBorderWidth . right ;
9554+ var newHeight = imageHeight + this . containerPadding . top + this . containerPadding . bottom + this . imageBorderWidth . top + this . imageBorderWidth . bottom ;
95049555
95059556 function postResize ( ) {
95069557 self . $lightbox . find ( '.lb-dataContainer' ) . width ( newWidth ) ;
@@ -9524,7 +9575,7 @@ return jQuery;
95249575 // Display the image and its details and begin preload neighboring images.
95259576 Lightbox . prototype . showImage = function ( ) {
95269577 this . $lightbox . find ( '.lb-loader' ) . stop ( true ) . hide ( ) ;
9527- this . $lightbox . find ( '.lb-image' ) . fadeIn ( 'slow' ) ;
9578+ this . $lightbox . find ( '.lb-image' ) . fadeIn ( this . options . imageFadeDuration ) ;
95289579
95299580 this . updateNav ( ) ;
95309581 this . updateDetails ( ) ;
@@ -9576,9 +9627,13 @@ return jQuery;
95769627 // Thanks Nate Wright for the fix. @https ://github.com/NateWr
95779628 if ( typeof this . album [ this . currentImageIndex ] . title !== 'undefined' &&
95789629 this . album [ this . currentImageIndex ] . title !== '' ) {
9579- this . $lightbox . find ( '.lb-caption' )
9580- . html ( this . album [ this . currentImageIndex ] . title )
9581- . fadeIn ( 'fast' )
9630+ var $caption = this . $lightbox . find ( '.lb-caption' ) ;
9631+ if ( this . options . sanitizeTitle ) {
9632+ $caption . text ( this . album [ this . currentImageIndex ] . title ) ;
9633+ } else {
9634+ $caption . html ( this . album [ this . currentImageIndex ] . title ) ;
9635+ }
9636+ $caption . fadeIn ( 'fast' )
95829637 . find ( 'a' ) . on ( 'click' , function ( event ) {
95839638 if ( $ ( this ) . attr ( 'target' ) !== undefined ) {
95849639 window . open ( $ ( this ) . attr ( 'href' ) , $ ( this ) . attr ( 'target' ) ) ;
0 commit comments