r111380 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111379‎ | r111380 | r111381 >
Date:15:25, 13 February 2012
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
[mw.debug] Clean up
* Instead of inline global variable and lazy-loading, using ResourceLoader (using mw.config and mw.loader)
* Can't use OutputPage::addJsConfigVars / OutputPage::addModules because debug is called after those are handled, using ResourceLoader::makeConfigSetScript instead
Modified paths:
  • /trunk/phase3/includes/debug/Debug.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.debug.init.js (added) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.debug.js (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/debug/Debug.php
@@ -62,7 +62,7 @@
6363 */
6464 public static function addModules( OutputPage $out ) {
6565 if ( self::$enabled ) {
66 - $out->addModules( 'mediawiki.debug' );
 66+ $out->addModules( 'mediawiki.debug.init' );
6767 }
6868 }
6969
@@ -272,12 +272,15 @@
273273 'memoryPeak' => $context->getLanguage()->formatSize( memory_get_peak_usage() ),
274274 'includes' => self::getFilesIncluded( $context ),
275275 );
276 - // TODO: Clean this up
277 - $html = Html::openElement( 'script' );
278 - $html .= 'var debugInfo = ' . Xml::encodeJsVar( $debugInfo ) . ';';
279 - $html .= " $(function() { mw.loader.using( 'mediawiki.debug', function() { mw.Debug.init( debugInfo ) } ); }); ";
280 - $html .= Html::closeElement( 'script' );
281276
 277+ // Cannot use OutputPage::addJsConfigVars because those are already outputted
 278+ // by the time this method is called.
 279+ $html = Html::inlineScript(
 280+ ResourceLoader::makeLoaderConditionalScript(
 281+ ResourceLoader::makeConfigSetScript( array( 'debugInfo' => $debugInfo ) )
 282+ )
 283+ );
 284+
282285 return $html;
283286 }
284287 }
Index: trunk/phase3/resources/Resources.php
@@ -543,7 +543,15 @@
544544 'scripts' => 'resources/mediawiki/mediawiki.debug.js',
545545 'styles' => 'resources/mediawiki/mediawiki.debug.css',
546546 'dependencies' => 'jquery.footHovzer',
 547+ 'position' => 'bottom',
547548 ),
 549+ 'mediawiki.debug.init' => array(
 550+ 'scripts' => 'resources/mediawiki/mediawiki.debug.init.js',
 551+ 'dependencies' => 'mediawiki.debug',
 552+ // Uses a custom mw.config variable that is set in debughtml,
 553+ // must be loaded on the bottom
 554+ 'position' => 'bottom',
 555+ ),
548556 'mediawiki.feedback' => array(
549557 'scripts' => 'resources/mediawiki/mediawiki.feedback.js',
550558 'dependencies' => array(
Index: trunk/phase3/resources/mediawiki/mediawiki.debug.js
@@ -1,5 +1,5 @@
22 /**
3 - * JavaScript for the new debug toolbar, enabled with $wgDebugToolbar
 3+ * JavaScript for the new debug toolbar, enabled through $wgDebugToolbar.
44 *
55 * @author John Du Hart
66 * @since 1.19
@@ -26,13 +26,15 @@
2727 data: {},
2828
2929 /**
30 - * Initializes the debugging pane
 30+ * Initializes the debugging pane.
 31+ * Shouldn't be called before the document is ready
 32+ * (since it binds to elements on the page).
3133 *
32 - * @param {Object} data
 34+ * @param {Object} data, defaults to 'debugInfo' from mw.config
3335 */
3436 init: function ( data ) {
3537
36 - this.data = data;
 38+ this.data = data || mw.config.get( 'debugInfo' );
3739 this.buildHtml();
3840
3941 // Insert the container into the DOM
Index: trunk/phase3/resources/mediawiki/mediawiki.debug.init.js
@@ -0,0 +1,3 @@
 2+jQuery( function () {
 3+ mediaWiki.Debug.init();
 4+} );
Property changes on: trunk/phase3/resources/mediawiki/mediawiki.debug.init.js
___________________________________________________________________
Added: svn:eol-style
15 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r112637MFT r111380, r111809, r111983, r112034, r112037, r112152reedy21:02, 28 February 2012

Comments

#Comment by Reedy (talk | contribs)   15:26, 13 February 2012

Aren't you on holiday?

#Comment by Krinkle (talk | contribs)   15:28, 13 February 2012

I did this in Brussels during FOSDEM but didn't have time to separate my working copy in proper commit. Right after FOSDEM I was off for a week, now I'm home for a few hours and then I'll be away for another week.

Pushing out my working copy right now :)

#Comment by Reedy (talk | contribs)   15:29, 13 February 2012

Aren't you on holiday? :P

Status & tagging log