r90845 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90844‎ | r90845 | r90846 >
Date:19:25, 26 June 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Bug #29106: Patch from Michael M. to address JS legacy globals in wikiEditor
Modified paths:
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.js
@@ -75,7 +75,7 @@
7676 * Path to images - this is a bit messy, and it would need to change if this code (and images) gets moved into the
7777 * core - or anywhere for that matter...
7878 */
79 - 'imgPath' : wgExtensionAssetsPath + '/WikiEditor/modules/images/',
 79+ 'imgPath' : mw.config.get( 'wgExtensionAssetsPath' ) + '/WikiEditor/modules/images/',
8080 /**
8181 * Checks the current browser against the browsers object to determine if the browser has been black-listed or not.
8282 * Because these rules are often very complex, the object contains configurable operators and can check against
@@ -158,7 +158,7 @@
159159 */
160160 'autoLang': function( object, lang ) {
161161 var defaultKey = $( 'body' ).hasClass( 'rtl' ) ? 'default-rtl' : 'default';
162 - return object[lang || wgUserLanguage] || object[defaultKey] || object['default'] || object;
 162+ return object[lang || mw.config.get( 'wgUserLanguage' )] || object[defaultKey] || object['default'] || object;
163163 },
164164 /**
165165 * Provides a way to extract the path of an icon in a certain language, automatically appending a version number for
@@ -175,7 +175,7 @@
176176 if ( src.substr( 0, 7 ) != 'http://' && src.substr( 0, 8 ) != 'https://' && src[0] != '/' ) {
177177 src = path + src;
178178 }
179 - return src + '?' + mediaWiki.loader.version( 'jquery.wikiEditor' );
 179+ return src + '?' + mw.loader.version( 'jquery.wikiEditor' );
180180 },
181181 /**
182182 * 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 @@
187187 * @param lang Language code, defaults to wgUserLanguage
188188 */
189189 'autoIconOrOffset': function( icon, offset, path, lang ) {
190 - lang = lang || wgUserLanguage;
 190+ lang = lang || mw.config.get( 'wgUserLanguage' );
191191 if ( typeof offset == 'object' && lang in offset ) {
192192 return offset[lang];
193193 } else if ( typeof icon == 'object' && lang in icon ) {
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
@@ -66,7 +66,7 @@
6767 return a.tabIndex - b.tabIndex;
6868 } );
6969 for( var i=0; i < $tabindexList.length; i++ ) {
70 - if( $tabindexList.eq( i ).attr('id') == context.$iframe.attr( 'id' ) ) {
 70+ if( $tabindexList.eq( i ).attr( 'id' ) == context.$iframe.attr( 'id' ) ) {
7171 $tabindexList.get( i + 1 ).focus();
7272 break;
7373 }
@@ -681,7 +681,7 @@
682682 'frameBorder': 0,
683683 'border': 0,
684684 'tabindex': 1,
685 - 'src': wgExtensionAssetsPath + '/WikiEditor/modules/jquery.wikiEditor.html?' +
 685+ 'src': mw.config.get( 'wgExtensionAssetsPath' ) + '/WikiEditor/modules/jquery.wikiEditor.html?' +
686686 'instance=' + context.instance + '&ts=' + ( new Date() ).getTime() + '&is=content',
687687 'id': 'wikiEditor-iframe-' + context.instance
688688 } )
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.templates.js
@@ -4,7 +4,7 @@
55
66 $( document ).ready( function() {
77 // Disable for template namespace
8 - if ( mediaWiki.config.get( 'wgNamespaceNumber' ) == 10 ) {
 8+ if ( mw.config.get( 'wgNamespaceNumber' ) == 10 ) {
99 return true;
1010 }
1111 // Add templates module
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
@@ -51,10 +51,10 @@
5252 context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty();
5353 context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show();
5454 $.post(
55 - mediaWiki.config.get( 'wgScriptPath' ) + '/api.php',
 55+ mw.util.wikiScript( 'api' ),
5656 {
5757 'action': 'parse',
58 - 'title': mediaWiki.config.get( 'wgPageName' ),
 58+ 'title': mw.config.get( 'wgPageName' ),
5959 'text': wikitext,
6060 'prop': 'text',
6161 'pst': '',
@@ -100,13 +100,13 @@
101101 'format': 'json'
102102 };
103103
104 - $.post( mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', postdata, function( data ) {
 104+ $.post( mw.util.wikiScript( 'api' ), postdata, function( data ) {
105105 try {
106106 var postdata2 = {
107107 'action': 'query',
108108 'indexpageids': '',
109109 'prop': 'revisions',
110 - 'titles': mediaWiki.config.get( 'wgPageName' ),
 110+ 'titles': mw.config.get( 'wgPageName' ),
111111 'rvdifftotext': data.parse.text['*'],
112112 'rvprop': '',
113113 'format': 'json'
@@ -115,9 +115,9 @@
116116 if ( section != '' )
117117 postdata['rvsection'] = section;
118118
119 - $.post( mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', postdata2, function( data ) {
 119+ $.post( mw.util.wikiScript( 'api' ) + postdata2, function( data ) {
120120 // Add diff CSS
121 - mediaWiki.loader.load( 'mediawiki.legacy.diff' );
 121+ mw.loader.load( 'mediawiki.legacy.diff' );
122122 try {
123123 var diff = data.query.pages[data.query.pageids[0]]
124124 .revisions[0].diff['*'];
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
@@ -637,7 +637,7 @@
638638 // section 0, if needed
639639 var structure = buildStructure( outline );
640640 if ( $( 'input[name=wpSection]' ).val() == '' ) {
641 - structure.unshift( { 'text': wgPageName.replace( /_/g, ' ' ), 'level': 1, 'index': 0 } );
 641+ structure.unshift( { 'text': mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ), 'level': 1, 'index': 0 } );
642642 }
643643 context.modules.toc.$toc.html( buildList( structure ) );
644644
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
@@ -110,7 +110,7 @@
111111 if ( typeof arguments.callee.regex == 'undefined' ) {
112112 // Cache the regex
113113 arguments.callee.regex =
114 - new RegExp( "^(" + wgUrlProtocols + "|www\\.)", 'i');
 114+ new RegExp( "^(" + mw.config.get( 'wgUrlProtocols' ) + "|www\\.)", 'i');
115115 }
116116 return s.match( arguments.callee.regex );
117117 }
@@ -174,7 +174,7 @@
175175 $( '#wikieditor-toolbar-link-int-target-status' ).data(
176176 'request',
177177 $.ajax( {
178 - url: wgScriptPath + '/api.php',
 178+ url: mw.util.wikiScript( 'api' ),
179179 dataType: 'json',
180180 data: {
181181 'action': 'query',
@@ -369,7 +369,7 @@
370370 }
371371
372372 var request = $.ajax( {
373 - url: wgScriptPath + '/api.php',
 373+ url: mw.util.wikiScript( 'api' ),
374374 data: {
375375 'action': 'opensearch',
376376 'search': title,
@@ -504,7 +504,7 @@
505505 open: function() {
506506 // Cache the articlepath regex
507507 $(this).data( 'articlePathRegex', new RegExp(
508 - '^' + $.escapeRE( wgServer + wgArticlePath )
 508+ '^' + $.escapeRE( mw.config.get( 'wgServer' ) + mw.config.get( 'wgArticlePath' ) )
509509 .replace( /\\\$1/g, '(.*)' ) + '$'
510510 ) );
511511 // Pre-fill the text fields based on the current selection
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
@@ -85,10 +85,10 @@
8686 $dialog.find( '.wikiEditor-preview-dialog-contents' ).empty();
8787 $dialog.find( '.wikiEditor-ui-loading' ).show();
8888 $.post(
89 - wgScriptPath + '/api.php',
 89+ mw.util.wikiScript( 'api' ),
9090 {
9191 'action': 'parse',
92 - 'title': wgPageName,
 92+ 'title': mw.config.get( 'wgPageName' ),
9393 'text': wikitext,
9494 'prop': 'text',
9595 'pst': '',
@@ -105,7 +105,8 @@
106106 context.modules.preview.previewText = wikitext;
107107 $dialog.find( '.wikiEditor-ui-loading' ).hide();
108108 $dialog.find( '.wikiEditor-preview-dialog-contents' )
109 - .html( '<h1 class="firstHeading" id="firstHeading">'+wgTitle+'</h1>' +
 109+ .html( '<h1 class="firstHeading" id="firstHeading">' +
 110+ mw.config.get( 'wgTitle' ) + '</h1>' +
110111 data.parse.text['*'] )
111112 .find( 'a:not([href^=#])' ).click( function() { return false; } );
112113 },
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.templateEditor.js
@@ -4,7 +4,7 @@
55
66 $( document ).ready( function() {
77 // Disable in template namespace
8 - if ( mediaWiki.config.get( 'wgNamespaceNumber' ) == 10 ) {
 8+ if ( mw.config.get( 'wgNamespaceNumber' ) == 10 ) {
99 return true;
1010 }
1111 // Add template editor module
Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js
@@ -4,7 +4,7 @@
55 ( function( $ ) { $.wikiEditor.modules.toolbar.config = {
66
77 getDefaultConfig: function() {
8 - var fileNamespace = mediaWiki.config.get( 'wgFormattedNamespaces' )[6];
 8+ var fileNamespace = mw.config.get( 'wgFormattedNamespaces' )[6];
99 return { 'toolbar': {
1010 // Main section
1111 'main': {
@@ -936,7 +936,7 @@
937937 {
938938 'description': { 'htmlMsg': 'wikieditor-toolbar-help-content-file-description' },
939939 'syntax': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-syntax', fileNamespace ] },
940 - 'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', stylepath ] }
 940+ 'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', mw.get( 'stylepath' ) ] }
941941 }
942942 ]
943943 },

Follow-up revisions

RevisionCommit summaryAuthorDate
r90850Follow-up r90845: mw.get > mw.config.getkrinkle19:54, 26 June 2011
r91342* Fix broken post call to api in side-to-side diffs...hartman08:46, 2 July 2011
r91343Clean up some global var leaking in WikiEditor toolbar...hartman08:54, 2 July 2011
r91347Correct for in loops on arrays....hartman09:09, 2 July 2011
r91349Adding quotes for the [rel=] stuff, since this broke one test....hartman09:17, 2 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89616Extension:WikiEditor Code quality, JSHint validation and JSPERF...krinkle23:18, 6 June 2011

Comments

#Comment by Krinkle (talk | contribs)   19:52, 26 June 2011
-							'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', stylepath ] }
+							'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', mw.get( 'stylepath' ) ] }

mw.config.get. Wasn't part of the patch.

#Comment by Krinkle (talk | contribs)   19:52, 26 June 2011
-'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', stylepath ] }
+'result': { 'htmlMsg': [ 'wikieditor-toolbar-help-content-file-result', mw.get( 'stylepath' ) ] }

mw.config.get. Wasn't part of the patch.

#Comment by Krinkle (talk | contribs)   19:55, 26 June 2011

Fixed in r90850.

Status & tagging log