Autosave: don't create the temporary permalink if the title field had focus (the user was typing a title) at the time of the last autosave. Fixes #27503

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


git-svn-id: http://core.svn.wordpress.org/trunk@27565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-03-25 22:22:14 +00:00
parent aee8de682b
commit 339a33bb45
2 changed files with 9 additions and 5 deletions

View File

@ -18,7 +18,8 @@ function array_unique_noempty(a) {
return out;
}
(function($){
( function($) {
var titleHasFocus = false;
tagBox = {
clean : function(tags) {
@ -309,9 +310,12 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
$('#active_post_lock').val( received.new_lock );
}
}
}).on( 'before-autosave.update-post-slug', function() {
titleHasFocus = document.activeElement && document.activeElement.id === 'title';
}).on( 'after-autosave.update-post-slug', function() {
// create slug area only if not already there
if ( ! $('#edit-slug-box > *').length ) {
// Create slug area only if not already there
// and the title field was not focused (user was not typing a title) when autosave ran
if ( ! $('#edit-slug-box > *').length && ! titleHasFocus ) {
$.post( ajaxurl, {
action: 'sample-permalink',
post_id: $('#post_ID').val(),
@ -501,7 +505,7 @@ jQuery(document).ready( function($) {
// Autosave new posts after a title is typed
if ( $( '#auto_draft' ).val() ) {
$( '#title' ).blur( function() {
if ( ! this.value || $( '#auto_draft' ).val() !== '1' ) {
if ( ! this.value || $('#edit-slug-box > *').length ) {
return;
}

File diff suppressed because one or more lines are too long