jenkins-bot has submitted this change and it was merged.

Change subject: Bug 43271: Always enable section collapsing html
......................................................................


Bug 43271: Always enable section collapsing html

Decide in javascript whether to collapse..

Change-Id: I7f360f5b571895597ba06e483bea3a910e446f87
---
M includes/formatters/MobileFormatter.php
M includes/formatters/MobileFormatterHTML.php
M javascripts/modules/mf-toggle.js
M less/modules/editor.less
M less/modules/mf-toggle.less
M stylesheets/modules/editor.css
M stylesheets/modules/mf-toggle.css
M tests/ApiParseExtenderTest.php
M tests/javascripts/modules/test_mf-toggle.js
9 files changed, 53 insertions(+), 13 deletions(-)

Approvals:
  JGonera: Looks good to me, but someone else must approve
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/formatters/MobileFormatter.php 
b/includes/formatters/MobileFormatter.php
index 06ae333..afa9286 100644
--- a/includes/formatters/MobileFormatter.php
+++ b/includes/formatters/MobileFormatter.php
@@ -206,9 +206,9 @@
                                $bt = '';
                        }
                        $s .= '</div>' // <div class="content_block">
-                               . $bt
-                               . "\n</div>"; // <div class="section">
+                               . $bt;
                }
+               $s .= "\n</div>";
                wfProfileOut( __METHOD__ );
                return $s;
        }
