Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -2374,11 +2374,12 @@ |
2375 | 2375 | } |
2376 | 2376 | continue; |
2377 | 2377 | } |
2378 | | - // Special handling for user and site groups; because users might change their stuff on-wiki like site or |
2379 | | - // user pages, or user preferences; we need to find the highest timestamp of these user-changable modules so |
2380 | | - // we can ensure cache misses on change |
| 2378 | + // Special handling for user and site groups; because users might change their stuff |
| 2379 | + // on-wiki like site or user pages, or user preferences; we need to find the highest |
| 2380 | + // timestamp of these user-changable modules so we can ensure cache misses on change |
2381 | 2381 | if ( $group === 'user' || $group === 'site' ) { |
2382 | | - // Create a fake request based on the one we are about to make so modules return correct times |
| 2382 | + // Create a fake request based on the one we are about to make so modules return |
| 2383 | + // correct times |
2383 | 2384 | $context = new ResourceLoaderContext( $resourceLoader, new FauxRequest( $query ) ); |
2384 | 2385 | // Get the maximum timestamp |
2385 | 2386 | $timestamp = 1; |
— | — | @@ -2425,26 +2426,32 @@ |
2426 | 2427 | // Startup - this will immediately load jquery and mediawiki modules |
2427 | 2428 | $scripts = $this->makeResourceLoaderLink( $sk, 'startup', 'scripts', true ); |
2428 | 2429 | |
2429 | | - // Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a |
2430 | | - // whole script tag -- grumble grumble... |
| 2430 | + // Configuration -- This could be merged together with the load and go, but |
| 2431 | + // makeGlobalVariablesScript returns a whole script tag -- grumble grumble... |
2431 | 2432 | $scripts .= Skin::makeGlobalVariablesScript( $sk->getSkinName() ) . "\n"; |
2432 | 2433 | |
2433 | | - // Script and Messages "only" |
2434 | | - |
2435 | | - // Scripts |
| 2434 | + // Script and Messages "only" requests |
2436 | 2435 | $scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleScripts(), 'scripts' ); |
2437 | | - |
2438 | | - // Messages |
2439 | 2436 | $scripts .= $this->makeResourceLoaderLink( $sk, $this->getModuleMessages(), 'messages' ); |
2440 | 2437 | |
2441 | | - // Modules - let the client calculate dependencies and batch requests as it likes |
| 2438 | + // Modules requests - let the client calculate dependencies and batch requests as it likes |
2442 | 2439 | if ( $this->getModules() ) { |
2443 | 2440 | $modules = FormatJson::encode( $this->getModules() ); |
2444 | 2441 | $scripts .= Html::inlineScript( |
2445 | | - "if ( window.mediaWiki ) { mediaWiki.loader.load( {$modules} ); mediaWiki.loader.go(); }" |
| 2442 | + ResourceLoader::makeLoaderConditionalScript( |
| 2443 | + "mediaWiki.loader.load( {$modules} ); mediaWiki.loader.go();" |
| 2444 | + ) |
2446 | 2445 | ) . "\n"; |
2447 | 2446 | } |
2448 | 2447 | |
| 2448 | + // Legacy Scripts |
| 2449 | + $scripts .= "\n" . $this->mScripts; |
| 2450 | + |
| 2451 | + // Add site JS if enabled |
| 2452 | + if ( $wgUseSiteJs ) { |
| 2453 | + $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' ); |
| 2454 | + } |
| 2455 | + |
2449 | 2456 | // Add user JS if enabled - trying to load user.options as a bundle if possible |
2450 | 2457 | $userOptionsAdded = false; |
2451 | 2458 | if ( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) { |
— | — | @@ -2453,20 +2460,16 @@ |
2454 | 2461 | # XXX: additional security check/prompt? |
2455 | 2462 | $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) ); |
2456 | 2463 | } else { |
2457 | | - $scripts .= $this->makeResourceLoaderLink( $sk, array( 'user', 'user.options' ), 'scripts' ); |
| 2464 | + $scripts .= $this->makeResourceLoaderLink( |
| 2465 | + $sk, array( 'user', 'user.options' ), 'scripts' |
| 2466 | + ); |
2458 | 2467 | $userOptionsAdded = true; |
2459 | 2468 | } |
2460 | 2469 | } |
2461 | 2470 | if ( !$userOptionsAdded ) { |
2462 | 2471 | $scripts .= $this->makeResourceLoaderLink( $sk, 'user.options', 'scripts' ); |
2463 | 2472 | } |
2464 | | - $scripts .= "\n" . $this->mScripts; |
2465 | | - |
2466 | | - // Add site JS if enabled |
2467 | | - if ( $wgUseSiteJs ) { |
2468 | | - $scripts .= $this->makeResourceLoaderLink( $sk, 'site', 'scripts' ); |
2469 | | - } |
2470 | | - |
| 2473 | + |
2471 | 2474 | return $scripts; |
2472 | 2475 | } |
2473 | 2476 | |
— | — | @@ -2584,9 +2587,15 @@ |
2585 | 2588 | } |
2586 | 2589 | } |
2587 | 2590 | } |
| 2591 | + |
| 2592 | + // Add styles to tags, pushing user modules to the end |
| 2593 | + $styles = array( array(), array() ); |
| 2594 | + foreach ( $this->getModuleStyles() as $module ) { |
| 2595 | + $styles[strpos( 'user', $module ) === 0 ? 1 : 0][] = $module; |
| 2596 | + } |
| 2597 | + $tags[] = $this->makeResourceLoaderLink( $sk, $styles[0], 'styles' ); |
| 2598 | + $tags[] = $this->makeResourceLoaderLink( $sk, $styles[1], 'styles' ); |
2588 | 2599 | |
2589 | | - $tags[] = $this->makeResourceLoaderLink( $sk, $this->getModuleStyles(), 'styles' ); |
2590 | | - |
2591 | 2600 | return implode( "\n", $tags ); |
2592 | 2601 | } |
2593 | 2602 | |