Brion VIBBER has submitted this change and it was merged. Change subject: Pull changes from multilightbox ......................................................................
Pull changes from multilightbox Fixes for resizing the image - should make things a little nicer Also fix for bind - should fix the library for IE users. Change-Id: I52ea4fcf0cb8b4ee3a6e2ca835f846264fffae3b --- M js/multilightbox/lightboximage.js M js/multilightbox/lightboxinterface.js 2 files changed, 31 insertions(+), 16 deletions(-) Approvals: Brion VIBBER: Verified; Looks good to me, approved jenkins-bot: Checked diff --git a/js/multilightbox/lightboximage.js b/js/multilightbox/lightboximage.js index 8205458..f39ecd1 100644 --- a/js/multilightbox/lightboximage.js +++ b/js/multilightbox/lightboximage.js @@ -28,11 +28,11 @@ LIP.autoResize = function ( ele ) { function updateRatios() { - if ( imgHeight !== 0 ) { + if ( imgHeight ) { imgHeightRatio = imgMaxHeight / imgHeight; } - if ( imgHeight !== 0 ) { + if ( imgWidth ) { imgWidthRatio = imgMaxWidth / imgWidth; } } @@ -47,6 +47,14 @@ imgWidth = $img.width(), imgHeight = $img.height(); + if ( this.globalMaxWidth && imgMaxWidth > this.globalMaxWidth ) { + imgMaxWidth = this.globalMaxWidth; + } + + if ( this.globalMaxHeight && imgMaxHeight > this.globalMaxHeight ) { + imgMaxHeight = this.globalMaxHeight; + } + updateRatios(); if ( imgWidth > imgMaxWidth ) { diff --git a/js/multilightbox/lightboxinterface.js b/js/multilightbox/lightboxinterface.js index 24af0ea..c17b497 100644 --- a/js/multilightbox/lightboxinterface.js +++ b/js/multilightbox/lightboxinterface.js @@ -10,19 +10,20 @@ function handleFullscreenChange() { // If we're no longer in fullscreen mode, make sure - if ( !this.fullscreenButtonJustPressed && + if ( !lbinterface.fullscreenButtonJustPressed && !document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullScreenElement ) { - this.fullscreen(); + lbinterface.fullscreen(); } else if ( this.fullscreenButtonJustPressed ) { - this.fullscreenButtonJustPressed = false; + lbinterface.fullscreenButtonJustPressed = false; } } var result, addToPre = [], - addToPost = []; + addToPost = [], + lbinterface = this; this.$overlay = $( '<div>' ) .addClass( 'mlb-overlay' ); @@ -56,18 +57,18 @@ this.$main ); - lightboxHooks.callAll( 'modifyInterface', this ); + lightboxHooks.callAll( 'modifyinterface', this ); window.addEventListener( 'keyup', function ( e ) { if ( e.keyCode === 27 ) { // Escape button pressed - this.unattach(); + lbinterface.unattach(); } - }.bind( this ) ); + } ); - window.addEventListener( 'fullscreenchange', handleFullscreenChange.bind( this ) ); - window.addEventListener( 'mozfullscreenchange', handleFullscreenChange.bind( this ) ); - window.addEventListener( 'webkitfullscreenchange', handleFullscreenChange.bind( this ) ); + window.addEventListener( 'fullscreenchange', handleFullscreenChange ); + window.addEventListener( 'mozfullscreenchange', handleFullscreenChange ); + window.addEventListener( 'webkitfullscreenchange', handleFullscreenChange ); } LIP = LightboxInterface.prototype; @@ -128,6 +129,8 @@ var ele = image.getImageElement( function () { iface.$image = $( ele ); iface.$imageDiv.html( ele ); + image.globalMaxWidth = iface.$image.width(); + image.globalMaxHeight = iface.$image.height(); image.autoResize( ele ); window.addEventListener( 'resize', function () { @@ -142,6 +145,8 @@ }; LIP.setupPreDiv = function ( buildDefaults, toAdd ) { + var lbinterface = this; + if ( buildDefaults ) { this.$controlBar = $( '<div>' ) .addClass( 'mlb-controls' ); @@ -149,15 +154,17 @@ this.$closeButton = $( '<div>' ) .text( ' ' ) .addClass( 'mlb-close' ) - .click( this.unattach.bind( this ) ); + .click( function () { + lbinterface.unattach(); + } ); this.$fullscreenButton = $( '<div>' ) .text( ' ' ) .addClass( 'mlb-fullscreen' ) .click( function () { - this.fullscreenButtonJustPressed = true; - this.fullscreen(); - }.bind( this ) ); + lbinterface.fullscreenButtonJustPressed = true; + lbinterface.fullscreen(); + } ); this.$controlBar.append( this.$closeButton, -- To view, visit https://gerrit.wikimedia.org/r/82561 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I52ea4fcf0cb8b4ee3a6e2ca835f846264fffae3b Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MultimediaViewer Gerrit-Branch: master Gerrit-Owner: MarkTraceur <mtrac...@member.fsf.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Rillke <rainerril...@hotmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits