Merge "StashEdit: Use postWithToken"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 12 Jun 2015 23:50:57 +0000 (23:50 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Jun 2015 23:50:57 +0000 (23:50 +0000)
resources/src/mediawiki.action/mediawiki.action.edit.stash.js

index 29c533d..8e7b168 100644 (file)
                        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();
                        }
 
-                       api.getToken( 'edit' ).then( stashEdit );
+                       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
+                       } );
                }
 
                function onKeyPress( e ) {