From 2526d518e157bdc21f0b2ceebaab1b458c12e997 Mon Sep 17 00:00:00 2001 From: Alex Z Date: Sat, 25 Oct 2008 19:05:05 +0000 Subject: [PATCH] Re-committing r42528: *Add "return false" to the onclick handler, which fixes the reason it was reverted (link causes Firefox to scroll to the top of the page) for JS-enabled browsers *Hide both arrows for JS-disabled so the link (which does nothing without JS) isn't there to mess up scrolling or break horribly with paranoid browser extensions *Tested for compatibility in Firefox 3.0.3, IE7, Safari 3.1.2, and Opera 9.52. --- RELEASE-NOTES | 2 ++ includes/ChangesList.php | 47 ++++++++++++++++++++++--------- languages/messages/MessagesEn.php | 2 ++ maintenance/language/messages.inc | 2 ++ skins/common/enhancedchanges.js | 39 +++++++++++++++++++++++++ skins/common/wikibits.js | 16 ----------- 6 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 skins/common/enhancedchanges.js diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d5c2dcb9ce..476643de4e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -283,6 +283,8 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 14609) User's namespaces to be searched default not updated after adding new namespace * Purge form uses valid XHTML and (bug 8992) uses $wgRequest instead of $_SERVER * (bug 12764) Special:LonelyPages shows transcluded pages +* (bug 16073) Enhanced RecentChanges uses onclick handler with better fallback if + JavaScript is disabled. === API changes in 1.14 === diff --git a/includes/ChangesList.php b/includes/ChangesList.php index 41d20398b2..ddf9b0f389 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -388,6 +388,23 @@ class OldChangesList extends ChangesList { * Generate a list of changes using an Enhanced system (use javascript). */ class EnhancedChangesList extends ChangesList { + + /** + * Add the JavaScript file for enhanced changeslist + * @ return string + */ + public function beginRecentChangesList() { + global $wgStylePath, $wgStyleVersion; + $this->rc_cache = array(); + $this->rcMoveIndex = 0; + $this->rcCacheIndex = 0; + $this->lastdate = ''; + $this->rclistOpen = false; + $script = Xml::tags( 'script', array( + 'type' => 'text/javascript', + 'src' => $wgStylePath . "/common/enhancedchanges.js?$wgStyleVersion" ), '' ); + return $script; + } /** * Format a line for enhanced recentchange (aka with javascript and block of lines). */ @@ -596,13 +613,16 @@ class EnhancedChangesList extends ChangesList { $users = ' [' . implode( $this->message['semicolon-separator'], $users ) . ']'; - # Arrow - $rci = 'RCI'.$this->rcCacheIndex; - $rcl = 'RCL'.$this->rcCacheIndex; - $rcm = 'RCM'.$this->rcCacheIndex; - $toggleLink = "javascript:toggleVisibility('$rci','$rcm','$rcl')"; - $tl = '' . $this->sideArrow() . ''; - $tl .= ''; + # ID for JS visibility toggle + $jsid = $this->rcCacheIndex; + # onclick handler to toggle hidden/expanded + $toggleLink = "onclick='toggleVisibility($jsid); return false'"; + # Title for tags + $expandTitle = wfMsg('rc-enhanced-expand'); + $closeTitle = wfMsg('rc-enhanced-hide'); + + $tl = "" . $this->sideArrow() . ""; + $tl .= ""; $r .= ''.$tl.' '; # Main line @@ -680,7 +700,7 @@ class EnhancedChangesList extends ChangesList { $r .= "\n"; # Sub-entries - $r .= '