Legoktm has submitted this change and it was merged.

Change subject: Makes sure that the zoom widget is initialized before zooming 
in/out
......................................................................


Makes sure that the zoom widget is initialized before zooming in/out

Initialized lazily the zoom widget

Change-Id: Ia92b41716b3fde4b5e3aeb8c82f5f8e8d012f620
---
M modules/page/ext.proofreadpage.page.edit.js
1 file changed, 27 insertions(+), 22 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 874f9e7..8d7b1fc 100644
--- a/modules/page/ext.proofreadpage.page.edit.js
+++ b/modules/page/ext.proofreadpage.page.edit.js
@@ -30,6 +30,23 @@
        }
 
        /**
+        * Ensure that the zoom system is properly initialized
+     *
+        * @param {Function} callback a function to use after making sure that 
the zoom system is activate
+        */
+       function withImageZoom( callback ) {
+               if ( $zoomImage.data( 'prpZoom' ) ) {
+                       callback();
+                       return;
+               }
+
+               mw.loader.using( 'jquery.prpZoom', function () {
+                       $zoomImage.prpZoom();
+                       callback();
+               } );
+       }
+
+       /**
         * Show or hide header and footer areas
         *
         * @param {string} speed string speed of the toggle. May be 'fast', 
'slow' or undefined
@@ -61,8 +78,6 @@
                                width: ''
                        } );
 
-                       $zoomImage.prpZoom();
-
                        isLayoutHorizontal = false;
 
                } else {
@@ -77,7 +92,6 @@
                                width: '100%'
                        } );
 
-                       $zoomImage.prpZoom();
                        $container.css( {
                                height: $( window ).height() / 3 + 'px'
                        } );
@@ -127,7 +141,9 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
$zoomImage.prpZoom( 'zoomIn' );
+                                                                       
withImageZoom( function () {
+                                                                               
$zoomImage.prpZoom( 'zoomIn' );
+                                                                       } );
                                                                }
                                                        }
                                                },
@@ -139,7 +155,9 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
$zoomImage.prpZoom( 'zoomOut' );
+                                                                       
withImageZoom( function () {
+                                                                               
$zoomImage.prpZoom( 'zoomOut' );
+                                                                       } );
                                                                }
                                                        }
                                                },
@@ -151,7 +169,9 @@
                                                        action: {
                                                                type: 
'callback',
                                                                execute: 
function () {
-                                                                       
$zoomImage.prpZoom( 'reset' );
+                                                                       
withImageZoom( function () {
+                                                                               
$zoomImage.prpZoom( 'reset' );
+                                                                       } );
                                                                }
                                                        }
                                                }
@@ -247,27 +267,12 @@
                }
        }
 
-       /**
-        * Init the zoom system
-        */
-       function initZoom() {
-               mw.loader.using( 'jquery.prpZoom', function () {
-                       $zoomImage.prpZoom();
-               } );
-       }
-
-       $( document ).ready( function () {
+       $( function () {
                initEnvironment();
                setupWikiEditor();
                setupPreferences();
                setupPageQuality();
                addButtons();
-       } );
-
-       // zoom should be init after the page is rendered
-       $( window ).load( function () {
-               initEnvironment();
-               initZoom();
        } );
 
 }( mw, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia92b41716b3fde4b5e3aeb8c82f5f8e8d012f620
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Phe <phil...@free.fr>
Gerrit-Reviewer: Samwilson <s...@samwilson.id.au>
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