jenkins-bot has submitted this change and it was merged. Change subject: Collapse on h1s when present ......................................................................
Collapse on h1s when present * When h1s are present collapse on these rather than h2s Bug: 52857 Change-Id: I5e8d723d061f7003599b2a7f639bbe1301ba92e0 --- M includes/formatters/MobileFormatter.php M includes/formatters/MobileFormatterHTML.php M javascripts/modules/editor/editor.js M javascripts/modules/mf-toggle.js M less/modules/editor.less M less/modules/toggle.less M stylesheets/modules/editor.css M stylesheets/modules/toggle.css 8 files changed, 27 insertions(+), 9 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/formatters/MobileFormatter.php b/includes/formatters/MobileFormatter.php index 775e128..d15e5e1 100644 --- a/includes/formatters/MobileFormatter.php +++ b/includes/formatters/MobileFormatter.php @@ -269,10 +269,11 @@ * @param string $s * @return string */ - protected function headingTransform( $s ) { + protected function headingTransform( $s, $tagName = 'h2' ) { wfProfileIn( __METHOD__ ); + $tagRegEx = '<' . $tagName . '.*</' . $tagName . '>'; $s = $this->pageTransformStart . - preg_replace( '%(<h2.*</h2>)%sU', $this->headingTransformStart . '\1' . $this->headingTransformEnd, $s ) . + preg_replace( '%(' . $tagRegEx . ')%sU', $this->headingTransformStart . '\1' . $this->headingTransformEnd, $s ) . $this->pageTransformEnd; wfProfileOut( __METHOD__ ); return $s; diff --git a/includes/formatters/MobileFormatterHTML.php b/includes/formatters/MobileFormatterHTML.php index f120893..58cadd4 100644 --- a/includes/formatters/MobileFormatterHTML.php +++ b/includes/formatters/MobileFormatterHTML.php @@ -22,7 +22,8 @@ protected function onHtmlReady( $html ) { wfProfileIn( __METHOD__ ); if ( $this->expandableSections ) { - $html = $this->headingTransform( $html ); + $tagName = strrpos( $html, '<h1' ) !== false ? 'h1' : 'h2'; + $html = $this->headingTransform( $html, $tagName ); } wfProfileOut( __METHOD__ ); return $html; diff --git a/javascripts/modules/editor/editor.js b/javascripts/modules/editor/editor.js index 558b672..fe1eb16 100644 --- a/javascripts/modules/editor/editor.js +++ b/javascripts/modules/editor/editor.js @@ -87,7 +87,7 @@ } ); // FIXME: remove when SkinMobile::doEditSectionLink present in cached pages - $( 'h2 .mw-editsection' ).each( function() { + $( '#content' ).find( 'h1,h2' ).find( '.mw-editsection' ).each( function() { var section = extractSectionIdFromEditLink( $( this ).find( 'a' ) ); if ( section ) { addEditButton( section, $( this ).parent() ). @@ -118,7 +118,7 @@ } ); // FIXME: remove when SkinMobile::doEditSectionLink present in cached pages - $( 'h2 .mw-editsection' ).each( function() { + $( '#content' ).find( 'h1,h2' ).find( '.mw-editsection' ).each( function() { var $heading = $( this ).closest( 'h2' ), $a = addEditButton( '', $heading ); if ( mw.config.get( 'wgMFMode' ) === 'stable' ) { diff --git a/javascripts/modules/mf-toggle.js b/javascripts/modules/mf-toggle.js index 1866b05..c8e7527 100644 --- a/javascripts/modules/mf-toggle.js +++ b/javascripts/modules/mf-toggle.js @@ -36,9 +36,12 @@ } function init() { - var $page = $( '#content' ); + var $page = $( '#content' ), tagName = 'h2'; $( 'html' ).removeClass( 'stub' ); - $page.find( 'h2' ).addClass( 'section_heading' ); + if ( $page.find( 'h1' ).length > 0 ) { + tagName = 'h1'; + } + $page.find( tagName ).addClass( 'section_heading' ); $page.find( '.section_heading' ).next( 'div' ).addClass( 'content_block' ); // use mouseup because mousedown blocks the click event and links diff --git a/less/modules/editor.less b/less/modules/editor.less index 9224369..fa0ea6e 100644 --- a/less/modules/editor.less +++ b/less/modules/editor.less @@ -13,8 +13,11 @@ right: 0; } - h2.openSection .edit-page { - display: block; + h1.openSection, + h2.openSection { + .edit-page { + display: block; + } } } diff --git a/less/modules/toggle.less b/less/modules/toggle.less index dc81f63..708144e 100644 --- a/less/modules/toggle.less +++ b/less/modules/toggle.less @@ -27,6 +27,11 @@ } } + h1.section_heading { + background-position: left 0.9em; + padding: 9pt 24px 9pt; + } + a.section_anchors { display: none; &.openSection { diff --git a/stylesheets/modules/editor.css b/stylesheets/modules/editor.css index 474a2f8..af2c5a2 100644 --- a/stylesheets/modules/editor.css +++ b/stylesheets/modules/editor.css @@ -20,6 +20,7 @@ bottom: 0; right: 0; } +.content h1.openSection .edit-page, .content h2.openSection .edit-page { display: block; } diff --git a/stylesheets/modules/toggle.css b/stylesheets/modules/toggle.css index db2cb3b..d9365ba 100644 --- a/stylesheets/modules/toggle.css +++ b/stylesheets/modules/toggle.css @@ -31,6 +31,10 @@ border-bottom: solid 1px #e2e3e4; margin-bottom: 9pt; } +.client-js h1.section_heading { + background-position: left 0.9em; + padding: 9pt 24px 9pt; +} .client-js a.section_anchors { display: none; margin-bottom: 5px; -- To view, visit https://gerrit.wikimedia.org/r/83931 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5e8d723d061f7003599b2a7f639bbe1301ba92e0 Gerrit-PatchSet: 11 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: JGonera <jgon...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits