r76074 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76073‎ | r76074 | r76075 >
Date:06:53, 5 November 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
* Break long lines
* For readability, rewrote ResourceLoaderFileModule::readScriptFiles() to use a loop instead of an excessively cute nested array_map() construction.
* In ResourceLoaderFileModule, check file_get_contents() result for errors. Golden rule of error checking: always check fopen(). Every call to fopen will fail some day for some user.
* In mediaWiki.loader.filter(): broke up a complex multi-line conditional into multiple commented if statements, for readability.
* Possessive "its" has no apostrophe.
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js (modified) (history)
  • /trunk/phase3/resources/mediawiki.language/mediawiki.language.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)
  • /trunk/phase3/resources/startup.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -96,9 +96,12 @@
9797 /**
9898 * Constructs a new module from an options array.
9999 *
100 - * @param {array} $options Options array. If not given or empty, an empty module will be constructed
101 - * @param {string} $localBasePath base path to prepend to all local paths in $options. Defaults to $IP
102 - * @param {string} $remoteBasePath base path to prepend to all remote paths in $options. Defaults to $wgScriptPath
 100+ * @param {array} $options Options array. If not given or empty, an empty
 101+ * module will be constructed
 102+ * @param {string} $localBasePath base path to prepend to all local paths
 103+ * in $options. Defaults to $IP
 104+ * @param {string} $remoteBasePath base path to prepend to all remote paths
 105+ * in $options. Defaults to $wgScriptPath
103106 *
104107 * @format $options
105108 * array(
@@ -130,7 +133,9 @@
131134 * 'group' => [group name string],
132135 * )
133136 */
134 - public function __construct( $options = array(), $localBasePath = null, $remoteBasePath = null ) {
 137+ public function __construct( $options = array(), $localBasePath = null,
 138+ $remoteBasePath = null )
 139+ {
135140 global $IP, $wgScriptPath;
136141 $this->localBasePath = $localBasePath === null ? $IP : $localBasePath;
137142 $this->remoteBasePath = $remoteBasePath === null ? $wgScriptPath : $remoteBasePath;
@@ -149,13 +154,15 @@
150155 case 'skinStyles':
151156 if ( !is_array( $option ) ) {
152157 throw new MWException(
153 - "Invalid collated file path list error. '$option' given, array expected."
 158+ "Invalid collated file path list error. " .
 159+ "'$option' given, array expected."
154160 );
155161 }
156162 foreach ( $option as $key => $value ) {
157163 if ( !is_string( $key ) ) {
158164 throw new MWException(
159 - "Invalid collated file path list key error. '$key' given, string expected."
 165+ "Invalid collated file path list key error. " .
 166+ "'$key' given, string expected."
160167 );
161168 }
162169 $this->{$member}[$key] = (array) $value;
@@ -227,7 +234,8 @@
228235 public function getStyles( ResourceLoaderContext $context ) {
229236 // Merge general styles and skin specific styles, retaining media type collation
230237 $styles = $this->readStyleFiles( $this->styles );
231 - $skinStyles = $this->readStyleFiles( self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ) );
 238+ $skinStyles = $this->readStyleFiles(
 239+ self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ) );
232240
233241 foreach ( $skinStyles as $media => $style ) {
234242 if ( isset( $styles[$media] ) ) {
@@ -282,11 +290,14 @@
283291 /**
284292 * Get the last modified timestamp of this module.
285293 *
286 - * Last modified timestamps are calculated from the highest last modified timestamp of this module's constituent
287 - * files as well as the files it depends on. This function is context-sensitive, only performing calculations on
288 - * files relevant to the given language, skin and debug mode.
 294+ * Last modified timestamps are calculated from the highest last modified
 295+ * timestamp of this module's constituent files as well as the files it
 296+ * depends on. This function is context-sensitive, only performing
 297+ * calculations on files relevant to the given language, skin and debug
 298+ * mode.
289299 *
290 - * @param {ResourceLoaderContext} $context Context in which to calculate the modified time
 300+ * @param {ResourceLoaderContext} $context Context in which to calculate
 301+ * the modified time
291302 * @return {integer} UNIX timestamp
292303 * @see {ResourceLoaderModule::getFileDependencies}
293304 */
@@ -304,7 +315,9 @@
305316 $files = array_merge( $files, $styleFiles );
306317 }
307318 $skinFiles = self::tryForKey(
308 - self::collateFilePathListByOption( $this->skinStyles, 'media', 'all' ), $context->getSkin(), 'default'
 319+ self::collateFilePathListByOption( $this->skinStyles, 'media', 'all' ),
 320+ $context->getSkin(),
 321+ 'default'
309322 );
310323 foreach ( $skinFiles as $styleFiles ) {
311324 $files = array_merge( $files, $styleFiles );
@@ -323,7 +336,8 @@
324337 // File deps need to be treated separately because they're already prefixed
325338 $files = array_merge( $files, $this->getFileDependencies( $context->getSkin() ) );
326339
327 - // If a module is nothing but a list of dependencies, we need to avoid giving max() an empty array
 340+ // If a module is nothing but a list of dependencies, we need to avoid
 341+ // giving max() an empty array
328342 if ( count( $files ) === 0 ) {
329343 return $this->modifiedTime[$context->getHash()] = 1;
330344 }
@@ -331,7 +345,9 @@
332346 wfProfileIn( __METHOD__.'-filemtime' );
333347 $filesMtime = max( array_map( 'filemtime', $files ) );
334348 wfProfileOut( __METHOD__.'-filemtime' );
335 - $this->modifiedTime[$context->getHash()] = max( $filesMtime, $this->getMsgBlobMtime( $context->getLanguage() ) );
 349+ $this->modifiedTime[$context->getHash()] = max(
 350+ $filesMtime,
 351+ $this->getMsgBlobMtime( $context->getLanguage() ) );
336352 wfProfileOut( __METHOD__ );
337353 return $this->modifiedTime[$context->getHash()];
338354 }
@@ -349,7 +365,8 @@
350366 /**
351367 * Collates file paths by option (where provided).
352368 *
353 - * @param {array} $list List of file paths in any combination of index/path or path/options pairs
 369+ * @param {array} $list List of file paths in any combination of index/path
 370+ * or path/options pairs
354371 * @return {array} List of file paths, collated by $option
355372 */
356373 protected static function collateFilePathListByOption( array $list, $option, $default ) {
@@ -379,12 +396,16 @@
380397 * @param {array} $list List of lists to select from
381398 * @param {string} $key Key to look for in $map
382399 * @param {string} $fallback Key to look for in $list if $key doesn't exist
383 - * @return {array} List of elements from $map which matched $key or $fallback, or an empty list in case of no match
 400+ * @return {array} List of elements from $map which matched $key or $fallback,
 401+ * or an empty list in case of no match
384402 */
385403 protected static function tryForKey( array $list, $key, $fallback = null ) {
386404 if ( isset( $list[$key] ) && is_array( $list[$key] ) ) {
387405 return $list[$key];
388 - } else if ( is_string( $fallback ) && isset( $list[$fallback] ) && is_array( $list[$fallback] ) ) {
 406+ } else if ( is_string( $fallback )
 407+ && isset( $list[$fallback] )
 408+ && is_array( $list[$fallback] ) )
 409+ {
389410 return $list[$fallback];
390411 }
391412 return array();
@@ -400,14 +421,24 @@
401422 if ( empty( $scripts ) ) {
402423 return '';
403424 }
404 - return implode( "\n", array_map( 'file_get_contents', array_map( array( $this, 'getLocalPath' ), array_unique( $scripts ) ) ) );
 425+ $js = '';
 426+ foreach ( array_unique( $scripts ) as $fileName ) {
 427+ $localPath = $this->getLocalPath( $fileName );
 428+ $contents = file_get_contents( $localPath );
 429+ if ( $contents === false ) {
 430+ throw new MWException( __METHOD__.": script file not found: \"$localPath\"" );
 431+ }
 432+ $js .= $contents . "\n";
 433+ }
 434+ return $js;
405435 }
406436
407437 /**
408438 * Gets the contents of a list of CSS files.
409439 *
410440 * @param {array} $styles List of file paths to styles to read, remap and concetenate
411 - * @return {array} List of concatenated and remapped CSS data from $styles, keyed by media type
 441+ * @return {array} List of concatenated and remapped CSS data from $styles,
 442+ * keyed by media type
412443 */
413444 protected function readStyleFiles( array $styles ) {
414445 if ( empty( $styles ) ) {
@@ -431,11 +462,17 @@
432463 * @return {string} CSS data in script file
433464 */
434465 protected function readStyleFile( $path ) {
435 - $style = file_get_contents( $this->getLocalPath( $path ) );
 466+ $localPath = $this->getLocalPath( $path );
 467+ $style = file_get_contents( $localPath );
 468+ if ( $style === false ) {
 469+ throw new MWException( __METHOD__.": style file not found: \"$localPath\"" );
 470+ }
436471 $dir = $this->getLocalPath( dirname( $path ) );
437472 $remoteDir = $this->getRemotePath( dirname( $path ) );
438473 // Get and register local file references
439 - $this->localFileRefs = array_merge( $this->localFileRefs, CSSMin::getLocalFileReferences( $style, $dir ) );
 474+ $this->localFileRefs = array_merge(
 475+ $this->localFileRefs,
 476+ CSSMin::getLocalFileReferences( $style, $dir ) );
440477 return CSSMin::remap(
441478 $style, $dir, $remoteDir, true
442479 );
Index: trunk/phase3/includes/resourceloader/ResourceLoaderWikiModule.php
@@ -25,8 +25,9 @@
2626 /**
2727 * Abstraction for resource loader modules which pull from wiki pages
2828 *
29 - * This can only be used for wiki pages in the MediaWiki and User namespaces, because of it's dependence on the
30 - * functionality of Title::isValidCssJsSubpage.
 29+ * This can only be used for wiki pages in the MediaWiki and User namespaces,
 30+ * because of it's dependence on the functionality of
 31+ * Title::isValidCssJsSubpage.
3132 */
3233 abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
3334
Index: trunk/phase3/resources/Resources.php
@@ -25,7 +25,9 @@
2626
2727 /* jQuery */
2828
29 - 'jquery' => new ResourceLoaderFileModule( array( 'scripts' => 'resources/jquery/jquery.js', 'debugRaw' => false ) ),
 29+ 'jquery' => new ResourceLoaderFileModule(
 30+ array( 'scripts' => 'resources/jquery/jquery.js', 'debugRaw' => false )
 31+ ),
3032
3133 /* jQuery Plugins */
3234
@@ -109,7 +111,9 @@
110112 ) ),
111113 'jquery.ui.droppable' => new ResourceLoaderFileModule( array(
112114 'scripts' => 'resources/jquery.ui/jquery.ui.droppable.js',
113 - 'dependencies' => array( 'jquery.ui.core', 'jquery.ui.mouse', 'jquery.ui.widget', 'jquery.ui.draggable' ),
 115+ 'dependencies' => array(
 116+ 'jquery.ui.core', 'jquery.ui.mouse', 'jquery.ui.widget', 'jquery.ui.draggable'
 117+ ),
114118 ) ),
115119 'jquery.ui.resizable' => new ResourceLoaderFileModule( array(
116120 'scripts' => 'resources/jquery.ui/jquery.ui.resizable.js',
@@ -393,7 +397,10 @@
394398
395399 'mediawiki.legacy.ajax' => new ResourceLoaderFileModule( array(
396400 'scripts' => 'skins/common/ajax.js',
397 - 'messages' => array( 'watch', 'unwatch', 'watching', 'unwatching', 'tooltip-ca-watch', 'tooltip-ca-unwatch' ),
 401+ 'messages' => array(
 402+ 'watch', 'unwatch', 'watching', 'unwatching', 'tooltip-ca-watch',
 403+ 'tooltip-ca-unwatch'
 404+ ),
398405 'dependencies' => 'mediawiki.legacy.wikibits',
399406 ) ),
400407 'mediawiki.legacy.ajaxwatch' => new ResourceLoaderFileModule( array(
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -60,9 +60,11 @@
6161 /* Prototypes */
6262
6363 /**
64 - * An object which allows single and multiple get/set/exists functionality on a list of key / value pairs.
 64+ * An object which allows single and multiple get/set/exists functionality
 65+ * on a list of key / value pairs.
6566 *
66 - * @param {boolean} global Whether to get/set/exists values on the window object or a private object
 67+ * @param {boolean} global Whether to get/set/exists values on the window
 68+ * object or a private object
6769 */
6870 function Map( global ) {
6971 this.values = ( global === true ) ? window : {};
@@ -216,7 +218,8 @@
217219 /* Public Members */
218220
219221 /*
220 - * Dummy function which in debug mode can be replaced with a function that does something clever
 222+ * Dummy function which in debug mode can be replaced with a function that
 223+ * does something clever
221224 */
222225 this.log = function() { };
223226
@@ -278,9 +281,11 @@
279282 /**
280283 * Mapping of registered modules
281284 *
282 - * The jquery module is pre-registered, because it must have already been provided for this object to have
283 - * been built, and in debug mode jquery would have been provided through a unique loader request, making it
284 - * impossible to hold back registration of jquery until after mediawiki.
 285+ * The jquery module is pre-registered, because it must have already
 286+ * been provided for this object to have been built, and in debug mode
 287+ * jquery would have been provided through a unique loader request,
 288+ * making it impossible to hold back registration of jquery until after
 289+ * mediawiki.
285290 *
286291 * Format:
287292 * {
@@ -347,7 +352,7 @@
348353 if ( typeof registry[module] === 'undefined' ) {
349354 throw new Error( 'Unknown dependency: ' + module );
350355 }
351 - // Resolves dynamic loader function and replaces it with it's own results
 356+ // Resolves dynamic loader function and replaces it with its own results
352357 if ( typeof registry[module].dependencies === 'function' ) {
353358 registry[module].dependencies = registry[module].dependencies();
354359 // Ensures the module's dependencies are always in an array
@@ -360,7 +365,8 @@
361366 if ( $.inArray( registry[module].dependencies[n], resolved ) === -1 ) {
362367 if ( $.inArray( registry[module].dependencies[n], unresolved ) !== -1 ) {
363368 throw new Error(
364 - 'Circular reference detected: ' + module + ' -> ' + registry[module].dependencies[n]
 369+ 'Circular reference detected: ' + module +
 370+ ' -> ' + registry[module].dependencies[n]
365371 );
366372 }
367373 recurse( registry[module].dependencies[n], resolved, unresolved );
@@ -371,7 +377,7 @@
372378 }
373379
374380 /**
375 - * Gets a list of modules names that a module dependencies in their proper dependency order
 381+ * Gets a list of module names that a module depends on in their proper dependency order
376382 *
377383 * @param mixed string module name or array of string module names
378384 * @return list of dependencies
@@ -401,11 +407,13 @@
402408 };
403409
404410 /**
405 - * Narrows a list of module names down to those matching a specific state. Possible states are 'undefined',
406 - * 'registered', 'loading', 'loaded', or 'ready'
 411+ * Narrows a list of module names down to those matching a specific
 412+ * state. Possible states are 'undefined', 'registered', 'loading',
 413+ * 'loaded', or 'ready'
407414 *
408415 * @param mixed string or array of strings of module states to filter by
409 - * @param array list of module names to filter (optional, all modules will be used by default)
 416+ * @param array list of module names to filter (optional, all modules
 417+ * will be used by default)
410418 * @return array list of filtered module names
411419 */
412420 function filter( states, modules ) {
@@ -424,17 +432,26 @@
425433 // Build a list of modules which are in one of the specified states
426434 for ( var s = 0; s < states.length; s++ ) {
427435 for ( var m = 0; m < modules.length; m++ ) {
428 - if (
429 - ( states[s] == 'undefined' && typeof registry[modules[m]] === 'undefined' ) ||
430 - ( typeof registry[modules[m]] === 'object' && registry[modules[m]].state === states[s] )
431 - ) {
432 - list[list.length] = modules[m];
 436+ if ( typeof registry[modules[m]] === 'undefined' ) {
 437+ // Module does not exist
 438+ if ( states[s] == 'undefined' ) {
 439+ // OK, undefined
 440+ list[list.length] = modules[m];
 441+ }
 442+ } else {
 443+ // Module exists, check state
 444+ if ( registry[modules[m]].state === states[s] ) {
 445+ // OK, correct state
 446+ list[list.length] = modules[m];
 447+ }
433448 }
434449 }
435450 }
436451 return list;
437452 }
438453
 454+ this.filter_ = filter;
 455+
439456 /**
440457 * Executes a loaded module, making it ready to use
441458 *
@@ -452,11 +469,16 @@
453470 }
454471 // Add style sheet to document
455472 if ( typeof registry[module].style === 'string' && registry[module].style.length ) {
456 - $( 'head' ).append( '<style type="text/css">' + registry[module].style + '</style>' );
457 - } else if ( typeof registry[module].style === 'object' && !( registry[module].style instanceof Array ) ) {
 473+ $( 'head' )
 474+ .append( '<style type="text/css">' + registry[module].style + '</style>' );
 475+ } else if ( typeof registry[module].style === 'object'
 476+ && !( registry[module].style instanceof Array ) )
 477+ {
458478 for ( var media in registry[module].style ) {
459479 $( 'head' ).append(
460 - '<style type="text/css" media="' + media + '">' + registry[module].style[media] + '</style>'
 480+ '<style type="text/css" media="' + media + '">' +
 481+ registry[module].style[media] +
 482+ '</style>'
461483 );
462484 }
463485 }
@@ -470,7 +492,10 @@
471493 registry[module].state = 'ready';
472494 // Run jobs who's dependencies have just been met
473495 for ( var j = 0; j < jobs.length; j++ ) {
474 - if ( compare( filter( 'ready', jobs[j].dependencies ), jobs[j].dependencies ) ) {
 496+ if ( compare(
 497+ filter( 'ready', jobs[j].dependencies ),
 498+ jobs[j].dependencies ) )
 499+ {
475500 if ( typeof jobs[j].ready === 'function' ) {
476501 jobs[j].ready();
477502 }
@@ -481,7 +506,10 @@
482507 // Execute modules who's dependencies have just been met
483508 for ( r in registry ) {
484509 if ( registry[r].state == 'loaded' ) {
485 - if ( compare( filter( ['ready'], registry[r].dependencies ), registry[r].dependencies ) ) {
 510+ if ( compare(
 511+ filter( ['ready'], registry[r].dependencies ),
 512+ registry[r].dependencies ) )
 513+ {
486514 execute( r );
487515 }
488516 }
@@ -504,7 +532,8 @@
505533 }
506534
507535 /**
508 - * Adds a dependencies to the queue with optional callbacks to be run when the dependencies are ready or fail
 536+ * Adds a dependencies to the queue with optional callbacks to be run
 537+ * when the dependencies are ready or fail
509538 *
510539 * @param mixed string moulde name or array of string module names
511540 * @param function ready callback to execute when all dependencies are ready
@@ -516,14 +545,17 @@
517546 dependencies = [dependencies];
518547 if ( dependencies[0] in registry ) {
519548 for ( var n = 0; n < registry[dependencies[0]].dependencies.length; n++ ) {
520 - dependencies[dependencies.length] = registry[dependencies[0]].dependencies[n];
 549+ dependencies[dependencies.length] =
 550+ registry[dependencies[0]].dependencies[n];
521551 }
522552 }
523553 }
524554 // Add ready and error callbacks if they were given
525555 if ( arguments.length > 1 ) {
526556 jobs[jobs.length] = {
527 - 'dependencies': filter( ['undefined', 'registered', 'loading', 'loaded'], dependencies ),
 557+ 'dependencies': filter(
 558+ ['undefined', 'registered', 'loading', 'loaded'],
 559+ dependencies ),
528560 'ready': ready,
529561 'error': error
530562 };
@@ -577,7 +609,8 @@
578610 queue = [];
579611 // After document ready, handle the batch
580612 if ( !suspended && batch.length ) {
581 - // Always order modules alphabetically to help reduce cache misses for otherwise identical content
 613+ // Always order modules alphabetically to help reduce cache
 614+ // misses for otherwise identical content
582615 batch.sort();
583616 // Build a list of request parameters
584617 var base = {
@@ -608,9 +641,11 @@
609642 { 'modules': groups[group].join( '|' ), 'version': formatVersionNumber( version ) }, base
610643 );
611644 }
612 - // Clear the batch - this MUST happen before we append the script element to the body or it's
613 - // possible that the script will be locally cached, instantly load, and work the batch again,
614 - // all before we've cleared it causing each request to include modules which are already loaded
 645+ // Clear the batch - this MUST happen before we append the
 646+ // script element to the body or it's possible that the script
 647+ // will be locally cached, instantly load, and work the batch
 648+ // again, all before we've cleared it causing each request to
 649+ // include modules which are already loaded
615650 batch = [];
616651 // Asynchronously append a script tag to the end of the body
617652 function request() {
@@ -633,8 +668,8 @@
634669 };
635670
636671 /**
637 - * Registers a module, letting the system know about it and it's dependencies. loader.js files contain calls
638 - * to this function.
 672+ * Registers a module, letting the system know about it and its
 673+ * dependencies. loader.js files contain calls to this function.
639674 */
640675 this.register = function( module, version, dependencies, group ) {
641676 // Allow multiple registration
@@ -666,14 +701,16 @@
667702 // Allow dependencies to be given as a single module name
668703 registry[module].dependencies = [dependencies];
669704 } else if ( typeof dependencies === 'object' || typeof dependencies === 'function' ) {
670 - // Allow dependencies to be given as an array of module names or a function which returns an array
 705+ // Allow dependencies to be given as an array of module names
 706+ // or a function which returns an array
671707 registry[module].dependencies = dependencies;
672708 }
673709 };
674710
675711 /**
676 - * Implements a module, giving the system a course of action to take upon loading. Results of a request for
677 - * one or more modules contain calls to this function.
 712+ * Implements a module, giving the system a course of action to take
 713+ * upon loading. Results of a request for one or more modules contain
 714+ * calls to this function.
678715 */
679716 this.implement = function( module, script, style, localization ) {
680717 // Automaically register module
@@ -684,27 +721,39 @@
685722 if ( typeof script !== 'function' ) {
686723 throw new Error( 'script must be a function, not a ' + typeof script );
687724 }
688 - if ( typeof style !== 'undefined' && typeof style !== 'string' && typeof style !== 'object' ) {
 725+ if ( typeof style !== 'undefined'
 726+ && typeof style !== 'string'
 727+ && typeof style !== 'object' )
 728+ {
689729 throw new Error( 'style must be a string or object, not a ' + typeof style );
690730 }
691 - if ( typeof localization !== 'undefined' && typeof localization !== 'object' ) {
 731+ if ( typeof localization !== 'undefined'
 732+ && typeof localization !== 'object' )
 733+ {
692734 throw new Error( 'localization must be an object, not a ' + typeof localization );
693735 }
694 - if ( typeof registry[module] !== 'undefined' && typeof registry[module].script !== 'undefined' ) {
 736+ if ( typeof registry[module] !== 'undefined'
 737+ && typeof registry[module].script !== 'undefined' )
 738+ {
695739 throw new Error( 'module already implemeneted: ' + module );
696740 }
697741 // Mark module as loaded
698742 registry[module].state = 'loaded';
699743 // Attach components
700744 registry[module].script = script;
701 - if ( typeof style === 'string' || typeof style === 'object' && !( style instanceof Array ) ) {
 745+ if ( typeof style === 'string'
 746+ || typeof style === 'object' && !( style instanceof Array ) )
 747+ {
702748 registry[module].style = style;
703749 }
704750 if ( typeof localization === 'object' ) {
705751 registry[module].messages = localization;
706752 }
707753 // Execute or queue callback
708 - if ( compare( filter( ['ready'], registry[module].dependencies ), registry[module].dependencies ) ) {
 754+ if ( compare(
 755+ filter( ['ready'], registry[module].dependencies ),
 756+ registry[module].dependencies ) )
 757+ {
709758 execute( module );
710759 } else {
711760 request( module );
@@ -714,7 +763,8 @@
715764 /**
716765 * Executes a function as soon as one or more required modules are ready
717766 *
718 - * @param mixed string or array of strings of modules names the callback dependencies to be ready before
 767+ * @param mixed string or array of strings of modules names the callback
 768+ * dependencies to be ready before
719769 * executing
720770 * @param function callback to execute when all dependencies are ready (optional)
721771 * @param function callback to execute when if dependencies have a errors (optional)
@@ -722,7 +772,8 @@
723773 this.using = function( dependencies, ready, error ) {
724774 // Validate input
725775 if ( typeof dependencies !== 'object' && typeof dependencies !== 'string' ) {
726 - throw new Error( 'dependencies must be a string or an array, not a ' + typeof dependencies )
 776+ throw new Error( 'dependencies must be a string or an array, not a ' +
 777+ typeof dependencies )
727778 }
728779 // Allow calling with a single dependency as a string
729780 if ( typeof dependencies === 'string' ) {
@@ -751,21 +802,29 @@
752803 /**
753804 * Loads an external script or one or more modules for future use
754805 *
755 - * @param {mixed} modules either the name of a module, array of modules, or a URL of an external script or style
756 - * @param {string} type mime-type to use if calling with a URL of an external script or style; acceptable values
757 - * are "text/css" and "text/javascript"; if no type is provided, text/javascript is assumed
 806+ * @param {mixed} modules either the name of a module, array of modules,
 807+ * or a URL of an external script or style
 808+ * @param {string} type mime-type to use if calling with a URL of an
 809+ * external script or style; acceptable values are "text/css" and
 810+ * "text/javascript"; if no type is provided, text/javascript is
 811+ * assumed
758812 */
759813 this.load = function( modules, type ) {
760814 // Validate input
761815 if ( typeof modules !== 'object' && typeof modules !== 'string' ) {
762 - throw new Error( 'dependencies must be a string or an array, not a ' + typeof dependencies )
 816+ throw new Error( 'dependencies must be a string or an array, not a ' +
 817+ typeof dependencies )
763818 }
764819 // Allow calling with an external script or single dependency as a string
765820 if ( typeof modules === 'string' ) {
766821 // Support adding arbitrary external scripts
767 - if ( modules.substr( 0, 7 ) == 'http://' || modules.substr( 0, 8 ) == 'https://' ) {
 822+ if ( modules.substr( 0, 7 ) == 'http://'
 823+ || modules.substr( 0, 8 ) == 'https://' )
 824+ {
768825 if ( type === 'text/css' ) {
769 - $( 'head' ).append( $( '<link rel="stylesheet" type="text/css" />' ).attr( 'href', modules ) );
 826+ $( 'head' )
 827+ .append( $( '<link rel="stylesheet" type="text/css" />' )
 828+ .attr( 'href', modules ) );
770829 return true;
771830 } else if ( type === 'text/javascript' || typeof type === 'undefined' ) {
772831 var script = '<script type="text/javascript" src="' + modules + '"></script>';
@@ -858,4 +917,4 @@
859918
860919 // Alias $j to jQuery for backwards compatibility
861920 window.$j = jQuery;
862 -window.mw = mediaWiki;
\ No newline at end of file
 921+window.mw = mediaWiki;
Index: trunk/phase3/resources/mediawiki.language/mediawiki.language.js
@@ -1,8 +1,9 @@
22 /**
33 * Base language object
44 *
5 - * Localized Language support attempts to mirror some of the functionality of Language.php in MediaWiki. This object
6 - * contains methods for loading and transforming message text.
 5+ * Localized Language support attempts to mirror some of the functionality of
 6+ * Language.php in MediaWiki. This object contains methods for loading and
 7+ * transforming message text.
78 */
89
910 mediaWiki.language = {
Index: trunk/phase3/resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js
@@ -4,8 +4,13 @@
55 $( function() {
66
77 // Select all h1-h6 elements that contain editsection links
8 - $('h1:has(.editsection a), h2:has(.editsection a), h3:has(.editsection a), h4:has(.editsection a), h5:has(.editsection a), h6:has(.editsection a)').live( 'contextmenu', function( e ) {
9 -
 8+ $('h1:has(.editsection a), ' +
 9+ 'h2:has(.editsection a), ' +
 10+ 'h3:has(.editsection a), ' +
 11+ 'h4:has(.editsection a), ' +
 12+ 'h5:has(.editsection a), ' +
 13+ 'h6:has(.editsection a)'
 14+ ).live( 'contextmenu', function( e ) {
1015 // Get href of the [edit] link
1116 var href = $(this).find( '.editsection a' ).attr( 'href' );
1217
@@ -19,4 +24,4 @@
2025
2126 });
2227
23 -});
\ No newline at end of file
 28+});
Index: trunk/phase3/resources/startup.js
@@ -1,11 +1,13 @@
22 /**
3 - * This script provides a function which is run to evaluate whether or not to continue loading the jquery and mediawiki
4 - * modules. This code should work on even the most ancient of browsers, so be very careful when editing.
 3+ * This script provides a function which is run to evaluate whether or not to
 4+ * continue loading the jquery and mediawiki modules. This code should work on
 5+ * even the most ancient of browsers, so be very careful when editing.
56 */
67 /**
78 * Returns false when run in a black-listed browser
89 *
9 - * This function will be deleted after it's used, so do not expand it to be generally useful beyond startup
 10+ * This function will be deleted after it's used, so do not expand it to be
 11+ * generally useful beyond startup
1012 *
1113 * jQuery has minimum requirements of:
1214 * * Firefox 2.0+
@@ -16,7 +18,9 @@
1719 */
1820 var isCompatible = function() {
1921 // IE < 6
20 - if ( navigator.appVersion.indexOf( 'MSIE' ) !== -1 && parseFloat( navigator.appVersion.split( 'MSIE' )[1] ) < 6 ) {
 22+ if ( navigator.appVersion.indexOf( 'MSIE' ) !== -1
 23+ && parseFloat( navigator.appVersion.split( 'MSIE' )[1] ) < 6 )
 24+ {
2125 return false;
2226 }
2327 // TODO: Firefox < 2

Comments

#Comment by MZMcBride (talk | contribs)   07:17, 5 November 2010

Looks like you missed an incorrect "it's":

- * This can only be used for wiki pages in the MediaWiki and User namespaces, because of it's dependence on the
- * functionality of Title::isValidCssJsSubpage.
+ * This can only be used for wiki pages in the MediaWiki and User namespaces, 
+ * because of it's dependence on the functionality of 
+ * Title::isValidCssJsSubpage.
#Comment by MaxSem (talk | contribs)   07:40, 5 November 2010

Status & tagging log