diff --git a/includes/formatters/MobileFormatterHTML.php 
b/includes/formatters/MobileFormatterHTML.php
index 5f6b671..6e43c02 100644
--- a/includes/formatters/MobileFormatterHTML.php
+++ b/includes/formatters/MobileFormatterHTML.php
@@ -17,7 +17,7 @@
 
        protected function onHtmlReady( $html ) {
                wfProfileIn( __METHOD__ );
-               if ( $this->expandableSections && strlen( $html ) > 4000 ) {
+               if ( $this->expandableSections ) {
                        $html = $this->headingTransform( $html );
                }
                wfProfileOut( __METHOD__ );
diff --git a/javascripts/modules/mf-toggle.js b/javascripts/modules/mf-toggle.js
index d8cf443..9772f9e 100644
--- a/javascripts/modules/mf-toggle.js
+++ b/javascripts/modules/mf-toggle.js
@@ -1,6 +1,6 @@
 ( function( M, $ ) {
 
-var toggle = ( function() {
+var MIN_SECTIONS = 2, toggle = ( function() {
 
        function wm_toggle_section( section_id ) {
                $( '#section_' + section_id + ',#content_' + section_id 
).toggleClass( 'openSection' );
@@ -17,6 +17,7 @@
        }
 
        function init() {
+               $( 'html' ).removeClass( 'stub' );
                function openSectionHandler() {
                        var sectionName = this.id ? this.id.split( '_' )[1] : 
-1;
                        if ( sectionName !== -1 ) {
@@ -39,17 +40,24 @@
                $( '#content_wrapper a' ).on( 'click', checkHash );
        }
 
+       // page is not long enough to collapse so don't worry
+       if ( $( '#content h2' ).length < MIN_SECTIONS ) {
+               $( 'html' ).addClass( 'stub' );
+       } else {
+               init();
+       }
+
        return {
                wm_reveal_for_hash: wm_reveal_for_hash,
                wm_toggle_section: wm_toggle_section,
-               init: init
+               enable: init
        };
 
 }());
 
 M.define( 'toggle', toggle );
 M.on( 'page-loaded', function() {
-       toggle.init();
+       toggle.enable();
 } );
 
 }( mw.mobileFrontend, jQuery ) );
diff --git a/less/modules/editor.less b/less/modules/editor.less
index a890d85..cbd511f 100644
--- a/less/modules/editor.less
+++ b/less/modules/editor.less
@@ -9,16 +9,21 @@
 .section_heading {
        .edit-page {
                margin: 0 30px 0 0;
-               display: none !important;
+               display: none;
                font-size: .65em;
                font-family: @fontFamily;
        }
 
        &.openSection .edit-page {
-               display: block !important;
+               display: block;
        }
 }
 
+.stub .edit-page {
+       margin: 0;
+       display: block;
+}
+
 .editor-overlay {
        .spinner {
                height: 100px;
diff --git a/less/modules/mf-toggle.less b/less/modules/mf-toggle.less
index cd5443c..843ecd8 100644
--- a/less/modules/mf-toggle.less
+++ b/less/modules/mf-toggle.less
@@ -55,6 +55,16 @@
        }
 }
 
+.stub {
+       .section_heading {
+               background: none;
+               cursor: auto;
+       }
+       .content_block {
+               display: block;
+       }
+}
+
 #content_wrapper .section {
        clear: both;
        border-bottom: solid 1px #E2E3E4;
diff --git a/stylesheets/modules/editor.css b/stylesheets/modules/editor.css
index 7fe9cc4..213123e 100644
--- a/stylesheets/modules/editor.css
+++ b/stylesheets/modules/editor.css
@@ -4,12 +4,16 @@
 }
 .section_heading .edit-page {
   margin: 0 30px 0 0;
-  display: none !important;
+  display: none;
   font-size: .65em;
   font-family: "Helvetica Neue", "Helvetica", "Nimbus Sans L", "Arial", 
"Liberation Sans", sans-serif;
 }
 .section_heading.openSection .edit-page {
-  display: block !important;
+  display: block;
+}
+.stub .edit-page {
+  margin: 0;
+  display: block;
 }
 .editor-overlay .spinner {
   height: 100px;
diff --git a/stylesheets/modules/mf-toggle.css 
b/stylesheets/modules/mf-toggle.css
index 0ebeaba..95258f0 100644
--- a/stylesheets/modules/mf-toggle.css
+++ b/stylesheets/modules/mf-toggle.css
@@ -55,6 +55,13 @@
 .client-js .content_block.openSection {
   display: block;
 }
+.stub .section_heading {
+  background: none;
+  cursor: auto;
+}
+.stub .content_block {
+  display: block;
+}
 #content_wrapper .section {
   clear: both;
   border-bottom: solid 1px #E2E3E4;
diff --git a/tests/ApiParseExtenderTest.php b/tests/ApiParseExtenderTest.php
index 6a770c3..66454ce 100644
--- a/tests/ApiParseExtenderTest.php
+++ b/tests/ApiParseExtenderTest.php
@@ -48,7 +48,13 @@
        public function getData() {
                return array(
                        array( array( 'mobileformat' => 'html', 'text' => "I 
exist\n\n<span class='nomobile'>I don't</span>" ),
-                               "<p>I exist\n</p><p></p>" ),
+                               '<div id="content_0" class="content_block 
openSection"><p>I exist</p><p></p></div>' ),
+                       array( array( 'mobileformat' => 'html', 'text' => 
"Lede<h2>Section1</h2>Text<h2>Section2</h2>Text" ),
+                               '<div id="content_0" class="content_block 
openSection">Lede</div>'
+                               . '<div class="section"><h2 
class="section_heading" id="section_1"><span id="Section1">Section1</span></h2>'
+                               . '<div class="content_block" 
id="content_1">Text</div><a id="anchor_1" href="#section_1" 
class="section_anchors">&#8593;Jump back a section</a></div>'
+                               . '<div class="section"><h2 
class="section_heading" id="section_2"><span id="Section2">Section2</span></h2>'
+                               . '<div class="content_block" 
id="content_2">Text</div><a id="anchor_2" href="#section_2" 
class="section_anchors">&#8593;Jump back a section</a></div>' ),
                );
        }
 }
\ No newline at end of file
diff --git a/tests/javascripts/modules/test_mf-toggle.js 
b/tests/javascripts/modules/test_mf-toggle.js
index 2db6c36..6082707 100644
--- a/tests/javascripts/modules/test_mf-toggle.js
+++ b/tests/javascripts/modules/test_mf-toggle.js
@@ -14,7 +14,7 @@
 QUnit.module( 'MobileFrontend toggle.js: wm_toggle_section', {
        setup: function() {
                $container = makeSections();
-               toggle.init();
+               toggle.enable();
                $("#section_1,#content_1,#anchor_1").addClass("openSection");
        },
        teardown: function() {
@@ -65,7 +65,7 @@
                $("body").addClass('beta');
                $container = makeSections();
 
-               toggle.init();
+               toggle.enable();
                $("#section_1,#content_1,#anchor_1").addClass("openSection");
        },
        teardown: function() {

-- 
To view, visit https://gerrit.wikimedia.org/r/71936
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7f360f5b571895597ba06e483bea3a910e446f87
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to