@@ -10253,13 +10253,13 @@ return jQuery;
10253
10253
} ) ;
10254
10254
10255
10255
/*!
10256
- * Lightbox v2.10 .0
10256
+ * Lightbox v2.11 .0
10257
10257
* by Lokesh Dhakar
10258
10258
*
10259
10259
* More info:
10260
10260
* http://lokeshdhakar.com/projects/lightbox2/
10261
10261
*
10262
- * Copyright 2007, 2018 Lokesh Dhakar
10262
+ * Copyright Lokesh Dhakar
10263
10263
* Released under the MIT license
10264
10264
* https://github.com/lokesh/lightbox2/blob/master/LICENSE
10265
10265
*
@@ -10353,7 +10353,7 @@ return jQuery;
10353
10353
}
10354
10354
10355
10355
var self = this ;
10356
- $ ( '<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' ) ) ;
10356
+ $ ( '<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' ) ) ;
10357
10357
10358
10358
// Cache jQuery objects
10359
10359
this . $lightbox = $ ( '#lightbox' ) ;
@@ -10388,7 +10388,6 @@ return jQuery;
10388
10388
if ( $ ( event . target ) . attr ( 'id' ) === 'lightbox' ) {
10389
10389
self . end ( ) ;
10390
10390
}
10391
- return false ;
10392
10391
} ) ;
10393
10392
10394
10393
this . $outerContainer . on ( 'click' , function ( event ) {
@@ -10455,10 +10454,6 @@ return jQuery;
10455
10454
10456
10455
$window . on ( 'resize' , $ . proxy ( this . sizeOverlay , this ) ) ;
10457
10456
10458
- $ ( 'select, object, embed' ) . css ( {
10459
- visibility : 'hidden'
10460
- } ) ;
10461
-
10462
10457
this . sizeOverlay ( ) ;
10463
10458
10464
10459
this . album = [ ] ;
@@ -10510,7 +10505,7 @@ return jQuery;
10510
10505
10511
10506
// Disable scrolling of the page while open
10512
10507
if ( this . options . disableScrolling ) {
10513
- $ ( 'html ' ) . addClass ( 'lb-disable-scrolling' ) ;
10508
+ $ ( 'body ' ) . addClass ( 'lb-disable-scrolling' ) ;
10514
10509
}
10515
10510
10516
10511
this . changeImage ( imageNumber ) ;
@@ -10519,15 +10514,17 @@ return jQuery;
10519
10514
// Hide most UI elements in preparation for the animated resizing of the lightbox.
10520
10515
Lightbox . prototype . changeImage = function ( imageNumber ) {
10521
10516
var self = this ;
10517
+ var filename = this . album [ imageNumber ] . link ;
10518
+ var filetype = filename . split ( '.' ) . slice ( - 1 ) [ 0 ] ;
10519
+ var $image = this . $lightbox . find ( '.lb-image' ) ;
10522
10520
10521
+ // Disable keyboard nav during transitions
10523
10522
this . disableKeyboardNav ( ) ;
10524
- var $image = this . $lightbox . find ( '.lb-image' ) ;
10525
10523
10524
+ // Show loading state
10526
10525
this . $overlay . fadeIn ( this . options . fadeDuration ) ;
10527
-
10528
10526
$ ( '.lb-loader' ) . fadeIn ( 'slow' ) ;
10529
10527
this . $lightbox . find ( '.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption' ) . hide ( ) ;
10530
-
10531
10528
this . $outerContainer . addClass ( 'animating' ) ;
10532
10529
10533
10530
// When image to show is preloaded, we send the width and height to sizeContainer()
@@ -10543,22 +10540,38 @@ return jQuery;
10543
10540
10544
10541
$image . attr ( {
10545
10542
'alt' : self . album [ imageNumber ] . alt ,
10546
- 'src' : self . album [ imageNumber ] . link
10543
+ 'src' : filename
10547
10544
} ) ;
10548
10545
10549
10546
$preloader = $ ( preloader ) ;
10550
10547
10551
10548
$image . width ( preloader . width ) ;
10552
10549
$image . height ( preloader . height ) ;
10550
+ windowWidth = $ ( window ) . width ( ) ;
10551
+ windowHeight = $ ( window ) . height ( ) ;
10552
+
10553
+ // Calculate the max image dimensions for the current viewport.
10554
+ // Take into account the border around the image and an additional 10px gutter on each side.
10555
+ maxImageWidth = windowWidth - self . containerPadding . left - self . containerPadding . right - self . imageBorderWidth . left - self . imageBorderWidth . right - 20 ;
10556
+ maxImageHeight = windowHeight - self . containerPadding . top - self . containerPadding . bottom - self . imageBorderWidth . top - self . imageBorderWidth . bottom - self . options . positionFromTop - 70 ;
10557
+
10558
+ /*
10559
+ SVGs that don't have width and height attributes specified are reporting width and height
10560
+ values of 0 in Firefox 47 and IE11 on Windows. To fix, we set the width and height to the max
10561
+ dimensions for the viewport rather than 0 x 0.
10562
+
10563
+ https://github.com/lokesh/lightbox2/issues/552
10564
+ */
10565
+
10566
+ if ( filetype === 'svg' ) {
10567
+ if ( ( preloader . width === 0 ) || preloader . height === 0 ) {
10568
+ $image . width ( maxImageWidth ) ;
10569
+ $image . height ( maxImageHeight ) ;
10570
+ }
10571
+ }
10553
10572
10573
+ // Fit image inside the viewport.
10554
10574
if ( self . options . fitImagesInViewport ) {
10555
- // Fit image inside the viewport.
10556
- // Take into account the border around the image and an additional 10px gutter on each side.
10557
-
10558
- windowWidth = $ ( window ) . width ( ) ;
10559
- windowHeight = $ ( window ) . height ( ) ;
10560
- maxImageWidth = windowWidth - self . containerPadding . left - self . containerPadding . right - self . imageBorderWidth . left - self . imageBorderWidth . right - 20 ;
10561
- maxImageHeight = windowHeight - self . containerPadding . top - self . containerPadding . bottom - self . imageBorderWidth . top - self . imageBorderWidth . bottom - 120 ;
10562
10575
10563
10576
// Check if image size is larger then maxWidth|maxHeight in settings
10564
10577
if ( self . options . maxWidth && self . options . maxWidth < maxImageWidth ) {
@@ -10587,18 +10600,31 @@ return jQuery;
10587
10600
self . sizeContainer ( $image . width ( ) , $image . height ( ) ) ;
10588
10601
} ;
10589
10602
10590
- preloader . src = this . album [ imageNumber ] . link ;
10603
+ // Preload image before showing
10604
+ preloader . src = this . album [ imageNumber ] . link ;
10591
10605
this . currentImageIndex = imageNumber ;
10592
10606
} ;
10593
10607
10594
10608
// Stretch overlay to fit the viewport
10595
10609
Lightbox . prototype . sizeOverlay = function ( ) {
10596
- this . $overlay
10597
- . width ( $ ( document ) . width ( ) )
10598
- . height ( $ ( document ) . height ( ) ) ;
10610
+ var self = this ;
10611
+ /*
10612
+ We use a setTimeout 0 to pause JS execution and let the rendering catch-up.
10613
+ Why do this? If the `disableScrolling` option is set to true, a class is added to the body
10614
+ tag that disables scrolling and hides the scrollbar. We want to make sure the scrollbar is
10615
+ hidden before we measure the document width, as the presence of the scrollbar will affect the
10616
+ number.
10617
+ */
10618
+ setTimeout ( function ( ) {
10619
+ self . $overlay
10620
+ . width ( $ ( document ) . width ( ) )
10621
+ . height ( $ ( document ) . height ( ) ) ;
10622
+
10623
+ } , 0 ) ;
10599
10624
} ;
10600
10625
10601
10626
// Animate the size of the lightbox to fit the image we are showing
10627
+ // This method also shows the the image.
10602
10628
Lightbox . prototype . sizeContainer = function ( imageWidth , imageHeight ) {
10603
10629
var self = this ;
10604
10630
@@ -10687,14 +10713,7 @@ return jQuery;
10687
10713
} else {
10688
10714
$caption . html ( this . album [ this . currentImageIndex ] . title ) ;
10689
10715
}
10690
- $caption . fadeIn ( 'fast' )
10691
- . find ( 'a' ) . on ( 'click' , function ( event ) {
10692
- if ( $ ( this ) . attr ( 'target' ) !== undefined ) {
10693
- window . open ( $ ( this ) . attr ( 'href' ) , $ ( this ) . attr ( 'target' ) ) ;
10694
- } else {
10695
- location . href = $ ( this ) . attr ( 'href' ) ;
10696
- }
10697
- } ) ;
10716
+ $caption . fadeIn ( 'fast' ) ;
10698
10717
}
10699
10718
10700
10719
if ( this . album . length > 1 && this . options . showImageNumberLabel ) {
@@ -10737,16 +10756,15 @@ return jQuery;
10737
10756
var KEYCODE_RIGHTARROW = 39 ;
10738
10757
10739
10758
var keycode = event . keyCode ;
10740
- var key = String . fromCharCode ( keycode ) . toLowerCase ( ) ;
10741
- if ( keycode === KEYCODE_ESC || key . match ( / x | o | c / ) ) {
10759
+ if ( keycode === KEYCODE_ESC ) {
10742
10760
this . end ( ) ;
10743
- } else if ( key === 'p' || keycode === KEYCODE_LEFTARROW ) {
10761
+ } else if ( keycode === KEYCODE_LEFTARROW ) {
10744
10762
if ( this . currentImageIndex !== 0 ) {
10745
10763
this . changeImage ( this . currentImageIndex - 1 ) ;
10746
10764
} else if ( this . options . wrapAround && this . album . length > 1 ) {
10747
10765
this . changeImage ( this . album . length - 1 ) ;
10748
10766
}
10749
- } else if ( key === 'n' || keycode === KEYCODE_RIGHTARROW ) {
10767
+ } else if ( keycode === KEYCODE_RIGHTARROW ) {
10750
10768
if ( this . currentImageIndex !== this . album . length - 1 ) {
10751
10769
this . changeImage ( this . currentImageIndex + 1 ) ;
10752
10770
} else if ( this . options . wrapAround && this . album . length > 1 ) {
@@ -10761,11 +10779,9 @@ return jQuery;
10761
10779
$ ( window ) . off ( 'resize' , this . sizeOverlay ) ;
10762
10780
this . $lightbox . fadeOut ( this . options . fadeDuration ) ;
10763
10781
this . $overlay . fadeOut ( this . options . fadeDuration ) ;
10764
- $ ( 'select, object, embed' ) . css ( {
10765
- visibility : 'visible'
10766
- } ) ;
10782
+
10767
10783
if ( this . options . disableScrolling ) {
10768
- $ ( 'html ' ) . removeClass ( 'lb-disable-scrolling' ) ;
10784
+ $ ( 'body ' ) . removeClass ( 'lb-disable-scrolling' ) ;
10769
10785
}
10770
10786
} ;
10771
10787
0 commit comments