mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Autosave fix up for duplicate drafts from andy. fixes #3379
git-svn-id: http://svn.automattic.com/wordpress/trunk@4614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a5b18aa47d
commit
1c1b7a2df6
@ -13,9 +13,10 @@ function autosave_start_timer() {
|
||||
form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
|
||||
}
|
||||
if(form.attachEvent) {
|
||||
$('save').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
||||
$('publish').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
||||
$('deletepost').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
||||
form.save ? form.save.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||
form.submit ? form.submit.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||
form.publish ? form.publish.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||
form.deletepost ? form.deletepost.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||
}
|
||||
}
|
||||
addLoadEvent(autosave_start_timer)
|
||||
@ -38,9 +39,9 @@ function autosave_update_post_ID() {
|
||||
var message;
|
||||
|
||||
if(isNaN(res)) {
|
||||
message = "<?php js_escape(__('Error: ')); ?>" + response;
|
||||
message = "<?php echo js_escape(__('Error: ')); ?>" + response;
|
||||
} else {
|
||||
message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time();
|
||||
message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time();
|
||||
$('post_ID').name = "post_ID";
|
||||
$('post_ID').value = res;
|
||||
// We need new nonces
|
||||
@ -57,10 +58,11 @@ function autosave_update_post_ID() {
|
||||
$('hiddenaction').value = 'editpost';
|
||||
}
|
||||
$('autosave').innerHTML = message;
|
||||
autosave_enable_buttons();
|
||||
}
|
||||
|
||||
function autosave_loading() {
|
||||
$('autosave').innerHTML = "<?php js_escape(__('Saving Draft...')); ?>";
|
||||
$('autosave').innerHTML = "<?php echo js_escape(__('Saving Draft...')); ?>";
|
||||
}
|
||||
|
||||
function autosave_saved() {
|
||||
@ -69,13 +71,30 @@ function autosave_saved() {
|
||||
var message;
|
||||
|
||||
if(isNaN(res)) {
|
||||
message = "<?php js_escape(__('Error: ')); ?>" + response;
|
||||
message = "<?php echo js_escape(__('Error: ')); ?>" + response;
|
||||
} else {
|
||||
message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
|
||||
message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
|
||||
}
|
||||
$('autosave').innerHTML = message;
|
||||
autosave_enable_buttons();
|
||||
}
|
||||
|
||||
|
||||
function autosave_disable_buttons() {
|
||||
var form = $('post');
|
||||
form.save ? form.save.disabled = 'disabled' : null;
|
||||
form.submit ? form.submit.disabled = 'disabled' : null;
|
||||
form.publish ? form.publish.disabled = 'disabled' : null;
|
||||
form.deletepost ? form.deletepost.disabled = 'disabled' : null;
|
||||
}
|
||||
|
||||
function autosave_enable_buttons() {
|
||||
var form = $('post');
|
||||
form.save ? form.save.disabled = '' : null;
|
||||
form.submit ? form.submit.disabled = '' : null;
|
||||
form.publish ? form.publish.disabled = '' : null;
|
||||
form.deletepost ? form.deletepost.disabled = '' : null;
|
||||
}
|
||||
|
||||
function autosave() {
|
||||
var form = $('post');
|
||||
var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content')) ? true : false;
|
||||
@ -95,6 +114,8 @@ function autosave() {
|
||||
if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast)
|
||||
return;
|
||||
|
||||
autosave_disable_buttons();
|
||||
|
||||
autosaveLast = form.post_title.value+form.content.value;
|
||||
|
||||
cats = document.getElementsByName("post_category[]");
|
||||
|
Loading…
Reference in New Issue
Block a user