Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/51320
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 on MobileFrontend object for easy access
* 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-application.js
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
7 files changed, 23 insertions(+), 42 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/20/51320/1
diff --git a/MobileFrontend.php b/MobileFrontend.php
index c3c10aa..72c1c9c 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -239,9 +239,6 @@
'mediawiki.jqueryMsg',
),
'scripts' => array(
- 'javascripts/common/mf-history-jquery.js',
- 'javascripts/modules/mf-toggle-dynamic.js',
- 'javascripts/modules/mf-search.js',
'javascripts/modules/mf-languages.js',
'javascripts/modules/mf-last-modified.js',
),
@@ -268,34 +265,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(
@@ -343,8 +329,10 @@
'stylesheets/modules/mf-tables.css',
),
'scripts' => array(
+ 'javascripts/common/mf-history-jquery.js',
'javascripts/modules/mf-random.js',
'javascripts/modules/mf-tables.js',
+ 'javascripts/modules/mf-toggle-dynamic.js',
),
'mobileTargets' => array( 'alpha' ),
);
@@ -372,6 +360,7 @@
'javascripts/modules/mf-cleanuptemplates.js',
'javascripts/modules/mf-watchlist.js',
'javascripts/modules/mf-photo.js',
+ 'javascripts/modules/mf-search.js',
'javascripts/modules/mf-references.js'
),
'messages' => array(
@@ -404,6 +393,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-application.js
b/javascripts/common/mf-application.js
index fd4a72e..d8b9984 100644
--- a/javascripts/common/mf-application.js
+++ b/javascripts/common/mf-application.js
@@ -217,6 +217,7 @@
$.extend( M, {
init: init,
+ dynamicPageLoadsEnabled: getConfig( 'alpha', false ),
emit: emit,
jQuery: typeof jQuery !== 'undefined' ? jQuery : false,
getApiUrl: getApiUrl,
diff --git a/javascripts/common/mf-history-jquery.js
b/javascripts/common/mf-history-jquery.js
index a65fcbb..df40d14 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.supportsHistoryApi ) {
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..94e98cc 100644
--- a/javascripts/common/mf-history.js
+++ b/javascripts/common/mf-history.js
@@ -1,11 +1,10 @@
-( 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 &&
+ M.dynamicPageLoadsEnabled &&
// 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
@@ -74,4 +73,4 @@
};
}() );
-} ( mw.mobileFrontend ) );
+} ( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/mf-references.js
b/javascripts/modules/mf-references.js
index fddeec2..fb9cc84 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,7 +65,7 @@
}
function init() {
- if ( inBeta ) {
+ if ( M.dynamicPageLoadsEnabled ) {
M.on( 'page-loaded', function() {
setupReferences( $( '#content' )[ 0 ] );
} ).on( 'section-rendered', function( ev,
container ) {
diff --git a/javascripts/modules/mf-toggle.js b/javascripts/modules/mf-toggle.js
index a7580a9..ce3883b 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: newchange
Gerrit-Change-Id: If29a84ea8417cf8883c351ab342414cbab1cbaca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits