Nikerabbit has uploaded a new change for review.

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


Change subject: Make the number of project tiles a variable to avoid magic 
numbers
......................................................................

Make the number of project tiles a variable to avoid magic numbers

Change-Id: Ie06ce33cfab19380dfa4ba38eca5ec2b2f682e39
---
M resources/js/ext.translate.mainpage.js
M specials/SpecialTwnMainPage.php
2 files changed, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TwnMainPage 
refs/changes/45/90745/1

diff --git a/resources/js/ext.translate.mainpage.js 
b/resources/js/ext.translate.mainpage.js
index e308f4f..913b104 100644
--- a/resources/js/ext.translate.mainpage.js
+++ b/resources/js/ext.translate.mainpage.js
@@ -110,6 +110,7 @@
         */
        function setupProjectTiles() {
                var language = mw.config.get( 'wgUserLanguage' ),
+                       maxProjectTiles = mw.config.get( 'maxProjectTiles' ),
                        $selector,
                        $tiles = $( '.project-tile' );
 
@@ -142,7 +143,7 @@
                        window.location.href = url;
                } );
 
-               if ( $tiles.length !== 8 ) {
+               if ( $tiles.length !== maxProjectTiles ) {
                        // We have less than 8 tiles, so all are shown
                        return;
                }
@@ -174,7 +175,7 @@
 
                // Replace the last shown tile with group selector.
                // Users without JavaScript will just see the original one.
-               $tiles.eq( 7 ).replaceWith( $selector );
+               $tiles.eq( maxProjectTiles - 1 ).replaceWith( $selector );
        }
 
        function signupLanguageSelector() {
diff --git a/specials/SpecialTwnMainPage.php b/specials/SpecialTwnMainPage.php
index ae69169..9c6b165 100644
--- a/specials/SpecialTwnMainPage.php
+++ b/specials/SpecialTwnMainPage.php
@@ -14,6 +14,8 @@
  * @ingroup SpecialPage
  */
 class SpecialTwnMainPage extends SpecialPage {
+       protected $maxProjectTiles = 8;
+
        function __construct() {
                parent::__construct( 'TwnMainPage' );
        }
@@ -58,6 +60,7 @@
                // Forcing wgULSPosition to personal to mimick that behavior 
regardless
                // of the position of the uls trigger in other pages.
                $out->addJsConfigVars( 'wgULSPosition', 'personal' );
+               $out->addJsConfigVars( 'maxProjectTiles', 
$this->maxProjectTiles );
 
                $out->addHTML( $out->headElement( $skin ) );
 
@@ -196,7 +199,7 @@
 
                foreach ( $projects as $group ) {
                        $tiles[] = $this->makeGroupTile( $group, 
$stats[$group->getId()] );
-                       if ( count( $tiles ) === 8 ) {
+                       if ( count( $tiles ) === $this->maxProjectTiles ) {
                                break;
                        }
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie06ce33cfab19380dfa4ba38eca5ec2b2f682e39
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TwnMainPage
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>

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

Reply via email to