Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189506

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
3 files changed, 26 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/06/189506/1

diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index e2e23c9..1251bb2 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -220,13 +220,28 @@
        }
 
        /**
-        * Makes sections expandable
+        * Formats headings
         *
         * @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 a98a272..efb1779 100644
--- a/less/ui.less
+++ b/less/ui.less
@@ -191,6 +191,15 @@
                        display: block;
                }
        }
+
+       // show edit section pencils on section headings inside collapsible 
blocks
+       .in-block {
+               position: relative;
+
+               > .edit-page {
+                       display: none;
+               }
+       }
 }
 
 .stub .edit-page {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8d8d47cd608d59fb1723758106547f1ab137daa2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>

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

Reply via email to