2 * Scripts for pre-emptive edit preparing on action=edit
6 var api
= new mw
.Api(), pending
= null, $form
= $( '#editform' );
8 function stashEdit( token
) {
9 var data
= $form
.serializeObject();
14 title
: mw
.config
.get( 'wgPageName' ),
15 section
: data
.wpSection
,
17 text
: data
.wpTextbox1
,
18 contentmodel
: data
.model
,
19 contentformat
: data
.format
,
20 baserevid
: data
.parentRevId
24 function onEditChanged() {
25 // If a stash request is already in flight, abort it, since its
26 // payload has just been invalidated by this change.
30 api
.getToken( 'edit' ).then( stashEdit
);
33 // We don't attempt to stash new section edits because in such cases
34 // the parser output varies on the edit summary (since it determines
35 // the new section's name).
36 if ( $form
.find( 'input[name=wpSection]' ).val() === 'new' ) {
40 $form
.find( '#wpTextbox1' ).on( 'change', onEditChanged
);
42 }( mediaWiki
, jQuery
) );