jenkins-bot has submitted this change and it was merged.
Change subject: Make the project tiles go to project page if one exists
......................................................................
Make the project tiles go to project page if one exists
Targets are currently hardcoded to Translating:Project label,
which works for many but not all projects in translatewiki.net
Change-Id: I6a85bef2773b91ca0cbc4ff27f196ced40ba4bae
---
M resources/css/ext.translate.mainpage.css
M resources/js/ext.translate.mainpage.js
M specials/SpecialTwnMainPage.php
3 files changed, 32 insertions(+), 6 deletions(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/css/ext.translate.mainpage.css
b/resources/css/ext.translate.mainpage.css
index 68c6bae..778df66 100644
--- a/resources/css/ext.translate.mainpage.css
+++ b/resources/css/ext.translate.mainpage.css
@@ -255,6 +255,10 @@
height: 180px;
}
+.project-tile.linked {
+ cursor: pointer;
+}
+
.project-tile:hover {
border-color: #777;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
diff --git a/resources/js/ext.translate.mainpage.js
b/resources/js/ext.translate.mainpage.js
index 8e4502e..d031ccd 100644
--- a/resources/js/ext.translate.mainpage.js
+++ b/resources/js/ext.translate.mainpage.js
@@ -7,7 +7,7 @@
'use strict';
$( document ).ready( function () {
- var $tiles, language;
+ var $tiles, language, $selector;
$tiles = $( '.project-tile' );
@@ -20,6 +20,13 @@
}
);
+ $tiles.click( function () {
+ var url = $( this ).data( 'url' );
+ if ( url ) {
+ window.location.href = url;
+ }
+ } );
+
if ( $tiles.length !== 8 ) {
// We have less than 8 tiles, so all are shown
return;
@@ -27,10 +34,9 @@
language = mw.config.get( 'wgUserLanguage' );
- // Take the last tile
- $tiles.eq( 7 )
- .empty()
- .addClass( 'more' )
+ // Prepare one project tile to be a message group selector.
+ $selector = $( '<div>' )
+ .addClass( 'project-tile more' )
.text( mw.msg( 'twnmp-show-more-projects' ) )
.one( 'click', function () {
$.when(
@@ -47,6 +53,10 @@
at: 'right bottom+275'
}
} );
+
+ // Replace the last shown tile with group selector.
+ // Users without JavaScript will just see the original one.
+ $tiles.eq( 7 ).replaceWith( $selector );
} );
}( jQuery, mediaWiki ) );
diff --git a/specials/SpecialTwnMainPage.php b/specials/SpecialTwnMainPage.php
index 5c0a2c8..dbedbb7 100644
--- a/specials/SpecialTwnMainPage.php
+++ b/specials/SpecialTwnMainPage.php
@@ -174,6 +174,18 @@
$proofread = round( 100 * $proofread /
$stats[MessageGroupStats::TOTAL] );
}
+ // Approximate project page links while we don't have config
value for them
+ $projectPage = Title::newFromText(
"Translating:{$group->getLabel()}" );
+ $dataUrl = $linked = '';
+ if ( $projectPage->exists() ) {
+ $dataUrl = str_replace(
+ 'X',
+ htmlspecialchars( $projectPage->getLocalUrl() ),
+ 'data-url="X"'
+ );
+ $linked = 'linked';
+ }
+
$image = Html::element( 'div', array( 'class' =>
"project-icon-$id" ) );
$label = htmlspecialchars( $group->getLabel(
$this->getContext() ) );
$stats = $statsbar->getHtml( $this->getContext() );
@@ -194,7 +206,7 @@
$out = <<<HTML
<div class="three columns twn-mainpage-project-tile">
- <div class="project-tile">
+ <div class="project-tile $linked" $dataUrl>
<div class="row project-top">
<div class="project-icon four columns">$image</div>
<div class="project-content eight columns">
--
To view, visit https://gerrit.wikimedia.org/r/83081
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6a85bef2773b91ca0cbc4ff27f196ced40ba4bae
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/TwnMainPage
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits