@@ -9210,7 +9210,7 @@ return jQuery;
9210
9210
} ) ) ;
9211
9211
9212
9212
/*!
9213
- * Lightbox v2.8.2
9213
+ * Lightbox v2.9.0
9214
9214
* by Lokesh Dhakar
9215
9215
*
9216
9216
* More info:
@@ -9252,15 +9252,25 @@ return jQuery;
9252
9252
Lightbox . defaults = {
9253
9253
albumLabel : 'Image %1 of %2' ,
9254
9254
alwaysShowNavOnTouchDevices : false ,
9255
- fadeDuration : 500 ,
9255
+ fadeDuration : 600 ,
9256
9256
fitImagesInViewport : true ,
9257
+ imageFadeDuration : 600 ,
9257
9258
// maxWidth: 800,
9258
9259
// maxHeight: 600,
9259
9260
positionFromTop : 50 ,
9260
9261
resizeDuration : 700 ,
9261
9262
showImageNumberLabel : true ,
9262
9263
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
9264
9274
} ;
9265
9275
9266
9276
Lightbox . prototype . option = function ( options ) {
@@ -9272,8 +9282,12 @@ return jQuery;
9272
9282
} ;
9273
9283
9274
9284
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
+ } ) ;
9277
9291
} ;
9278
9292
9279
9293
// Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes
@@ -9297,12 +9311,23 @@ return jQuery;
9297
9311
this . $overlay = $ ( '#lightboxOverlay' ) ;
9298
9312
this . $outerContainer = this . $lightbox . find ( '.lb-outerContainer' ) ;
9299
9313
this . $container = this . $lightbox . find ( '.lb-container' ) ;
9314
+ this . $image = this . $lightbox . find ( '.lb-image' ) ;
9315
+ this . $nav = this . $lightbox . find ( '.lb-nav' ) ;
9300
9316
9301
9317
// 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
+ } ;
9306
9331
9307
9332
// Attach event handlers to the newly minted DOM elements
9308
9333
this . $overlay . hide ( ) . on ( 'click' , function ( ) {
@@ -9342,6 +9367,32 @@ return jQuery;
9342
9367
return false ;
9343
9368
} ) ;
9344
9369
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
+
9345
9396
this . $lightbox . find ( '.lb-loader, .lb-close' ) . on ( 'click' , function ( ) {
9346
9397
self . end ( ) ;
9347
9398
return false ;
@@ -9453,8 +9504,8 @@ return jQuery;
9453
9504
9454
9505
windowWidth = $ ( window ) . width ( ) ;
9455
9506
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 ;
9458
9509
9459
9510
// Check if image size is larger then maxWidth|maxHeight in settings
9460
9511
if ( self . options . maxWidth && self . options . maxWidth < maxImageWidth ) {
@@ -9499,8 +9550,8 @@ return jQuery;
9499
9550
9500
9551
var oldWidth = this . $outerContainer . outerWidth ( ) ;
9501
9552
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 ;
9504
9555
9505
9556
function postResize ( ) {
9506
9557
self . $lightbox . find ( '.lb-dataContainer' ) . width ( newWidth ) ;
@@ -9524,7 +9575,7 @@ return jQuery;
9524
9575
// Display the image and its details and begin preload neighboring images.
9525
9576
Lightbox . prototype . showImage = function ( ) {
9526
9577
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 ) ;
9528
9579
9529
9580
this . updateNav ( ) ;
9530
9581
this . updateDetails ( ) ;
@@ -9576,9 +9627,13 @@ return jQuery;
9576
9627
// Thanks Nate Wright for the fix. @https ://github.com/NateWr
9577
9628
if ( typeof this . album [ this . currentImageIndex ] . title !== 'undefined' &&
9578
9629
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' )
9582
9637
. find ( 'a' ) . on ( 'click' , function ( event ) {
9583
9638
if ( $ ( this ) . attr ( 'target' ) !== undefined ) {
9584
9639
window . open ( $ ( this ) . attr ( 'href' ) , $ ( this ) . attr ( 'target' ) ) ;
0 commit comments