Pmiazga has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/375411 )

Change subject: Move the mobile revision navigation links to top
......................................................................

Move the mobile revision navigation links to top

To unify the browsing history experience between both desktop
and mobile we need to move the revision next/prev buttons to
top of the page.

Changes:
 - moved rendering navigation links logic to SpecialMobilePage
 - added new styles to create a margin between navigation links
 and page title and aligned NEXT link to the right
 - renamed $title->getLocalUrl() to valid getLocalURL()
 - split showHeader() into set of smaller functions for easier
 understanding and maitenance

Bug: T166253
Change-Id: Ibe377b6b3b7b3dba2f75edc08ac9bbe1d2620321
---
M includes/diff/InlineDifferenceEngine.php
M includes/specials/SpecialMobileDiff.php
M resources/mobile.special.mobilediff.styles/mobilediff.less
3 files changed, 88 insertions(+), 55 deletions(-)


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

diff --git a/includes/diff/InlineDifferenceEngine.php 
b/includes/diff/InlineDifferenceEngine.php
index 2354819..d858143 100644
--- a/includes/diff/InlineDifferenceEngine.php
+++ b/includes/diff/InlineDifferenceEngine.php
@@ -82,25 +82,6 @@
                        $diff .
                        '</div>'
                );
-               $prev = $rev->getPrevious();
-               $next = $rev->getNext();
-               if ( $prev || $next ) {
-                       $history = Html::openElement( 'ul', [ 'class' => 'hlist 
revision-history-links' ] );
-                       if ( $prev ) {
-                               $history .= Html::openElement( 'li' ) .
-                                       Html::element( 'a', [
-                                               'href' => 
SpecialPage::getTitleFor( 'MobileDiff', $prev->getId() )->getLocalUrl()
-                                       ], $this->msg( 'previousdiff' ) ) . 
Html::closeElement( 'li' );
-                       }
-                       if ( $next ) {
-                               $history .= Html::openElement( 'li' ) .
-                                       Html::element( 'a', [
-                                               'href' => 
SpecialPage::getTitleFor( 'MobileDiff', $next->getId() )->getLocalUrl()
-                                       ], $this->msg( 'nextdiff' ) ) . 
Html::closeElement( 'li' );
-                       }
-                       $history .= Html::closeElement( 'ul' );
-                       $output->addHtml( $history );
-               }
 
                $output->addHtml( Html::rawElement(
                        'div',
@@ -236,4 +217,5 @@
                }
                return $linkInfo;
        }
+
 }
diff --git a/includes/specials/SpecialMobileDiff.php 
b/includes/specials/SpecialMobileDiff.php
index 3a98b00..3dde5ac 100644
--- a/includes/specials/SpecialMobileDiff.php
+++ b/includes/specials/SpecialMobileDiff.php
@@ -178,14 +178,49 @@
 
        /**
         * Render the header of a diff page including:
+        * Navigation links
         * Name with url to page
         * Bytes added/removed
         * Day and time of edit
         * Edit Comment
         */
        private function showHeader() {
-               $title = $this->targetTitle;
+               if ( $this->rev->isMinor() ) {
+                       $minor = ChangesList::flag( 'minor' );
+               } else {
+                       $minor = '';
+               }
+               $this->getOutput()->addHTML(
+                       $this->getRevisionNavigationLinksHTML() .
+                       $this->getIntroHTML() .
+                       $minor .
+                       $this->getCommentHTML()
+               );
+       }
 
+       /**
+        * Get the edit comment
+        * @return string Build HTML for edit comment section
+        */
+       private function getCommentHTML() {
+               if ( $this->rev->getComment() !== '' ) {
+                       $comment = Linker::formatComment( 
$this->rev->getComment(), $this->targetTitle );
+               } else {
+                       $comment = $this->msg( 
'mobile-frontend-changeslist-nocomment' )->escaped();
+               }
+
+               return Html::rawElement(
+                       'div',
+                       [ 'id' => 'mw-mf-diff-comment' ],
+                       $comment
+               );
+       }
+
+       /**
+        * Get the intro HTML
+        * @return string Built HTML for intro section
+        */
+       private function getIntroHTML() {
                if ( $this->prevRev ) {
                        $bytesChanged = $this->rev->getSize() - 
$this->prevRev->getSize();
                } else {
@@ -205,46 +240,57 @@
                                'meta mw-mf-bytesremoved mw-ui-icon-small' );
                        $bytesChanged = abs( $bytesChanged );
                }
-
-               if ( $this->rev->isMinor() ) {
-                       $minor = ChangesList::flag( 'minor' );
-               } else {
-                       $minor = '';
-               }
-               if ( $this->rev->getComment() !== '' ) {
-                       $comment = Linker::formatComment( 
$this->rev->getComment(), $title );
-               } else {
-                       $comment = $this->msg( 
'mobile-frontend-changeslist-nocomment' )->escaped();
-               }
-
                $ts = new MWTimestamp( $this->rev->getTimestamp() );
-               $this->getOutput()->addHtml(
-                       Html::openElement( 'div', [ 'id' => 'mw-mf-diff-info', 
'class' => 'page-summary' ] )
-                               . Html::openElement( 'h2', [] )
+
+               return Html::openElement( 'div', [ 'id' => 'mw-mf-diff-info', 
'class' => 'page-summary' ] )
+                       . Html::openElement( 'h2', [] )
                                . Html::element( 'a',
                                        [
-                                               'href' => $title->getLocalURL(),
+                                               'href' => 
$this->targetTitle->getLocalURL()
                                        ],
-                                       $title->getPrefixedText()
+                                       $this->targetTitle->getPrefixedText()
                                )
-                               . Html::closeElement( 'h2' )
-                               . $this->msg( 'mobile-frontend-diffview-comma' 
)->rawParams(
-                                       Html::element( 'span', [ 'class' => 
$sizeClass ],
-                                               $this->msg( $changeMsg 
)->numParams( $bytesChanged )->text()
-                                       ),
-                                       Html::element(
-                                               'span', [ 'class' => 
'mw-mf-diff-date meta' ],
-                                               
$this->getLanguage()->getHumanTimestamp( $ts )
-                                       )
-                               )->text()
-                       . Html::closeElement( 'div' )
-                       . $minor
-                       . Html::rawElement(
-                               'div',
-                               [ 'id' => 'mw-mf-diff-comment' ],
-                               $comment
-                       )
-               );
+                       . Html::closeElement( 'h2' )
+                       . $this->msg( 'mobile-frontend-diffview-comma' 
)->rawParams(
+                               Html::element( 'span', [ 'class' => $sizeClass 
],
+                                       $this->msg( $changeMsg )->numParams( 
$bytesChanged )->text()
+                               ),
+                               Html::element(
+                                       'span', [ 'class' => 'mw-mf-diff-date 
meta' ],
+                                       
$this->getLanguage()->getHumanTimestamp( $ts )
+                               )
+                       )->text()
+               . Html::closeElement( 'div' );
+       }
+
+       /**
+        * Render the revision navigation links
+        * @return string built HTML for Revision navigation links
+        */
+       private function getRevisionNavigationLinksHTML() {
+               $prev = $this->rev->getPrevious();
+               $next = $this->rev->getNext();
+               $history = '';
+
+               if ( $prev || $next ) {
+                       $history = Html::openElement( 'ul', [ 'class' => 'hlist 
revision-history-links' ] );
+                       if ( $prev ) {
+                               $history .= Html::openElement( 'li', [ 'class' 
=> 'revision-history-prev' ] )
+                                       . Html::element( 'a', [
+                                               'href' => 
SpecialPage::getTitleFor( 'MobileDiff', $prev->getId() )
+                                                       ->getLocalURL()
+                                       ], $this->msg( 'previousdiff' ) ) . 
Html::closeElement( 'li' );
+                       }
+                       if ( $next ) {
+                               $history .= Html::openElement( 'li', [ 'class' 
=> 'revision-history-next' ] )
+                                       . Html::element( 'a', [
+                                               'href' => 
SpecialPage::getTitleFor( 'MobileDiff', $next->getId() )
+                                                       ->getLocalURL()
+                                       ], $this->msg( 'nextdiff' ) ) . 
Html::closeElement( 'li' );
+                       }
+                       $history .= Html::closeElement( 'ul' );
+               }
+               return $history;
        }
 
        /**
diff --git a/resources/mobile.special.mobilediff.styles/mobilediff.less 
b/resources/mobile.special.mobilediff.styles/mobilediff.less
index f228132..1b3303c 100644
--- a/resources/mobile.special.mobilediff.styles/mobilediff.less
+++ b/resources/mobile.special.mobilediff.styles/mobilediff.less
@@ -119,6 +119,11 @@
 .revision-history-links {
        font-size: 0.9em;
        margin-top: 8px;
+       margin-bottom: 12px;
+
+       .revision-history-next {
+               float: right;
+       }
 }
 
 @media all and ( min-width: @wgMFDeviceWidthDesktop ) {

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

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

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

Reply via email to