Merge "Made ReplicatedBagOStuff wrapping the SQL class the default stash"
[lhc/web/wiklou.git] / resources / src / mediawiki.api / mediawiki.api.edit.js
1 /**
2 * @class mw.Api.plugin.edit
3 */
4 ( function ( mw, $ ) {
5
6 $.extend( mw.Api.prototype, {
7
8 /**
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.
12 *
13 * @param {Object} params API parameters
14 * @return {jQuery.Promise} See #post
15 */
16 postWithEditToken: function ( params ) {
17 return this.postWithToken( 'edit', params );
18 },
19
20 /**
21 * API helper to grab an edit token.
22 *
23 * @return {jQuery.Promise}
24 * @return {Function} return.done
25 * @return {string} return.done.token Received token.
26 */
27 getEditToken: function () {
28 return this.getToken( 'edit' );
29 },
30
31 /**
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}
39 */
40 newSection: function ( title, header, message, additionalParams ) {
41 return this.postWithEditToken( $.extend( {
42 action: 'edit',
43 section: 'new',
44 title: String( title ),
45 summary: header,
46 text: message
47 }, additionalParams ) );
48 }
49 } );
50
51 /**
52 * @class mw.Api
53 * @mixins mw.Api.plugin.edit
54 */
55
56 }( mediaWiki, jQuery ) );