When autosaving a new post for the first time after a title was typed, cancel the autosave if the user is submitting the form. (Includes a precommit fix for customize-controls.css.) Props Nessworthy, davidmarichal, fixes #27657

git-svn-id: https://develop.svn.wordpress.org/trunk@27951 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-04-05 01:28:35 +00:00
parent 36f0a60829
commit 30cdc10180
2 changed files with 13 additions and 3 deletions

View File

@ -536,6 +536,7 @@ body {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
border: 4px solid #2ea2cc;
-webkit-border-radius: 2px;
border-radius: 2px;
}
#customize-control-header_image .header-view.button.selected {

View File

@ -504,13 +504,22 @@ jQuery(document).ready( function($) {
// Autosave new posts after a title is typed
if ( $( '#auto_draft' ).val() ) {
$( '#title' ).blur( function() {
var cancel;
if ( ! this.value || $('#edit-slug-box > *').length ) {
return;
}
if ( wp.autosave ) {
wp.autosave.server.triggerSave();
}
// Cancel the autosave when the blur was triggered by the user submitting the form
$('form#post').one( 'submit', function() {
cancel = true;
});
window.setTimeout( function() {
if ( ! cancel && wp.autosave ) {
wp.autosave.server.triggerSave();
}
}, 200 );
});
}