2 * @class mw.Api.plugin.edit
6 $.extend( mw
.Api
.prototype, {
9 * Post to API with edit token. If we have no token, get one and try to post.
10 * If we have a cached token try using that, and if it fails, blank out the
11 * cached token and start over.
13 * @param {Object} params API parameters
14 * @return {jQuery.Promise} See #post
16 postWithEditToken: function ( params
) {
17 return this.postWithToken( 'edit', params
);
21 * API helper to grab an edit token.
23 * @return {jQuery.Promise}
24 * @return {Function} return.done
25 * @return {string} return.done.token Received token.
27 getEditToken: function () {
28 return this.getToken( 'edit' );
32 * Post a new section to the page.
33 * @see #postWithEditToken
34 * @param {mw.Title|String} title Target page
35 * @param {string} header
36 * @param {string} message wikitext message
37 * @param {Object} [additionalParams] Additional API parameters, e.g. `{ redirect: true }`
38 * @return {jQuery.Promise}
40 newSection: function ( title
, header
, message
, additionalParams
) {
41 return this.postWithEditToken( $.extend( {
44 title
: String( title
),
47 }, additionalParams
) );
53 * @mixins mw.Api.plugin.edit
56 }( mediaWiki
, jQuery
) );