r111989 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111988‎ | r111989 | r111990 >
Date:04:03, 21 February 2012
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
* (bug 34538) Fixed compatibility with $wgResourceLoaderExperimentalAsyncLoading in some extensions.
* Tested AbuseFilter.
* Did not test ArticleCreationWorkflow, Configure, ContributionTracking, FlaggedRevs, FundraiserPortal, InlineCategorizer, MarkAsHelpful, Math/Mathjax.
* Fixed a typo in a comment in LiveTranslate.
* Did not review extensions alphabetically after MoodBar.
Modified paths:
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js (modified) (history)
  • /trunk/extensions/AbuseFilter/modules/ext.abuseFilter.examine.js (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.init/ext.articleCreation.init.js (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult/ext.articleCreation.searchResult.js (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.user/ext.articleCreation.user.js (modified) (history)
  • /trunk/extensions/Configure/Configure.js (modified) (history)
  • /trunk/extensions/ContributionTracking/modules/jquery.contributionTracking.js (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.advanced.js (modified) (history)
  • /trunk/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.review.js (modified) (history)
  • /trunk/extensions/FundraiserPortal/Templates/donateScripts.js (modified) (history)
  • /trunk/extensions/InlineCategorizer/modules/ext.inlineCategorizer.core.js (modified) (history)
  • /trunk/extensions/InlineCategorizer/modules/ext.inlineCategorizer.init.js (modified) (history)
  • /trunk/extensions/LiveTranslate/includes/ext.livetranslate.js (modified) (history)
  • /trunk/extensions/MarkAsHelpful/modules/ext.markAsHelpful/ext.markAsHelpful.js (modified) (history)
  • /trunk/extensions/Math/modules/ext.math.mathjax.enabler.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.user/ext.articleCreation.user.js
@@ -251,6 +251,8 @@
252252
253253 });
254254
255 - ac.init();
 255+ $(document).ready( function() {
 256+ ac.init();
 257+ } );
256258
257259 })( jQuery, window.mw );
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.init/ext.articleCreation.init.js
@@ -1,9 +1,9 @@
2 -(function($,mw) {
 2+jQuery( document ).ready( function() {
33 var newTitle = 'Special:ArticleCreationLanding' + '/' +
44 encodeURIComponent(wgPageName);
55 var landingURL = mw.config.get('wgArticlePath').replace( '$1', newTitle );
66 // change the link to point to the new special page
7 - $("div.noarticletext")
 7+ jQuery("div.noarticletext")
88 .find('a[href*="action=edit"]')
99 .attr( 'href', landingURL );
10 -})( jQuery, window.mediaWiki );
 10+} );
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.searchResult/ext.articleCreation.searchResult.js
@@ -1,9 +1,9 @@
2 -(function($,mw) {
 2+jQuery( document ).ready( function() {
33 var newTitle = 'Special:ArticleCreationLanding' + '/' +
44 encodeURIComponent(mw.config.get('acSearch'));
55 var landingURL = mw.config.get('wgArticlePath').replace( '$1', newTitle );
66 // change the link to point to the new special page
7 - $("div.searchresults")
 7+ jQuery("div.searchresults")
88 .find('a[href*="action=edit"]')
99 .attr( 'href', landingURL );
10 -})( jQuery, window.mediaWiki );
 10+} );
