jenkins-bot has submitted this change and it was merged.

Change subject: Fix broken full screen mode on Safari
......................................................................


Fix broken full screen mode on Safari

Bug: T138079
Change-Id: I9ff2d75d4d6b482659f16c8b5ef45d99dae47093
---
M modules/fullscreen/MapDialog.js
M modules/kartographer.js
M modules/live/MWMap.js
3 files changed, 28 insertions(+), 17 deletions(-)

Approvals:
  MaxSem: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/fullscreen/MapDialog.js b/modules/fullscreen/MapDialog.js
index a4b66a9..df6ac80 100644
--- a/modules/fullscreen/MapDialog.js
+++ b/modules/fullscreen/MapDialog.js
@@ -149,24 +149,21 @@
                                                extendedData = {};
 
                                        self.map = map;
-                                       self.map.addControl( new CloseControl( 
{ dialog: self } ) );
-
-                                       // copy of the initial settings
                                        self.mapData = mapData;
+
+                                       map.addControl( new CloseControl( { 
dialog: self } ) );
 
                                        if ( fullScreenState ) {
                                                // override with full screen 
state
                                                $.extend( extendedData, 
mapData, fullScreenState );
-                                               self.map.setView( new L.LatLng( 
extendedData.latitude, extendedData.longitude ), extendedData.zoom, true );
+                                               map.setView( new L.LatLng( 
extendedData.latitude, extendedData.longitude ), extendedData.zoom );
                                        }
 
                                        if ( typeof mapData.maptagId === 
'number' ) {
-                                               self.map.on( 'moveend', 
self.onMapMove, self );
+                                               map.on( 'moveend', 
self.onMapMove, self );
                                        }
 
-                                       mw.hook( 'wikipage.maps' ).fire( 
self.map, true /* isFullScreen */ );
-
-                                       this.map.invalidateSize();
+                                       mw.hook( 'wikipage.maps' ).fire( map, 
true /* isFullScreen */ );
                                } );
                        }, this );
        };
diff --git a/modules/kartographer.js b/modules/kartographer.js
index fa24af3..0dbb2cc 100644
--- a/modules/kartographer.js
+++ b/modules/kartographer.js
@@ -64,6 +64,14 @@
                                getWindowManager()
                                        .openWindow( getMapDialog(), dialogData 
)
                                        .then( function ( opened ) {
+                                               // It takes 250ms for the 
dialog to open,
+                                               // we'd better invalidate the 
size once it opened.
+                                               setTimeout( function () {
+                                                       var map = 
getMapDialog().map;
+                                                       if ( map ) {
+                                                               
map.invalidateSize();
+                                                       }
+                                               }, 300 );
                                                return opened;
                                        } )
                                        .then( function ( closing ) {
diff --git a/modules/live/MWMap.js b/modules/live/MWMap.js
index 8bd63f4..9b9bfd9 100644
--- a/modules/live/MWMap.js
+++ b/modules/live/MWMap.js
@@ -218,22 +218,28 @@
         * The hack is to try jQuery which will pick up CSS dimensions. T125263
         *
         * However in full screen, the container size is actually [0,0] at that
-        * time. Let's default to 300px temporarily, so that the map has a 
default
-        * size to initialize itself (with an acceptable fullscreen minimum 
value).
+        * time. In that case, the script looks for the first visible parent and
+        * takes its `height` and `width` to initialize the map.
         *
         * @private
         */
        MWMap.prototype._fixMapSize = function () {
-               var width, height, $container = this.$container;
+               var width, height, $visibleParent = this.$container.closest( 
':visible' );
 
                // Get `max` properties in case the container was wrapped
                // with {@link #responsiveContainerWrap}.
-               width = $container.css( 'max-width' );
-               height = $container.css( 'max-height' );
-               width = ( !width || width === 'none' ) ? $container.width() : 
width;
-               height = ( !height || height === 'none' ) ? $container.height() 
: height;
+               width = $visibleParent.css( 'max-width' );
+               height = $visibleParent.css( 'max-height' );
+               width = ( !width || width === 'none' ) ? $visibleParent.width() 
: width;
+               height = ( !height || height === 'none' ) ? 
$visibleParent.height() : height;
 
-               this.map._size = new L.Point( width || 300, height || 300 );
+               while ( ( !height && $visibleParent.parent().length ) ) {
+                       $visibleParent = $visibleParent.parent();
+                       width = $visibleParent.outerWidth( true );
+                       height = $visibleParent.outerHeight( true );
+               }
+
+               this.map._size = new L.Point( width, height );
        };
 
        MWMap.prototype.setView = function ( center, zoom, options, save ) {
@@ -244,7 +250,7 @@
                try {
                        center = L.latLng( center );
                        zoom = isNaN( zoom ) ? this.map.options.fallbackZoom : 
zoom;
-                       map.setView( center, zoom, true );
+                       map.setView( center, zoom, options );
                } catch ( e ) {
                        // Determines best center of the map
                        maxBounds = getValidBounds( map );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9ff2d75d4d6b482659f16c8b5ef45d99dae47093
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: JGirault <julien.inbox.w...@gmail.com>
Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com>
Gerrit-Reviewer: Yurik <yu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to