From: Bartosz Dziewoński Date: Fri, 13 Dec 2013 20:56:02 +0000 (+0100) Subject: Make legend on Special:RecentChanges and Special:Watchlist collapsible X-Git-Tag: 1.31.0-rc.0~17583^2~1 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=a9e0c52c064f6d405b957dec99e79f86b59e0918;p=lhc%2Fweb%2Fwiklou.git Make legend on Special:RecentChanges and Special:Watchlist collapsible Some of the code added here is duplicated, redundant or would be better off placed somewhere else. I know about this, but this is not the time to fix that (and nobody would review such patches anyway…). Bug: 52005 Change-Id: I02f2ced42f33649b6c972d35a4739372ca265e10 --- diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 470b150c6c..107e2c4728 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -161,6 +161,7 @@ class ChangesList extends ContextSource { $this->lastdate = ''; $this->rclistOpen = false; $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' ); + $this->getOutput()->addModules( 'mediawiki.special.changeslist.js' ); return '
'; } diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 1c3a0fbd96..99cf0dee6c 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -41,6 +41,7 @@ class EnhancedChangesList extends ChangesList { $this->getOutput()->addModules( array( 'jquery.makeCollapsible', 'mediawiki.icon', + 'mediawiki.special.changeslist.js', ) ); return '
'; diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 3b1291b0c1..3b121fb817 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -664,7 +664,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { global $wgRecentChangesFlags; $user = $context->getUser(); # The legend showing what the letters and stuff mean - $legend = Xml::openElement( 'dl', array( 'class' => 'mw-changeslist-legend' ) ) . "\n"; + $legend = Xml::openElement( 'dl' ) . "\n"; # Iterates through them and gets the messages for both letter and tooltip $legendItems = $wgRecentChangesFlags; if ( !$user->useRCPatrol() ) { @@ -700,6 +700,14 @@ class SpecialRecentChanges extends IncludableSpecialPage { $context->msg( 'recentchanges-label-plusminus' )->text() ) . "\n"; $legend .= Xml::closeElement( 'dl' ) . "\n"; + + # Collapsibility + $legend = + '
' . + $context->msg( 'recentchanges-legend-heading' )->parse() . + '
' . $legend . '
' . + '
'; + return $legend; } diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 9e93881e77..4d86744781 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -40,6 +40,7 @@ class SpecialWatchlist extends SpecialPage { $user = $this->getUser(); $output = $this->getOutput(); $output->addModuleStyles( 'mediawiki.special.changeslist' ); + $output->addModules( 'mediawiki.special.changeslist.js' ); # Anons don't get a watchlist $this->requireLogin( 'watchlistanontext' ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 225aa0750c..23b989ad21 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2186,6 +2186,7 @@ Your email address is not revealed when other users contact you.', 'recentchanges-label-bot' => 'This edit was performed by a bot', 'recentchanges-label-unpatrolled' => 'This edit has not yet been patrolled', 'recentchanges-label-plusminus' => 'The page size changed by this number of bytes', +'recentchanges-legend-heading' => "'''Legend:'''", 'recentchanges-legend-newpage' => '(also see [[Special:NewPages|list of new pages]])', 'recentchanges-legend-plusminus' => "(''±123'')", 'rcnotefrom' => "Below are the changes since '''$2''' (up to '''$1''' shown).", diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index fb260b5c3f..807beddf23 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -3592,6 +3592,7 @@ See also: 'recentchanges-label-plusminus' => 'Legend item for plus/minus. Preceded by legend example {{msg-mw|Recentchanges-legend-plusminus}}.', +'recentchanges-legend-heading' => 'Used as a heading for legend box on [[Special:RecentChanges]] and [[Special:Watchlist]].', 'recentchanges-legend-newpage' => 'Used as legend in [[Special:RecentChanges]]. Preceded by {{msg-mw|Recentchanges-label-newpage}}.', 'recentchanges-legend-plusminus' => 'A plus/minus sign with a number for the legend.', 'rcnotefrom' => 'This message is displayed at [[Special:RecentChanges]] when viewing recentchanges from some specific time. diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 4ca74f773c..dab977eea1 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1308,6 +1308,7 @@ $wgMessageStructure = array( 'recentchanges-label-bot', 'recentchanges-label-unpatrolled', 'recentchanges-label-plusminus', + 'recentchanges-legend-heading', 'recentchanges-legend-newpage', 'recentchanges-legend-plusminus', 'rcnotefrom', diff --git a/resources/Resources.php b/resources/Resources.php index d2a06b782e..ceacee654e 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1013,6 +1013,13 @@ return array( 'mediawiki.special.changeslist' => array( 'styles' => 'resources/mediawiki.special/mediawiki.special.changeslist.css', ), + 'mediawiki.special.changeslist.js' => array( + 'scripts' => 'resources/mediawiki.special/mediawiki.special.changeslist.js', + 'dependencies' => array( + 'jquery.makeCollapsible', + 'jquery.cookie', + ), + ), 'mediawiki.special.changeslist.enhanced' => array( 'styles' => 'resources/mediawiki.special/mediawiki.special.changeslist.enhanced.css', ), diff --git a/resources/mediawiki.special/mediawiki.special.changeslist.css b/resources/mediawiki.special/mediawiki.special.changeslist.css index b96a26e1aa..b1af745e40 100644 --- a/resources/mediawiki.special/mediawiki.special.changeslist.css +++ b/resources/mediawiki.special/mediawiki.special.changeslist.css @@ -17,6 +17,11 @@ border: 1px solid #ddd; } +.mw-changeslist-legend dl { + /* Parent element defines sufficient padding */ + margin-bottom: 0; +} + .mw-changeslist-legend dt { float: left; } diff --git a/resources/mediawiki.special/mediawiki.special.changeslist.js b/resources/mediawiki.special/mediawiki.special.changeslist.js new file mode 100644 index 0000000000..df606f5c53 --- /dev/null +++ b/resources/mediawiki.special/mediawiki.special.changeslist.js @@ -0,0 +1,21 @@ +/* Remember the collapse state of the legend on recent changes and watchlist pages. */ +jQuery( document ).ready( function ( $ ) { + var + cookieName = 'changeslist-state', + cookieOptions = { + expires: 30, + path: '/' + }, + isCollapsed = $.cookie( cookieName ) === 'collapsed'; + + $( '.mw-changeslist-legend' ) + .makeCollapsible( { + collapsed: isCollapsed + } ) + .on( 'beforeExpand.mw-collapsible', function () { + $.cookie( cookieName, 'expanded', cookieOptions ); + } ) + .on( 'beforeCollapse.mw-collapsible', function () { + $.cookie( cookieName, 'collapsed', cookieOptions ); + } ); +} );