Jdlrobson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405233 )
Change subject: Update the font size on back button presses ...................................................................... Update the font size on back button presses Bug: T185166 Change-Id: I4d3edda3d18711af19203b979cf9ec9919068c07 --- M resources/mobile.init/init.js 1 file changed, 32 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/33/405233/1 diff --git a/resources/mobile.init/init.js b/resources/mobile.init/init.js index f19af16..df86cea 100644 --- a/resources/mobile.init/init.js +++ b/resources/mobile.init/init.js @@ -5,16 +5,14 @@ * @class mw.mobileFrontend * @singleton */ -( function ( M, $ ) { - var currentPage, skin, +( function ( M, $, storage ) { + var currentPage, skin, userFontSize, PageGateway = M.require( 'mobile.startup/PageGateway' ), BetaOptinPanel = M.require( 'mobile.init/BetaOptinPanel' ), gateway = new PageGateway( new mw.Api() ), util = mw.util, user = mw.user, - storage = mw.storage, context = M.require( 'mobile.startup/context' ), - userFontSize = mw.storage.get( 'userFontSize' ), Page = M.require( 'mobile.startup/Page' ), experiments = mw.experiments, activeExperiments = mw.config.get( 'wgMFExperiments' ) || {}, @@ -157,9 +155,36 @@ } ); } } - if ( userFontSize !== '100' ) { - $( '#content p, .content p' ).css( 'font-size', userFontSize + '%' ); + + /** + * Updates the font size based on the current value in storage + * + * @method + * @ignore + */ + function updateFontSize() { + if ( !userFontSize ) { + // first visit + userFontSize = storage.get( 'userFontSize' ); + if ( userFontSize === '100' ) { + // No need to change the font size from the normal size. + return; + } + } else { + userFontSize = storage.get( 'userFontSize' ); + } + // actually change the font size. + $( '#content p, .content p' ) + .css( 'font-size', userFontSize + '%' ); } + + // Font must be updated on back button press as users may click + // back after changing font. + $( window ).on( 'pageshow', function () { + updateFontSize(); + } ); + updateFontSize(); + if ( activeExperiments.betaoptin ) { displayBetaOptIn( activeExperiments.betaoptin, getCurrentPage() ); } @@ -169,4 +194,4 @@ } ); /* eslint-enable no-console */ -}( mw.mobileFrontend, jQuery ) ); +}( mw.mobileFrontend, jQuery, mw.storage ) ); -- To view, visit https://gerrit.wikimedia.org/r/405233 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4d3edda3d18711af19203b979cf9ec9919068c07 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: specialpages Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits