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

Revision: 90845
Author:   mah
Date:     2011-06-26 19:25:27 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
Bug #29106: Patch from Michael M. to address JS legacy globals in wikiEditor

Modified Paths:
--------------
    trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js
    trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
    trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js

Modified: trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js
===================================================================
--- trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js        
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js        
2011-06-26 19:25:27 UTC (rev 90845)
@@ -4,7 +4,7 @@
 
 $( document ).ready( function() {
        // Disable in template namespace
-       if ( mediaWiki.config.get( 'wgNamespaceNumber' ) == 10 ) {
+       if ( mw.config.get( 'wgNamespaceNumber' ) == 10 ) {
                return true;
        }
        // Add template editor module

Modified: trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js
===================================================================
--- trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js     
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js     
2011-06-26 19:25:27 UTC (rev 90845)
@@ -4,7 +4,7 @@
 
 $( document ).ready( function() {
        // Disable for template namespace
-       if ( mediaWiki.config.get( 'wgNamespaceNumber' ) == 10 ) {
+       if ( mw.config.get( 'wgNamespaceNumber' ) == 10 ) {
                return true;
        }
        // Add templates module

Modified: 
trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js     
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js     
2011-06-26 19:25:27 UTC (rev 90845)
@@ -110,7 +110,7 @@
                                        if ( typeof arguments.callee.regex == 
'undefined' ) {
                                                // Cache the regex
                                                arguments.callee.regex =
-                                                       new RegExp( "^(" + 
wgUrlProtocols + "|www\\.)", 'i');
+                                                       new RegExp( "^(" + 
mw.config.get( 'wgUrlProtocols' ) + "|www\\.)", 'i');
                                        }
                                        return s.match( arguments.callee.regex 
);
                                }
@@ -174,7 +174,7 @@
                                        $( 
'#wikieditor-toolbar-link-int-target-status' ).data(
                                                'request',
                                                $.ajax( {
-                                                       url: wgScriptPath + 
'/api.php',
+                                                       url: 
mw.util.wikiScript( 'api' ),
                                                        dataType: 'json',
                                                        data: {
                                                                'action': 
'query',
@@ -369,7 +369,7 @@
                                                }
                                                
                                                var request = $.ajax( {
-                                                       url: wgScriptPath + 
'/api.php',
+                                                       url: 
mw.util.wikiScript( 'api' ),
                                                        data: {
                                                                'action': 
'opensearch',
                                                                'search': title,
@@ -504,7 +504,7 @@
                                open: function() {
                                        // Cache the articlepath regex
                                        $(this).data( 'articlePathRegex', new 
RegExp(
-                                               '^' + $.escapeRE( wgServer + 
wgArticlePath )
+                                               '^' + $.escapeRE( 
mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ) )
                                                        .replace( /\\\$1/g, 
'(.*)' ) + '$'
                                        ) );
                                        // Pre-fill the text fields based on 
the current selection

Modified: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js     
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js     
2011-06-26 19:25:27 UTC (rev 90845)
@@ -66,7 +66,7 @@
                                                        return a.tabIndex - 
b.tabIndex;
                                                } );
                                                for( var i=0; i < 
$tabindexList.length; i++ ) {
-                                                       if( $tabindexList.eq( i 
).attr('id') == context.$iframe.attr( 'id' ) ) {
+                                                       if( $tabindexList.eq( i 
).attr( 'id' ) == context.$iframe.attr( 'id' ) ) {
                                                                
$tabindexList.get( i + 1 ).focus();
                                                                break;
                                                        }
@@ -681,7 +681,7 @@
                                'frameBorder': 0,
                                'border': 0,
                                'tabindex': 1,
-                               'src': wgExtensionAssetsPath + 
'/WikiEditor/modules/jquery.wikiEditor.html?' +
+                               'src': mw.config.get( 'wgExtensionAssetsPath' ) 
+ '/WikiEditor/modules/jquery.wikiEditor.html?' +
                                        'instance=' + context.instance + '&ts=' 
+ ( new Date() ).getTime() + '&is=content',
                                'id': 'wikiEditor-iframe-' + context.instance
                        } )

Modified: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js    2011-06-26 
19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js    2011-06-26 
19:25:27 UTC (rev 90845)
@@ -75,7 +75,7 @@
         * Path to images - this is a bit messy, and it would need to change if 
this code (and images) gets moved into the
         * core - or anywhere for that matter...
         */
-       'imgPath' : wgExtensionAssetsPath + '/WikiEditor/modules/images/',
+       'imgPath' : mw.config.get( 'wgExtensionAssetsPath' ) + 
'/WikiEditor/modules/images/',
        /**
         * Checks the current browser against the browsers object to determine 
if the browser has been black-listed or not.
         * Because these rules are often very complex, the object contains 
configurable operators and can check against
@@ -158,7 +158,7 @@
         */
        'autoLang': function( object, lang ) {
                var defaultKey = $( 'body' ).hasClass( 'rtl' ) ? 'default-rtl' 
: 'default';
-               return object[lang || wgUserLanguage] || object[defaultKey] || 
object['default'] || object;
+               return object[lang || mw.config.get( 'wgUserLanguage' )] || 
object[defaultKey] || object['default'] || object;
        },
        /**
         * Provides a way to extract the path of an icon in a certain language, 
automatically appending a version number for
@@ -175,7 +175,7 @@
                if ( src.substr( 0, 7 ) != 'http://' && src.substr( 0, 8 ) != 
'https://' && src[0] != '/' ) {
                        src = path + src;
                }
-               return src + '?' + mediaWiki.loader.version( 
'jquery.wikiEditor' );
+               return src + '?' + mw.loader.version( 'jquery.wikiEditor' );
        },
        /**
         * Get the sprite offset for a language if available, icon for a 
language if available, or the default offset or icon,
@@ -186,7 +186,7 @@
         * @param lang Language code, defaults to wgUserLanguage
         */
        'autoIconOrOffset': function( icon, offset, path, lang ) {
-               lang = lang || wgUserLanguage;
+               lang = lang || mw.config.get( 'wgUserLanguage' );
                if ( typeof offset == 'object' && lang in offset ) {
                        return offset[lang];
                } else if ( typeof icon == 'object' && lang in icon ) {

Modified: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js    
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js    
2011-06-26 19:25:27 UTC (rev 90845)
@@ -51,10 +51,10 @@
                                context.modules.preview.$preview.find( 
'.wikiEditor-preview-contents' ).empty();
                                context.modules.preview.$preview.find( 
'.wikiEditor-preview-loading' ).show();
                                $.post(
-                                       mediaWiki.config.get( 'wgScriptPath' ) 
+ '/api.php',
+                                       mw.util.wikiScript( 'api' ),
                                        {
                                                'action': 'parse',
-                                               'title': mediaWiki.config.get( 
'wgPageName' ),
+                                               'title': mw.config.get( 
'wgPageName' ),
                                                'text': wikitext,
                                                'prop': 'text',
                                                'pst': '',
@@ -100,13 +100,13 @@
                                        'format': 'json'
                                };
                                
-                               $.post( mediaWiki.config.get( 'wgScriptPath' ) 
+ '/api.php', postdata, function( data ) {
+                               $.post( mw.util.wikiScript( 'api' ), postdata, 
function( data ) {
                                        try {
                                                var postdata2 = {
                                                        'action': 'query',
                                                        'indexpageids': '',
                                                        'prop': 'revisions',
-                                                       'titles': 
mediaWiki.config.get( 'wgPageName' ),
+                                                       'titles': 
mw.config.get( 'wgPageName' ),
                                                        'rvdifftotext': 
data.parse.text['*'],
                                                        'rvprop': '',
                                                        'format': 'json'
@@ -115,9 +115,9 @@
                                                if ( section != '' )
                                                        postdata['rvsection'] = 
section;
                                                
-                                               $.post( mediaWiki.config.get( 
'wgScriptPath' ) + '/api.php', postdata2, function( data ) {
+                                               $.post( mw.util.wikiScript( 
'api' ) + postdata2, function( data ) {
                                                                // Add diff CSS
-                                                               
mediaWiki.loader.load( 'mediawiki.legacy.diff' );
+                                                               mw.loader.load( 
'mediawiki.legacy.diff' );
                                                                try {
                                                                        var 
diff = data.query.pages[data.query.pageids[0]]
                                                                                
.revisions[0].diff['*'];

Modified: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js      
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js      
2011-06-26 19:25:27 UTC (rev 90845)
@@ -85,10 +85,10 @@
                                                        $dialog.find( 
'.wikiEditor-preview-dialog-contents' ).empty();
                                                        $dialog.find( 
'.wikiEditor-ui-loading' ).show();
                                                        $.post(
-                                                               wgScriptPath + 
'/api.php',
+                                                               
mw.util.wikiScript( 'api' ),
                                                                {
                                                                        
'action': 'parse',
-                                                                       
'title': wgPageName,
+                                                                       
'title': mw.config.get( 'wgPageName' ),
                                                                        'text': 
wikitext,
                                                                        'prop': 
'text',
                                                                        'pst': 
'',
@@ -105,7 +105,8 @@
                                                                        
context.modules.preview.previewText = wikitext;
                                                                        
$dialog.find( '.wikiEditor-ui-loading' ).hide();
                                                                        
$dialog.find( '.wikiEditor-preview-dialog-contents' )
-                                                                               
.html( '<h1 class="firstHeading" id="firstHeading">'+wgTitle+'</h1>' + 
+                                                                               
.html( '<h1 class="firstHeading" id="firstHeading">' +
+                                                                               
        mw.config.get( 'wgTitle' ) + '</h1>' +
                                                                                
        data.parse.text['*'] )
                                                                                
.find( 'a:not([href^=#])' ).click( function() { return false; } );
                                                                },

Modified: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js        
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js        
2011-06-26 19:25:27 UTC (rev 90845)
@@ -637,7 +637,7 @@
                        // section 0, if needed
                        var structure = buildStructure( outline );
                        if ( $( 'input[name=wpSection]' ).val() == '' ) {
-                               structure.unshift( { 'text': 
wgPageName.replace( /_/g, ' ' ), 'level': 1, 'index': 0 } );
+                               structure.unshift( { 'text': mw.config.get( 
'wgPageName' ).replace( /_/g, ' ' ), 'level': 1, 'index': 0 } );
                        }
                        context.modules.toc.$toc.html( buildList( structure ) );
                        

Modified: 
trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js
===================================================================
--- trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js     
2011-06-26 19:20:14 UTC (rev 90844)
+++ trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js     
2011-06-26 19:25:27 UTC (rev 90845)
@@ -4,7 +4,7 @@
 ( function( $ ) { $.wikiEditor.modules.toolbar.config = {
 
 getDefaultConfig: function() {
-       var fileNamespace = mediaWiki.config.get( 'wgFormattedNamespaces' )[6];
+       var fileNamespace = mw.config.get( 'wgFormattedNamespaces' )[6];
        return { 'toolbar': {
                // Main section
                'main': {
@@ -936,7 +936,7 @@
                                                {
                                                        'description': { 
'htmlMsg': 'wikieditor-toolbar-help-content-file-description' },
                                                        'syntax': { 'htmlMsg': 
[ 'wikieditor-toolbar-help-content-file-syntax', fileNamespace ] },
-                                                       'result': { 'htmlMsg': 
[ 'wikieditor-toolbar-help-content-file-result', stylepath ] }
+                                                       'result': { 'htmlMsg': 
[ 'wikieditor-toolbar-help-content-file-result', mw.get( 'stylepath' ) ] }
                                                }
                                        ]
                                },


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

Reply via email to