@@ -10253,13 +10253,13 @@ return jQuery;
1025310253} ) ;
1025410254
1025510255/*!
10256- * Lightbox v2.10 .0
10256+ * Lightbox v2.11 .0
1025710257 * by Lokesh Dhakar
1025810258 *
1025910259 * More info:
1026010260 * http://lokeshdhakar.com/projects/lightbox2/
1026110261 *
10262- * Copyright 2007, 2018 Lokesh Dhakar
10262+ * Copyright Lokesh Dhakar
1026310263 * Released under the MIT license
1026410264 * https://github.com/lokesh/lightbox2/blob/master/LICENSE
1026510265 *
@@ -10353,7 +10353,7 @@ return jQuery;
1035310353 }
1035410354
1035510355 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' ) ) ;
1035710357
1035810358 // Cache jQuery objects
1035910359 this . $lightbox = $ ( '#lightbox' ) ;
@@ -10388,7 +10388,6 @@ return jQuery;
1038810388 if ( $ ( event . target ) . attr ( 'id' ) === 'lightbox' ) {
1038910389 self . end ( ) ;
1039010390 }
10391- return false ;
1039210391 } ) ;
1039310392
1039410393 this . $outerContainer . on ( 'click' , function ( event ) {
@@ -10455,10 +10454,6 @@ return jQuery;
1045510454
1045610455 $window . on ( 'resize' , $ . proxy ( this . sizeOverlay , this ) ) ;
1045710456
10458- $ ( 'select, object, embed' ) . css ( {
10459- visibility : 'hidden'
10460- } ) ;
10461-
1046210457 this . sizeOverlay ( ) ;
1046310458
1046410459 this . album = [ ] ;
@@ -10510,7 +10505,7 @@ return jQuery;
1051010505
1051110506 // Disable scrolling of the page while open
1051210507 if ( this . options . disableScrolling ) {
10513- $ ( 'html ' ) . addClass ( 'lb-disable-scrolling' ) ;
10508+ $ ( 'body ' ) . addClass ( 'lb-disable-scrolling' ) ;
1051410509 }
1051510510
1051610511 this . changeImage ( imageNumber ) ;
@@ -10519,15 +10514,17 @@ return jQuery;
1051910514 // Hide most UI elements in preparation for the animated resizing of the lightbox.
1052010515 Lightbox . prototype . changeImage = function ( imageNumber ) {
1052110516 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' ) ;
1052210520
10521+ // Disable keyboard nav during transitions
1052310522 this . disableKeyboardNav ( ) ;
10524- var $image = this . $lightbox . find ( '.lb-image' ) ;
1052510523
10524+ // Show loading state
1052610525 this . $overlay . fadeIn ( this . options . fadeDuration ) ;
10527-
1052810526 $ ( '.lb-loader' ) . fadeIn ( 'slow' ) ;
1052910527 this . $lightbox . find ( '.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption' ) . hide ( ) ;
10530-
1053110528 this . $outerContainer . addClass ( 'animating' ) ;
1053210529
1053310530 // When image to show is preloaded, we send the width and height to sizeContainer()
@@ -10543,22 +10540,38 @@ return jQuery;
1054310540
1054410541 $image . attr ( {
1054510542 'alt' : self . album [ imageNumber ] . alt ,
10546- 'src' : self . album [ imageNumber ] . link
10543+ 'src' : filename
1054710544 } ) ;
1054810545
1054910546 $preloader = $ ( preloader ) ;
1055010547
1055110548 $image . width ( preloader . width ) ;
1055210549 $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+ }
1055310572
10573+ // Fit image inside the viewport.
1055410574 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 ;
1056210575
1056310576 // Check if image size is larger then maxWidth|maxHeight in settings
1056410577 if ( self . options . maxWidth && self . options . maxWidth < maxImageWidth ) {
@@ -10587,18 +10600,31 @@ return jQuery;
1058710600 self . sizeContainer ( $image . width ( ) , $image . height ( ) ) ;
1058810601 } ;
1058910602
10590- preloader . src = this . album [ imageNumber ] . link ;
10603+ // Preload image before showing
10604+ preloader . src = this . album [ imageNumber ] . link ;
1059110605 this . currentImageIndex = imageNumber ;
1059210606 } ;
1059310607
1059410608 // Stretch overlay to fit the viewport
1059510609 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 ) ;
1059910624 } ;
1060010625
1060110626 // Animate the size of the lightbox to fit the image we are showing
10627+ // This method also shows the the image.
1060210628 Lightbox . prototype . sizeContainer = function ( imageWidth , imageHeight ) {
1060310629 var self = this ;
1060410630
@@ -10687,14 +10713,7 @@ return jQuery;
1068710713 } else {
1068810714 $caption . html ( this . album [ this . currentImageIndex ] . title ) ;
1068910715 }
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' ) ;
1069810717 }
1069910718
1070010719 if ( this . album . length > 1 && this . options . showImageNumberLabel ) {
@@ -10737,16 +10756,15 @@ return jQuery;
1073710756 var KEYCODE_RIGHTARROW = 39 ;
1073810757
1073910758 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 ) {
1074210760 this . end ( ) ;
10743- } else if ( key === 'p' || keycode === KEYCODE_LEFTARROW ) {
10761+ } else if ( keycode === KEYCODE_LEFTARROW ) {
1074410762 if ( this . currentImageIndex !== 0 ) {
1074510763 this . changeImage ( this . currentImageIndex - 1 ) ;
1074610764 } else if ( this . options . wrapAround && this . album . length > 1 ) {
1074710765 this . changeImage ( this . album . length - 1 ) ;
1074810766 }
10749- } else if ( key === 'n' || keycode === KEYCODE_RIGHTARROW ) {
10767+ } else if ( keycode === KEYCODE_RIGHTARROW ) {
1075010768 if ( this . currentImageIndex !== this . album . length - 1 ) {
1075110769 this . changeImage ( this . currentImageIndex + 1 ) ;
1075210770 } else if ( this . options . wrapAround && this . album . length > 1 ) {
@@ -10761,11 +10779,9 @@ return jQuery;
1076110779 $ ( window ) . off ( 'resize' , this . sizeOverlay ) ;
1076210780 this . $lightbox . fadeOut ( this . options . fadeDuration ) ;
1076310781 this . $overlay . fadeOut ( this . options . fadeDuration ) ;
10764- $ ( 'select, object, embed' ) . css ( {
10765- visibility : 'visible'
10766- } ) ;
10782+
1076710783 if ( this . options . disableScrolling ) {
10768- $ ( 'html ' ) . removeClass ( 'lb-disable-scrolling' ) ;
10784+ $ ( 'body ' ) . removeClass ( 'lb-disable-scrolling' ) ;
1076910785 }
1077010786 } ;
1077110787
0 commit comments