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

Change subject: Alpha, Beta: Center-align the last-modified bar on tablets
......................................................................


Alpha, Beta: Center-align the last-modified bar on tablets

Also:
* generate the last modified bar using a template.
* make sure the background stretches to the full page width

Bug: T98925
Change-Id: I38cefa7dd5c81b4ba900ca34c29c7ef6412db9de
---
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
M less/tablet/common.beta.less
M less/ui.less
M resources/mobile.head/init.js
A templates/history.mustache
6 files changed, 54 insertions(+), 19 deletions(-)

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



diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index f6b65cc..c751562 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -190,11 +190,20 @@
         * @param array $data Data used to build the page
         */
        protected function renderHistoryLink( $data ) {
-               if ( isset( $data['historyLink'] ) ) {
+               $action = Action::getActionName( RequestContext::getMain() );
+               if ( isset( $data['historyLink'] ) && $action === 'view' ) {
                        $historyLink = $data['historyLink'];
-                       $historyLabel = $historyLink['text'];
-                       unset( $historyLink['text'] );
-                       echo Html::element( 'a', $historyLink, $historyLabel );
+                       $args = array(
+                               'isMainPage' => 
$this->getSkin()->getTitle()->isMainPage(),
+                               'link' => $historyLink['href'],
+                               'text' => $historyLink['text'],
+                               'username' => $historyLink['data-user-name'],
+                               'userGender' => 
$historyLink['data-user-gender'],
+                               'timestamp' => $historyLink['data-timestamp']
+                       );
+                       $templateParser = new TemplateParser(
+                               __DIR__ . '/../../templates/' );
+                       echo $templateParser->processTemplate( 'history', $args 
);
                }
        }
 
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 8a16858..c040e1f 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -634,7 +634,6 @@
                $unixTimestamp = wfTimestamp( TS_UNIX, $timestamp );
                $historyUrl = $this->mobileContext->getMobileUrl( 
$title->getFullURL( 'action=history' ) );
                $link = array(
-                       'id' => 'mw-mf-last-modified',
                        'data-timestamp' => $isMainPage ? '' : $unixTimestamp,
                        'href' => $historyUrl,
                        'text' => $lastModified,
@@ -652,9 +651,6 @@
                        } else {
                                $link['data-user-gender'] = 'unknown';
                        }
-               }
-               if ( !$title->isMainPage() ) {
-                       $link['class'] = 'last-modified-bar truncated-text';
                }
                $link['href'] = SpecialPage::getTitleFor( 'History', $title 
)->getLocalURL();
                return $link;
diff --git a/less/tablet/common.beta.less b/less/tablet/common.beta.less
index 5ade7ba..5537749 100644
--- a/less/tablet/common.beta.less
+++ b/less/tablet/common.beta.less
@@ -20,6 +20,13 @@
                        // so that the icon image is aligned with the content
                        right: -@iconGutterWidth;
                }
+
+               #mw-mf-last-modified {
+                       max-width: @contentMaxWidthTablet;
+                       margin-left: auto;
+                       margin-right: auto;
+                       padding: 5px @contentPaddingTablet;
+               }
        }
 
        .beta {
diff --git a/less/ui.less b/less/ui.less
index f378805..cfda712 100644
--- a/less/ui.less
+++ b/less/ui.less
@@ -15,7 +15,7 @@
 
        .last-modified-bar {
                background-color: @colorGray14;
-               padding: 5px @contentMargin;
+               padding: 0 @contentMargin;
                display: block;
                color: @colorGray6;
                a {
diff --git a/resources/mobile.head/init.js b/resources/mobile.head/init.js
index bbc21d6..e263da5 100644
--- a/resources/mobile.head/init.js
+++ b/resources/mobile.head/init.js
@@ -13,10 +13,11 @@
         */
        function initHistoryLink() {
                var $lastModified = $( '#mw-mf-last-modified' ),
-                       historyUrl = $lastModified.attr( 'href' ),
-                       ts = $lastModified.data( 'timestamp' ),
-                       username = $lastModified.data( 'user-name' ) || false,
-                       gender = $lastModified.data( 'user-gender' ),
+                       $lastModifiedLink = $lastModified.find( 'a' ),
+                       historyUrl = $lastModifiedLink.attr( 'href' ),
+                       ts = $lastModifiedLink.data( 'timestamp' ),
+                       username = $lastModifiedLink.data( 'user-name' ) || 
false,
+                       gender = $lastModifiedLink.data( 'user-gender' ),
                        keys = {
                                seconds: 
'mobile-frontend-last-modified-with-user-seconds',
                                minutes: 
'mobile-frontend-last-modified-with-user-minutes',
@@ -37,7 +38,7 @@
                                ] );
                        }
                        if ( time.isRecent( delta ) ) {
-                               $lastModified.addClass( 'active' );
+                               $lastModified.parent( '.last-modified-bar' 
).addClass( 'active' );
                        }
 
                        args = args.concat( [ historyUrl,
@@ -47,11 +48,23 @@
                                username ? mw.util.getUrl( 
'Special:UserProfile/' + username ) : ''
                        ] );
 
-                       $( '<div>' ).attr( 'id', 'mw-mf-last-modified' )
-                               .attr( 'class', $lastModified.attr( 'class' ) )
-                               .html( mw.message.apply( this, args ).parse() )
-                               .insertBefore( $lastModified );
-                       $lastModified.remove();
+                       $lastModifiedLink.html( mw.message.apply( this, args 
).parse() );
+
+                       // FIXME: remove this when the cache clears. Today is 
05/21/2015.
+                       // Make the cached DOM look similar to the new DOM
+                       if ( $lastModified.hasClass( 'last-modified-bar' ) ) {
+                               $lastModified
+                                       .removeClass( 'last-modified-bar' )
+                                       .wrap( '<div 
class="last-modified-bar"></div>' );
+                       }
+               } else {
+                       // FIXME: remove this when the cache clears. Today is 
05/21/2015.
+                       // Make the cached DOM look similar to the new DOM on 
the Main_Page
+                       // It's important that this runs when the DOM is ready, 
otherwise it won't work
+                       // in stable where the 'history-link-loaded' event is 
fired before the DOM is ready.
+                       $( function () {
+                               $( '#mw-mf-last-modified' ).removeClass( 
'last-modified-bar' );
+                       } );
                }
        }
 
diff --git a/templates/history.mustache b/templates/history.mustache
new file mode 100644
index 0000000..3f089bd
--- /dev/null
+++ b/templates/history.mustache
@@ -0,0 +1,10 @@
+<div{{^isMainPage}} class="last-modified-bar"{{/isMainPage}}>
+       <div id="mw-mf-last-modified">
+               <a href="{{link}}" class="truncated-text"
+                       data-user-name="{{username}}"
+                       data-user-gender="{{userGender}}"
+                       data-timestamp="{{timestamp}}">
+                       {{text}}
+               </a>
+       </div>
+</div>
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I38cefa7dd5c81b4ba900ca34c29c7ef6412db9de
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: Phuedx <g...@samsmith.io>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to