Revert "StashEdit: Use postWithToken"
authorOri.livneh <ori@wikimedia.org>
Wed, 17 Jun 2015 19:51:49 +0000 (19:51 +0000)
committerAlex Monk <krenair@gmail.com>
Wed, 17 Jun 2015 19:54:24 +0000 (19:54 +0000)
This reverts commit 155ad712c3.

Bug: T102863
Change-Id: Ia30b535a44a3aa4d6e79f14bbccb6f4a1b065aa2

resources/src/mediawiki.action/mediawiki.action.edit.stash.js

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