Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -113,8 +113,6 @@ |
114 | 114 | // Because these are keyed by module, in the case that more than one module asked for the same script only the |
115 | 115 | // first will end up being registered - the client loader can't handle multiple modules per implementation yet, |
116 | 116 | // so this is fine, but causes silent failure it strange abusive cases |
117 | | - $this->scripts = array_unique( $this->scripts ); |
118 | | - $this->styles = array_unique( $this->styles ); |
119 | 117 | $this->loadedModules = array_unique( $this->loadedModules ); |
120 | 118 | $retval = ''; |
121 | 119 | |
Index: branches/resourceloader/phase3/resources/core/mw.js |
— | — | @@ -2,7 +2,21 @@ |
3 | 3 | * Core MediaWiki JavaScript Library |
4 | 4 | */ |
5 | 5 | |
6 | | -window.mw = { |
| 6 | +// Make calling .indexOf() on an array work on older browsers |
| 7 | +if ( typeof Array.prototype.indexOf === 'undefined' ) { |
| 8 | + Array.prototype.indexOf = function( needle ) { |
| 9 | + for ( var i = 0; i < this.length; i++ ) { |
| 10 | + if ( this[i] === needle ) { |
| 11 | + return i; |
| 12 | + } |
| 13 | + } |
| 14 | + return -1; |
| 15 | + }; |
| 16 | +} |
| 17 | + |
| 18 | +// Extend window.mw rather than overriding it. This is a temporary fix designed to prevent |
| 19 | +// stuff from blowing up when usability.js (setting mw.usability) is run before this file. |
| 20 | +window.mw = $.extend( typeof window.mw === 'undefined' ? {} : window.mw, { |
7 | 21 | |
8 | 22 | /* Public Members */ |
9 | 23 | |
— | — | @@ -67,7 +81,7 @@ |
68 | 82 | this.buildQueryString = function( parameters ) { |
69 | 83 | if ( typeof parameters === 'object' ) { |
70 | 84 | var parts = []; |
71 | | - for ( p in parameters ) { |
| 85 | + for ( var p in parameters ) { |
72 | 86 | parts[parts.length] = that.urlencode( p ) + '=' + that.urlencode( parameters[p] ); |
73 | 87 | } |
74 | 88 | return parts.join( '&' ); |
— | — | @@ -93,7 +107,7 @@ |
94 | 108 | */ |
95 | 109 | this.set = function( keys, value ) { |
96 | 110 | if ( typeof keys === 'object' ) { |
97 | | - for ( key in keys ) { |
| 111 | + for ( var key in keys ) { |
98 | 112 | values[key] = keys[key]; |
99 | 113 | } |
100 | 114 | } else if ( typeof keys === 'string' && typeof value !== 'undefined' ) { |
— | — | @@ -106,7 +120,7 @@ |
107 | 121 | this.get = function( keys, fallback ) { |
108 | 122 | if ( typeof keys === 'object' ) { |
109 | 123 | var result = {}; |
110 | | - for ( k in keys ) { |
| 124 | + for ( var k = 0; k < keys.length; k++ ) { |
111 | 125 | if ( typeof values[keys[k]] !== 'undefined' ) { |
112 | 126 | result[keys[k]] = values[keys[k]]; |
113 | 127 | } |
— | — | @@ -134,7 +148,7 @@ |
135 | 149 | |
136 | 150 | this.set = function( keys, value ) { |
137 | 151 | if ( typeof keys === 'object' ) { |
138 | | - for ( key in keys ) { |
| 152 | + for ( var key in keys ) { |
139 | 153 | messages[key] = keys[key]; |
140 | 154 | } |
141 | 155 | } else if ( typeof keys === 'string' && typeof value !== 'undefined' ) { |
— | — | @@ -181,13 +195,6 @@ |
182 | 196 | // True after document ready occurs |
183 | 197 | var ready = false; |
184 | 198 | |
185 | | - /* Event Bindings */ |
186 | | - |
187 | | - $( document ).ready( function() { |
188 | | - ready = true; |
189 | | - that.work(); |
190 | | - } ); |
191 | | - |
192 | 199 | /* Private Functions */ |
193 | 200 | |
194 | 201 | /** |
— | — | @@ -196,7 +203,7 @@ |
197 | 204 | function pending( requirements ) { |
198 | 205 | // Collect the names of pending modules |
199 | 206 | var list = []; |
200 | | - for ( r in requirements ) { |
| 207 | + for ( var r = 0; r < requirements.length; r++ ) { |
201 | 208 | if ( |
202 | 209 | typeof registry[requirements[r]] === 'undefined' || |
203 | 210 | typeof registry[requirements[r]].state === 'undefined' || |
— | — | @@ -235,8 +242,8 @@ |
236 | 243 | * Processes the queue, loading and executing when things when ready. |
237 | 244 | */ |
238 | 245 | this.work = function() { |
239 | | - for ( q in queue ) { |
240 | | - for ( p in queue[q].pending ) { |
| 246 | + for ( var q = 0; q < queue.length; q++ ) { |
| 247 | + for ( var p = 0; p < queue[q].pending.length; p++ ) { |
241 | 248 | var requirement = queue[q].pending[p]; |
242 | 249 | // If it's not in the registry yet, we're certainly not ready to execute |
243 | 250 | if ( |
— | — | @@ -259,13 +266,15 @@ |
260 | 267 | break; |
261 | 268 | case 'ready': |
262 | 269 | // This doesn't belong in the queue item's pending list |
263 | | - queue[q].pending.splice( p ); |
| 270 | + queue[q].pending.splice( p, 1 ); |
| 271 | + // Correct the array index |
| 272 | + p--; |
264 | 273 | break; |
265 | 274 | } |
266 | 275 | } |
267 | 276 | } |
268 | 277 | // If all pending requirements have been satisfied, we're ready to execute the callback |
269 | | - if ( typeof queue[q].pending.length == 0 ) { |
| 278 | + if ( queue[q].pending.length == 0 ) { |
270 | 279 | queue[q].callback(); |
271 | 280 | // Clean up the queue |
272 | 281 | queue.splice( q, 1 ); |
— | — | @@ -381,5 +390,12 @@ |
382 | 391 | that.work(); |
383 | 392 | } |
384 | 393 | }; |
| 394 | + |
| 395 | + /* Event Bindings */ |
| 396 | + |
| 397 | + $( document ).ready( function() { |
| 398 | + ready = true; |
| 399 | + that.work(); |
| 400 | + } ); |
385 | 401 | } )() |
386 | | -}; |
| 402 | +} ); |