Post locks and autosave:

- Move nonces refreshing from autosave to lock checking.
- Do autosave only when there is something to save.
See #23295

git-svn-id: http://core.svn.wordpress.org/trunk@24209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz
2013-05-08 22:52:55 +00:00
parent 19c3b4bfdc
commit d0c5c59c94
4 changed files with 39 additions and 25 deletions
+17 -2
View File
@@ -252,7 +252,10 @@ WPRemoveThumbnail = function(nonce){
};
$(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
var lock = $('#active_post_lock').val(), post_id = $('#post_ID').val(), send = {};
var lock = $('#active_post_lock').val(),
post_id = $('#post_ID').val(),
post_nonce = $('#_wpnonce').val(),
send = {};
if ( !post_id )
return;
@@ -262,6 +265,9 @@ $(document).on( 'heartbeat-send.refresh-lock', function( e, data ) {
if ( lock )
send['lock'] = lock;
if ( post_nonce )
send['post_nonce'] = post_nonce;
data['wp-refresh-post-lock'] = send;
});
@@ -286,7 +292,9 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
});
// Save the latest changes and disable
autosave();
if ( ! autosave() )
window.onbeforeunload = null;
autosave = function(){};
}
@@ -301,6 +309,13 @@ $(document).on( 'heartbeat-tick.refresh-lock', function( e, data ) {
} else if ( received.new_lock ) {
$('#active_post_lock').val( received.new_lock );
}
if ( received.update_nonces ) {
$.each( received.update_nonces, function( selector, value ) {
if ( selector.match(/^replace-/) )
$( '#' + selector.replace('replace-', '') ).val( value );
});
}
}
});