4 * This is an implementation of MessagePoster for wikitext talk pages.
6 * @class mw.messagePoster.WikitextMessagePoster
7 * @extends mw.messagePoster.MessagePoster
10 * @param {mw.Title} title Wikitext page in a talk namespace, to post to
11 * @param {mw.Api} api mw.Api object to use
13 function WikitextMessagePoster( title, api ) {
19 WikitextMessagePoster,
20 mw.messagePoster.MessagePoster
26 WikitextMessagePoster.prototype.post = function ( subject, body ) {
27 mw.messagePoster.WikitextMessagePoster.parent.prototype.post.call( this, subject, body );
29 // Add signature if needed
30 if ( body.indexOf( '~~~' ) === -1 ) {
34 return this.api.newSection(
39 ).then( function ( resp, jqXHR ) {
40 if ( resp.edit.result === 'Success' ) {
41 return $.Deferred().resolve( resp, jqXHR );
43 // mw.Api checks for response error. Are there actually cases where the
44 // request fails, but it's not caught there?
45 return $.Deferred().reject( 'api-unexpected' );
47 }, function ( code, details ) {
48 return $.Deferred().reject( 'api-fail', code, details );
52 mw.messagePoster.factory.register( 'wikitext', WikitextMessagePoster );
53 mw.messagePoster.WikitextMessagePoster = WikitextMessagePoster;
54 }( mediaWiki, jQuery ) );