r42528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42527‎ | r42528 | r42529 >
Date:02:27, 25 October 2008
Author:mrzman
Status:old (Comments)
Tags:
Comment:
Re-committing r42514:
(bug 16073) * Use onclick handler for expand/collapse in enhanced recentchanges.
* Hide the expandable content with JavaScript for better fallback if JS is disabled for whatever reason.
* Move enhancedchanges JS to separate file.
* Less cryptic id names.

with some tweaks suggested by Brion and Danny B on the bug.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ChangesList.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/enhancedchanges.js (added) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1050,6 +1050,8 @@
10511051 'rc_categories_any',
10521052 'rc-change-size',
10531053 'newsectionsummary',
 1054+ 'rc-enhanced-expand',
 1055+ 'rc-enhanced-hide',
10541056 ),
10551057 'recentchangeslinked' => array(
10561058 'recentchangeslinked',
Index: trunk/phase3/skins/common/wikibits.js
@@ -104,22 +104,6 @@
105105 }
106106 }
107107
108 -// for enhanced RecentChanges
109 -function toggleVisibility(_levelId, _otherId, _linkId) {
110 - var thisLevel = document.getElementById(_levelId);
111 - var otherLevel = document.getElementById(_otherId);
112 - var linkLevel = document.getElementById(_linkId);
113 - if (thisLevel.style.display == 'none') {
114 - thisLevel.style.display = 'block';
115 - otherLevel.style.display = 'none';
116 - linkLevel.style.display = 'inline';
117 - } else {
118 - thisLevel.style.display = 'none';
119 - otherLevel.style.display = 'inline';
120 - linkLevel.style.display = 'none';
121 - }
122 -}
123 -
124108 function showTocToggle() {
125109 if (document.createTextNode) {
126110 // Uses DOM calls to avoid document.write + XHTML issues
Index: trunk/phase3/skins/common/enhancedchanges.js
@@ -0,0 +1,39 @@
 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+ '}'
 21+);
 22+
 23+/*
 24+ * Switch an RC line between hidden/shown
 25+ * @param int idNumber : the id number of the RC group
 26+*/
 27+function toggleVisibility(idNumber) {
 28+ var openarrow = document.getElementById("mw-rc-openarrow-"+idNumber);
 29+ var closearrow = document.getElementById("mw-rc-closearrow-"+idNumber);
 30+ var subentries = document.getElementById("mw-rc-subentries-"+idNumber);
 31+ if (openarrow.className == 'mw-changeslist-expanded') {
 32+ openarrow.className = 'mw-changeslist-hidden';
 33+ closearrow.className = 'mw-changeslist-expanded';
 34+ subentries.className = 'mw-changeslist-expanded';
 35+ } else {
 36+ openarrow.className = 'mw-changeslist-expanded';
 37+ closearrow.className = 'mw-changeslist-hidden';
 38+ subentries.className = 'mw-changeslist-hidden';
 39+ }
 40+}
Property changes on: trunk/phase3/skins/common/enhancedchanges.js
___________________________________________________________________
Added: svn:eol-style
141 + native
Index: trunk/phase3/includes/ChangesList.php
@@ -388,7 +388,24 @@
389389 * Generate a list of changes using an Enhanced system (use javascript).
390390 */
391391 class EnhancedChangesList extends ChangesList {
 392+
392393 /**
 394+ * Add the JavaScript file for enhanced changeslist
 395+ * @ return string
 396+ */
 397+ public function beginRecentChangesList() {
 398+ global $wgStylePath, $wgStyleVersion;
 399+ $this->rc_cache = array();
 400+ $this->rcMoveIndex = 0;
 401+ $this->rcCacheIndex = 0;
 402+ $this->lastdate = '';
 403+ $this->rclistOpen = false;
 404+ $script = Xml::tags( 'script', array(
 405+ 'type' => 'text/javascript',
 406+ 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' );
 407+ return $script;
 408+ }
 409+ /**
393410 * Format a line for enhanced recentchange (aka with javascript and block of lines).
394411 */
395412 public function recentChangesLine( &$baseRC, $watched = false ) {
@@ -596,13 +613,16 @@
597614
598615 $users = ' <span class="changedby">[' . implode( $this->message['semicolon-separator'], $users ) . ']</span>';
599616
600 - # Arrow
601 - $rci = 'RCI'.$this->rcCacheIndex;
602 - $rcl = 'RCL'.$this->rcCacheIndex;
603 - $rcm = 'RCM'.$this->rcCacheIndex;
604 - $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')";
605 - $tl = '<span id="'.$rcm.'"><a href="'.$toggleLink.'">' . $this->sideArrow() . '</a></span>';
606 - $tl .= '<span id="'.$rcl.'" style="display:none"><a href="'.$toggleLink.'">' . $this->downArrow() . '</a></span>';
 617+ # ID for JS visibility toggle
 618+ $jsid = $this->rcCacheIndex;
 619+ # onclick handler to toggle hidden/expanded
 620+ $toggleLink = "onclick='toggleVisibility($jsid)'";
 621+ # Title for <a> tags
 622+ $expandTitle = wfMsg('rc-enhanced-expand');
 623+ $closeTitle = wfMsg('rc-enhanced-hide');
 624+
 625+ $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
 626+ $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
607627 $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
608628
609629 # Main line
@@ -680,7 +700,7 @@
681701 $r .= "</td></tr></table>\n";
682702
683703 # Sub-entries
684 - $r .= '<div id="'.$rci.'" style="display:none;"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
 704+ $r .= '<div id="mw-rc-subentries-'.$jsid.'" class="mw-changeslist-hidden"><table cellpadding="0" cellspacing="0" border="0" style="background: none">';
685705 foreach( $block as $rcObj ) {
686706 # Get rc_xxxx variables
687707 // FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
@@ -759,11 +779,10 @@
760780 * @param string $alt text
761781 * @return string HTML <img> tag
762782 */
763 - protected function arrow( $dir, $alt='' ) {
 783+ protected function arrow( $dir ) {
764784 global $wgStylePath;
765785 $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' );
766 - $encAlt = htmlspecialchars( $alt );
767 - return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />";
 786+ return "<img src=\"$encUrl\" width=\"12\" height=\"12\" />";
768787 }
769788
770789 /**
@@ -774,7 +793,7 @@
775794 protected function sideArrow() {
776795 global $wgContLang;
777796 $dir = $wgContLang->isRTL() ? 'l' : 'r';
778 - return $this->arrow( $dir, '+' );
 797+ return $this->arrow( $dir );
779798 }
780799
781800 /**
@@ -783,7 +802,7 @@
784803 * @return string HTML <img> tag
785804 */
786805 protected function downArrow() {
787 - return $this->arrow( 'd', '-' );
 806+ return $this->arrow( 'd' );
788807 }
789808
790809 /**
@@ -791,7 +810,7 @@
792811 * @return string HTML <img> tag
793812 */
794813 protected function spacerArrow() {
795 - return $this->arrow( '', ' ' );
 814+ return $this->arrow( '' );
796815 }
797816
798817 /**
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1385,7 +1385,7 @@
13861386 * to ensure that client-side caches don't keep obsolete copies of global
13871387 * styles.
13881388 */
1389 -$wgStyleVersion = '182';
 1389+$wgStyleVersion = '183';
13901390
13911391
13921392 # Server-side caching:
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1726,6 +1726,8 @@
17271727 'rc_categories_any' => 'Any',
17281728 'rc-change-size' => '$1', # only translate this message to other languages if you have to change it
17291729 'newsectionsummary' => '/* $1 */ new section',
 1730+'rc-enhanced-expand' => 'Show details (requires JavaScript)',
 1731+'rc-enhanced-hide' => 'Hide details',
17301732
17311733 # Recent changes linked
17321734 'recentchangeslinked' => 'Related changes',
Index: trunk/phase3/RELEASE-NOTES
@@ -283,6 +283,8 @@
284284 * (bug 14609) User's namespaces to be searched default not updated after adding new namespace
285285 * Purge form uses valid XHTML and (bug 8992) uses $wgRequest instead of $_SERVER
286286 * (bug 12764) Special:LonelyPages shows transcluded pages
 287+* (bug 16073) Enhanced RecentChanges uses onclick handler with better fallback if
 288+ JavaScript is disabled.
287289
288290 === API changes in 1.14 ===
289291

Follow-up revisions

RevisionCommit summaryAuthorDate
r42531Reverted r42528. Links with href="#" make firefox scroll to the top of the pa...tstarling05:52, 25 October 2008
r42568Re-committing r42528:...mrzman19:05, 25 October 2008
r42573Hold back r42568 for now "Re-committing r42528:" (enhanced RC no-JS fallbacks)...brion20:30, 25 October 2008
r42576Fix for r42528 (enhanced RC JS/fallback fixes), use "visibility:hidden" rathe...mrzman20:57, 25 October 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r42514(bug 16073) * Use onclick handler for expand/collapse in enhanced recentchanges....mrzman23:10, 24 October 2008
r42521Revert r42514 for now "(bug 16073) * Use onclick handler for expand/collapse ...brion00:10, 25 October 2008

Comments

#Comment by Tim Starling (talk | contribs)   05:51, 25 October 2008

Makes Firefox scroll to the top of the page when such a link is clicked. Reverting.

Status & tagging log