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.js50
1 files changed, 19 insertions, 31 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
index f0665220..436b0720 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
@@ -33,6 +33,8 @@ fn: {
* @param config Configuration object to create module from
*/
create: function ( context ) {
+ var api = new mw.Api();
+
if ( 'initialized' in context.modules.preview ) {
return;
}
@@ -53,18 +55,12 @@ fn: {
}
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' ).empty();
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).show();
- $.ajax( {
- url: mw.util.wikiScript( 'api' ),
- type: 'POST',
- dataType: 'json',
- data: {
- format: 'json',
- action: 'parse',
- title: mw.config.get( 'wgPageName' ),
- text: wikitext,
- prop: 'text|modules',
- pst: ''
- }
+ api.post( {
+ action: 'parse',
+ title: mw.config.get( 'wgPageName' ),
+ text: wikitext,
+ prop: 'text|modules',
+ pst: ''
} ).done( function ( data ) {
if ( !data.parse || !data.parse.text || data.parse.text['*'] === undefined ) {
return;
@@ -74,6 +70,7 @@ fn: {
context.modules.preview.$preview.find( '.wikiEditor-preview-loading' ).hide();
context.modules.preview.$preview.find( '.wikiEditor-preview-contents' )
.html( data.parse.text['*'] )
+ .append( '<div class="visualClear"></div>' )
.find( 'a:not([href^=#])' )
.click( false );
@@ -101,21 +98,14 @@ fn: {
context.$changesTab.find( '.wikiEditor-preview-loading' ).show();
// Call the API. First PST the input, then diff it
- $.ajax( {
- url: mw.util.wikiScript( 'api' ),
- type: 'POST',
- dataType: 'json',
- data: {
- format: 'json',
- action: 'parse',
- title: mw.config.get( 'wgPageName' ),
- onlypst: '',
- text: wikitext
- }
+ api.post( {
+ action: 'parse',
+ title: mw.config.get( 'wgPageName' ),
+ onlypst: '',
+ text: wikitext
} ).done( function ( data ) {
try {
var postdata2 = {
- format: 'json',
action: 'query',
indexpageids: '',
prop: 'revisions',
@@ -128,19 +118,17 @@ fn: {
postdata2.rvsection = section;
}
- $.ajax( {
- url: mw.util.wikiScript( 'api' ),
- type: 'POST',
- dataType: 'json',
- data: postdata2
- } ).done( function ( data ) {
+ api.post( postdata2 )
+ .done( function ( data ) {
// Add diff CSS
mw.loader.load( 'mediawiki.action.history.diff' );
try {
var diff = data.query.pages[data.query.pageids[0]]
.revisions[0].diff['*'];
- context.$changesTab.find( 'table.diff tbody' ).html( diff );
+ context.$changesTab.find( 'table.diff tbody' )
+ .html( diff )
+ .append( '<div class="visualClear"></div>' );
context.modules.preview.changesText = wikitext;
} catch ( e ) {
// "data.blah is undefined" error, ignore