Index: trunk/extensions/Configure/Configure.js
@@ -3,547 +3,548 @@
44 * create JavaScript buttons to allow to modify the form to have more
55 * flexibility
66 */
 7+jQuery( document ).ready( function ( $ ) {
 8+ // Tabs and TOC
 9+ // ------------
710
8 -// Tabs and TOC
9 -// ------------
 11+ $( '#configure' )
 12+ .addClass( 'jsprefs' )
 13+ .wrap( '<table><tbody><tr><td class="config-col-form"></td></tr></tbody></table>' )
 14+ .parent()
 15+ .before( '<td class="config-col-toc"><ul class="configtoc" id="configtoc"></ul></td>' );
1016
11 -$( '#configure' )
12 - .addClass( 'jsprefs' )
13 - .wrap( '<table><tbody><tr><td class="config-col-form"></td></tr></tbody></table>' )
14 - .parent()
15 - .before( '<td class="config-col-toc"><ul class="configtoc" id="configtoc"></ul></td>' );
 17+ $( '#configure' )
 18+ .children( 'fieldset' )
 19+ .addClass( 'configsection' )
 20+ .hide()
 21+ .children( 'legend' )
 22+ .each( function( i ) {
 23+ $( this ).parent().attr( 'id', 'config-section-' + i );
 24+ if ( i === 0 ) {
 25+ $( this ).parent().show();
 26+ }
1627
17 -$( '#configure' )
18 - .children( 'fieldset' )
19 - .addClass( 'configsection' )
20 - .hide()
21 - .children( 'legend' )
22 - .each( function( i ) {
23 - $( this ).parent().attr( 'id', 'config-section-' + i );
24 - if ( i === 0 ) {
25 - $( this ).parent().show();
26 - }
 28+ var item = $( '<li></li>' )
 29+ .addClass( i === 0 ? 'selected' : null )
 30+ .append(
 31+ $( '<a></a>' )
 32+ .text( $( this ).text() )
 33+ .attr( 'href', '#config-section-' + i )
 34+ .mousedown( function( e ) {
 35+ $( this ).parent().parent().find( 'li' ).removeClass( 'selected' );
 36+ $( this ).parent().addClass( 'selected' );
 37+ e.preventDefault();
 38+ return false;
 39+ } )
 40+ .click( function( e ) {
 41+ $( '#configure > fieldset' ).hide();
 42+ $( '#config-section-' + i ).show();
 43+ $( '#config-section-' + i + ' h2' ).show();
 44+ $( '#config-section-' + i + ' .configure-table' ).show();
 45+ e.preventDefault();
 46+ return false;
 47+ } )
 48+ );
2749
28 - var item = $( '<li></li>' )
29 - .addClass( i === 0 ? 'selected' : null )
30 - .append(
31 - $( '<a></a>' )
32 - .text( $( this ).text() )
33 - .attr( 'href', '#config-section-' + i )
 50+ $( this ).parent().find( 'table.configure-table' ).each( function( j ) {
 51+ $( this ).attr( 'id', 'config-table-' + i + '-' + j );
 52+ } );
 53+
 54+ var heads = $( this ).parent().find( 'h2' )
 55+ if ( heads.length > 1 ) {
 56+ var sub = $( '<ul></ul>' ).hide();
 57+
 58+ heads.each( function( j ) {
 59+ $( this ).attr( 'id', 'config-head-' + i + '-' + j );
 60+ sub.append(
 61+ $( '<li></li>' )
 62+ .addClass( i === 0 ? 'selected' : null )
 63+ .append(
 64+ $( '<a></a>' )
 65+ .text( $( this ).text() )
 66+ .attr( 'href', '#config-table-' + i + '-' + j )
 67+ .mousedown( function( e ) {
 68+ $( this ).parent().parent().find( 'li' ).removeClass( 'selected' );
 69+ $( this ).parent().addClass( 'selected' );
 70+ $( this ).parent().parent().parent().parent().find( 'li' ).removeClass( 'selected' );
 71+ $( this ).parent().parent().parent().addClass( 'selected' );
 72+ e.preventDefault();
 73+ return false;
 74+ } )
 75+ .click( function( e ) {
 76+ $( '#configure > fieldset' ).hide();
 77+ $( '#config-section-' + i ).show();
 78+ $( '#config-section-' + i + ' h2' ).hide();
 79+ $( '#config-section-' + i + ' .configure-table' ).hide();
 80+ $( '#config-head-' + i + '-' + j ).show();
 81+ $( '#config-table-' + i + '-' + j ).show();
 82+ e.preventDefault();
 83+ return false;
 84+ } )
 85+ ) );
 86+ } );
 87+
 88+ item.append( sub );
 89+ item.prepend( $( '<a></a>' )
 90+ .text( '[+]' )
 91+ .attr( 'href', 'javascript:' )
3492 .mousedown( function( e ) {
35 - $( this ).parent().parent().find( 'li' ).removeClass( 'selected' );
36 - $( this ).parent().addClass( 'selected' );
3793 e.preventDefault();
3894 return false;
3995 } )
4096 .click( function( e ) {
41 - $( '#configure > fieldset' ).hide();
42 - $( '#config-section-' + i ).show();
43 - $( '#config-section-' + i + ' h2' ).show();
44 - $( '#config-section-' + i + ' .configure-table' ).show();
45 - e.preventDefault();
46 - return false;
47 - } )
48 - );
 97+ if ( sub.css( 'display' ) == 'none' ) {
 98+ sub.show();
 99+ $(this).text( '[-]' );
 100+ } else {
 101+ sub.hide();
 102+ $(this).text( '[+]' );
 103+ }
 104+ } ) );
 105+ }
49106
50 - $( this ).parent().find( 'table.configure-table' ).each( function( j ) {
51 - $( this ).attr( 'id', 'config-table-' + i + '-' + j );
 107+ $( '#configtoc' ).append( item );
52108 } );
53109
54 - var heads = $( this ).parent().find( 'h2' )
55 - if ( heads.length > 1 ) {
56 - var sub = $( '<ul></ul>' ).hide();
 110+ $( '.config-col-toc' ).append(
 111+ $( '<a></a>' )
 112+ .css( 'align', 'right' )
 113+ .attr( 'href', 'javascript:;' )
 114+ .append( $( '<img />' )
 115+ .attr( 'src', stylepath + '/common/images/Arr_l.png' )
 116+ )
 117+ .mousedown( function( e ) {
 118+ e.preventDefault();
 119+ return false;
 120+ } )
 121+ .click( function( e ) {
 122+ if ( $( '#configtoc' ).css( 'display' ) == 'none' ) {
 123+ $( '#configtoc' ).show();
 124+ $( this ).children( 'img' ).remove();
 125+ $( this ).append( $( '<img />' )
 126+ .attr( 'src', stylepath + '/common/images/Arr_l.png' )
 127+ );
 128+ } else {
 129+ $( '#configtoc' ).hide();
 130+ $( this ).children( 'img' ).remove();
 131+ $( this ).append( $( '<img />' )
 132+ .attr( 'src', stylepath + '/common/images/Arr_r.png' )
 133+ );
 134+ }
 135+ e.preventDefault();
 136+ return false;
 137+ }
 138+ )
 139+ );
57140
58 - heads.each( function( j ) {
59 - $( this ).attr( 'id', 'config-head-' + i + '-' + j );
60 - sub.append(
61 - $( '<li></li>' )
62 - .addClass( i === 0 ? 'selected' : null )
63 - .append(
64 - $( '<a></a>' )
65 - .text( $( this ).text() )
66 - .attr( 'href', '#config-table-' + i + '-' + j )
67 - .mousedown( function( e ) {
68 - $( this ).parent().parent().find( 'li' ).removeClass( 'selected' );
69 - $( this ).parent().addClass( 'selected' );
70 - $( this ).parent().parent().parent().parent().find( 'li' ).removeClass( 'selected' );
71 - $( this ).parent().parent().parent().addClass( 'selected' );
72 - e.preventDefault();
73 - return false;
74 - } )
75 - .click( function( e ) {
76 - $( '#configure > fieldset' ).hide();
77 - $( '#config-section-' + i ).show();
78 - $( '#config-section-' + i + ' h2' ).hide();
79 - $( '#config-section-' + i + ' .configure-table' ).hide();
80 - $( '#config-head-' + i + '-' + j ).show();
81 - $( '#config-table-' + i + '-' + j ).show();
82 - e.preventDefault();
83 - return false;
84 - } )
85 - ) );
86 - } );
 141+ // Associative tables
 142+ // ------------------
87143
88 - item.append( sub );
89 - item.prepend( $( '<a></a>' )
90 - .text( '[+]' )
91 - .attr( 'href', 'javascript:' )
92 - .mousedown( function( e ) {
93 - e.preventDefault();
94 - return false;
95 - } )
96 - .click( function( e ) {
97 - if ( sub.css( 'display' ) == 'none' ) {
98 - sub.show();
99 - $(this).text( '[-]' );
100 - } else {
101 - sub.hide();
102 - $(this).text( '[+]' );
103 - }
104 - } ) );
105 - }
106 -
107 - $( '#configtoc' ).append( item );
108 - } );
109 -
110 -$( '.config-col-toc' ).append(
111 - $( '<a></a>' )
112 - .css( 'align', 'right' )
113 - .attr( 'href', 'javascript:;' )
114 - .append( $( '<img />' )
115 - .attr( 'src', stylepath + '/common/images/Arr_l.png' )
116 - )
117 - .mousedown( function( e ) {
118 - e.preventDefault();
119 - return false;
120 - } )
121 - .click( function( e ) {
122 - if ( $( '#configtoc' ).css( 'display' ) == 'none' ) {
123 - $( '#configtoc' ).show();
124 - $( this ).children( 'img' ).remove();
125 - $( this ).append( $( '<img />' )
126 - .attr( 'src', stylepath + '/common/images/Arr_l.png' )
127 - );
128 - } else {
129 - $( '#configtoc' ).hide();
130 - $( this ).children( 'img' ).remove();
131 - $( this ).append( $( '<img />' )
132 - .attr( 'src', stylepath + '/common/images/Arr_r.png' )
133 - );
 144+ /**
 145+ * Fix an associative table
 146+ */
 147+ window.fixAssocTable = function( table ){
 148+ var startName = 'wp' + table.attr( 'id' );
 149+ table.chidren( 'tr' ).each( function( i ) {
 150+ if ( i == 0 ) {
 151+ return;
134152 }
135 - e.preventDefault();
136 - return false;
137 - }
138 - )
139 -);
 153+ var inputs = $( this ).chidren( 'input' );
 154+ inputs[0].attr( 'name', startName + '-key-' + (i - 1) );
 155+ inputs[1].attr( 'name', startName + '-val-' + (i - 1) );
 156+ } );
 157+ }
140158
141 -// Associative tables
142 -// ------------------
 159+ $( '#configure table.assoc' ).each( function() {
 160+ var table = $( this );
143161
144 -/**
145 - * Fix an associative table
146 - */
147 -window.fixAssocTable = function( table ){
148 - var startName = 'wp' + table.attr( 'id' );
149 - table.chidren( 'tr' ).each( function( i ) {
150 - if ( i == 0 ) {
 162+ if ( table.hasClass( 'disabled' ) ) {
151163 return;
152164 }
153 - var inputs = $( this ).chidren( 'input' );
154 - inputs[0].attr( 'name', startName + '-key-' + (i - 1) );
155 - inputs[1].attr( 'name', startName + '-val-' + (i - 1) );
156 - } );
157 -}
158 -
159 -$( '#configure table.assoc' ).each( function() {
160 - var table = $( this );
161 -
162 - if ( table.hasClass( 'disabled' ) ) {
163 - return;
164 - }
165 - table.children( 'tr' ).each( function( i ) {
166 - if ( i == 0 ) {
167 - $( this ).append( $( '<th></th>' ).text( mediaWiki.msg( 'configure-js-remove-row' ) ) );
168 - } else {
169 - $( this ).append(
170 - $( '<td></td>' )
171 - .addClass( 'button' )
172 - .append(
173 - $( '<input></input>' )
174 - .attr( 'type', 'button' )
175 - .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
176 - .click( function() {
177 - $( this ).parent().parent().remove();
178 - fixAssocTable( table );
179 - } )
180 - )
181 - );
182 - }
183 - } );
184 - table.parent().append(
185 - $( '<input></input>' )
186 - .attr( 'type', 'button' )
187 - .attr( 'value', mediaWiki.msg( 'configure-js-add' ) )
188 - .addClass( 'button' )
189 - .click( function() {
190 - table.append(
191 - $( '<tr></tr>' )
 165+ table.children( 'tr' ).each( function( i ) {
 166+ if ( i == 0 ) {
 167+ $( this ).append( $( '<th></th>' ).text( mediaWiki.msg( 'configure-js-remove-row' ) ) );
 168+ } else {
 169+ $( this ).append(
 170+ $( '<td></td>' )
 171+ .addClass( 'button' )
192172 .append(
193 - $( '<td></td>' )
194 - .append(
195 - $( '<input></input>' )
196 - .attr( 'type', 'text' )
197 - )
 173+ $( '<input></input>' )
 174+ .attr( 'type', 'button' )
 175+ .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
 176+ .click( function() {
 177+ $( this ).parent().parent().remove();
 178+ fixAssocTable( table );
 179+ } )
198180 )
199 - .append(
200 - $( '<td></td>' )
201 - .append(
202 - $( '<input></input>' )
203 - .attr( 'type', 'text' )
204 - )
205 - )
206 - .append(
207 - $( '<td></td>' )
208 - .append(
209 - $( '<input></input>' )
210 - .attr( 'type', 'button' )
211 - .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
212 - .click( function() {
213 - $( this ).parent().parent().remove();
214 - fixAssocTable( table );
215 - } )
216 - )
217 - )
218181 );
219 - fixAssocTable( table );
220 - } )
221 - );
222 -} );
 182+ }
 183+ } );
 184+ table.parent().append(
 185+ $( '<input></input>' )
 186+ .attr( 'type', 'button' )
 187+ .attr( 'value', mediaWiki.msg( 'configure-js-add' ) )
 188+ .addClass( 'button' )
 189+ .click( function() {
 190+ table.append(
 191+ $( '<tr></tr>' )
 192+ .append(
 193+ $( '<td></td>' )
 194+ .append(
 195+ $( '<input></input>' )
 196+ .attr( 'type', 'text' )
 197+ )
 198+ )
 199+ .append(
 200+ $( '<td></td>' )
 201+ .append(
 202+ $( '<input></input>' )
 203+ .attr( 'type', 'text' )
 204+ )
 205+ )
 206+ .append(
 207+ $( '<td></td>' )
 208+ .append(
 209+ $( '<input></input>' )
 210+ .attr( 'type', 'button' )
 211+ .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
 212+ .click( function() {
 213+ $( this ).parent().parent().remove();
 214+ fixAssocTable( table );
 215+ } )
 216+ )
 217+ )
 218+ );
 219+ fixAssocTable( table );
 220+ } )
 221+ );
 222+ } );
223223
224 -// Images
225 -// ------
 224+ // Images
 225+ // ------
226226
227 -$( '.image-selector' ).blur( function() {
228 - var data = {
229 - 'action': 'query',
230 - 'titles': $( this ).attr( 'value' ),
231 - 'prop': 'imageinfo',
232 - 'iiprop': 'url',
233 - 'format': 'json'
234 - };
235 - var input = $( this );
236 - $.getJSON(
237 - mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ),
238 - data,
239 - function( obj ) {
240 - var found = false;
241 - for ( var i in obj.query.pages ) {
242 - if( obj.query.pages[i].imageinfo && obj.query.pages[i].imageinfo[0].url ) {
243 - $( '#image-url-preview-' + input.attr( 'id' ).substr( 18 ) ).attr( 'src', obj.query.pages[i].imageinfo[0].url );
244 - found = true;
 227+ $( '.image-selector' ).blur( function() {
 228+ var data = {
 229+ 'action': 'query',
 230+ 'titles': $( this ).attr( 'value' ),
 231+ 'prop': 'imageinfo',
 232+ 'iiprop': 'url',
 233+ 'format': 'json'
 234+ };
 235+ var input = $( this );
 236+ $.getJSON(
 237+ mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ),
 238+ data,
 239+ function( obj ) {
 240+ var found = false;
 241+ for ( var i in obj.query.pages ) {
 242+ if( obj.query.pages[i].imageinfo && obj.query.pages[i].imageinfo[0].url ) {
 243+ $( '#image-url-preview-' + input.attr( 'id' ).substr( 18 ) ).attr( 'src', obj.query.pages[i].imageinfo[0].url );
 244+ found = true;
 245+ }
245246 }
 247+ if ( !found ) {
 248+ $( '#image-url-preview-' + input.attr( 'id' ).substr( 18 ) ).attr( 'src', input.attr( 'value' ) );
 249+ }
246250 }
247 - if ( !found ) {
248 - $( '#image-url-preview-' + input.attr( 'id' ).substr( 18 ) ).attr( 'src', input.attr( 'value' ) );
249 - }
250 - }
251 - );
252 -} );
253 -
254 -// $wgGroupPermissions and $wgAutopromote stuff, only if ajax is enabled
255 -// ---------------------------------------------------------------------
256 -
257 -$( '.ajax-group' ).each( function() {
258 - var table = $( this );
259 - // Button "remove this row"
260 - table.children( 'tr' ).each( function( i ) {
261 - if ( i == 0 ) {
262 - $( this ).append( $( '<th></th>' ).text( mediaWiki.msg( 'configure-js-remove' ) ) );
263 - } else {
264 - $( this ).append(
265 - $( '<td></td>' )
266 - .addClass( 'button' )
267 - .append(
268 - $( '<input></input>' )
269 - .attr( 'type', 'button' )
270 - .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
271 - .click( function() {
272 - $( this ).parent().parent().remove();
273 - } )
274 - )
275 - );
276 - }
 251+ );
277252 } );
278 - // Button "add a new row"
279 - table.parent().append(
280 - $( '<input></input>' )
281 - .addClass( 'button-add' )
282 - .attr( 'type', 'button' )
283 - .attr( 'value', mediaWiki.msg( 'configure-js-add' ) )
284 - .click( function() {
285 - var groupname = prompt( mediaWiki.msg( 'configure-js-prompt-group' ) );
286 - if( groupname == null )
287 - return;
288253
289 - var data = {
290 - 'action': 'configure',
291 - 'prop': 'ajax',
292 - 'format': 'json',
293 - 'ajaxgroup': groupname,
294 - 'ajaxsetting': table.attr( 'id' )
295 - };
 254+ // $wgGroupPermissions and $wgAutopromote stuff, only if ajax is enabled
 255+ // ---------------------------------------------------------------------
296256
297 - $.getJSON(
298 - mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ),
299 - data,
300 - function( obj ) {
301 - if ( obj.configure.ajax ) {
302 - var resp = obj.configure.ajax;
303 - error = false;
304 - table.append(
305 - $( '<tr></tr>' )
306 - .addClass( 'configure-maintable-row' )
307 - .attr( 'id', 'wp' + table.attr( 'id' ) + groupname )
308 - .append( $( '<td></td>' ).text( groupname ) )
309 - .append( $( '<td></td>' ).html( resp ) )
310 - .append(
311 - $( '<td></td>' )
312 - .append(
313 - $( '<input></input>' )
314 - .attr( 'type', 'button' )
315 - .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
316 - .click( function() {
317 - $( this ).parent().parent().remove();
318 - } )
319 - )
320 - )
321 - );
322 - } else {
323 - alert( mediaWiki.msg( 'configure-js-group-exists' ) );
324 - }
325 - }
326 - );
327 - } )
328 - );
329 -} );
330 -
331 -$( '#configure-form' ).submit( function(){
332257 $( '.ajax-group' ).each( function() {
333258 var table = $( this );
334 - var cont = '';
335 - table.children( 'tr.configure-maintable-row' ).each( function() {
336 - if( cont != '' ) cont += "\n";
337 - cont += $( this ).attr( 'id' );
 259+ // Button "remove this row"
 260+ table.children( 'tr' ).each( function( i ) {
 261+ if ( i == 0 ) {
 262+ $( this ).append( $( '<th></th>' ).text( mediaWiki.msg( 'configure-js-remove' ) ) );
 263+ } else {
 264+ $( this ).append(
 265+ $( '<td></td>' )
 266+ .addClass( 'button' )
 267+ .append(
 268+ $( '<input></input>' )
 269+ .attr( 'type', 'button' )
 270+ .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
 271+ .click( function() {
 272+ $( this ).parent().parent().remove();
 273+ } )
 274+ )
 275+ );
 276+ }
338277 } );
 278+ // Button "add a new row"
339279 table.parent().append(
340280 $( '<input></input>' )
341 - .attr( 'type', 'hidden' )
342 - .attr( 'name', 'wp' + table.attr( 'id' ) + '-vals' )
343 - .attr( 'value', cont )
 281+ .addClass( 'button-add' )
 282+ .attr( 'type', 'button' )
 283+ .attr( 'value', mediaWiki.msg( 'configure-js-add' ) )
 284+ .click( function() {
 285+ var groupname = prompt( mediaWiki.msg( 'configure-js-prompt-group' ) );
 286+ if( groupname == null )
 287+ return;
 288+
 289+ var data = {
 290+ 'action': 'configure',
 291+ 'prop': 'ajax',
 292+ 'format': 'json',
 293+ 'ajaxgroup': groupname,
 294+ 'ajaxsetting': table.attr( 'id' )
 295+ };
 296+
 297+ $.getJSON(
 298+ mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ),
 299+ data,
 300+ function( obj ) {
 301+ if ( obj.configure.ajax ) {
 302+ var resp = obj.configure.ajax;
 303+ error = false;
 304+ table.append(
 305+ $( '<tr></tr>' )
 306+ .addClass( 'configure-maintable-row' )
 307+ .attr( 'id', 'wp' + table.attr( 'id' ) + groupname )
 308+ .append( $( '<td></td>' ).text( groupname ) )
 309+ .append( $( '<td></td>' ).html( resp ) )
 310+ .append(
 311+ $( '<td></td>' )
 312+ .append(
 313+ $( '<input></input>' )
 314+ .attr( 'type', 'button' )
 315+ .attr( 'value', mediaWiki.msg( 'configure-js-remove-row' ) )
 316+ .click( function() {
 317+ $( this ).parent().parent().remove();
 318+ } )
 319+ )
 320+ )
 321+ );
 322+ } else {
 323+ alert( mediaWiki.msg( 'configure-js-group-exists' ) );
 324+ }
 325+ }
 326+ );
 327+ } )
344328 );
345329 } );
346 -} );
347330
348 -// Big lists
349 -// ---------
350 -
351 -// Summarise the setting contained in 'div' to the summary field 'summary'.
352 -window.summariseSetting = function( div ) {
353 -
354 - if ( div.hasClass( 'assoc' ) ) {
355 - // If it's too big to display as an associative array, it's too big to display as a summary.
356 - return '';
357 - } else if ( div.hasClass( 'ns-bool' ) || div.hasClass( 'ns-simple' ) || div.hasClass( 'group-bool-element' ) || div.hasClass( 'group-array-element' ) ) {
358 - var matches = [];
359 - div.find( 'label' ).each( function() {
360 - if ( $( '#' + $( this ).attr( 'for' ) ).attr( 'checked' ) ) {
361 - matches.push( $( this ).text() );
362 - }
 331+ $( '#configure-form' ).submit( function(){
 332+ $( '.ajax-group' ).each( function() {
 333+ var table = $( this );
 334+ var cont = '';
 335+ table.children( 'tr.configure-maintable-row' ).each( function() {
 336+ if( cont != '' ) cont += "\n";
 337+ cont += $( this ).attr( 'id' );
 338+ } );
 339+ table.parent().append(
 340+ $( '<input></input>' )
 341+ .attr( 'type', 'hidden' )
 342+ .attr( 'name', 'wp' + table.attr( 'id' ) + '-vals' )
 343+ .attr( 'value', cont )
 344+ );
363345 } );
364 - return matches.join( ', ' );
365 - } else if ( div.hasClass( 'ns-array' ) || div.hasClass( 'ns-text' ) || div.hasClass( 'configure-rate-limits-action' ) ) {
366 - // Basic strategy: find all labels, and list the values of their corresponding inputs, if those inputs have a value
 346+ } );
367347
368 - var body = $( '<tbody></tbody>' )
369 - .append( $( '<tr></tr>' )
370 - .append( $( '<th></th>' ).text( div.find( 'th:first' ).text() ) )
371 - .append( $( '<th></th>' ).text( div.find( 'th:last' ).text() ) )
372 - );
 348+ // Big lists
 349+ // ---------
373350
374 - var rows = false;
 351+ // Summarise the setting contained in 'div' to the summary field 'summary'.
 352+ window.summariseSetting = function( div ) {
375353
376 - if ( div.hasClass( 'configure-rate-limits-action' ) ) {
377 - div.find( 'tr' ).each( function( i ) {
378 - if ( i == 0 ) {
379 - return;
 354+ if ( div.hasClass( 'assoc' ) ) {
 355+ // If it's too big to display as an associative array, it's too big to display as a summary.
 356+ return '';
 357+ } else if ( div.hasClass( 'ns-bool' ) || div.hasClass( 'ns-simple' ) || div.hasClass( 'group-bool-element' ) || div.hasClass( 'group-array-element' ) ) {
 358+ var matches = [];
 359+ div.find( 'label' ).each( function() {
 360+ if ( $( '#' + $( this ).attr( 'for' ) ).attr( 'checked' ) ) {
 361+ matches.push( $( this ).text() );
380362 }
381 - var typeDesc = $( this ).find( 'td:first' ).text();
382 - var periodField = $( '#' + $( this ).attr( 'id' ) + '-period' );
383 - var countField = $( '#' + $( this ).attr( 'id' ) + '-count' );
 363+ } );
 364+ return matches.join( ', ' );
 365+ } else if ( div.hasClass( 'ns-array' ) || div.hasClass( 'ns-text' ) || div.hasClass( 'configure-rate-limits-action' ) ) {
 366+ // Basic strategy: find all labels, and list the values of their corresponding inputs, if those inputs have a value
384367
385 - if ( periodField.attr( 'value' ) > 0 ) {
386 - rows = true;
 368+ var body = $( '<tbody></tbody>' )
 369+ .append( $( '<tr></tr>' )
 370+ .append( $( '<th></th>' ).text( div.find( 'th:first' ).text() ) )
 371+ .append( $( '<th></th>' ).text( div.find( 'th:last' ).text() ) )
 372+ );
387373
388 - body.append( $( '<tr></tr>' )
389 - .append( $( '<td></td>' ).text( typeDesc ) )
390 - .append( $( '<td></td>' ).text( mediaWiki.msg(
391 - 'configure-throttle-summary', countField.attr( 'value' ), periodField.attr( 'value' ) ) ) )
392 - );
393 - }
394 - } );
395 - } else {
396 - div.find( 'label' ).each( function( i ) {
397 - if ( i == 0 ) {
398 - return;
399 - }
400 - var arrayfield = $( '#' + $( this ).attr( 'for' ) );
401 - if ( arrayfield.attr( 'value' ) > 0 ) {
402 - rows = true;
 374+ var rows = false;
403375
404 - body.append( $( '<tr></tr>' )
405 - .append( $( '<td></td>' ).text( $( this ).text() ) )
406 - .append( $( '<td></td>' ).text( arrayfield.attr( 'value' ) ) )
407 - );
408 - }
409 - } );
410 - }
 376+ if ( div.hasClass( 'configure-rate-limits-action' ) ) {
 377+ div.find( 'tr' ).each( function( i ) {
 378+ if ( i == 0 ) {
 379+ return;
 380+ }
 381+ var typeDesc = $( this ).find( 'td:first' ).text();
 382+ var periodField = $( '#' + $( this ).attr( 'id' ) + '-period' );
 383+ var countField = $( '#' + $( this ).attr( 'id' ) + '-count' );
411384
412 - if ( !rows ) {
413 - body.append( $( '<tr></tr>' )
414 - .append( $( '<th></th>' )
415 - .attr( 'colspan', 2 )
416 - .text( mediaWiki.msg( 'configure-js-summary-none' ) )
417 - )
418 - );
419 - }
 385+ if ( periodField.attr( 'value' ) > 0 ) {
 386+ rows = true;
420387
421 - return $( '<table></table>' ).addClass( 'assoc' ).append( body ).html();
422 - } else if ( div.hasClass( 'promotion-conds-element' ) || div.hasClass( 'configure-rate-limits-action' ) ) {
423 - return '';
424 - } else {
425 - return 'Useless type';
426 - }
427 -}
 388+ body.append( $( '<tr></tr>' )
 389+ .append( $( '<td></td>' ).text( typeDesc ) )
 390+ .append( $( '<td></td>' ).text( mediaWiki.msg(
 391+ 'configure-throttle-summary', countField.attr( 'value' ), periodField.attr( 'value' ) ) ) )
 392+ );
 393+ }
 394+ } );
 395+ } else {
 396+ div.find( 'label' ).each( function( i ) {
 397+ if ( i == 0 ) {
 398+ return;
 399+ }
 400+ var arrayfield = $( '#' + $( this ).attr( 'for' ) );
 401+ if ( arrayfield.attr( 'value' ) > 0 ) {
 402+ rows = true;
428403
429 -$( '.configure-biglist' ).each( function( l ) {
430 - var list = $( this );
431 - var summary = $( '<div></div>' )
432 - .addClass( 'configure-biglist-summary' )
433 - .html( summariseSetting( list ) );
434 - var header = $( '<span></span>' ).text( mediaWiki.msg( 'configure-js-biglist-hidden' ) );
435 - var toogle = $( '<a></a>' )
436 - .addClass( 'configure-biglist-toggle-link' )
437 - .attr( 'href', 'javascript:' )
438 - .text( mediaWiki.msg( 'configure-js-biglist-show' ) )
439 - .click( function() {
440 - if ( list.css( 'display' ) == 'none' ) {
441 - toogle.text( mediaWiki.msg( 'configure-js-biglist-hide' ) );
442 - header.text( mediaWiki.msg( 'configure-js-biglist-shown' ) );
443 - list.show();
444 - summary.hide();
445 - } else {
446 - toogle.text( mediaWiki.msg( 'configure-js-biglist-show' ) );
447 - header.text( mediaWiki.msg( 'configure-js-biglist-hidden' ) );
448 - list.hide();
449 - summary.html( summariseSetting( list ) ).show();
 404+ body.append( $( '<tr></tr>' )
 405+ .append( $( '<td></td>' ).text( $( this ).text() ) )
 406+ .append( $( '<td></td>' ).text( arrayfield.attr( 'value' ) ) )
 407+ );
 408+ }
 409+ } );
450410 }
451 - } );
452411
453 - list.hide();
454 - list.before(
455 - $( '<div></div>' )
456 - .addClass( 'configure-biglist-placeholder' )
457 - .append( toogle )
458 - .append( header )
459 - );
460 - list.before(
461 - summary
462 - );
463 -} );
 412+ if ( !rows ) {
 413+ body.append( $( '<tr></tr>' )
 414+ .append( $( '<th></th>' )
 415+ .attr( 'colspan', 2 )
 416+ .text( mediaWiki.msg( 'configure-js-summary-none' ) )
 417+ )
 418+ );
 419+ }
464420
465 -// Search
466 -// ------
 421+ return $( '<table></table>' ).addClass( 'assoc' ).append( body ).html();
 422+ } else if ( div.hasClass( 'promotion-conds-element' ) || div.hasClass( 'configure-rate-limits-action' ) ) {
 423+ return '';
 424+ } else {
 425+ return 'Useless type';
 426+ }
 427+ }
467428
468 -window.allSettings = undefined;
 429+ $( '.configure-biglist' ).each( function( l ) {
 430+ var list = $( this );
 431+ var summary = $( '<div></div>' )
 432+ .addClass( 'configure-biglist-summary' )
 433+ .html( summariseSetting( list ) );
 434+ var header = $( '<span></span>' ).text( mediaWiki.msg( 'configure-js-biglist-hidden' ) );
 435+ var toogle = $( '<a></a>' )
 436+ .addClass( 'configure-biglist-toggle-link' )
 437+ .attr( 'href', 'javascript:' )
 438+ .text( mediaWiki.msg( 'configure-js-biglist-show' ) )
 439+ .click( function() {
 440+ if ( list.css( 'display' ) == 'none' ) {
 441+ toogle.text( mediaWiki.msg( 'configure-js-biglist-hide' ) );
 442+ header.text( mediaWiki.msg( 'configure-js-biglist-shown' ) );
 443+ list.show();
 444+ summary.hide();
 445+ } else {
 446+ toogle.text( mediaWiki.msg( 'configure-js-biglist-show' ) );
 447+ header.text( mediaWiki.msg( 'configure-js-biglist-hidden' ) );
 448+ list.hide();
 449+ summary.html( summariseSetting( list ) ).show();
 450+ }
 451+ } );
469452
470 -( function() {
471 - allSettings = [];
 453+ list.hide();
 454+ list.before(
 455+ $( '<div></div>' )
 456+ .addClass( 'configure-biglist-placeholder' )
 457+ .append( toogle )
 458+ .append( header )
 459+ );
 460+ list.before(
 461+ summary
 462+ );
 463+ } );
472464
473 - // For each section...
474 - var rootElement = document.getElementById( 'configure' );
475 - var fieldsets = rootElement.getElementsByTagName( 'fieldset' );
476 - for( var fid=0; fid<fieldsets.length; ++fid ) {
477 - // For each subsection...
478 - var fieldset = fieldsets[fid];
479 - var fieldset_title = window.getInnerText( fieldset.getElementsByTagName( 'legend' )[0] );
480 - var subsections = getElementsByClassName( fieldset, 'table', 'configure-table' );
481 - for( var sid=0; sid<subsections.length; ++sid ) {
482 - var subsection;
483 - if (subsections[sid].getElementsByTagName( 'tbody' ).length > 0) {
484 - subsection = subsections[sid].getElementsByTagName( 'tbody' )[0];
485 - } else {
486 - subsection = subsections[sid];
487 - }
488 - var heading = document.getElementById( subsection.parentNode.id.replace( 'config-table', 'config-head' ) );
 465+ // Search
 466+ // ------
489467
490 - // For each setting...
491 - for( var i=0; i<subsection.childNodes.length;++i ) {
492 - var row = subsection.childNodes[i];
493 - if( typeof row.ELEMENT_NODE == "undefined" ){
494 - var wantedType = 1; // ELEMENT_NODE
 468+ window.allSettings = undefined;
 469+
 470+ ( function() {
 471+ allSettings = [];
 472+
 473+ // For each section...
 474+ var rootElement = document.getElementById( 'configure' );
 475+ var fieldsets = rootElement.getElementsByTagName( 'fieldset' );
 476+ for( var fid=0; fid<fieldsets.length; ++fid ) {
 477+ // For each subsection...
 478+ var fieldset = fieldsets[fid];
 479+ var fieldset_title = window.getInnerText( fieldset.getElementsByTagName( 'legend' )[0] );
 480+ var subsections = getElementsByClassName( fieldset, 'table', 'configure-table' );
 481+ for( var sid=0; sid<subsections.length; ++sid ) {
 482+ var subsection;
 483+ if (subsections[sid].getElementsByTagName( 'tbody' ).length > 0) {
 484+ subsection = subsections[sid].getElementsByTagName( 'tbody' )[0];
495485 } else {
496 - var wantedType = row.ELEMENT_NODE;
 486+ subsection = subsections[sid];
497487 }
498 - if ( row.nodeType != wantedType || ( row.tagName != 'tr' && row.tagName != 'TR' ) ) {
499 - continue;
500 - }
 488+ var heading = document.getElementById( subsection.parentNode.id.replace( 'config-table', 'config-head' ) );
501489
502 - var desc_cell = getElementsByClassName( row, 'td', 'configure-left-column' )[0];
503 - if( typeof desc_cell == "undefined" ){
504 - continue;
505 - }
 490+ // For each setting...
 491+ for( var i=0; i<subsection.childNodes.length;++i ) {
 492+ var row = subsection.childNodes[i];
 493+ if( typeof row.ELEMENT_NODE == "undefined" ){
 494+ var wantedType = 1; // ELEMENT_NODE
 495+ } else {
 496+ var wantedType = row.ELEMENT_NODE;
 497+ }
 498+ if ( row.nodeType != wantedType || ( row.tagName != 'tr' && row.tagName != 'TR' ) ) {
 499+ continue;
 500+ }
506501
507 - var description;
 502+ var desc_cell = getElementsByClassName( row, 'td', 'configure-left-column' )[0];
 503+ if( typeof desc_cell == "undefined" ){
 504+ continue;
 505+ }
508506
509 - if ( desc_cell.getElementsByTagName( 'p' ).length ) { // Ward off comments like "This setting has been customised"
510 - description = window.getInnerText( desc_cell.getElementsByTagName( 'p' )[0] );
511 - } else {
512 - description = window.getInnerText( desc_cell );
 507+ var description;
 508+
 509+ if ( desc_cell.getElementsByTagName( 'p' ).length ) { // Ward off comments like "This setting has been customised"
 510+ description = window.getInnerText( desc_cell.getElementsByTagName( 'p' )[0] );
 511+ } else {
 512+ description = window.getInnerText( desc_cell );
 513+ }
 514+
 515+ allSettings.push( { 'description': description.toLowerCase(), 'fid':fid+1, 'sid':sid, 'displayDescription': description } );
513516 }
514 -
515 - allSettings.push( { 'description': description.toLowerCase(), 'fid':fid+1, 'sid':sid, 'displayDescription': description } );
516517 }
517518 }
518 - }
519 -} )();
 519+ } )();
520520
521 -$( '#configure-search-form' ).show();
522 -$( '#configure-search-input' ).keyup( function() {
523 - var query = $( '#configure-search-input' ).attr( 'value' ).toLowerCase();
 521+ $( '#configure-search-form' ).show();
 522+ $( '#configure-search-input' ).keyup( function() {
 523+ var query = $( '#configure-search-input' ).attr( 'value' ).toLowerCase();
524524
525 - $( '#configure-search-results' ).children( 'li' ).remove();
 525+ $( '#configure-search-results' ).children( 'li' ).remove();
526526
527 - if ( query == '' ) {
528 - return;
529 - }
 527+ if ( query == '' ) {
 528+ return;
 529+ }
530530
531 - var isMatch = function( element ) { return element.description.indexOf( query ) !== -1; }
532 - for( var i=0; i<allSettings.length; ++i ) {
533 - var data = allSettings[i];
534 - if ( isMatch( data ) ) {
535 - $( '#configure-search-results' ).append(
536 - $( '<li></li>' ).append(
537 - $( '<a></a>' )
538 - .attr( 'href', '#config-head-'+data.fid+'-'+data.sid )
539 - .text( data.displayDescription )
540 - .click( function() {
541 - $( '#configure > fieldset' ).hide();
542 - $( '#config-section-' + data.fid ).show();
543 - $( '#config-section-' + data.fid + ' h2' ).show();
544 - $( '#config-section-' + data.fid + ' .configure-table' ).show();
545 - } )
546 - )
547 - );
 531+ var isMatch = function( element ) { return element.description.indexOf( query ) !== -1; }
 532+ for( var i=0; i<allSettings.length; ++i ) {
 533+ var data = allSettings[i];
 534+ if ( isMatch( data ) ) {
 535+ $( '#configure-search-results' ).append(
 536+ $( '<li></li>' ).append(
 537+ $( '<a></a>' )
 538+ .attr( 'href', '#config-head-'+data.fid+'-'+data.sid )
 539+ .text( data.displayDescription )
 540+ .click( function() {
 541+ $( '#configure > fieldset' ).hide();
 542+ $( '#config-section-' + data.fid ).show();
 543+ $( '#config-section-' + data.fid + ' h2' ).show();
 544+ $( '#config-section-' + data.fid + ' .configure-table' ).show();
 545+ } )
 546+ )
 547+ );
 548+ }
548549 }
549 - }
 550+ } );
550551 } );
Index: trunk/extensions/Math/modules/ext.math.mathjax.enabler.js
@@ -83,4 +83,6 @@
8484 }
8585 }
8686
87 -mathJax.Init();
 87+jQuery( document ).ready( function() {
 88+ mathJax.Init();
 89+} );
Index: trunk/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.review.js
@@ -412,7 +412,9 @@
413413 }
414414 };
415415
416 -// Perform some onload (which is when this script is included) events:
417 -fr.init();
 416+// Perform some onload events:
 417+$(document).ready( function() {
 418+ fr.init();
 419+} );
418420
419421 })( jQuery );
Index: trunk/extensions/FlaggedRevs/frontend/modules/ext.flaggedRevs.advanced.js
@@ -203,7 +203,9 @@
204204 }
205205 };
206206
207 -// Perform some onload (which is when this script is included) events:
208 -fr.init();
 207+// Perform some onload events:
 208+$(document).ready( function() {
 209+ fr.init();
 210+} );
209211
210212 })( jQuery );
Index: trunk/extensions/FundraiserPortal/Templates/donateScripts.js
@@ -38,9 +38,11 @@
3939 }
4040 }
4141
42 -var wgDonateButton = getDonateButton();
 42+jQuery( document ).ready( function() {
 43+ var wgDonateButton = getDonateButton();
4344
44 -if ( ! wgDonateButton ) {
45 - var wgDonateButton = pickDonateButton();
46 - setDonateButton( wgDonateButton );
47 -}
 45+ if ( ! wgDonateButton ) {
 46+ var wgDonateButton = pickDonateButton();
 47+ setDonateButton( wgDonateButton );
 48+ }
 49+} );
Index: trunk/extensions/ContributionTracking/modules/jquery.contributionTracking.js
@@ -112,4 +112,6 @@
113113
114114 } )( jQuery );
115115
116 -$.bindAjaxControls();
\ No newline at end of file
 116+jQuery(document).ready( function() {
 117+ $.bindAjaxControls();
 118+} );
Index: trunk/extensions/InlineCategorizer/modules/ext.inlineCategorizer.init.js
@@ -1,8 +1,8 @@
2 -/**
3 - * Initialize an instance of InlineCategorizer into mw.page
4 - */
5 -mw.page.inlineCategorizer = new mw.InlineCategorizer();
62 jQuery( document ).ready( function(){
 3+ /**
 4+ * Initialize an instance of InlineCategorizer into mw.page
 5+ */
 6+ mw.page.inlineCategorizer = new mw.InlineCategorizer();
77 // Separate function for call to prevent jQuery
88 // from executing it in the document context.
99 mw.page.inlineCategorizer.setup();
Index: trunk/extensions/InlineCategorizer/modules/ext.inlineCategorizer.core.js
@@ -8,20 +8,23 @@
99 * Relies on: mw.config (wgFormattedNamespaces, wgNamespaceIds,
1010 * wgCaseSensitiveNamespaces, wgUserGroups), mw.util.wikiGetlink
1111 */
12 -( function( $ ) {
 12+( function ($) {
1313
1414 /* Local scope */
1515
1616 var catNsId = mw.config.get( 'wgNamespaceIds' ).category,
17 - defaultOptions = {
 17+ isCatNsSensitive = $.inArray( 14, mw.config.get( 'wgCaseSensitiveNamespaces' ) ) !== -1;
 18+
 19+ function getDefaultOptions() {
 20+ return {
1821 catLinkWrapper: '<li>',
1922 $container: $( '.catlinks' ),
2023 $containerNormal: $( '#mw-normal-catlinks' ),
2124 categoryLinkSelector: 'li a:not(.icon)',
2225 multiEdit: $.inArray( 'user', mw.config.get( 'wgUserGroups' ) ) !== -1,
2326 resolveRedirects: true
24 - },
25 - isCatNsSensitive = $.inArray( 14, mw.config.get( 'wgCaseSensitiveNamespaces' ) ) !== -1;
 27+ };
 28+ }
2629
2730 /**
2831 * @return {String}
@@ -195,7 +198,7 @@
196199 */
197200 mw.InlineCategorizer = function( options ) {
198201
199 - this.options = options = $.extend( defaultOptions, options );
 202+ this.options = options = $.extend( getDefaultOptions(), options );
200203
201204 // Save scope in shortcut
202205 var ajaxcat = this;
@@ -1149,4 +1152,4 @@
11501153 }
11511154 };
11521155
1153 -} )( jQuery );
 1156+})(jQuery);
Index: trunk/extensions/LiveTranslate/includes/ext.livetranslate.js
@@ -1,5 +1,5 @@
22 /**
3 - * JavasSript for the Live Translate extension.
 3+ * JavaScript for the Live Translate extension.
44 * @see https://www.mediawiki.org/wiki/Extension:Live_Translate
55 *
66 * @licence GNU GPL v3 or later
@@ -40,4 +40,4 @@
4141
4242 window.liveTranslate = lt;
4343
44 -}() );
\ No newline at end of file
 44+}() );
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.edit.js
@@ -7,7 +7,7 @@
88 *
99 * @var {jQuery}
1010 */
11 - var $filterBox = $( '#' + mw.config.get( 'abuseFilterBoxName' ) );
 11+ var $filterBox = [];
1212
1313 /**
1414 * Reference to this
@@ -178,6 +178,7 @@
179179 * On ready initialization
180180 */
181181 $( function( $ ) {
 182+ $filterBox = $( '#' + mw.config.get( 'abuseFilterBoxName' ) );
182183 // Hide the syntax ok message when the text changes
183184 $filterBox.keyup( function() {
184185 var $el = $( '#mw-abusefilter-syntaxresult' );
Index: trunk/extensions/AbuseFilter/modules/ext.abuseFilter.examine.js
@@ -12,7 +12,7 @@
1313 *
1414 * @type {jQuery}
1515 */
16 - var $syntaxResult = $( '#mw-abusefilter-syntaxresult' );
 16+ var $syntaxResult = [];
1717
1818 /**
1919 * Tests the filter against an rc event or abuse log entry
@@ -84,6 +84,7 @@
8585 };
8686
8787 $( function( $ ) {
 88+ $syntaxResult = $( '#mw-abusefilter-syntaxresult' );
8889 $( '#mw-abusefilter-examine-test' ).click( that.examinerTestFilter );
8990 } );
90 -} )( jQuery, mediaWiki );
\ No newline at end of file
 91+} )( jQuery, mediaWiki );
Index: trunk/extensions/MarkAsHelpful/modules/ext.markAsHelpful/ext.markAsHelpful.js
@@ -105,20 +105,22 @@
106106
107107 // Some live events for the different modes
108108
109 - /*
110 - * Click Event for marking an item as helpful.
111 - */
112 - $( '.markashelpful-mark' ).live( 'click', function() {
113 - mah.markItem( $(this), 'mark' );
114 - } );
 109+ $(document).ready( function() {
 110+ /*
 111+ * Click Event for marking an item as helpful.
 112+ */
 113+ $( '.markashelpful-mark' ).live( 'click', function() {
 114+ mah.markItem( $(this), 'mark' );
 115+ } );
115116
116 - /*
117 - * Click Event for removing helpful status from an item.
118 - */
119 - $( '.markashelpful-undo' ).live( 'click', function() {
120 - mah.markItem( $(this), 'unmark' );
 117+ /*
 118+ * Click Event for removing helpful status from an item.
 119+ */
 120+ $( '.markashelpful-undo' ).live( 'click', function() {
 121+ mah.markItem( $(this), 'unmark' );
 122+ } );
 123+
 124+ // Initialize MarkAsHelpful
 125+ mah.init();
121126 } );
122 -
123 - // Initialize MarkAsHelpful
124 - $( mah.init );
125 -} ) ( jQuery );
\ No newline at end of file
 127+} ) ( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r112302Partial revert of r111989: the FundraiserPortal change appears to have been b...tstarling05:20, 24 February 2012
r112462(bug 34538) Fixed compatibility with $wgResourceLoaderExperimentalAsyncLoadin...tstarling00:56, 27 February 2012
r112573[mediawiki.action.edit] Clean up and bug fixes...krinkle03:17, 28 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111983* Fixed failure of the edit toolbar to load when $wgResourceLoaderExperimenta...tstarling23:29, 20 February 2012
r111984Bug 34538 again. Bug reproduced and fix tested.tstarling23:47, 20 February 2012
r111985* Fixed load order like bug 34538...tstarling00:00, 21 February 2012

Comments

#Comment by Krinkle (talk | contribs)   21:27, 22 February 2012

I haven't tested any of this, but I see a few pieces of concern that you may not have been aware of. Nothing critical, just small bits and pieces.

- var $filterBox = $( '#' + mw.config.get( 'abuseFilterBoxName' ) );
+ var $filterBox = [];
..
- var $syntaxResult = $( '#mw-abusefilter-syntaxresult' );
+ var $syntaxResult = [];

This file contains several references to $filterBox outside the document-ready callback. I don't know if those methods are called directly but it feels wrong. But initializing it to an empty array doesn't make sense either way. Things like $filterBox.val() will fail if it's not a jQuery object. Either leave it undefined (var $filterBox;) or initialize it to an empty jQuery object (var $filterBox = $( [] );) to keep it compatible in a lazy way.


- (function($,mw) {
-    $("div.searchresults")
- })( jQuery, window.mediaWiki );
+ jQuery( document ).ready( function() {
+   jQuery("div.searchresults")
+ } );

$ can be aliased locally without an additional closure via the first argument of the document-ready callback.


+ jQuery( document ).ready( function() {
    var wgDonateButton = getDonateButton();
..
+ } );

Again, I don't know this extension. But this can potentially break stuff if anything else outside this file was referring to wgDonateButton, which is now in a "lower" context, and no longer exposed. It wasn't a global since ResourceLoader uses closures per module, but it was exposed to other files within the same module (if the module has multiple files). Probably not an issue here thoguh (unless this file is not loaded with ResourceLoader in which case the breakage much more likely).

#Comment by Tim Starling (talk | contribs)   23:51, 22 February 2012

Initialising to an empty array was Roan's idea, he told me to do it when I wrote r111983. There were some instances in the core already of the same pattern. You're right that it seems a bit wrong.

I don't see the point in creating a $ alias for a single-line function.

Yes there are references $filterBox, but only in functions called from callbacks registered in the document ready hook. Note that the object is anonymous and does not provide any global variables which would allow it to be called from an external module or from HTML, so the ready callback is the only entry point.

The wgDonateButton thing does appear to be a bug.

#Comment by Krinkle (talk | contribs)   03:52, 23 February 2012

Alrighty.

by the way, the alias. I meant something like this:

jQuery( document ).ready( function( $ ) {
   $("div.searchresults")
} );

saves a few chars and slight speed improvement by accessing jQuery via $ from the local scope instead of several steps up in the chain to the window property.

#Comment by Tim Starling (talk | contribs)   05:51, 24 February 2012

For the record, on my laptop with Firefox 10, a global variable reference takes about 0.6us longer than a local variable reference, and running jQuery('div.searchresults').find('a[href*="action=edit"]') on a typical search results page takes 250us.

#Comment by Catrope (talk | contribs)   02:44, 28 February 2012

For the record, I did say to initialize to $([]), not [].

Status & tagging log