http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72168

Revision: 72168
Author:   tparscal
Date:     2010-09-01 22:21:43 +0000 (Wed, 01 Sep 2010)

Log Message:
-----------
Integrated lots of legacy stuff to use resource loader. Not using document 
ready anymore, now we're using go() at the end of the page.

Modified Paths:
--------------
    branches/resourceloader/phase3/includes/ChangesList.php
    branches/resourceloader/phase3/includes/HTMLForm.php
    branches/resourceloader/phase3/includes/HistoryPage.php
    branches/resourceloader/phase3/includes/ImagePage.php
    branches/resourceloader/phase3/includes/OutputPage.php
    branches/resourceloader/phase3/includes/ProtectionForm.php
    branches/resourceloader/phase3/includes/diff/DifferenceInterface.php
    branches/resourceloader/phase3/includes/specials/SpecialBlockip.php
    branches/resourceloader/phase3/includes/specials/SpecialPreferences.php
    branches/resourceloader/phase3/includes/specials/SpecialSearch.php
    branches/resourceloader/phase3/includes/specials/SpecialUpload.php
    branches/resourceloader/phase3/resources/Resources.php
    branches/resourceloader/phase3/resources/mediawiki/mediawiki.js

Modified: branches/resourceloader/phase3/includes/ChangesList.php
===================================================================
--- branches/resourceloader/phase3/includes/ChangesList.php     2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/ChangesList.php     2010-09-01 
22:21:43 UTC (rev 72168)
@@ -601,13 +601,13 @@
         * @return String
         */
        public function beginRecentChangesList() {
-               global $wgStylePath, $wgStyleVersion;
+               global $wgStylePath, $wgStyleVersion, $wgOut;
                $this->rc_cache = array();
                $this->rcMoveIndex = 0;
                $this->rcCacheIndex = 0;
                $this->lastdate = '';
                $this->rclistOpen = false;
-               $script = Html::linkedScript( $wgStylePath . 
"/common/enhancedchanges.js?$wgStyleVersion" );
+               $wgOut->addModules( 'mediawiki.legacy.enhancedchanges' );
                return $script;
        }
        /**

Modified: branches/resourceloader/phase3/includes/HTMLForm.php
===================================================================
--- branches/resourceloader/phase3/includes/HTMLForm.php        2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/HTMLForm.php        2010-09-01 
22:21:43 UTC (rev 72168)
@@ -158,7 +158,7 @@
 
                global $wgOut, $wgStylePath;
 
-               $wgOut->addScriptFile( "$wgStylePath/common/htmlform.js" );
+               $wgOut->addModules( 'mediawiki.legacy.htmlform' );
        }
 
        /**

Modified: branches/resourceloader/phase3/includes/HistoryPage.php
===================================================================
--- branches/resourceloader/phase3/includes/HistoryPage.php     2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/HistoryPage.php     2010-09-01 
22:21:43 UTC (rev 72168)
@@ -81,7 +81,7 @@
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                $wgOut->setSyndicated( true );
                $wgOut->setFeedAppendQuery( 'action=history' );
-               $wgOut->addScriptFile( 'history.js' );
+               $wgOut->addModules( array( 'mediawiki.legacy.history' ) );
 
                $logPage = SpecialPage::getTitleFor( 'Log' );
                $logLink = $this->skin->link(

Modified: branches/resourceloader/phase3/includes/ImagePage.php
===================================================================
--- branches/resourceloader/phase3/includes/ImagePage.php       2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/ImagePage.php       2010-09-01 
22:21:43 UTC (rev 72168)
@@ -147,7 +147,7 @@
                        $collapse = htmlspecialchars( Xml::escapeJsString( 
wfMsg( 'metadata-collapse' ) ) );
                        $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 
'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
                        $wgOut->addWikiText( $this->makeMetadataTable( 
$formattedMetadata ) );
-                       $wgOut->addScriptFile( 'metadata.js' );
+                       $wgOut->addModules( array( 'mediawiki.legacy.metadata' 
) );
                        $wgOut->addHTML(
                                "<script 
type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', 
'$collapse');</script>\n" );
                }

Modified: branches/resourceloader/phase3/includes/OutputPage.php
===================================================================
--- branches/resourceloader/phase3/includes/OutputPage.php      2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/OutputPage.php      2010-09-01 
22:21:43 UTC (rev 72168)
@@ -2055,8 +2055,7 @@
                        $data['messages'][$message] = wfMsg( $message );
                }
                $this->addScript( Html::inlineScript( 'var passwordSecurity=' . 
FormatJson::encode( $data ) ) );
-               $this->addScriptFile( 'password.js' );
-               $this->addStyle( 'common/password.css' );
+               $this->addModules( 'mediawiki.legacy.password' );
        }
 
        /** @deprecated */
@@ -2345,7 +2344,7 @@
                if ( $this->getModules() ) {
                        // Modules - let the client calculate dependencies and 
batch requests as it likes
                        $scripts .= Html::inlineScript(
-                               'mediaWiki.loader.load( ' . FormatJson::encode( 
$this->getModules() ) . ' )'
+                               'mediaWiki.loader.load( ' . FormatJson::encode( 
$this->getModules() ) . ' );'
                        );
                }
                // TODO: User Scripts should be included using the resource 
loader
@@ -2366,8 +2365,9 @@
                                }
                        }
                }
-
                $scripts .= "\n" . $this->mScripts;
+               // This should be at the bottom of the body - below ALL other 
scripts
+               $scripts .= Html::inlineScript( 'mediaWiki.loader.go();' );
                return $scripts;
        }
 

Modified: branches/resourceloader/phase3/includes/ProtectionForm.php
===================================================================
--- branches/resourceloader/phase3/includes/ProtectionForm.php  2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/ProtectionForm.php  2010-09-01 
22:21:43 UTC (rev 72168)
@@ -330,14 +330,14 @@
         * @return String: HTML form
         */
        function buildForm() {
-               global $wgUser, $wgLang;
+               global $wgUser, $wgLang, $wgOut;
 
                $mProtectreasonother = Xml::label( wfMsg( 'protectcomment' ), 
'wpProtectReasonSelection' );
                $mProtectreason = Xml::label( wfMsg( 'protect-otherreason' ), 
'mwProtect-reason' );
 
                $out = '';
                if( !$this->disabled ) {
-                       $out .= $this->buildScript();
+                       $wgOut->addModules( 'mediawiki.legacy.protect' );
                        $out .= Xml::openElement( 'form', array( 'method' => 
'post',
                                'action' => $this->mTitle->getLocalUrl( 
'action=protect' ),
                                'id' => 'mw-Protect-Form', 'onsubmit' => 
'ProtectionForm.enableUnchainedInputs(true)' ) );
@@ -572,12 +572,7 @@
                        return $msg;
                }
        }
