mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-09-25 11:18:35 +00:00
Bug #29106: Patch from Michael M. to address JS legacy globals in wikiEditor
This commit is contained in:
parent
a36fff1552
commit
b18069c06a
Notes:
Mark A. Hershberger
2011-06-26 19:25:27 +00:00
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -110,7 +110,7 @@ getDefaultConfig: function () {
|
|||
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 @@ getDefaultConfig: function () {
|
|||
$( '#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 @@ getDefaultConfig: function () {
|
|||
}
|
||||
|
||||
var request = $.ajax( {
|
||||
url: wgScriptPath + '/api.php',
|
||||
url: mw.util.wikiScript( 'api' ),
|
||||
data: {
|
||||
'action': 'opensearch',
|
||||
'search': title,
|
||||
|
@ -504,7 +504,7 @@ getDefaultConfig: function () {
|
|||
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
|
||||
|
|
|
@ -66,7 +66,7 @@ context.evt = $.extend( context.evt, {
|
|||
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 @@ context.fn = $.extend( context.fn, {
|
|||
'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
|
||||
} )
|
||||
|
|
|
@ -75,7 +75,7 @@ $.wikiEditor = {
|
|||
* 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 @@ $.wikiEditor = {
|
|||
*/
|
||||
'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 @@ $.wikiEditor = {
|
|||
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 @@ $.wikiEditor = {
|
|||
* @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 ) {
|
||||
|
|
|
@ -51,10 +51,10 @@ fn: {
|
|||
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 @@ fn: {
|
|||
'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 @@ fn: {
|
|||
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['*'];
|
||||
|
|
|
@ -85,10 +85,10 @@ fn: {
|
|||
$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 @@ fn: {
|
|||
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; } );
|
||||
},
|
||||
|
|
|
@ -637,7 +637,7 @@ fn: {
|
|||
// 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 ) );
|
||||
|
||||
|
|
|
@ -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 @@ getDefaultConfig: function() {
|
|||
{
|
||||
'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' ) ] }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue