Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/61580
Change subject: Beta: Lazy load sections in beta ...................................................................... Beta: Lazy load sections in beta Change-Id: I608b8294df475d2b1796620e7ce75e81c18edffb --- M MobileFrontend.php M includes/MobileFrontend.body.php M includes/skins/SkinMobile.php M javascripts/common/history-beta.js M javascripts/common/mf-history-jquery.js 5 files changed, 43 insertions(+), 41 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/80/61580/1 diff --git a/MobileFrontend.php b/MobileFrontend.php index 80e20e2..f3f42f9 100644 --- a/MobileFrontend.php +++ b/MobileFrontend.php @@ -290,8 +290,9 @@ ), 'scripts' => array( 'javascripts/modules/mf-languages.js', - 'javascripts/common/history-beta.js', 'javascripts/views/page.js', + 'javascripts/common/history-beta.js', + 'javascripts/modules/mf-toggle-dynamic.js', ), 'position' => 'bottom', 'messages' => array( @@ -414,7 +415,6 @@ 'javascripts/common/mf-history-jquery.js', 'javascripts/modules/mf-tables.js', 'javascripts/modules/mf-translator.js', - 'javascripts/modules/mf-toggle-dynamic.js', 'javascripts/modules/talk.js', ), ); diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php index 7eced46..6cac599 100644 --- a/includes/MobileFrontend.body.php +++ b/includes/MobileFrontend.body.php @@ -141,7 +141,7 @@ } $isFilePage = $this->getTitle()->getNamespace() === NS_FILE; - $formatter->enableRemovableSections( $context->isAlphaGroupMember() && !$isFilePage ); + $formatter->enableRemovableSections( $context->isBetaGroupMember() && !$isFilePage ); $doc = $formatter->getDoc(); wfProfileOut( __METHOD__ . '-formatter-init' ); diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php index dd7d8ef..3dad588 100644 --- a/includes/skins/SkinMobile.php +++ b/includes/skins/SkinMobile.php @@ -267,12 +267,12 @@ if ( $inBeta ) { $out->addModules( 'mobile.beta' ); $mode = 'beta'; + } else { + $out->addModules( 'mobile.toggling' ); } if ( $inAlpha ) { $out->addModules( 'mobile.alpha' ); $mode = 'alpha'; - } else { - $out->addModules( 'mobile.toggling' ); } wfRunHooks( 'EnableMobileModules', array( $out, $mode ) ); diff --git a/javascripts/common/history-beta.js b/javascripts/common/history-beta.js index 4ed94e5..70b3235 100644 --- a/javascripts/common/history-beta.js +++ b/javascripts/common/history-beta.js @@ -1,5 +1,7 @@ ( function( M, $ ) { var api = M.require( 'api' ), + Page = M.require( 'page' ), + currentTitle = mw.config.get( 'wgTitle', '' ), cache = {}; function retrievePage( pageTitle, endpoint ) { @@ -35,6 +37,23 @@ return cachedPage; } + function renderPage( pageData ) { + var page = new Page( $.extend( pageData, { el: $( '#content' )[0] } ) ); + + if ( page.isMainPage ) { + M.emit( 'homepage-loaded' ); + } + M.emit( 'page-loaded', page ); + } + + function loadPage( pageTitle ) { + currentTitle = pageTitle; + return M.history.retrievePage( pageTitle ).done( function( resp ) { + renderPage( resp ); + } ); + } + M.history.retrievePage = retrievePage; + M.history.loadPage = loadPage; } ( mw.mobileFrontend, jQuery ) ); diff --git a/javascripts/common/mf-history-jquery.js b/javascripts/common/mf-history-jquery.js index f0256c5..efd82a1 100644 --- a/javascripts/common/mf-history-jquery.js +++ b/javascripts/common/mf-history-jquery.js @@ -2,14 +2,13 @@ var firstRun, - Page = M.require( 'page' ), makeStubPage, linkHijacking = false, // FIXME: allow user to opt in/out - creates various problems in current implementation in alpha updateQueryStringParameter = M.history.updateQueryStringParameter, getArticleUrl = M.history.getArticleUrl, currentTitle = mw.config.get( 'wgTitle', '' ), navigateToPage, - loadPage, + loadPage = M.history.loadPage, loadLanguages, apiUrl = M.getApiUrl(), api = M.require( 'api' ), @@ -76,16 +75,6 @@ } ); } - function renderPage( pageData ) { - var page = new Page( $.extend( pageData, { el: $( '#content' )[0] } ) ); - - $( '#content_0' ).removeClass( 'loading' ); // reset loader - if ( page.isMainPage ) { - M.emit( 'homepage-loaded' ); - } - M.emit( 'page-loaded', page ); - } - loadLanguages = function( title ) { $( '#mw-mf-language-section' ).remove(); $.ajax( { @@ -117,28 +106,6 @@ return $content; }; - loadPage = function( pageTitle, constructPage ) { - currentTitle = pageTitle; - if ( constructPage ) { - makeStubPage( pageTitle, M.message( 'mobile-frontend-ajax-page-loading', pageTitle ) ); - } - return M.history.retrievePage( pageTitle ).done( function( resp ) { - renderPage( resp ); - } ).fail( function( resp ) { - if ( resp.error && resp.error.code !== 'missingtitle' ) { - window.location.href = getArticleUrl( pageTitle ); - } - if ( constructPage ) { // when not constructing page there will be links to fall back to - $( '#content_0' ).removeClass( 'loading' ). - text( M.message( 'mobile-frontend-ajax-page-error', pageTitle ) ). - addClass( 'ajaxError' ); // reset loader - $( '<button>' ).text( mw.msg( 'mobile-frontend-ajax-random-retry' ) ).on( 'click', function() { - loadPage( pageTitle, constructPage ); - } ).appendTo( '#content_0' ); - } - } ); - }; - M.on( 'page-loaded', function() { if ( linkHijacking ) { hijackLinks(); @@ -151,7 +118,24 @@ mw.config.set( 'wgTitle', title ); mw.config.set( 'wgArticleId', -1 ); // FIXME: no longer valid document.title = mw.message( 'pagetitle', title ).parse(); - page = loadPage( title, typeof constructPage === 'undefined' ? true : constructPage ); + if ( constructPage ) { + makeStubPage( title, M.message( 'mobile-frontend-ajax-page-loading', title ) ); + } + page = loadPage( title, typeof constructPage === 'undefined' ? true : constructPage ).fail( function( resp ) { + if ( resp.error && resp.error.code !== 'missingtitle' ) { + window.location.href = getArticleUrl( title ); + } + if ( constructPage ) { // when not constructing page there will be links to fall back to + $( '#content_0' ).removeClass( 'loading' ). + text( M.message( 'mobile-frontend-ajax-page-error', title ) ). + addClass( 'ajaxError' ); // reset loader + $( '<button>' ).text( mw.msg( 'mobile-frontend-ajax-random-retry' ) ).on( 'click', function() { + loadPage( title ); + } ).appendTo( '#content_0' ); + } + } ).done( function() { + $( '#content_0' ).removeClass( 'loading' ); // reset loader + } ); window.history.pushState( { title: title, hash: true }, title, getArticleUrl( title ) ); return page; }; @@ -182,7 +166,6 @@ } ); M.history.makeStubPage = makeStubPage; - M.history.loadPage = loadPage; M.history.navigateToPage = navigateToPage; } ( mw.mobileFrontend, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/61580 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I608b8294df475d2b1796620e7ce75e81c18edffb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits