Gilles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/133218

Change subject: Fix IE9 support
......................................................................

Fix IE9 support

- Fix JS error on pushState
- Fix blur issue where blur(0px) filter would blur anyway
- Fix wrapper sizing issue where its size would be 0 when measured

Bug: 65225
Change-Id: If9279cd56f55f71f261ec54dda8228194988b9ae
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/597
---
M resources/mmv/mmv.bootstrap.js
M resources/mmv/mmv.js
M resources/mmv/ui/mmv.ui.canvas.js
M tests/qunit/mmv/ui/mmv.ui.canvas.test.js
4 files changed, 16 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer 
refs/changes/18/133218/1

diff --git a/resources/mmv/mmv.bootstrap.js b/resources/mmv/mmv.bootstrap.js
index 46c6049..02dbb1c 100755
--- a/resources/mmv/mmv.bootstrap.js
+++ b/resources/mmv/mmv.bootstrap.js
@@ -321,11 +321,12 @@
                // The advantage of using pushState when it's available is that 
it has to ability to truly
                // clear the hash, not leaving "#" in the history
                // An entry with "#" in the history has the side-effect of 
resetting the scroll position when navigating the history
-               if ( this.browserHistory ) {
+               if ( this.browserHistory && this.browserHistory.pushState ) {
                        // In order to truly clear the hash, we need to 
reconstruct the hash-free URL
                        if ( hash === '#' ) {
                                hash = window.location.href.replace( /#.*$/, '' 
);
                        }
+
                        this.browserHistory.pushState( null, null, hash );
                } else {
                        // Since we voluntarily changed the hash, we don't want 
MMVB.hash (which will trigger on hashchange event) to treat it
diff --git a/resources/mmv/mmv.js b/resources/mmv/mmv.js
index b561267..7d57289 100755
--- a/resources/mmv/mmv.js
+++ b/resources/mmv/mmv.js
@@ -198,7 +198,7 @@
         */
        MMVP.resize = function ( ui ) {
                var viewer = this,
-                       image = this.thumbs[ this.currentIndex].image,
+                       image = this.thumbs[ this.currentIndex ].image,
                        imageWidths;
 
                this.preloadThumbnails();
diff --git a/resources/mmv/ui/mmv.ui.canvas.js 
b/resources/mmv/ui/mmv.ui.canvas.js
index 2d04c27..261029b 100644
--- a/resources/mmv/ui/mmv.ui.canvas.js
+++ b/resources/mmv/ui/mmv.ui.canvas.js
@@ -260,7 +260,7 @@
        C.unblur = function() {
                // We apply empty CSS values to remove the inline styles 
applied by jQuery
                // so that they don't get in the way of styles defined in CSS
-               this.$image.css( { '-webkit-filter' : '', 'opacity' : '' } )
+               this.$image.css( { '-webkit-filter' : '', 'opacity' : '', 
'filter' : '' } )
                        .removeClass( 'blurred' );
        };
 
@@ -284,10 +284,17 @@
         * @returns {mw.mmv.model.ThumbnailWidth}
         */
        C.getLightboxImageWidths = function ( image ) {
-               var thumb = image.thumbnail;
+               var thumb = image.thumbnail,
+                       $window = $( window ),
+                       available_width = $window.width(),
+                       available_height = $window.height() - $( 
'.mw-mmv-controls' ).height();
+
+               // For the above don't rely on this.$imageWrapper's sizing 
anymore because it's fragile
+               // Depending on what the wrapper contains, its size can be 0 on 
some browsers.
+               // Therefore, we calculate the available space manually
 
                return this.thumbnailWidthCalculator.calculateWidths(
-                       this.$imageWrapper.width(), 
this.$imageWrapper.height(), thumb.width, thumb.height );
+                       available_width, available_height, thumb.width, 
thumb.height );
        };
 
        /**
diff --git a/tests/qunit/mmv/ui/mmv.ui.canvas.test.js 
b/tests/qunit/mmv/ui/mmv.ui.canvas.test.js
index a6875e3..f04e26c 100644
--- a/tests/qunit/mmv/ui/mmv.ui.canvas.test.js
+++ b/tests/qunit/mmv/ui/mmv.ui.canvas.test.js
@@ -261,7 +261,7 @@
                assert.ok( ! blurredThumbnailShown, 'Placeholder state is 
correct' );
        } );
 
-       QUnit.test( 'Unblur', 3, function ( assert ) {
+       QUnit.test( 'Unblur', 4, function ( assert ) {
                var $qf = $( '#qunit-fixture' ),
                        canvas = new mw.mmv.ui.Canvas( $qf ),
                        oldAnimate = $.fn.animate;
@@ -290,6 +290,8 @@
                canvas.unblurWithAnimation();
 
                assert.ok( ! canvas.$image.css( '-webkit-filter' ) || 
!canvas.$image.css( '-webkit-filter' ).length,
+                       'Image has no -webkit-filter left' );
+               assert.ok( ! canvas.$image.css( 'filter' ) || 
!canvas.$image.css( 'filter' ).length || canvas.$image.css( 'filter' ) === 
'none',
                        'Image has no filter left' );
                assert.strictEqual( parseInt( canvas.$image.css( 'opacity' ), 
10 ), 1,
                        'Image is fully opaque' );

-- 
To view, visit https://gerrit.wikimedia.org/r/133218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9279cd56f55f71f261ec54dda8228194988b9ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gilles <gdu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to