r107822 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107821‎ | r107822 | r107823 >
Date:12:18, 2 January 2012
Author:nikerabbit
Status:deferred
Tags:
Comment:
Made CC use resource loader and made the JS not use legacy globals. The JS code could probably be cleaned up more with jQuery
Modified paths:
  • /trunk/extensions/CleanChanges/CleanChanges.php (modified) (history)
  • /trunk/extensions/CleanChanges/CleanChanges_body.php (modified) (history)
  • /trunk/extensions/CleanChanges/cleanchanges.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CleanChanges/CleanChanges.php
@@ -50,3 +50,14 @@
5151 $wgHooks['SpecialRecentChangesPanel'][] = 'CCFilters::trailerForm';
5252 }
5353 }
 54+
 55+$resourcePaths = array(
 56+ 'localBasePath' => dirname( __FILE__ ),
 57+ 'remoteExtPath' => 'CleanChanges'
 58+);
 59+
 60+// Client-side resource modules
 61+$wgResourceModules['ext.cleanchanges'] = array(
 62+ 'scripts' => 'cleanchanges.js',
 63+) + $resourcePaths;
 64+
Index: trunk/extensions/CleanChanges/cleanchanges.js
@@ -1,25 +1,21 @@
2 -/*
3 - * Adapted from monobook, with possibility to set display to block or inline.
4 - */
5 -function toggleVisibilityE(_levelId, _otherId, _linkId, _type) {
6 - var thisLevel = document.getElementById(_levelId);
7 - var otherLevel = document.getElementById(_otherId);
8 - var linkLevel = document.getElementById(_linkId);
9 - if (thisLevel.style.display == 'none') {
10 - thisLevel.style.display = _type;
11 - otherLevel.style.display = 'none';
12 - linkLevel.style.display = 'inline';
13 - } else {
14 - thisLevel.style.display = 'none';
15 - otherLevel.style.display = 'inline';
16 - linkLevel.style.display = 'none';
 2+(function ( $ ) {
 3+ window.toggleVisibilityE = function ( _levelId, _otherId, _linkId, _type ) {
 4+ var thisLevel = document.getElementById( _levelId );
 5+ var otherLevel = document.getElementById( _otherId );
 6+ var linkLevel = document.getElementById( _linkId );
 7+ if (thisLevel.style.display == 'none') {
 8+ thisLevel.style.display = _type;
 9+ otherLevel.style.display = 'none';
 10+ linkLevel.style.display = 'inline';
 11+ } else {
 12+ thisLevel.style.display = 'none';
 13+ otherLevel.style.display = 'inline';
 14+ linkLevel.style.display = 'none';
 15+ }
1716 }
18 -}
 17+
 18+ window.showUserInfo = function ( sourceVar, targetId ) {
 19+ $( '#' + targetId ).html( mw.config.get( sourceVar ) );
 20+ }
1921
20 -/*
21 - * Simple function to add user information inline.
22 - */
23 -function showUserInfo( sourceVar, targetId ) {
24 - var targetElement = document.getElementById(targetId);
25 - targetElement.innerHTML = eval( sourceVar );
26 -}
 22+} )( jQuery );
\ No newline at end of file
Index: trunk/extensions/CleanChanges/CleanChanges_body.php
@@ -28,8 +28,8 @@
2929 }
3030
3131 if ( $list instanceof NCL ) {
32 - global $wgOut, $wgExtensionAssetsPath;
33 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CleanChanges/cleanchanges.js" );
 32+ global $wgOut;
 33+ $wgOut->addModules( 'ext.cleanchanges' );
3434 }
3535
3636 /* If some list was specified, stop processing */

Status & tagging log