Bene has uploaded a new change for review.
https://gerrit.wikimedia.org/r/203953
Change subject: Get rid of $wgMFPageSections config
......................................................................
Get rid of $wgMFPageSections config
This variable was used on two places to determine if we are in
mobile mode. Both places can use more intelligent conditions.
To place the toc, simply looking up if a #toc already exists and
replacing it is much easier.
For toggling of sections no check is needed at all because on the
skin's desktop version, there is a div under #content wrapping
the whole content so that the selector >h1,>h2,>h3,>h4,>h5,>h6
wont work in that place anyways and therefore the condition is not
needed.
Bug: T95884
Change-Id: Icc586d9d76f81f512e2a94d326a7f28168bc44ef
---
M includes/skins/SkinMinerva.php
M javascripts/modules/toc/init.js
M javascripts/modules/toggling/init.js
3 files changed, 8 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/53/203953/1
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index f768211..10844f6 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -856,8 +856,7 @@
'wgMFDeviceWidthTablet' => $config->get(
'MFDeviceWidthTablet' ),
'wgMFMode' => $this->getMode(),
'wgMFCollapseSectionsByDefault' => $config->get(
'MFCollapseSectionsByDefault' ),
- 'wgMFTocEnabled' => $this->getOutput()->getProperty(
'MinervaTOC' ),
- 'wgMFPageSections' => $this->isMobileMode
+ 'wgMFTocEnabled' => $this->getOutput()->getProperty(
'MinervaTOC' )
);
if ( $this->isAuthenticatedUser() ) {
diff --git a/javascripts/modules/toc/init.js b/javascripts/modules/toc/init.js
index fdd42ef..a44f26f 100644
--- a/javascripts/modules/toc/init.js
+++ b/javascripts/modules/toc/init.js
@@ -22,15 +22,17 @@
toc = new TableOfContents( {
sections: sections
} );
- if ( mw.config.get( 'wgMFPageSections' ) ) {
- toc.appendTo( page.getLeadSectionElement() );
- } else {
+
+ // if there is a toc already, replace it
+ if ( this.$( '#toc' ).length > 0 ) {
// don't show toc at end of page, when no
sections there
toc.insertAfter( '#toc' );
// remove the original parser toc
this.$( '#toc' ).remove();
// prevent to float text right of toc
this.$( '.toc-mobile' ).after( '<div
style="clear:both;"></div>' );
+ } else {
+ toc.appendTo( page.getLeadSectionElement() );
}
toggle.enable( toc.$el, 'toc-' );
}
diff --git a/javascripts/modules/toggling/init.js
b/javascripts/modules/toggling/init.js
index d57bf93..138c791 100644
--- a/javascripts/modules/toggling/init.js
+++ b/javascripts/modules/toggling/init.js
@@ -200,7 +200,7 @@
$container = $container || $( '#content' );
$( 'html' ).removeClass( 'stub' );
- $firstHeading = $container.find( '> h1,> h2,> h3,> h4,> h5,>
h6' ).eq( 0 );
+ $firstHeading = $container.find( '> h1,> h2,> h3,> h4,> h5,>
h6,.section-heading' ).eq( 0 );
tagName = $firstHeading.prop( 'tagName' ) || 'H1';
if ( collapseSectionsByDefault === undefined ) {
@@ -319,9 +319,7 @@
!mw.config.get( 'wgIsMainPage' ) &&
mw.config.get( 'wgAction' ) === 'view'
) {
- if ( mw.config.get( 'wgMFPageSections' ) ) {
- init( $( '#content' ), 'content-' );
- }
+ init( $( '#content' ), 'content-' );
}
M.define( 'toggle', {
--
To view, visit https://gerrit.wikimedia.org/r/203953
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc586d9d76f81f512e2a94d326a7f28168bc44ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits