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 * @param {Function} [ok] Success callback (deprecated)
15 * @param {Function} [err] Error callback (deprecated)
16 * @return {jQuery.Promise} See #post
18 postWithEditToken: function ( params
, ok
, err
) {
19 return this.postWithToken( 'edit', params
).done( ok
).fail( err
);
23 * Api helper to grab an edit token.
25 * @param {Function} [ok] Success callback
26 * @param {Function} [err] Error callback
27 * @return {jQuery.Promise}
28 * @return {Function} return.done
29 * @return {string} return.done.token Received token.
31 getEditToken: function ( ok
, err
) {
32 return this.getToken( 'edit' ).done( ok
).fail( err
);
36 * Create a new section of the page.
37 * @see #postWithEditToken
38 * @param {mw.Title|String} title Target page
39 * @param {string} header
40 * @param {string} message wikitext message
41 * @param {Function} [ok] Success handler
42 * @param {Function} [err] Error handler
43 * @return {jQuery.Promise}
45 newSection: function ( title
, header
, message
, ok
, err
) {
46 return this.postWithEditToken( {
50 title
: title
.toString(),
59 * @mixins mw.Api.plugin.edit
62 }( mediaWiki
, jQuery
) );