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

Change subject: Show edit pencil on all headings
......................................................................


Show edit pencil on all headings

Bug: T87644
Change-Id: I8d8d47cd608d59fb1723758106547f1ab137daa2
---
M includes/MobileFormatter.php
M javascripts/modules/editor/init.js
M less/ui.less
M tests/phpunit/MobileFormatterTest.php
4 files changed, 32 insertions(+), 3 deletions(-)

Approvals:
  Phuedx: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index 7dedc32..a95210e 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -237,13 +237,33 @@
        }
 
        /**
-        * Makes sections expandable
+        * Transforms heading for toggling and editing
+        *
+        * - Add css classes to all h-tags (h1-h6) _inside_ a section
+        *   to enable editing of these sections. Doesn't add this class to the 
first
+        *   heading ($tagName)
+        * - Wraps section-content inside a div to enable toggling
         *
         * @param string $s
         * @param string $tagName
         * @return string
         */
        protected function headingTransform( $s, $tagName = 'h2' ) {
+               // add in-block class to all headings included in this section 
(except the first one)
+               $s = preg_replace_callback(
+                       '/<(h[1-6])>/si',
+                       function ( $match ) use ( $tagName ) {
+                               $tag = $match[1];
+                               $cssClass = '';
+                               if ( $tag !== $tagName ) {
+                                       $cssClass = ' class="in-block"';
+                               }
+                               return '<' . $tag . $cssClass . '>';
+                       },
+                       $s
+               );
+
+               // Makes sections expandable
                $tagRegEx = '<' . $tagName . '.*</' . $tagName . '>';
                $s = $this->pageTransformStart .
                        preg_replace(
diff --git a/javascripts/modules/editor/init.js 
b/javascripts/modules/editor/init.js
index 5953f08..d5fb544 100644
--- a/javascripts/modules/editor/init.js
+++ b/javascripts/modules/editor/init.js
@@ -199,7 +199,7 @@
                        }
                }
 
-               $( '.edit-page' ).on( 'click', function ( ev ) {
+               $( '.edit-page' ).show().on( 'click', function ( ev ) {
                        // prevent folding section when clicking Edit
                        ev.stopPropagation();
                } );
diff --git a/less/ui.less b/less/ui.less
index 9ebf3e0..8861932 100644
--- a/less/ui.less
+++ b/less/ui.less
@@ -190,6 +190,15 @@
                        display: block;
                }
        }
+
+       // show edit section pencils on section headings inside collapsible 
blocks
+       .in-block {
+               position: relative;
+
+               > .edit-page {
+                       display: none;
+               }
+       }
 }
 
 .stub .edit-page {
diff --git a/tests/phpunit/MobileFormatterTest.php 
b/tests/phpunit/MobileFormatterTest.php
index 4044818..3be4a38 100644
--- a/tests/phpunit/MobileFormatterTest.php
+++ b/tests/phpunit/MobileFormatterTest.php
@@ -78,7 +78,7 @@
                                        . '<h3><span>h3</span></h3>'
                                        . '<div>'
                                        . $longLine
-                                       . '<h4><span>h4</span></h4>'
+                                       . '<h4 
class="in-block"><span>h4</span></h4>'
                                        . 'h4 text.'
                                        . '</div>',
                                $enableSections

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I8d8d47cd608d59fb1723758106547f1ab137daa2
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to