Changed the way that ResourceLoaderFileModule and mediaWiki.loader work in debug...
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.js
1 /*
2 * JavaScript backwards-compatibility and support
3 */
4
5 // Make calling .indexOf() on an array work on older browsers
6 if ( typeof Array.prototype.indexOf === 'undefined' ) {
7 Array.prototype.indexOf = function( needle ) {
8 for ( var i = 0; i < this.length; i++ ) {
9 if ( this[i] === needle ) {
10 return i;
11 }
12 }
13 return -1;
14 };
15 }
16 // Add array comparison functionality
17 if ( typeof Array.prototype.compare === 'undefined' ) {
18 Array.prototype.compare = function( against ) {
19 if ( this.length != against.length ) {
20 return false;
21 }
22 for ( var i = 0; i < against.length; i++ ) {
23 if ( this[i].compare ) {
24 if ( !this[i].compare( against[i] ) ) {
25 return false;
26 }
27 }
28 if ( this[i] !== against[i] ) {
29 return false;
30 }
31 }
32 return true;
33 };
34 }
35
36 /*
37 * Core MediaWiki JavaScript Library
38 */
39 // Attach to window
40 window.mediaWiki = new ( function( $ ) {
41
42 /* Constants */
43
44 // This will not change until we are 100% ready to turn off legacy globals
45 var LEGACY_GLOBALS = true;
46
47 /* Private Members */
48
49 var that = this;
50
51 /* Prototypes */
52
53 this.prototypes = {
54 /*
55 * An object which allows single and multiple get/set/exists functionality on a list of key / value pairs
56 *
57 * @param {boolean} global whether to get/set/exists values on the window object or a private object
58 * @param {function} parser function to perform extra processing; in the form of function( value, options )
59 * @param {function} fallback function to format default fallback; in the form of function( key )
60 * where value is the data to be parsed and options is additional data passed through to the parser
61 */
62 'map': function( global, parser, fallback ) {
63
64 /* Private Members */
65
66 var that = this;
67 var values = global === true ? window : {};
68
69 /* Public Methods */
70
71 /**
72 * Gets one or more values
73 *
74 * If called with no arguments, all values will be returned. If a parser is in use, no parsing will take
75 * place when calling with no arguments or calling with an array of names.
76 *
77 * @param {mixed} selection string name of value to get, array of string names of values to get, or object
78 * of name/option pairs
79 * @param {object} options optional set of options which are also passed to a parser if in use; only used
80 * when selection is a string
81 * @format options
82 * {
83 * // Value to use if key does not exist
84 * 'fallback': ''
85 * }
86 */
87 this.get = function( selection, options ) {
88 if ( typeof selection === 'object' ) {
89 var results = {};
90 for ( var s in selection ) {
91 if ( selection.hasOwnProperty( s ) ) {
92 if ( typeof s === 'string' ) {
93 return that.get( values[s], selection[s] );
94 } else {
95 return that.get( selection[s] );
96 }
97 }
98 }
99 return results;
100 } else if ( typeof selection === 'string' ) {
101 if ( typeof values[selection] === 'undefined' ) {
102 if ( typeof options === 'object' && 'fallback' in options ) {
103 return options.fallback;
104 } else if ( typeof fallback === 'function' ) {
105 return fallback( selection );
106 } else {
107 return null;
108 }
109 } else {
110 if ( typeof parser === 'function' ) {
111 return parser( values[selection], options );
112 } else {
113 return values[selection];
114 }
115 }
116 } else {
117 return values;
118 }
119 };
120
121 /**
122 * Sets one or multiple configuration values using a key and a value or an object of keys and values
123 *
124 * @param {mixed} key string of name by which value will be made accessible, or object of name/value pairs
125 * @param {mixed} value optional value to set, only in use when key is a string
126 */
127 this.set = function( selection, value ) {
128 if ( typeof selection === 'object' ) {
129 for ( var s in selection ) {
130 values[s] = selection[s];
131 }
132 } else if ( typeof selection === 'string' && typeof value !== 'undefined' ) {
133 values[selection] = value;
134 }
135 };
136
137 /**
138 * Checks if one or multiple configuration fields exist
139 */
140 this.exists = function( selection ) {
141 if ( typeof keys === 'object' ) {
142 for ( var s = 0; s < selection.length; s++ ) {
143 if ( !( selection[s] in values ) ) {
144 return false;
145 }
146 }
147 return true;
148 } else {
149 return selection in values;
150 }
151 };
152 }
153 };
154
155 /* Methods */
156
157 /*
158 * Dummy function which in debug mode can be replaced with a function that does something clever
159 */
160 this.log = function() { };
161
162 /*
163 * List of configuration values
164 *
165 * In legacy mode the values this object wraps will be in the global space
166 */
167 this.config = new this.prototypes.map( LEGACY_GLOBALS );
168
169 /*
170 * Information about the current user
171 */
172 this.user = new ( function() {
173
174 /* Public Members */
175
176 this.options = new that.prototypes.map();
177 } )();
178
179 /*
180 * Basic parser, can be replaced with something more robust
181 */
182 this.parser = function( text, options ) {
183 if ( typeof options === 'object' && typeof options.parameters === 'object' ) {
184 text = text.replace( /\$(\d+)/g, function( str, match ) {
185 var index = parseInt( match, 10 ) - 1;
186 return index in options.parameters ? options.parameters[index] : '$' + match;
187 } );
188 }
189 return text;
190 };
191
192 /*
193 * Localization system
194 */
195 this.msg = new that.prototypes.map( false, this.parser, function( key ) { return '<' + key + '>'; } );
196
197 /*
198 * Client-side module loader which integrates with the MediaWiki ResourceLoader
199 */
200 this.loader = new ( function() {
201
202 /* Private Members */
203
204 var that = this;
205 /*
206 * Mapping of registered modules
207 *
208 * The jquery module is pre-registered, because it must have already been provided for this object to have
209 * been built, and in debug mode jquery would have been provided through a unique loader request, making it
210 * impossible to hold back registration of jquery until after mediawiki.
211 *
212 * Format:
213 * {
214 * 'moduleName': {
215 * 'dependencies': ['required module', 'required module', ...], (or) function() {}
216 * 'state': 'registered', 'loading', 'loaded', 'ready', or 'error'
217 * 'script': function() {},
218 * 'style': 'css code string',
219 * 'messages': { 'key': 'value' },
220 * 'version': ############## (unix timestamp)
221 * }
222 * }
223 */
224 var registry = {};
225 // List of modules which will be loaded as when ready
226 var batch = [];
227 // List of modules to be loaded
228 var queue = [];
229 // List of callback functions waiting for modules to be ready to be called
230 var jobs = [];
231 // Flag indicating that requests should be suspended
232 var suspended = true;
233 // Flag inidicating that document ready has occured
234 var ready = false;
235
236 /* Private Methods */
237
238 /**
239 * Generates an ISO8601 "basic" string from a UNIX timestamp
240 */
241 function formatVersionNumber( timestamp ) {
242 function pad( a, b, c ) {
243 return [a < 10 ? '0' + a : a, b < 10 ? '0' + b : b, c < 10 ? '0' + c : c].join( '' );
244 }
245 var d = new Date()
246 d.setTime( timestamp * 1000 );
247 return [
248 pad( d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate() ), 'T',
249 pad( d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds() ), 'Z'
250 ].join( '' );
251 }
252
253 /**
254 * Recursively resolves dependencies and detects circular references
255 */
256 function recurse( module, resolved, unresolved ) {
257 unresolved[unresolved.length] = module;
258 // Resolves dynamic loader function and replaces it with it's own results
259 if ( typeof registry[module].dependencies === 'function' ) {
260 registry[module].dependencies = registry[module].dependencies();
261 // Ensures the module's dependencies are always in an array
262 if ( typeof registry[module].dependencies !== 'object' ) {
263 registry[module].dependencies = [registry[module].dependencies];
264 }
265 }
266 // Tracks down dependencies
267 for ( var n = 0; n < registry[module].dependencies.length; n++ ) {
268 if ( resolved.indexOf( registry[module].dependencies[n] ) === -1 ) {
269 if ( unresolved.indexOf( registry[module].dependencies[n] ) !== -1 ) {
270 throw new Error(
271 'Circular reference detected: ' + module + ' -> ' + registry[module].dependencies[n]
272 );
273 }
274 recurse( registry[module].dependencies[n], resolved, unresolved );
275 }
276 }
277 resolved[resolved.length] = module;
278 unresolved.splice( unresolved.indexOf( module ), 1 );
279 }
280
281 /**
282 * Gets a list of modules names that a module dependencies in their proper dependency order
283 *
284 * @param mixed string module name or array of string module names
285 * @return list of dependencies
286 * @throws Error if circular reference is detected
287 */
288 function resolve( module, resolved, unresolved ) {
289 // Allow calling with an array of module names
290 if ( typeof module === 'object' ) {
291 var modules = [];
292 for ( var m = 0; m < module.length; m++ ) {
293 var dependencies = resolve( module[m] );
294 for ( var n = 0; n < dependencies.length; n++ ) {
295 modules[modules.length] = dependencies[n];
296 }
297 }
298 return modules;
299 } else if ( typeof module === 'string' ) {
300 // Undefined modules have no dependencies
301 if ( !( module in registry ) ) {
302 return [];
303 }
304 var resolved = [];
305 recurse( module, resolved, [] );
306 return resolved;
307 }
308 throw new Error( 'Invalid module argument: ' + module );
309 };
310
311 /**
312 * Narrows a list of module names down to those matching a specific state. Possible states are 'undefined',
313 * 'registered', 'loading', 'loaded', or 'ready'
314 *
315 * @param mixed string or array of strings of module states to filter by
316 * @param array list of module names to filter (optional, all modules will be used by default)
317 * @return array list of filtered module names
318 */
319 function filter( states, modules ) {
320 // Allow states to be given as a string
321 if ( typeof states === 'string' ) {
322 states = [states];
323 }
324 // If called without a list of modules, build and use a list of all modules
325 var list = [];
326 if ( typeof modules === 'undefined' ) {
327 modules = [];
328 for ( module in registry ) {
329 modules[modules.length] = module;
330 }
331 }
332 // Build a list of modules which are in one of the specified states
333 for ( var s = 0; s < states.length; s++ ) {
334 for ( var m = 0; m < modules.length; m++ ) {
335 if (
336 ( states[s] == 'undefined' && typeof registry[modules[m]] === 'undefined' ) ||
337 ( typeof registry[modules[m]] === 'object' && registry[modules[m]].state === states[s] )
338 ) {
339 list[list.length] = modules[m];
340 }
341 }
342 }
343 return list;
344 }
345
346 /**
347 * Executes a loaded module, making it ready to use
348 *
349 * @param string module name to execute
350 */
351 function execute( module ) {
352 if ( typeof registry[module] === 'undefined' ) {
353 throw new Error( 'Module has not been registered yet: ' + module );
354 } else if ( registry[module].state === 'registered' ) {
355 throw new Error( 'Module has not been requested from the server yet: ' + module );
356 } else if ( registry[module].state === 'loading' ) {
357 throw new Error( 'Module has not completed loading yet: ' + module );
358 } else if ( registry[module].state === 'ready' ) {
359 throw new Error( 'Module has already been loaded: ' + module );
360 }
361 // Add style sheet to document
362 if ( typeof registry[module].style === 'string' && registry[module].style.length ) {
363 $( 'head' ).append( '<style type="text/css">' + registry[module].style + '</style>' );
364 } else if ( typeof registry[module].style === 'object' && !( registry[module].style instanceof Array ) ) {
365 for ( var media in registry[module].style ) {
366 $( 'head' ).append(
367 '<style type="text/css" media="' + media + '">' + registry[module].style[media] + '</style>'
368 );
369 }
370 }
371 // Add localizations to message system
372 if ( typeof registry[module].messages === 'object' ) {
373 mediaWiki.msg.set( registry[module].messages );
374 }
375 // Execute script
376 try {
377 registry[module].script();
378 registry[module].state = 'ready';
379 // Run jobs who's dependencies have just been met
380 for ( var j = 0; j < jobs.length; j++ ) {
381 if ( filter( 'ready', jobs[j].dependencies ).compare( jobs[j].dependencies ) ) {
382 if ( typeof jobs[j].ready === 'function' ) {
383 jobs[j].ready();
384 }
385 jobs.splice( j, 1 );
386 j--;
387 }
388 }
389 // Execute modules who's dependencies have just been met
390 for ( r in registry ) {
391 if ( registry[r].state == 'loaded' ) {
392 if ( filter( ['ready'], registry[r].dependencies ).compare( registry[r].dependencies ) ) {
393 execute( r );
394 }
395 }
396 }
397 } catch ( e ) {
398 mediaWiki.log( 'Exception thrown by ' + module + ': ' + e.message );
399 mediaWiki.log( e );
400 registry[module].state = 'error';
401 // Run error callbacks of jobs affected by this condition
402 for ( var j = 0; j < jobs.length; j++ ) {
403 if ( jobs[j].dependencies.indexOf( module ) !== -1 ) {
404 if ( typeof jobs[j].error === 'function' ) {
405 jobs[j].error();
406 }
407 jobs.splice( j, 1 );
408 j--;
409 }
410 }
411 }
412 }
413
414 /**
415 * Adds a dependencies to the queue with optional callbacks to be run when the dependencies are ready or fail
416 *
417 * @param mixed string moulde name or array of string module names
418 * @param function ready callback to execute when all dependencies are ready
419 * @param function error callback to execute when any dependency fails
420 */
421 function request( dependencies, ready, error ) {
422 // Allow calling by single module name
423 if ( typeof dependencies === 'string' ) {
424 dependencies = [dependencies];
425 if ( dependencies[0] in registry ) {
426 for ( var n = 0; n < registry[dependencies[0]].dependencies.length; n++ ) {
427 dependencies[dependencies.length] = registry[dependencies[0]].dependencies[n];
428 }
429 }
430 }
431 // Add ready and error callbacks if they were given
432 if ( arguments.length > 1 ) {
433 jobs[jobs.length] = {
434 'dependencies': filter( ['undefined', 'registered', 'loading', 'loaded'], dependencies ),
435 'ready': ready,
436 'error': error
437 };
438 }
439 // Queue up any dependencies that are undefined or registered
440 dependencies = filter( ['undefined', 'registered'], dependencies );
441 for ( var n = 0; n < dependencies.length; n++ ) {
442 if ( queue.indexOf( dependencies[n] ) === -1 ) {
443 queue[queue.length] = dependencies[n];
444 }
445 }
446 // Work the queue
447 that.work();
448 }
449
450 function sortQuery(o) {
451 var sorted = {}, key, a = [];
452 for ( key in o ) {
453 if ( o.hasOwnProperty( key ) ) {
454 a.push( key );
455 }
456 }
457 a.sort();
458 for ( key = 0; key < a.length; key++ ) {
459 sorted[a[key]] = o[a[key]];
460 }
461 return sorted;
462 }
463
464 /* Public Methods */
465
466 /**
467 * Requests dependencies from server, loading and executing when things when ready.
468 */
469 this.work = function() {
470 // Appends a list of modules to the batch
471 for ( var q = 0; q < queue.length; q++ ) {
472 // Only request modules which are undefined or registered
473 if ( !( queue[q] in registry ) || registry[queue[q]].state == 'registered' ) {
474 // Prevent duplicate entries
475 if ( batch.indexOf( queue[q] ) === -1 ) {
476 batch[batch.length] = queue[q];
477 // Mark registered modules as loading
478 if ( queue[q] in registry ) {
479 registry[queue[q]].state = 'loading';
480 }
481 }
482 }
483 }
484 // Clean up the queue
485 queue = [];
486 // After document ready, handle the batch
487 if ( !suspended && batch.length ) {
488 // Always order modules alphabetically to help reduce cache misses for otherwise identical content
489 batch.sort();
490 // Build a list of request parameters
491 var base = {
492 'skin': mediaWiki.config.get( 'skin' ),
493 'lang': mediaWiki.config.get( 'wgUserLanguage' ),
494 'debug': mediaWiki.config.get( 'debug' )
495 };
496 // Extend request parameters with a list of modules in the batch
497 var requests = [];
498 // Split into groups
499 var groups = {};
500 for ( var b = 0; b < batch.length; b++ ) {
501 var group = registry[batch[b]].group;
502 if ( !( group in groups ) ) {
503 groups[group] = [];
504 }
505 groups[group][groups[group].length] = batch[b];
506 }
507 for ( var group in groups ) {
508 // Calculate the highest timestamp
509 var version = 0;
510 for ( var g = 0; g < groups[group].length; g++ ) {
511 if ( registry[groups[group][g]].version > version ) {
512 version = registry[groups[group][g]].version;
513 }
514 }
515 requests[requests.length] = $.extend(
516 { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base
517 );
518 }
519 // Clear the batch - this MUST happen before we append the script element to the body or it's
520 // possible that the script will be locally cached, instantly load, and work the batch again,
521 // all before we've cleared it causing each request to include modules which are already loaded
522 batch = [];
523 // Asynchronously append a script tag to the end of the body
524 function request() {
525 var html = '';
526 for ( var r = 0; r < requests.length; r++ ) {
527 requests[r] = sortQuery( requests[r] );
528 // Build out the HTML
529 var src = mediaWiki.config.get( 'wgLoadScript' ) + '?' + $.param( requests[r] );
530 html += '<script type="text/javascript" src="' + src + '"></script>';
531 }
532 return html;
533 }
534 // Load asynchronously after doumument ready
535 if ( ready ) {
536 setTimeout( function() { $( 'body' ).append( request() ); }, 0 )
537 } else {
538 document.write( request() );
539 }
540 }
541 };
542
543 /**
544 * Registers a module, letting the system know about it and it's dependencies. loader.js files contain calls
545 * to this function.
546 */
547 this.register = function( module, version, dependencies, group ) {
548 // Allow multiple registration
549 if ( typeof module === 'object' ) {
550 for ( var m = 0; m < module.length; m++ ) {
551 if ( typeof module[m] === 'string' ) {
552 that.register( module[m] );
553 } else if ( typeof module[m] === 'object' ) {
554 that.register.apply( that, module[m] );
555 }
556 }
557 return;
558 }
559 // Validate input
560 if ( typeof module !== 'string' ) {
561 throw new Error( 'module must be a string, not a ' + typeof module );
562 }
563 if ( typeof registry[module] !== 'undefined' ) {
564 throw new Error( 'module already implemeneted: ' + module );
565 }
566 // List the module as registered
567 registry[module] = {
568 'state': 'registered',
569 'group': typeof group === 'string' ? group : null,
570 'dependencies': [],
571 'version': typeof version !== 'undefined' ? parseInt( version ) : 0
572 };
573 if ( typeof dependencies === 'string' ) {
574 // Allow dependencies to be given as a single module name
575 registry[module].dependencies = [dependencies];
576 } else if ( typeof dependencies === 'object' || typeof dependencies === 'function' ) {
577 // Allow dependencies to be given as an array of module names or a function which returns an array
578 registry[module].dependencies = dependencies;
579 }
580 };
581
582 /**
583 * Implements a module, giving the system a course of action to take upon loading. Results of a request for
584 * one or more modules contain calls to this function.
585 */
586 this.implement = function( module, script, style, localization ) {
587 // Automaically register module
588 if ( typeof registry[module] === 'undefined' ) {
589 that.register( module );
590 }
591 // Validate input
592 if ( typeof script !== 'function' ) {
593 throw new Error( 'script must be a function, not a ' + typeof script );
594 }
595 if ( typeof style !== 'undefined' && typeof style !== 'string' && typeof style !== 'object' ) {
596 throw new Error( 'style must be a string or object, not a ' + typeof style );
597 }
598 if ( typeof localization !== 'undefined' && typeof localization !== 'object' ) {
599 throw new Error( 'localization must be an object, not a ' + typeof localization );
600 }
601 if ( typeof registry[module] !== 'undefined' && typeof registry[module].script !== 'undefined' ) {
602 throw new Error( 'module already implemeneted: ' + module );
603 }
604 // Mark module as loaded
605 registry[module].state = 'loaded';
606 // Attach components
607 registry[module].script = script;
608 if ( typeof style === 'string' || typeof style === 'object' && !( style instanceof Array ) ) {
609 registry[module].style = style;
610 }
611 if ( typeof localization === 'object' ) {
612 registry[module].messages = localization;
613 }
614 // Execute or queue callback
615 if ( filter( ['ready'], registry[module].dependencies ).compare( registry[module].dependencies ) ) {
616 execute( module );
617 } else {
618 request( module );
619 }
620 };
621
622 /**
623 * Executes a function as soon as one or more required modules are ready
624 *
625 * @param mixed string or array of strings of modules names the callback dependencies to be ready before
626 * executing
627 * @param function callback to execute when all dependencies are ready (optional)
628 * @param function callback to execute when if dependencies have a errors (optional)
629 */
630 this.using = function( dependencies, ready, error ) {
631 // Validate input
632 if ( typeof dependencies !== 'object' && typeof dependencies !== 'string' ) {
633 throw new Error( 'dependencies must be a string or an array, not a ' + typeof dependencies )
634 }
635 // Allow calling with a single dependency as a string
636 if ( typeof dependencies === 'string' ) {
637 dependencies = [dependencies];
638 }
639 // Resolve entire dependency map
640 dependencies = resolve( dependencies );
641 // If all dependencies are met, execute ready immediately
642 if ( filter( ['ready'], dependencies ).compare( dependencies ) ) {
643 if ( typeof ready === 'function' ) {
644 ready();
645 }
646 }
647 // If any dependencies have errors execute error immediately
648 else if ( filter( ['error'], dependencies ).length ) {
649 if ( typeof error === 'function' ) {
650 error();
651 }
652 }
653 // Since some dependencies are not yet ready, queue up a request
654 else {
655 request( dependencies, ready, error );
656 }
657 };
658
659 /**
660 * Loads an external script or one or more modules for future use
661 *
662 * @param {mixed} modules either the name of a module, array of modules, or a URL of an external script or style
663 * @param {string} type mime-type to use if calling with a URL of an external script or style; acceptable values
664 * are "text/css" and "text/javascript"; if no type is provided, text/javascript is assumed
665 */
666 this.load = function( modules, type ) {
667 // Validate input
668 if ( typeof modules !== 'object' && typeof modules !== 'string' ) {
669 throw new Error( 'dependencies must be a string or an array, not a ' + typeof dependencies )
670 }
671 // Allow calling with an external script or single dependency as a string
672 if ( typeof modules === 'string' ) {
673 // Support adding arbitrary external scripts
674 if ( modules.substr( 0, 7 ) == 'http://' || modules.substr( 0, 8 ) == 'https://' ) {
675 if ( type === 'text/css' ) {
676 setTimeout( function() {
677 $( 'head' ).append( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules );
678 }, 0 );
679 return true;
680 } else if ( type === 'text/javascript' || typeof type === 'undefined' ) {
681 setTimeout( function() {
682 $( 'body' ).append( '<script type="text/javascript"></script>' ).attr( 'src', modules )
683 }, 0 );
684 return true;
685 }
686 // Unknown type
687 return false;
688 }
689 // Called with single module
690 modules = [modules];
691 }
692 // Resolve entire dependency map
693 modules = resolve( modules );
694 // If all modules are ready, nothing dependency be done
695 if ( filter( ['ready'], modules ).compare( modules ) ) {
696 return true;
697 }
698 // If any modules have errors return false
699 else if ( filter( ['error'], modules ).length ) {
700 return false;
701 }
702 // Since some modules are not yet ready, queue up a request
703 else {
704 request( modules );
705 return true;
706 }
707 };
708
709 /**
710 * Flushes the request queue and begin executing load requests on demand
711 */
712 this.go = function() {
713 suspended = false;
714 that.work();
715 };
716
717 /**
718 * Changes the state of a module
719 *
720 * @param mixed module string module name or object of module name/state pairs
721 * @param string state string state name
722 */
723 this.state = function( module, state ) {
724 if ( typeof module === 'object' ) {
725 for ( var m in module ) {
726 that.state( m, module[m] );
727 }
728 return;
729 }
730 if ( !( module in registry ) ) {
731 that.register( module );
732 }
733 registry[module].state = state;
734 };
735
736 /**
737 * Gets the version of a module
738 *
739 * @param string module name of module to get version for
740 */
741 this.version = function( module ) {
742 if ( module in registry && 'version' in registry[module] ) {
743 return formatVersionNumber( registry[module].version );
744 }
745 return null;
746 }
747
748 /* Cache document ready status */
749
750 $(document).ready( function() { ready = true; } );
751 } )();
752
753 /* Extension points */
754
755 this.util = {};
756 this.legacy = {};
757
758 } )( jQuery );
759
760 /* Auto-register from pre-loaded startup scripts */
761
762 if ( typeof startUp === 'function' ) {
763 startUp();
764 delete startUp;
765 }
766
767 // Alias $j to jQuery for backwards compatibility
768 window.$j = jQuery;