summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.preview.js')
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.preview.js103
1 files changed, 54 insertions, 49 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
index 22c6d89e..39907364 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
@@ -1,25 +1,28 @@
/* Preview module for wikiEditor */
-( function( $ ) { $.wikiEditor.modules.preview = {
+( function ( $, mw ) {
+
+$.wikiEditor.modules.preview = {
/**
* Compatability map
*/
-'browsers': {
+browsers: {
// Left-to-right languages
- 'ltr': {
- 'msie': [['>=', 7]],
- 'firefox': [['>=', 3]],
- 'opera': [['>=', 9.6]],
- 'safari': [['>=', 4]]
+ ltr: {
+ msie: [['>=', 7]],
+ firefox: [['>=', 3]],
+ opera: [['>=', 9.6]],
+ safari: [['>=', 4]]
},
// Right-to-left languages
- 'rtl': {
- 'msie': [['>=', 8]],
- 'firefox': [['>=', 3]],
- 'opera': [['>=', 9.6]],
- 'safari': [['>=', 4]]
+ rtl: {
+ msie: [['>=', 8]],
+ firefox: [['>=', 3]],
+ opera: [['>=', 9.6]],
+ safari: [['>=', 4]]
}
},
+
/**
* Internally used functions
*/
@@ -29,7 +32,7 @@ fn: {
* @param context Context object of editor to create module in
* @param config Configuration object to create module from
*/
- create: function( context, config ) {
+ create: function ( context, config ) {
if ( 'initialized' in context.modules.preview ) {
return;
}
@@ -41,11 +44,11 @@ fn: {
context.modules.preview.$preview = context.fn.addView( {
'name': 'preview',
'titleMsg': 'wikieditor-preview-tab',
- 'init': function( context ) {
+ 'init': function ( context ) {
// Gets the latest copy of the wikitext
var wikitext = context.$textarea.textSelection( 'getContents' );
// Aborts when nothing has changed since the last preview
- if ( context.modules.preview.previewText == wikitext ) {
+ if ( context.modules.preview.previewText === wikitext ) {
return;
}
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty();
@@ -53,14 +56,14 @@ fn: {
$.post(
mw.util.wikiScript( 'api' ),
{
- 'action': 'parse',
- 'title': mw.config.get( 'wgPageName' ),
- 'text': wikitext,
- 'prop': 'text',
- 'pst': '',
- 'format': 'json'
+ format: 'json',
+ action: 'parse',
+ title: mw.config.get( 'wgPageName' ),
+ text: wikitext,
+ prop: 'text',
+ pst: ''
},
- function( data ) {
+ function ( data ) {
if (
typeof data.parse == 'undefined' ||
typeof data.parse.text == 'undefined' ||
@@ -72,7 +75,7 @@ fn: {
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide();
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' )
.html( data.parse.text['*'] )
- .find( 'a:not([href^=#])' ).click( function() { return false; } );
+ .find( 'a:not([href^=#])' ).click( false );
},
'json'
);
@@ -82,7 +85,7 @@ fn: {
context.$changesTab = context.fn.addView( {
'name': 'changes',
'titleMsg': 'wikieditor-preview-changes-tab',
- 'init': function( context ) {
+ 'init': function ( context ) {
// Gets the latest copy of the wikitext
var wikitext = context.$textarea.textSelection( 'getContents' );
// Aborts when nothing has changed since the last time
@@ -94,28 +97,28 @@ fn: {
// Call the API. First PST the input, then diff it
var postdata = {
- 'action': 'parse',
- 'onlypst': '',
- 'text': wikitext,
- 'format': 'json'
+ format: 'json',
+ action: 'parse',
+ onlypst: '',
+ text: wikitext
};
- $.post( mw.util.wikiScript( 'api' ), postdata, function( data ) {
+ $.post( mw.util.wikiScript( 'api' ), postdata, function ( data ) {
try {
var postdata2 = {
- 'action': 'query',
- 'indexpageids': '',
- 'prop': 'revisions',
- 'titles': mw.config.get( 'wgPageName' ),
- 'rvdifftotext': data.parse.text['*'],
- 'rvprop': '',
- 'format': 'json'
+ format: 'json',
+ action: 'query',
+ indexpageids: '',
+ prop: 'revisions',
+ titles: mw.config.get( 'wgPageName' ),
+ rvdifftotext: data.parse.text['*'],
+ rvprop: ''
};
- var section = $( '[name=wpSection]' ).val();
- if ( section != '' )
- postdata2['rvsection'] = section;
+ var section = $( '[name="wpSection"]' ).val();
+ if ( section !== '' )
+ postdata2.rvsection = section;
- $.post( mw.util.wikiScript( 'api' ), postdata2, function( data ) {
+ $.post( mw.util.wikiScript( 'api' ), postdata2, function ( data ) {
// Add diff CSS
mw.loader.load( 'mediawiki.action.history.diff' );
try {
@@ -129,17 +132,17 @@ fn: {
} catch ( e ) { } // "blah is undefined" error, ignore
}, 'json'
);
- } catch( e ) { } // "blah is undefined" error, ignore
+ } catch ( e ) { } // "blah is undefined" error, ignore
}, 'json' );
}
} );
- var loadingMsg = mediaWiki.msg( 'wikieditor-preview-loading' );
+ var loadingMsg = mw.msg( 'wikieditor-preview-loading' );
context.modules.preview.$preview
.add( context.$changesTab )
- .append( $( '<div />' )
+ .append( $( '<div>' )
.addClass( 'wikiEditor-preview-loading' )
- .append( $( '<img />' )
+ .append( $( '<img>' )
.addClass( 'wikiEditor-preview-spinner' )
.attr( {
'src': $.wikiEditor.imgPath + 'dialogs/loading.gif',
@@ -149,16 +152,18 @@ fn: {
} )
)
.append(
- $( '<span></span>' ).text( loadingMsg )
+ $( '<span>' ).text( loadingMsg )
)
)
- .append( $( '<div />' )
+ .append( $( '<div>' )
.addClass( 'wikiEditor-preview-contents' )
);
context.$changesTab.find( '.wikiEditor-preview-contents' )
- .html( '<table class="diff"><col class="diff-marker" /><col class="diff-content" />' +
- '<col class="diff-marker" /><col class="diff-content" /><tbody /></table>' );
+ .html( '<table class="diff"><col class="diff-marker"/><col class="diff-content"/>' +
+ '<col class="diff-marker"/><col class="diff-content"/><tbody/></table>' );
}
}
-}; } )( jQuery );
+};
+
+}( jQuery, mediaWiki ) );