Legoktm has submitted this change and it was merged.

Change subject: Initializes the zoom widget after page loading
......................................................................


Initializes the zoom widget after page loading

Bug: T145724
Change-Id: I310d5d6acc0db54a0ae97fbe8727549eec842692
---
M modules/page/ext.proofreadpage.page.edit.js
1 file changed, 20 insertions(+), 8 deletions(-)

Approvals:
  Legoktm: Verified; Looks good to me, approved



diff --git a/modules/page/ext.proofreadpage.page.edit.js 
b/modules/page/ext.proofreadpage.page.edit.js
index 8d7b1fc..c9cd2ee 100644
--- a/modules/page/ext.proofreadpage.page.edit.js
+++ b/modules/page/ext.proofreadpage.page.edit.js
@@ -31,18 +31,22 @@
 
        /**
         * Ensure that the zoom system is properly initialized
-     *
-        * @param {Function} callback a function to use after making sure that 
the zoom system is activate
+        *
+        * @param {Function} success a function to use after making sure that 
the zoom system is activate
         */
-       function withImageZoom( callback ) {
+       function ensureImageZoomInitialization( success ) {
                if ( $zoomImage.data( 'prpZoom' ) ) {
-                       callback();
+                       if ( success ) {
+                               success();
+                       }
                        return;
                }
 
                mw.loader.using( 'jquery.prpZoom', function () {
                        $zoomImage.prpZoom();
-                       callback();
+                       if ( success ) {
+                               success();
+                       }
                } );
        }
 
@@ -77,6 +81,7 @@
                        $editForm.find( '.prp-page-content' ).css( {
                                width: ''
                        } );
+                       ensureImageZoomInitialization();
 
                        isLayoutHorizontal = false;
 
@@ -95,6 +100,7 @@
                        $container.css( {
                                height: $( window ).height() / 3 + 'px'
                        } );
+                       ensureImageZoomInitialization();
 
                        isLayoutHorizontal = true;
                }
@@ -141,7 +147,7 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
withImageZoom( function () {
+                                                                       
ensureImageZoomInitialization( function () {
                                                                                
$zoomImage.prpZoom( 'zoomIn' );
                                                                        } );
                                                                }
@@ -155,7 +161,7 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
withImageZoom( function () {
+                                                                       
ensureImageZoomInitialization( function () {
                                                                                
$zoomImage.prpZoom( 'zoomOut' );
                                                                        } );
                                                                }
@@ -169,7 +175,7 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
withImageZoom( function () {
+                                                                       
ensureImageZoomInitialization( function () {
                                                                                
$zoomImage.prpZoom( 'reset' );
                                                                        } );
                                                                }
@@ -275,4 +281,10 @@
                addButtons();
        } );
 
+       // zoom should be initialized after the page is rendered
+       $( window ).load( function () {
+               initEnvironment();
+               ensureImageZoomInitialization();
+       } );
+
 }( mw, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I310d5d6acc0db54a0ae97fbe8727549eec842692
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Tpt <thoma...@hotmail.fr>

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

Reply via email to