diff --git a/resources/multilightbox/lightboxinterface.js b/resources/multilightbox/lightboxinterface.js index 614b5b59b..867bbac36 100644 --- a/resources/multilightbox/lightboxinterface.js +++ b/resources/multilightbox/lightboxinterface.js @@ -241,6 +241,8 @@ } } ); + this.setupFullscreenButton(); + this.$controlBar.append( this.$closeButton, this.$fullscreenButton @@ -254,6 +256,15 @@ this.addElementsToDiv( this.$preDiv, toAdd ); }; + LIP.setupFullscreenButton = function () { + // If the browser doesn't support fullscreen mode, hide the fullscreen button + if ( $.support.fullscreen ) { + this.$fullscreenButton.show(); + } else { + this.$fullscreenButton.hide(); + } + }; + LIP.setupPostDiv = function ( buildDefaults, toAdd ) { if ( buildDefaults ) { lightboxHooks.callAll( 'modifyDefaultPostDiv', this ); diff --git a/tests/qunit/lightboxinterface.test.js b/tests/qunit/lightboxinterface.test.js index fb6d6c15a..5e7c09b8c 100644 --- a/tests/qunit/lightboxinterface.test.js +++ b/tests/qunit/lightboxinterface.test.js @@ -49,10 +49,11 @@ lightbox.load(img); } ); - QUnit.test( 'Fullscreen mode', 6, function ( assert ) { + QUnit.test( 'Fullscreen mode', 8, function ( assert ) { var lightbox = new window.LightboxInterface(), oldFnEnterFullscreen = $.fn.enterFullscreen, - oldFnExitFullscreen = $.fn.exitFullscreen; + oldFnExitFullscreen = $.fn.exitFullscreen, + oldSupportFullscreen = $.support.fullscreen; // Since we don't want these tests to really open fullscreen // which is subject to user security confirmation, @@ -63,6 +64,18 @@ // Attach lightbox to testing fixture to avoid interference with other tests. lightbox.attach( '#qunit-fixture' ); + $.support.fullscreen = false; + lightbox.setupFullscreenButton(); + + assert.ok( !lightbox.$fullscreenButton.is(':visible'), + 'Fullscreen button is hidden when fullscreen mode is unavailable' ); + + $.support.fullscreen = true; + lightbox.setupFullscreenButton(); + + assert.ok( lightbox.$fullscreenButton.is(':visible'), + 'Fullscreen button is visible when fullscreen mode is available' ); + // Entering fullscreen lightbox.$fullscreenButton.click(); @@ -97,6 +110,7 @@ $.fn.enterFullscreen = oldFnEnterFullscreen; $.fn.exitFullscreen = oldFnExitFullscreen; + $.support.fullscreen = oldSupportFullscreen; } ); }( mediaWiki, jQuery ) ); diff --git a/tests/qunit/mmv.lightboxinterface.test.js b/tests/qunit/mmv.lightboxinterface.test.js index 04bb342ff..bb4c3423c 100644 --- a/tests/qunit/mmv.lightboxinterface.test.js +++ b/tests/qunit/mmv.lightboxinterface.test.js @@ -192,7 +192,7 @@ $.each ( lightbox.$buttons, function ( idx, e ) { var $e = $( e ), - offset = $e.offset(), + offset = $e.show().offset(), width = $e.width(), height = $e.height(), disabled = $e.hasClass( 'disabled' );