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

Built from https://develop.svn.wordpress.org/trunk@27951


git-svn-id: http://core.svn.wordpress.org/trunk@27781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-04-05 01:29:14 +00:00
parent 24d026f682
commit 2194145373
6 changed files with 17 additions and 6 deletions

View File

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

File diff suppressed because one or more lines are too long

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 {

File diff suppressed because one or more lines are too long

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 );
});
}

File diff suppressed because one or more lines are too long