[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Makes sure that the zoom widget is initialized before zoomin...
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(); s
[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Makes sure that the zoom widget is initialized before zoomin...
Tpt has uploaded a new change for review. https://gerrit.wikimedia.org/r/311743 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, 26 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage refs/changes/43/311743/1 diff --git a/modules/page/ext.proofreadpage.page.edit.js b/modules/page/ext.proofreadpage.page.edit.js index 874f9e7..ba1c957 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,15 +267,6 @@ } } - /** -* Init the zoom system -*/ - function initZoom() { - mw.loader.using( 'jquery.prpZoom', function () { - $zoomImage.prpZoom(); - } ); - } - $( document ).ready( function () { initEnvironment(); setupWikiEditor(); @@ -2