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