JGonera has submitted this change and it was merged.
Change subject: Alpha: Move dynamic section loading from beta to alpha
......................................................................
Alpha: Move dynamic section loading from beta to alpha
Whilst this is not a priority this risks breaking and also
adds an element of inconsistency between alpha and beta
Already there are various bugs (e.g. bug 44562)
* only define mf-search.js once - in stable module
* don't define mf-toggle.css twice - it's in mobile.styles
* define dynamicPageLoadsEnabled in history module
* Remove repeated code in mf-history-jquery.js
* Now jQuery is ubiquitous add to closure in mf-history.js
* Remove traces of lead section toggling code from toggle.js
Change-Id: If29a84ea8417cf8883c351ab342414cbab1cbaca
---
M MobileFrontend.php
M includes/MobileFrontend.body.php
M javascripts/common/mf-history-jquery.js
M javascripts/common/mf-history.js
M javascripts/modules/mf-references.js
M javascripts/modules/mf-toggle.js
6 files changed, 28 insertions(+), 49 deletions(-)
Approvals:
JGonera: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 708c867..01224e2 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -239,9 +239,6 @@
'mobile.stable',
),
'scripts' => array(
- 'javascripts/common/mf-history-jquery.js',
- 'javascripts/modules/mf-toggle-dynamic.js',
- 'javascripts/modules/mf-search.js',
'javascripts/modules/mf-languages.js',
),
'position' => 'bottom',
@@ -260,34 +257,23 @@
// mf-history-jquery.js
'mobile-frontend-ajax-page-loading',
'mobile-frontend-ajax-page-error',
-
- // for mf-search.js
- 'mobile-frontend-search-help',
- 'mobile-frontend-search-noresults',
- 'mobile-frontend-overlay-escape',
),
'mobileTargets' => array( 'beta', 'alpha' ),
);
-$wgResourceModules['mobile.stable-only'] = $wgMFMobileResourceBoilerplate +
array(
+$wgResourceModules['mobile.toggling'] = $wgMFMobileResourceBoilerplate + array(
'dependencies' => array( 'mobile.startup' ),
'messages' => array(
// for mf-toggle.js
'mobile-frontend-close-section',
'mobile-frontend-show-button',
'mobile-frontend-hide-button',
-
- // for mf-search.js
- 'mobile-frontend-search-help',
- 'mobile-frontend-search-noresults',
- 'mobile-frontend-overlay-escape',
),
- 'styles' => array( 'stylesheets/modules/mf-toggle.css' ),
+ 'styles' => array(),
'scripts' => array(
'javascripts/modules/mf-toggle.js',
- 'javascripts/modules/mf-search.js',
),
- 'mobileTargets' => array( 'stable' ),
+ 'mobileTargets' => array( 'stable', 'beta' ),
);
$wgResourceModules['mobile.action.edit'] = $wgMFMobileResourceBoilerplate +
array(
@@ -336,9 +322,11 @@
),
'scripts' => array(
'javascripts/modules/mf-inline-style-scrubber.js',
+ 'javascripts/common/mf-history-jquery.js',
'javascripts/modules/mf-random.js',
'javascripts/modules/mf-tables.js',
'javascripts/modules/mf-translator.js',
+ 'javascripts/modules/mf-toggle-dynamic.js',
),
'mobileTargets' => array( 'alpha' ),
);
@@ -368,6 +356,7 @@
'javascripts/modules/mf-last-modified.js',
'javascripts/modules/mf-watchstar.js',
'javascripts/modules/mf-photo.js',
+ 'javascripts/modules/mf-search.js',
'javascripts/modules/mf-references.js'
),
'messages' => array(
@@ -409,6 +398,11 @@
'mobile-frontend-photo-upload-comment',
'mobile-frontend-photo-submit',
'mobile-frontend-photo-cancel',
+
+ // for mf-search.js
+ 'mobile-frontend-search-help',
+ 'mobile-frontend-search-noresults',
+ 'mobile-frontend-overlay-escape',
),
'mobileTargets' => array( 'stable', 'beta', 'alpha' ),
);
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index f2ab8be..04ff07d 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -133,7 +133,7 @@
}
$isFilePage = $this->getTitle()->getNamespace() === NS_FILE;
- $formatter->enableRemovableSections(
$context->isBetaGroupMember() && !$isFilePage );
+ $formatter->enableRemovableSections(
$context->isAlphaGroupMember() && !$isFilePage );
$doc = $formatter->getDoc();
wfProfileOut( __METHOD__ . '-formatter-init' );
diff --git a/javascripts/common/mf-history-jquery.js
b/javascripts/common/mf-history-jquery.js
index a65fcbb..5fa4e09 100644
--- a/javascripts/common/mf-history-jquery.js
+++ b/javascripts/common/mf-history-jquery.js
@@ -1,6 +1,6 @@
( function( M, $ ) {
- var inBeta = M.getConfig( 'beta', false ),
+ var
firstRun,
makeStubPage,
updateQueryStringParameter =
M.history.updateQueryStringParameter,
@@ -10,13 +10,7 @@
loadPage,
loadLanguages,
languagesTemplate,
- apiUrl = M.getConfig( 'scriptPath', '' ) + '/api.php',
- ua = window.navigator.userAgent,
- supportsHistoryApi = window.history && window.history.pushState
&& window.history.replaceState && inBeta &&
- // bug 41407 - certain S60 devices crash when you use
pushState
- !( ua.match( /Series60/ ) && ua.match( /WebKit/ ) ) &&
- // bug 41605 disable for Android 4.x phones that are
not Chrome
- !( ua.match( /Android 4\./ ) && ua.match( /WebKit/ ) &&
!ua.match( /Chrome/ ) );
+ apiUrl = M.getConfig( 'scriptPath', '' ) + '/api.php';
function gatherTemplates() {
languagesTemplate = $( '#mw-mf-language-section' ).clone();
@@ -192,7 +186,7 @@
hijackLinks();
} );
- if ( supportsHistoryApi ) {
+ if ( M.history.isDynamicPageLoadEnabled ) {
navigateToPage = function( title, constructPage ) {
var page;
M.setConfig( 'title', title );
diff --git a/javascripts/common/mf-history.js b/javascripts/common/mf-history.js
index 042567d..b1927c7 100644
--- a/javascripts/common/mf-history.js
+++ b/javascripts/common/mf-history.js
@@ -1,15 +1,14 @@
-( function( M ) {
+( function( M, $ ) {
M.history = ( function() {
var initialised = false,
- $ = M.jQuery,
- inBeta = M.getConfig( 'beta', false ),
ua = window.navigator.userAgent,
- supportsHistoryApi = window.history && window.history.pushState
&& window.history.replaceState && inBeta &&
+ supportsHistoryApi = window.history && window.history.pushState
&& window.history.replaceState &&
// bug 41407 - certain S60 devices crash when you use
pushState
!( ua.match( /Series60/ ) && ua.match( /WebKit/ ) ) &&
// bug 41605 disable for Android 4.x phones that are
not Chrome
!( ua.match( /Android 4\./ ) && ua.match( /WebKit/ ) &&
!ua.match( /Chrome/ ) ),
+ isDynamicPageLoadEnabled = M.getConfig( 'alpha', false ) &&
supportsHistoryApi,
currentTitle = M.getConfig( 'title', '' ),
URL_TEMPLATE = M.getConfig( 'pageUrl', '' ),
navigateToPage = function( title ) {
@@ -46,12 +45,13 @@
return {
getArticleUrl: getArticleUrl,
+ isDynamicPageLoadEnabled: isDynamicPageLoadEnabled,
navigateToPage: navigateToPage,
replaceHash: function( newHash ) {
var hashChanged = newHash !== window.location.hash,
id = newHash.slice( 1 ),
hashNode = document.getElementById( id );
- if ( supportsHistoryApi && hashChanged ) {
+ if ( isDynamicPageLoadEnabled && hashChanged ) {
window.history.replaceState( { title:
currentTitle, hash: true }, currentTitle, newHash );
} else if ( hashChanged && hashNode ) {
hashNode.removeAttribute( 'id' );
@@ -62,7 +62,7 @@
},
pushState: function( hash ) {
var hashChanged = hash !== window.location.hash;
- if ( supportsHistoryApi && hashChanged ) {
+ if ( isDynamicPageLoadEnabled && hashChanged ) {
window.history.pushState( { title:
currentTitle, hash: true }, currentTitle, hash );
} else if ( hashChanged ) {
window.location.hash = hash;
@@ -74,4 +74,4 @@
};
}() );
-} ( mw.mobileFrontend ) );
+} ( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/mf-references.js
b/javascripts/modules/mf-references.js
index b03b9eb..2395f0f 100644
--- a/javascripts/modules/mf-references.js
+++ b/javascripts/modules/mf-references.js
@@ -1,6 +1,6 @@
( function( M, $ ) {
var references = ( function() {
- var inBeta = M.getConfig( 'beta', false ),
+ var
popup = M.require( 'notifications' );
function collect() {
@@ -65,12 +65,10 @@
}
function init() {
- if ( inBeta ) {
- M.
- on( 'page-loaded', function() {
- setupReferences( $( '#content'
)[ 0 ] );
- } ).
- on( 'section-rendered', setupReferences
);
+ if ( M.history.isDynamicPageLoadEnabled ) {
+ M.on( 'page-loaded', function() {
+ setupReferences( $( '#content' )[ 0 ] );
+ } ).on( 'section-rendered', setupReferences );
} else {
setupReferences.apply( this, arguments );
}
diff --git a/javascripts/modules/mf-toggle.js b/javascripts/modules/mf-toggle.js
index 12eb4e8..b021e55 100644
--- a/javascripts/modules/mf-toggle.js
+++ b/javascripts/modules/mf-toggle.js
@@ -56,17 +56,10 @@
function init() {
u( document.documentElement ).addClass( 'togglingEnabled' );
var i, a, heading, h2,
- sectionHeadings = [], content, firstHeadings;
+ sectionHeadings = [], content;
content = document.getElementById( 'content_wrapper' );
h2 = document.getElementsByTagName( 'H2' );
- if ( M.getConfig( 'beta' ) ) {
- firstHeadings = document.getElementsByTagName( 'H1' );
- if ( firstHeadings.length === 1 && // special cases
for some pages do not have an H1 (e.g. main page) - off topic they should..
- u( firstHeadings[ 0 ] ).hasClass(
'section_heading' ) ) {
- sectionHeadings.push( firstHeadings[ 0 ] );
- }
- }
for( i = 0; i < h2.length; i++) {
heading = h2[i];
--
To view, visit https://gerrit.wikimedia.org/r/51320
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If29a84ea8417cf8883c351ab342414cbab1cbaca
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits