Merge "Type hint against LinkTarget in WatchedItemStore"
[lhc/web/wiklou.git] / resources / src / mediawiki.messagePoster.wikitext / WikitextMessagePoster.js
index a2dbcd4..e87f8a7 100644 (file)
@@ -1,4 +1,4 @@
-( function ( mw, $ ) {
+( function () {
        /**
         * This is an implementation of MessagePoster for wikitext talk pages.
         *
 
        /**
         * @inheritdoc
+        * @param {string} subject Section title.
+        * @param {string} body Message body, as wikitext. Signature code will automatically be added unless the message already contains the string ~~~.
+        * @param {Object} [options] Message options:
+        * @param {string} [options.tags] [Change tags](https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Tags) to add to the message's revision, pipe-separated.
         */
-       WikitextMessagePoster.prototype.post = function ( subject, body ) {
-               mw.messagePoster.WikitextMessagePoster.parent.prototype.post.call( this, subject, body );
+       WikitextMessagePoster.prototype.post = function ( subject, body, options ) {
+               var additionalParams;
+               options = options || {};
+               mw.messagePoster.WikitextMessagePoster.parent.prototype.post.call( this, subject, body, options );
 
                // Add signature if needed
                if ( body.indexOf( '~~~' ) === -1 ) {
                        body += '\n\n~~~~';
                }
 
+               additionalParams = { redirect: true };
+               if ( options.tags !== undefined ) {
+                       additionalParams.tags = options.tags;
+               }
                return this.api.newSection(
                        this.title,
                        subject,
                        body,
-                       { redirect: true }
+                       additionalParams
                ).then( function ( resp, jqXHR ) {
                        if ( resp.edit.result === 'Success' ) {
                                return $.Deferred().resolve( resp, jqXHR );
@@ -50,4 +60,4 @@
 
        mw.messagePoster.factory.register( 'wikitext', WikitextMessagePoster );
        mw.messagePoster.WikitextMessagePoster = WikitextMessagePoster;
-}( mediaWiki, jQuery ) );
+}() );