Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -23,12 +23,9 @@ |
24 | 24 | $this->setHeaders(); |
25 | 25 | $this->outputHeader(); |
26 | 26 | |
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' ); |
29 | 29 | |
30 | | - // Add script file to the output headers |
31 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
32 | | - |
33 | 30 | // Check permissions |
34 | 31 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
35 | 32 | |
Index: trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php |
— | — | @@ -31,12 +31,9 @@ |
32 | 32 | // Begin output |
33 | 33 | $this->setHeaders(); |
34 | 34 | |
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' ); |
37 | 37 | |
38 | | - // Add script file to the output headers |
39 | | - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CentralNotice/centralnotice.js" ); |
40 | | - |
41 | 38 | // Initialize error variable |
42 | 39 | $this->centralNoticeError = false; |
43 | 40 | |
Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php |
— | — | @@ -22,17 +22,8 @@ |
23 | 23 | // Begin output |
24 | 24 | $this->setHeaders(); |
25 | 25 | |
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' ); |
37 | 28 | |
38 | 29 | // Check permissions |
39 | 30 | $this->editable = $wgUser->isAllowed( 'centralnotice-admin' ); |
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -24,11 +24,8 @@ |
25 | 25 | // Begin output |
26 | 26 | $this->setHeaders(); |
27 | 27 | |
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' ); |
33 | 30 | |
34 | 31 | // Initialize error variable |
35 | 32 | $this->centralNoticeError = false; |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -80,6 +80,15 @@ |
81 | 81 | # Unit tests |
82 | 82 | $wgHooks['UnitTestsList'][] = 'efCentralNoticeUnitTests'; |
83 | 83 | |
| 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 | + |
84 | 93 | function efCentralNoticeUnitTests( &$files ) { |
85 | 94 | $files[] = dirname( __FILE__ ) . '/tests/CentralNoticeTest.php'; |
86 | 95 | 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 ) { |
3 | 4 | var thisCollapsed = document.getElementById( 'cn-collapsed-'+logId ); |
4 | 5 | var thisUncollapsed = document.getElementById( 'cn-uncollapsed-'+logId ); |
5 | 6 | var thisDetails = document.getElementById( 'cn-log-details-'+logId ); |
— | — | @@ -11,8 +12,10 @@ |
12 | 13 | thisUncollapsed.style.display = "block"; |
13 | 14 | thisDetails.style.display = "table-row"; |
14 | 15 | } |
15 | | -} |
16 | | -function toggleFilterDisplay() { |
| 16 | +}; |
| 17 | + |
| 18 | +// Collapse and uncollapse log filter interface |
| 19 | +window.toggleFilterDisplay = function() { |
17 | 20 | var thisCollapsed = document.getElementById( 'cn-collapsed-filter-arrow' ); |
18 | 21 | var thisUncollapsed = document.getElementById( 'cn-uncollapsed-filter-arrow' ); |
19 | 22 | var thisFilters = document.getElementById( 'cn-log-filters' ); |
— | — | @@ -25,26 +28,29 @@ |
26 | 29 | thisUncollapsed.style.display = "inline-block"; |
27 | 30 | thisFilters.style.display = "block"; |
28 | 31 | } |
29 | | -} |
30 | | -function switchLogs( baseUrl, logType ) { |
| 32 | +}; |
| 33 | + |
| 34 | +// Switch among various log displays |
| 35 | +window.switchLogs = function( baseUrl, logType ) { |
31 | 36 | encodeURIComponent( logType ); |
32 | 37 | window.location = baseUrl + '?log=' + logType; |
33 | | -} |
34 | | -function selectProjects( selectAll ) { |
| 38 | +}; |
| 39 | + |
| 40 | +window.selectProjects = function( selectAll ) { |
35 | 41 | var selectBox = document.getElementById('projects[]'); |
36 | 42 | var firstSelect = selectBox.options.length - 1; |
37 | 43 | for (var i = firstSelect; i >= 0; i--) { |
38 | 44 | selectBox.options[i].selected = selectAll; |
39 | 45 | } |
40 | | -} |
41 | | -function selectLanguages( selectAll ) { |
| 46 | +}; |
| 47 | +window.selectLanguages = function( selectAll ) { |
42 | 48 | var selectBox = document.getElementById('project_languages[]'); |
43 | 49 | var firstSelect = selectBox.options.length - 1; |
44 | 50 | for (var i = firstSelect; i >= 0; i--) { |
45 | 51 | selectBox.options[i].selected = selectAll; |
46 | 52 | } |
47 | | -} |
48 | | -function top10Languages() { |
| 53 | +}; |
| 54 | +window.top10Languages = function() { |
49 | 55 | var selectBox = document.getElementById('project_languages[]'); |
50 | 56 | var top10 = new Array('en','de','fr','it','pt','ja','es','pl','ru','nl'); |
51 | 57 | selectLanguages(false); |
— | — | @@ -54,15 +60,17 @@ |
55 | 61 | selectBox.options[i].selected = true; |
56 | 62 | } |
57 | 63 | } |
58 | | -} |
59 | | -function insertButton( buttonType ) { |
| 64 | +}; |
| 65 | + |
| 66 | +// Insert banner close button |
| 67 | +window.insertButton = function( buttonType ) { |
60 | 68 | var bannerField = document.getElementById('templateBody'); |
61 | 69 | switch( buttonType ) { |
62 | 70 | case 'close': // Insert close button |
63 | 71 | 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>'; |
65 | 73 | } 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>'; |
67 | 75 | } |
68 | 76 | break; |
69 | 77 | } |
— | — | @@ -82,19 +90,21 @@ |
83 | 91 | bannerField.value += buttonValue; |
84 | 92 | } |
85 | 93 | 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 ) { |
88 | 98 | var output = ''; |
89 | 99 | var pos = form.templateBody.value.indexOf("document.write"); |
90 | 100 | if( pos > -1 ) { |
91 | | - output += documentWriteError + '\n'; |
| 101 | + output += mw.msg( 'centralnotice-documentwrite-error' ) + '\n'; |
92 | 102 | } |
93 | 103 | if( output ) { |
94 | 104 | alert( output ); |
95 | 105 | return false; |
96 | 106 | } |
97 | 107 | return true; |
98 | | -} |
| 108 | +}; |
99 | 109 | |
100 | 110 | ( function( $ ) { |
101 | 111 | $(document).ready(function() { |