JGirault has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/338399 )

Change subject: Fix Y offset not being applied correctly
......................................................................

Fix Y offset not being applied correctly

Bug: T158438
Change-Id: Ia604c4a8cb109497557cbafff08812eab1bc9db2
---
M modules/dialog/dialog.js
1 file changed, 12 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Kartographer 
refs/changes/99/338399/1

diff --git a/modules/dialog/dialog.js b/modules/dialog/dialog.js
index 89ff03d..a75dd8f 100644
--- a/modules/dialog/dialog.js
+++ b/modules/dialog/dialog.js
@@ -138,7 +138,8 @@
        MapDialog.prototype.offsetMap = function ( isSidebarOpen ) {
                var map = this.map,
                        offsetX = isSidebarOpen ? SIDEBAR_WIDTH / -2 : 0,
-                       targetPoint = map.project( map.getCenter(), 
map.getZoom() ).subtract( [ offsetX, -1 * FOOTER_HEIGHT ] ),
+                       offsetY = FOOTER_HEIGHT / -2,
+                       targetPoint = map.project( map.getCenter(), 
map.getZoom() ).subtract( [ offsetX, offsetY ] ),
                        targetLatLng = map.unproject( targetPoint, 
map.getZoom() );
 
                map.setView( targetLatLng, map.getZoom() );
@@ -181,7 +182,9 @@
        MapDialog.prototype.getSetupProcess = function ( options ) {
                return MapDialog.super.prototype.getSetupProcess.call( this, 
options )
                        .next( function () {
-                               var dialog = this;
+                               var dialog = this,
+                                       isFirstTimeOpen = 
!dialog.$mapDetailsButton,
+                                       isSideBarVisible = dialog.sideBar;
 
                                if ( options.map && options.map !== dialog.map 
) {
 
@@ -204,24 +207,22 @@
                                                        .text( 
dialog.map.captionText );
                                        }
 
-                                       if ( !dialog.$mapDetailsButton ) {
+                                       if ( isFirstTimeOpen ) {
                                                // The button does not exist 
yet, add it
                                                dialog.addFooterButton();
-
-                                       } else if ( dialog.sideBar ) {
+                                       } else if ( isSideBarVisible ) {
                                                // The button exists, the 
sidebar was open, call `tearDown` and reopen it.
                                                dialog.sideBar.tearDown();
                                                dialog.map.doWhenReady( 
function () {
                                                        dialog.offsetMap( true 
);
                                                        dialog.toggleSideBar( 
true );
                                                } );
-
-                                       } else {
-                                               // The button exists, the 
sidebar was not open, simply run `offsetMap`
-                                               dialog.map.doWhenReady( 
function () {
-                                                       dialog.offsetMap( false 
);
-                                               } );
+                                               return;
                                        }
+                                       // The button exists, the sidebar was 
not open, simply run `offsetMap`
+                                       dialog.map.doWhenReady( function () {
+                                               dialog.offsetMap( false );
+                                       } );
                                }
                        }, this );
        };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia604c4a8cb109497557cbafff08812eab1bc9db2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Kartographer
Gerrit-Branch: master
Gerrit-Owner: JGirault <jgira...@wikimedia.org>

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

Reply via email to