Merge "Make number of PBKDF2 iterations used for deriving session secret configurable"
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.edit.stash.js
index 8e7b168..20bfa0e 100644 (file)
@@ -3,7 +3,7 @@
  */
 ( function ( mw, $ ) {
        $( function () {
-               var idleTimeout = 4000,
+               var idleTimeout = 3000,
                        api = new mw.Api(),
                        pending = null,
                        $form = $( '#editform' ),
                        data = {},
                        timer = null;
 
+               function stashEdit( token ) {
+                       data = $form.serializeObject();
+
+                       pending = api.post( {
+                               action: 'stashedit',
+                               token: token,
+                               title: mw.config.get( 'wgPageName' ),
+                               section: data.wpSection,
+                               sectiontitle: '',
+                               text: data.wpTextbox1,
+                               contentmodel: data.model,
+                               contentformat: data.format,
+                               baserevid: data.parentRevId
+                       } );
+               }
+
                /* Has the edit body text changed since the last stashEdit() call? */
                function isChanged() {
                        // Normalize line endings to CRLF, like $.fn.serializeObject does.
                                pending.abort();
                        }
 
-                       data = $form.serializeObject();
-                       pending = api.postWithToken( 'edit', {
-                               action: 'stashedit',
-                               title: mw.config.get( 'wgPageName' ),
-                               section: data.wpSection,
-                               sectiontitle: '',
-                               text: data.wpTextbox1,
-                               contentmodel: data.model,
-                               contentformat: data.format,
-                               baserevid: data.parentRevId
-                       } );
+                       api.getToken( 'csrf' ).then( stashEdit );
                }
 
                function onKeyPress( e ) {