r99189 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99188‎ | r99189 | r99190 >
Date:04:01, 7 October 2011
Author:kaldari
Status:ok (Comments)
Tags:fundraising 
Comment:
quick and dirty resourceloaderification - should move all js functions out of global scope at some point
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/centralnotice.js (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -23,12 +23,9 @@
2424 $this->setHeaders();
2525 $this->outputHeader();
2626
27 - // Add style file to the output headers
28 - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" );
 27+ // Output ResourceLoader module for styling and javascript functions
 28+ $wgOut->addModules( 'ext.centralNotice.interface' );
2929
30 - // Add script file to the output headers
31 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
32 -
3330 // Check permissions
3431 $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
3532
Index: trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php
@@ -31,12 +31,9 @@
3232 // Begin output
3333 $this->setHeaders();
3434
35 - // Add style file to the output headers
36 - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" );
 35+ // Output ResourceLoader module for styling and javascript functions
 36+ $wgOut->addModules( 'ext.centralNotice.interface' );
3737
38 - // Add script file to the output headers
39 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
40 -
4138 // Initialize error variable
4239 $this->centralNoticeError = false;
4340
Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -22,17 +22,8 @@
2323 // Begin output
2424 $this->setHeaders();
2525
26 - // Add style file to the output headers
27 - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" );
28 -
29 - // Add localized script error messages
30 - $scriptVars = array(
31 - 'documentWriteError' => wfMsg( 'centralnotice-documentwrite-error' )
32 - );
33 - $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
34 -
35 - // Add script file to the output headers
36 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
 26+ // Output ResourceLoader module for styling and javascript functions
 27+ $wgOut->addModules( 'ext.centralNotice.interface' );
3728
3829 // Check permissions
3930 $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
@@ -24,11 +24,8 @@
2525 // Begin output
2626 $this->setHeaders();
2727
28 - // Add style file to the output headers
29 - $wgOut->addExtensionStyle( "$wgExtensionAssetsPath/CentralNotice/centralnotice.css" );
30 -
31 - // Add script file to the output headers
32 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" );
 28+ // Output ResourceLoader module for styling and javascript functions
 29+ $wgOut->addModules( 'ext.centralNotice.interface' );
3330
3431 // Initialize error variable
3532 $this->centralNoticeError = false;
Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -80,6 +80,15 @@
8181 # Unit tests
8282 $wgHooks['UnitTestsList'][] = 'efCentralNoticeUnitTests';
8383
 84+// Register ResourceLoader modules
 85+$wgResourceModules['ext.centralNotice.interface'] = array(
 86+ 'localBasePath' => dirname( __FILE__ ),
 87+ 'remoteExtPath' => 'CentralNotice',
 88+ 'scripts' => 'centralnotice.js',
 89+ 'styles' => 'centralnotice.css',
 90+ 'messages' => 'centralnotice-documentwrite-error'
 91+);
 92+
8493 function efCentralNoticeUnitTests( &$files ) {
8594 $files[] = dirname( __FILE__ ) . '/tests/CentralNoticeTest.php';
8695 return true;
Index: trunk/extensions/CentralNotice/centralnotice.js
@@ -1,4 +1,5 @@
2 -function toggleLogDisplay( logId ) {
 2+// Collapse and uncollapse detailed view for an individual log entry
 3+window.toggleLogDisplay = function( logId ) {
34 var thisCollapsed = document.getElementById( 'cn-collapsed-'+logId );
45 var thisUncollapsed = document.getElementById( 'cn-uncollapsed-'+logId );
56 var thisDetails = document.getElementById( 'cn-log-details-'+logId );
@@ -11,8 +12,10 @@
1213 thisUncollapsed.style.display = "block";
1314 thisDetails.style.display = "table-row";
1415 }
15 -}
16 -function toggleFilterDisplay() {
 16+};
 17+
 18+// Collapse and uncollapse log filter interface
 19+window.toggleFilterDisplay = function() {
1720 var thisCollapsed = document.getElementById( 'cn-collapsed-filter-arrow' );
1821 var thisUncollapsed = document.getElementById( 'cn-uncollapsed-filter-arrow' );
1922 var thisFilters = document.getElementById( 'cn-log-filters' );
@@ -25,26 +28,29 @@
2629 thisUncollapsed.style.display = "inline-block";
2730 thisFilters.style.display = "block";
2831 }
29 -}
30 -function switchLogs( baseUrl, logType ) {
 32+};
 33+
 34+// Switch among various log displays
 35+window.switchLogs = function( baseUrl, logType ) {
3136 encodeURIComponent( logType );
3237 window.location = baseUrl + '?log=' + logType;
33 -}
34 -function selectProjects( selectAll ) {
 38+};
 39+
 40+window.selectProjects = function( selectAll ) {
3541 var selectBox = document.getElementById('projects[]');
3642 var firstSelect = selectBox.options.length - 1;
3743 for (var i = firstSelect; i >= 0; i--) {
3844 selectBox.options[i].selected = selectAll;
3945 }
40 -}
41 -function selectLanguages( selectAll ) {
 46+};
 47+window.selectLanguages = function( selectAll ) {
4248 var selectBox = document.getElementById('project_languages[]');
4349 var firstSelect = selectBox.options.length - 1;
4450 for (var i = firstSelect; i >= 0; i--) {
4551 selectBox.options[i].selected = selectAll;
4652 }
47 -}
48 -function top10Languages() {
 53+};
 54+window.top10Languages = function() {
4955 var selectBox = document.getElementById('project_languages[]');
5056 var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl');
5157 selectLanguages(false);
@@ -54,15 +60,17 @@
5561 selectBox.options[i].selected = true;
5662 }
5763 }
58 -}
59 -function insertButton( buttonType ) {
 64+};
 65+
 66+// Insert banner close button
 67+window.insertButton = function( buttonType ) {
6068 var bannerField = document.getElementById('templateBody');
6169 switch( buttonType ) {
6270 case 'close': // Insert close button
6371 if ( $( '#fundraising' ).is( ':checked' ) ) {
64 - var buttonValue = '<a href="#" onclick="hideBanner(\'fundraising\');return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>';
 72+ var buttonValue = '<a href="#" onclick="hideBanner(\'fundraising\');return false;"><img border="0" src="' + mw.config.get( 'stylepath' ) + '/common/images/closewindow.png" alt="Close" /></a>';
6573 } else {
66 - var buttonValue = '<a href="#" onclick="hideBanner();return false;"><img border="0" src="'+stylepath+'/common/images/closewindow.png" alt="Close" /></a>';
 74+ var buttonValue = '<a href="#" onclick="hideBanner();return false;"><img border="0" src="' + mw.config.get( 'stylepath' ) + '/common/images/closewindow.png" alt="Close" /></a>';
6775 }
6876 break;
6977 }
@@ -82,19 +90,21 @@
8391 bannerField.value += buttonValue;
8492 }
8593 bannerField.focus();
86 -}
87 -function validateBannerForm( form ) {
 94+};
 95+
 96+// Make sure the contents of the banner body are valid
 97+window.validateBannerForm = function( form ) {
8898 var output = '';
8999 var pos = form.templateBody.value.indexOf("document.write");
90100 if( pos > -1 ) {
91 - output += documentWriteError + '\n';
 101+ output += mw.msg( 'centralnotice-documentwrite-error' ) + '\n';
92102 }
93103 if( output ) {
94104 alert( output );
95105 return false;
96106 }
97107 return true;
98 -}
 108+};
99109
100110 ( function( $ ) {
101111 $(document).ready(function() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r100100MFT r92510, r92676, r96496, r97304, r99160, r99165, r99169, r99176, r99178, r...awjrichards23:56, 17 October 2011

Comments

#Comment by Kaldari (talk | contribs)   04:25, 7 October 2011

BTW, I fixed the two super long lines in r99191.

Status & tagging log