-
-       function buildScript() {
-               global $wgStylePath, $wgStyleVersion;
-               return Html::linkedScript( 
"$wgStylePath/common/protect.js?$wgStyleVersion.1" );
-       }
-
+       
        function buildCleanupScript() {
                global $wgRestrictionLevels, $wgGroupPermissions;
                $script = 'var wgCascadeableLevels=';

Modified: branches/resourceloader/phase3/includes/diff/DifferenceInterface.php
===================================================================
--- branches/resourceloader/phase3/includes/diff/DifferenceInterface.php        
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/diff/DifferenceInterface.php        
2010-09-01 22:21:43 UTC (rev 72168)
@@ -576,10 +576,7 @@
         */
        function showDiffStyle() {
                global $wgStylePath, $wgStyleVersion, $wgOut;
-               $wgOut->addStyle( 'common/diff.css' );
-
-               // JS is needed to detect old versions of Mozilla to work 
around an annoyance bug.
-               $wgOut->addScript( "<script type=\"text/javascript\" 
src=\"$wgStylePath/common/diff.js?$wgStyleVersion\"></script>" );
+               $wgOut->addModules( 'mediawiki.legacy.diff' );
        }
 
        /**

Modified: branches/resourceloader/phase3/includes/specials/SpecialBlockip.php
===================================================================
--- branches/resourceloader/phase3/includes/specials/SpecialBlockip.php 
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/specials/SpecialBlockip.php 
2010-09-01 22:21:43 UTC (rev 72168)
@@ -196,8 +196,8 @@
                        wfMsgForContent( 'ipbreasonotherlist' ), 
$this->BlockReasonList, 'wpBlockDropDown', 4 );
 
                global $wgStylePath, $wgStyleVersion;
+               $wgOut->addModules( 'mediawiki.legacy.block' );
                $wgOut->addHTML(
-                       Xml::tags( 'script', array( 'type' => 
'text/javascript', 'src' => "$wgStylePath/common/block.js?$wgStyleVersion" ), 
'' ) .
                        Xml::openElement( 'form', array( 'method' => 'post', 
'action' => $titleObj->getLocalURL( 'action=submit' ), 'id' => 'blockip' ) ) .
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', null, wfMsg( 'blockip-legend' ) 
) .

Modified: 
branches/resourceloader/phase3/includes/specials/SpecialPreferences.php
===================================================================
--- branches/resourceloader/phase3/includes/specials/SpecialPreferences.php     
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/specials/SpecialPreferences.php     
2010-09-01 22:21:43 UTC (rev 72168)
@@ -52,7 +52,7 @@
                        return;
                }
                
-               $wgOut->addScriptFile( 'prefs.js' );
+               $wgOut->addModules( 'mediawiki.legacy.prefs' );
 
                if ( $wgRequest->getCheck( 'success' ) ) {
                        $wgOut->wrapWikiMsg(

Modified: branches/resourceloader/phase3/includes/specials/SpecialSearch.php
===================================================================
--- branches/resourceloader/phase3/includes/specials/SpecialSearch.php  
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/specials/SpecialSearch.php  
2010-09-01 22:21:43 UTC (rev 72168)
@@ -366,7 +366,7 @@
                $wgOut->setArticleRelated( false );
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
                // add javascript specific to special:search
-               $wgOut->addScriptFile( 'search.js' );
+               $wgOut->addModules( 'mediawiki.legacy.search' );
 
                // Bug #16886: Sister projects box moves down the first extract 
on IE7  
                $wgOut->addStyle( 'common/IE70Fixes.css', 'screen', 'IE 7' );

Modified: branches/resourceloader/phase3/includes/specials/SpecialUpload.php
===================================================================
--- branches/resourceloader/phase3/includes/specials/SpecialUpload.php  
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/includes/specials/SpecialUpload.php  
2010-09-01 22:21:43 UTC (rev 72168)
@@ -1065,8 +1065,7 @@
                $wgOut->addScript( Skin::makeVariablesScript( $scriptVars ) );
 
                // For <charinsert> support
-               $wgOut->addScriptFile( 'edit.js' );
-               $wgOut->addScriptFile( 'upload.js' );
+               $wgOut->addModules( array( 'mediawiki.legacy.edit', 
'mediawiki.legacy.upload' ) );
        }
 
        /**

Modified: branches/resourceloader/phase3/resources/Resources.php
===================================================================
--- branches/resourceloader/phase3/resources/Resources.php      2010-09-01 
22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/resources/Resources.php      2010-09-01 
22:21:43 UTC (rev 72168)
@@ -269,85 +269,85 @@
        'mediawiki.legacy.ajax' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/ajax.js',
                'messages' => array( 'watch', 'unwatch', 'watching', 
'unwatching', 'tooltip-ca-watch', 'tooltip-ca-unwatch' ),
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.ajaxwatch' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/ajaxwatch.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.block' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/block.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.changepassword' => new ResourceLoaderFileModule( 
array(
                'scripts' => 'skins/common/changepassword.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
-       'mediawiki.legacy.edit' => new ResourceLoaderFileModule( array(
-               'scripts' => 'skins/common/edit.js',
-               'dependencies' => 'mediawiki',
-       ) ),
-       'mediawiki.legacy.enhancedchanges' => new ResourceLoaderFileModule( 
array(
-               'scripts' => 'skins/common/enhancedchanges.js',
-               'dependencies' => 'mediawiki',
-       ) ),
        'mediawiki.legacy.commonPrint' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/commonPrint.css',
        ) ),
        'mediawiki.legacy.config' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/config.js',
                'styles' => array( 'skins/common/config.css', 
'skins/common/config-cc.css' ),
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.diff' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/diff.js',
                'styles' => 'skins/common/diff.css',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
+       'mediawiki.legacy.edit' => new ResourceLoaderFileModule( array(
+               'scripts' => 'skins/common/edit.js',
+               'dependencies' => 'mediawiki.legacy.wikibits',
+       ) ),
+       'mediawiki.legacy.enhancedchanges' => new ResourceLoaderFileModule( 
array(
+               'scripts' => 'skins/common/enhancedchanges.js',
+               'dependencies' => 'mediawiki.legacy.wikibits',
+       ) ),
        'mediawiki.legacy.history' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/history.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.htmlform' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/htmlform.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.IEFixes' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/IEFixes.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.metadata' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/metadata.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.mwsuggest' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/mwsuggest.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.password' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/password.js',
                'styles' => 'skins/common/password.css',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.prefs' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/prefs.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => array( 'mediawiki.legacy.wikibits', 
'mediawiki.legacy.htmlform' ),
        ) ),
        'mediawiki.legacy.preview' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/preview.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.protect' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/protect.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.rightclickedit' => new ResourceLoaderFileModule( 
array(
                'scripts' => 'skins/common/rightclickedit.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.search' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/search.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.shared' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/shared.css',
@@ -355,7 +355,7 @@
        ) ),
        'mediawiki.legacy.upload' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/upload.js',
-               'dependencies' => 'mediawiki',
+               'dependencies' => 'mediawiki.legacy.wikibits',
        ) ),
        'mediawiki.legacy.wikibits' => new ResourceLoaderFileModule( array(
                'scripts' => 'skins/common/wikibits.js',

Modified: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js
===================================================================
--- branches/resourceloader/phase3/resources/mediawiki/mediawiki.js     
2010-09-01 22:18:10 UTC (rev 72167)
+++ branches/resourceloader/phase3/resources/mediawiki/mediawiki.js     
2010-09-01 22:21:43 UTC (rev 72168)
@@ -188,8 +188,8 @@
                var queue = [];
                // List of callback functions waiting for modules to be ready 
to be called
                var jobs = [];
-               // Flag indicating document ready has occured
-               var ready = [];
+               // Flag indicating that requests should be suspended
+               var suspended = true;
                
                /* Private Methods */
                
@@ -210,8 +210,7 @@
                                pad1( date.getUTCDate() ) + 'T' +
                                pad1( date.getUTCHours() ) + ':' +
                                pad1( date.getUTCMinutes() ) + ':' +
-                               pad1( date.getUTCSeconds() ) + '.' +
-                               pad2( date.getUTCMilliseconds() ) +
+                               pad1( date.getUTCSeconds() ) +
                                'Z';
                }
                /**
@@ -424,7 +423,7 @@
                        // Clean up the queue
                        queue = [];
                        // After document ready, handle the batch
-                       if ( ready && batch.length ) {
+                       if ( !suspended && batch.length ) {
                                // Always order modules alphabetically to help 
reduce cache misses for otherwise identical content
                                batch.sort();
                                // Build a list of request parameters
@@ -610,13 +609,13 @@
                                return true;
                        }
                };
-               
-               /* Event Bindings */
-               
-               $( document ).ready( function() {
-                       ready = true;
+               /**
+                * Flush the request queue and begin executing load requests on 
demand
+                */
+               this.go = function() {
+                       suspended = false;
                        that.work();
-               } );
+               }
        } )();
        
        /* Extension points */



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to