Merge "Use mediawiki.api.parse"

This commit is contained in:
jenkins-bot 2014-10-16 17:16:42 +00:00 committed by Gerrit Code Review
commit aefe1def47
2 changed files with 10 additions and 16 deletions

View file

@ -104,7 +104,8 @@ $wgResourceModules['ext.codeEditor.geshi'] = array(
'messages' => array(
'editsection',
'savearticle'
)
),
'dependencies' => 'mediawiki.api.parse',
) + $tpl;
// Experimental feature; not ready yet.

View file

@ -91,26 +91,19 @@ $( function () {
.text( mw.msg( 'savearticle' ) )
.click( function () {
// horrible hack ;)
var src, tag;
var src, tag, api = new mw.Api();
src = codeEditor.getSession().getValue();
tag = '<source lang="' + geshiLang + '">' + src + '</source>';
$.ajax( mw.config.get( 'wgScriptPath' ) + '/api' + mw.config.get( 'wgScriptExtension' ), {
data: {
action: 'parse',
text: tag,
format: 'json'
},
type: 'POST',
success: function ( data ) {
var $html = $( data.parse.text['*'] );
$div.replaceWith( $html );
setupEditor( $html );
api.parse( tag )
.done( function ( html ) {
var $html = $( html );
$div.replaceWith( $html );
setupEditor( $html );
closeEditor();
event.preventDefault();
}
closeEditor();
event.preventDefault();
} );
} );
$cancel = $( '<button>' )