r78987 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78986‎ | r78987 | r78988 >
Date:00:29, 25 December 2010
Author:krinkle
Status:ok
Tags:
Comment:
Reverting r78889 and r78865. Breaks changeslist on translatewiki (unpatrolled-flag exclamation mark popping up on page histories and and diff-views where they shouldn't instead of an 'm' for minor)
- = ChangesList::flag( 'minor' );
- The jquery effects plugin and collapsible implementation, also in those commits, are redundant now.
- If/when skins.commons is needed again, we can simply add that part back in.
- (r78891 is not reverted because the file it altered was deleted while r78865 was -merged)
Modified paths:
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/jquery.effects/jquery.effects.fade.js (deleted) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.changeslist.css (deleted) (history)
  • /trunk/phase3/resources/skins.common (deleted) (history)
  • /trunk/phase3/skins/common/enhancedchanges.js (added) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/enhancedchanges.js
@@ -0,0 +1,40 @@
 2+/*
 3+ JavaScript file for enhanced recentchanges
 4+ */
 5+
 6+/*
 7+ * Add the CSS to hide parts that should be collapsed
 8+ *
 9+ * We do this with JS so everything will be expanded by default
 10+ * if JS is disabled
 11+ */
 12+appendCSS('.mw-changeslist-hidden {'+
 13+ ' display:none;'+
 14+ '}'+
 15+ 'div.mw-changeslist-expanded {'+
 16+ ' display:block;'+
 17+ '}'+
 18+ 'span.mw-changeslist-expanded {'+
 19+ ' display:inline !important;'+
 20+ ' visibility:visible !important;'+
 21+ '}'
 22+);
 23+
 24+/*
 25+ * Switch an RC line between hidden/shown
 26+ * @param int idNumber : the id number of the RC group
 27+*/
 28+window.toggleVisibility = function(idNumber) {
 29+ var openarrow = document.getElementById("mw-rc-openarrow-"+idNumber);
 30+ var closearrow = document.getElementById("mw-rc-closearrow-"+idNumber);
 31+ var subentries = document.getElementById("mw-rc-subentries-"+idNumber);
 32+ if (openarrow.className == 'mw-changeslist-expanded') {
 33+ openarrow.className = 'mw-changeslist-hidden';
 34+ closearrow.className = 'mw-changeslist-expanded';
 35+ subentries.className = 'mw-changeslist-expanded';
 36+ } else {
 37+ openarrow.className = 'mw-changeslist-expanded';
 38+ closearrow.className = 'mw-changeslist-hidden';
 39+ subentries.className = 'mw-changeslist-hidden';
 40+ }
 41+};
Property changes on: trunk/phase3/skins/common/enhancedchanges.js
___________________________________________________________________
Added: svn:eol-style
142 + native
Index: trunk/phase3/skins/common/shared.css
@@ -831,6 +831,18 @@
832832 word-wrap: break-word;
833833 }
834834
 835+table.mw-enhanced-rc {
 836+ background: none;
 837+ border:0;
 838+ border-spacing:0;
 839+}
 840+td.mw-enhanced-rc {
 841+ white-space:nowrap;
 842+ padding:0;
 843+ vertical-align:top;
 844+ font-family:monospace
 845+}
 846+
835847 #mw-addcategory-prompt {
836848 display: inline;
837849 margin-left: 1em;
Index: trunk/phase3/includes/OutputPage.php
@@ -1617,7 +1617,7 @@
16181618 $sk = $wgUser->getSkin();
16191619
16201620 // Add base resources
1621 - $this->addModules( array( 'mediawiki.legacy.wikibits', 'mediawiki.util', 'skins.common' ) );
 1621+ $this->addModules( array( 'mediawiki.legacy.wikibits', 'mediawiki.util' ) );
16221622
16231623 // Add various resources if required
16241624 if ( $wgUseAjax ) {
Index: trunk/phase3/includes/ChangesList.php
@@ -30,7 +30,7 @@
3131 class ChangesList {
3232 public $skin;
3333 protected $watchlist = false;
34 -
 34+
3535 /**
3636 * Changeslist contructor
3737 * @param $skin Skin
@@ -81,19 +81,21 @@
8282 }
8383 }
8484
 85+
8586 /**
8687 * Returns the appropriate flags for new page, minor change and patrolling
87 - * @param $flags Associative array of 'flag' => Bool
 88+ * @param $new Boolean
 89+ * @param $minor Boolean
 90+ * @param $patrolled Boolean
8891 * @param $nothing String to use for empty space
 92+ * @param $bot Boolean
8993 * @return String
9094 */
91 - protected function recentChangesFlags( $flags, $nothing = ' ' ) {
92 - $f = '';
93 - foreach( array( 'newpage', 'minor', 'bot', 'unpatrolled' ) as $flag ){
94 - $f .= isset( $flags[$flag] ) && $flags[$flag]
95 - ? self::flag( $flag )
96 - : $nothing;
97 - }
 95+ protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
 96+ $f = $new ? self::flag( 'newpage' ) : $nothing;
 97+ $f .= $minor ? self::flag( 'minor' ) : $nothing;
 98+ $f .= $bot ? self::flag( 'bot' ) : $nothing;
 99+ $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing;
98100 return $f;
99101 }
100102
@@ -109,18 +111,22 @@
110112 public static function flag( $key ) {
111113 static $messages = null;
112114 if ( is_null( $messages ) ) {
113 - $messages = array(
114 - 'newpage' => array( 'newpageletter', 'recentchanges-label-newpage' ),
115 - 'minor' => array( 'minoreditletter', 'recentchanges-label-minor' ),
116 - 'bot' => array( 'boteditletter', 'recentchanges-label-bot' ),
117 - 'unpatrolled' => array( 'unpatrolledletter', 'recentchanges-label-unpatrolled' ),
118 - );
119 - foreach( $messages as $key => &$value ) {
120 - $value[0] = wfMsgExt( $value[0], 'escapenoentities' );
121 - $value[1] = wfMsgExt( $value[1], 'escapenoentities' );
 115+ foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' .
 116+ 'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' .
 117+ 'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) {
 118+ $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' );
122119 }
123120 }
124 - return "<abbr class='$key' title='" . $messages[$key][1] . "'>" . $messages[$key][0] . '</abbr>';
 121+ # Inconsistent naming, bleh
 122+ if ( $key == 'newpage' || $key == 'unpatrolled' ) {
 123+ $key2 = $key;
 124+ } else {
 125+ $key2 = $key . 'edit';
 126+ }
 127+ return "<abbr class=\"$key\" title=\""
 128+ . $messages["recentchanges-label-$key"] . "\">"
 129+ . $messages["${key2}letter"]
 130+ . '</abbr>';
125131 }
126132
127133 /**
@@ -501,15 +507,8 @@
502508 } else {
503509 $this->insertDiffHist( $s, $rc, $unpatrolled );
504510 # M, N, b and ! (minor, new, bot and unpatrolled)
505 - $s .= $this->recentChangesFlags(
506 - array(
507 - 'new' => $rc->mAttribs['rc_new'],
508 - 'minor' => $rc->mAttribs['rc_minor'],
509 - 'unpatrolled' => $unpatrolled,
510 - 'bot' => $rc->mAttribs['rc_bot']
511 - ),
512 - ''
513 - );
 511+ $s .= $this->recentChangesFlags( $rc->mAttribs['rc_new'], $rc->mAttribs['rc_minor'],
 512+ $unpatrolled, '', $rc->mAttribs['rc_bot'] );
514513 $this->insertArticleLink( $s, $rc, $unpatrolled, $watched );
515514 }
516515 # Edit/log timestamp
@@ -567,7 +566,7 @@
568567 $this->rcCacheIndex = 0;
569568 $this->lastdate = '';
570569 $this->rclistOpen = false;
571 - $wgOut->addModuleStyles( 'mediawiki.special.changeslist' );
 570+ $wgOut->addModules( 'mediawiki.legacy.enhancedchanges' );
572571 return '';
573572 }
574573 /**
@@ -740,9 +739,9 @@
741740 # Add the namespace and title of the block as part of the class
742741 if ( $block[0]->mAttribs['rc_log_type'] ) {
743742 # Log entry
744 - $classes = 'collapsible collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
 743+ $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-log-' . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] );
745744 } else {
746 - $classes = 'collapsible collapsed mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
 745+ $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass( 'mw-changeslist-ns' . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] );
747746 }
748747 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
749748 Html::openElement( 'tr' );
@@ -805,28 +804,23 @@
806805 $users = ' <span class="changedby">[' .
807806 implode( $this->message['semicolon-separator'], $users ) . ']</span>';
808807
 808+ # ID for JS visibility toggle
 809+ $jsid = $this->rcCacheIndex;
 810+ # onclick handler to toggle hidden/expanded
 811+ $toggleLink = "onclick='toggleVisibility($jsid); return false'";
809812 # Title for <a> tags
810813 $expandTitle = htmlspecialchars( wfMsg( 'rc-enhanced-expand' ) );
811814 $closeTitle = htmlspecialchars( wfMsg( 'rc-enhanced-hide' ) );
812815
813 - $tl = "<span class='collapsible-expander'>"
814 - . "<span class='mw-rc-openarrow'>"
815 - . "<a href='#' title='$expandTitle'>{$this->sideArrow()}</a>"
816 - . "</span><span class='mw-rc-closearrow'>"
817 - . "<a href='#' title='$closeTitle'>{$this->downArrow()}</a>"
818 - . "</span></span>";
819 - $r .= "<td>$tl</td>";
 816+ $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
 817+ $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
 818+ $r .= '<td class="mw-enhanced-rc">'.$tl.'&#160;';
820819
821820 # Main line
822 - $r .= '<td class="mw-enhanced-rc">' . $this->recentChangesFlags( array(
823 - 'new' => $isnew,
824 - 'minor' => false,
825 - 'unpatrolled' => $unpatrolled,
826 - 'bot' => $bot ,
827 - ) );
 821+ $r .= $this->recentChangesFlags( $isnew, false, $unpatrolled, '&#160;', $bot );
828822
829823 # Timestamp
830 - $r .= '&#160;'.$block[0]->timestamp.'&#160;</td><td>';
 824+ $r .= '&#160;'.$block[0]->timestamp.'&#160;</td><td style="padding:0px;">';
831825
832826 # Article link
833827 if( $namehidden ) {
@@ -914,7 +908,11 @@
915909 $r .= $users;
916910 $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
917911
 912+ $r .= "</td></tr></table>\n";
 913+
918914 # Sub-entries
 915+ $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden">';
 916+ $r .= '<table class="mw-enhanced-rc">';
919917 foreach( $block as $rcObj ) {
920918 # Extract fields from DB into the function scope (rc_xxxx variables)
921919 // FIXME: Would be good to replace this extract() call with something
@@ -924,14 +922,10 @@
925923 extract( $rcObj->mAttribs );
926924
927925 #$r .= '<tr><td valign="top">'.$this->spacerArrow();
928 - $r .= '<tr><td></td><td class="mw-enhanced-rc">';
929 - $r .= $this->recentChangesFlags( array(
930 - 'new' => $rc_new,
931 - 'minor' => $rc_minor,
932 - 'unpatrolled' => $rcObj->unpatrolled,
933 - 'bot' => $rc_bot,
934 - ) );
935 - $r .= '&#160;</td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">';
 926+ $r .= '<tr><td style="vertical-align:top;font-family:monospace; padding:0px;">';
 927+ $r .= $this->spacerIndent() . $this->spacerIndent();
 928+ $r .= $this->recentChangesFlags( $rc_new, $rc_minor, $rcObj->unpatrolled, '&#160;', $rc_bot );
 929+ $r .= '&#160;</td><td style="vertical-align:top; padding:0px;"><span style="font-family:monospace">';
936930
937931 $params = $queryParams;
938932
@@ -989,7 +983,7 @@
990984
991985 $r .= "</td></tr>\n";
992986 }
993 - $r .= "</table>\n";
 987+ $r .= "</table></div>\n";
994988
995989 $this->rcCacheIndex++;
996990
@@ -1042,6 +1036,14 @@
10431037 }
10441038
10451039 /**
 1040+ * Add a set of spaces
 1041+ * @return String: HTML <td> tag
 1042+ */
 1043+ protected function spacerIndent() {
 1044+ return '&#160;&#160;&#160;&#160;&#160;';
 1045+ }
 1046+
 1047+ /**
10461048 * Enhanced RC ungrouped line.
10471049 * @return String: a HTML formated line (generated using $r)
10481050 */
@@ -1066,19 +1068,14 @@
10671069 $r = Html::openElement( 'table', array( 'class' => $classes ) ) .
10681070 Html::openElement( 'tr' );
10691071
1070 - $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow();
 1072+ $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow() . '&#160;';
10711073 # Flag and Timestamp
10721074 if( $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) {
10731075 $r .= '&#160;&#160;&#160;&#160;'; // 4 flags -> 4 spaces
10741076 } else {
1075 - $r .= $this->recentChangesFlags( array(
1076 - 'new' => $rc_type == RC_NEW,
1077 - 'minor' => $rc_minor,
1078 - 'unpatrolled' => $rcObj->unpatrolled,
1079 - 'bot' => $rc_bot
1080 - ) );
 1077+ $r .= $this->recentChangesFlags( $rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, '&#160;', $rc_bot );
10811078 }
1082 - $r .= '&#160;'.$rcObj->timestamp.'&#160;</td><td>';
 1079+ $r .= '&#160;'.$rcObj->timestamp.'&#160;</td><td style="padding:0px;">';
10831080 # Article or log link
10841081 if( $rc_log_type ) {
10851082 $logtitle = Title::newFromText( "Log/$rc_log_type", NS_SPECIAL );
Index: trunk/phase3/resources/Resources.php
@@ -10,16 +10,6 @@
1111 'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ),
1212
1313 /* Skins */
14 -
15 - 'skins.common' => array(
16 - 'scripts' => 'resources/skins.common/skins.common.js',
17 - 'styles' => array(
18 - 'resources/skins.common/skins.common.css',
19 - 'resources/skins.common/skins.common.print.css' => array( 'media' => 'print' )
20 - ),
21 - 'messages' => array( 'hide', 'show' ),
22 - 'dependencies' => array( 'jquery.effects.fade' ),
23 - ),
2414
2515 'skins.vector' => array(
2616 'styles' => array( 'skins/vector/screen.css' => array( 'media' => 'screen' ) )
@@ -308,10 +298,6 @@
309299 'scripts' => 'resources/jquery.effects/jquery.effects.explode.js',
310300 'dependencies' => 'jquery.effects.core',
311301 ),
312 - 'jquery.effects.fade' => array(
313 - 'scripts' => 'resources/jquery.effects/jquery.effects.fade.js',
314 - 'dependencies' => 'jquery.effects.core',
315 - ),
316302 'jquery.effects.fold' => array(
317303 'scripts' => 'resources/jquery.effects/jquery.effects.fold.js',
318304 'dependencies' => 'jquery.effects.core',
@@ -368,9 +354,6 @@
369355 'scripts' => 'resources/mediawiki.special/mediawiki.special.preferences.js',
370356 'styles' => 'resources/mediawiki.special/mediawiki.special.preferences.css',
371357 ),
372 - 'mediawiki.special.changeslist' => array(
373 - 'styles' => 'resources/mediawiki.special/mediawiki.special.changeslist.css',
374 - ),
375358 'mediawiki.special.search' => array(
376359 'scripts' => 'resources/mediawiki.special/mediawiki.special.search.js',
377360 ),
@@ -456,6 +439,10 @@
457440 'scripts' => 'skins/common/edit.js',
458441 'dependencies' => 'mediawiki.legacy.wikibits',
459442 ),
 443+ 'mediawiki.legacy.enhancedchanges' => array(
 444+ 'scripts' => 'skins/common/enhancedchanges.js',
 445+ 'dependencies' => 'mediawiki.legacy.wikibits',
 446+ ),
460447 'mediawiki.legacy.history' => array(
461448 'scripts' => 'skins/common/history.js',
462449 'dependencies' => 'mediawiki.legacy.wikibits',
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeslist.css
@@ -1,40 +0,0 @@
2 -/**
3 - * Styling for Special:Watchlist and Special:RecentChanges
4 - */
5 -
6 -table.mw-enhanced-rc {
7 - background: none;
8 - border:0;
9 - border-spacing:0;
10 -}
11 -
12 -table.mw-enhanced-rc th, table.mw-enhanced-rc td {
13 - padding:0;
14 - vertical-align:top;
15 -}
16 -
17 -td.mw-enhanced-rc {
18 - white-space:nowrap;
19 - font-family:monospace;
20 -}
21 -
22 -.mw-enhanced-rc-time {
23 - font-family: monospace;
24 -}
25 -
26 -table.mw-enhanced-rc td.mw-enhanced-rc-nested {
27 - padding-left: 1em;
28 -}
29 -
30 -/* Show/hide arrows in enhanced changeslist */
31 -.mw-enhanced-rc .collapsible-expander {
32 - float: none;
33 -}
34 -
35 -.mw-rc-openarrow,
36 -.show .mw-rc-closearrow {
37 - display: none;
38 -}
39 -.show .mw-rc-openarrow {
40 - display: inline;
41 -}
Index: trunk/phase3/resources/jquery.effects/jquery.effects.fade.js
@@ -1,32 +0,0 @@
2 -/*
3 -* jQuery UI Effects Fade @VERSION
4 -*
5 -* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
6 -* Dual licensed under the MIT or GPL Version 2 licenses.
7 -* http://jquery.org/license
8 -*
9 -* http://docs.jquery.com/UI/Effects/Fade
10 -*
11 -* Depends:
12 -* jquery.effects.core.js
13 -*/
14 -(function( $, undefined ) {
15 -
16 - $.effects.fade = function(o) {
17 - return this.queue(function() {
18 - var elem = $(this),
19 - mode = $.effects.setMode(elem, o.options.mode || 'hide');
20 -
21 - elem.animate({ opacity: mode }, {
22 - queue: false,
23 - duration: o.duration,
24 - easing: o.options.easing,
25 - complete: function() {
26 - (o.callback && o.callback.apply(this, arguments));
27 - elem.dequeue();
28 - }
29 - });
30 - });
31 - };
32 -
33 -})(jQuery);
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r78865(bug 17456) implement CollapsibleTables in core javascript. Using ResourceLo...happy-melon00:06, 23 December 2010
r78889Follow-up r78865 CR; restore arrow helper functions, fixing fatal on TWN.happy-melon15:03, 23 December 2010
r78891Follow-up r78865 CRhappy-melon16:21, 23 December 2010

Status & tagging log