Autosave fix up for duplicate drafts from andy. fixes #3379
git-svn-id: https://develop.svn.wordpress.org/trunk@4614 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
315908c7d6
commit
d1721ba4d7
|
@ -13,9 +13,10 @@ function autosave_start_timer() {
|
||||||
form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
|
form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
|
||||||
}
|
}
|
||||||
if(form.attachEvent) {
|
if(form.attachEvent) {
|
||||||
$('save').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
form.save ? form.save.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||||
$('publish').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
form.submit ? form.submit.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null;
|
||||||
$('deletepost').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
|
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)
|
addLoadEvent(autosave_start_timer)
|
||||||
|
@ -38,9 +39,9 @@ function autosave_update_post_ID() {
|
||||||
var message;
|
var message;
|
||||||
|
|
||||||
if(isNaN(res)) {
|
if(isNaN(res)) {
|
||||||
message = "<?php js_escape(__('Error: ')); ?>" + response;
|
message = "<?php echo js_escape(__('Error: ')); ?>" + response;
|
||||||
} else {
|
} 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').name = "post_ID";
|
||||||
$('post_ID').value = res;
|
$('post_ID').value = res;
|
||||||
// We need new nonces
|
// We need new nonces
|
||||||
|
@ -57,10 +58,11 @@ function autosave_update_post_ID() {
|
||||||
$('hiddenaction').value = 'editpost';
|
$('hiddenaction').value = 'editpost';
|
||||||
}
|
}
|
||||||
$('autosave').innerHTML = message;
|
$('autosave').innerHTML = message;
|
||||||
|
autosave_enable_buttons();
|
||||||
}
|
}
|
||||||
|
|
||||||
function autosave_loading() {
|
function autosave_loading() {
|
||||||
$('autosave').innerHTML = "<?php js_escape(__('Saving Draft...')); ?>";
|
$('autosave').innerHTML = "<?php echo js_escape(__('Saving Draft...')); ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function autosave_saved() {
|
function autosave_saved() {
|
||||||
|
@ -69,11 +71,28 @@ function autosave_saved() {
|
||||||
var message;
|
var message;
|
||||||
|
|
||||||
if(isNaN(res)) {
|
if(isNaN(res)) {
|
||||||
message = "<?php js_escape(__('Error: ')); ?>" + response;
|
message = "<?php echo js_escape(__('Error: ')); ?>" + response;
|
||||||
} else {
|
} else {
|
||||||
message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
|
message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
|
||||||
}
|
}
|
||||||
$('autosave').innerHTML = message;
|
$('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() {
|
function autosave() {
|
||||||
|
@ -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)
|
if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
autosave_disable_buttons();
|
||||||
|
|
||||||
autosaveLast = form.post_title.value+form.content.value;
|
autosaveLast = form.post_title.value+form.content.value;
|
||||||
|
|
||||||
cats = document.getElementsByName("post_category[]");
|
cats = document.getElementsByName("post_category[]");
|
||||||
|
|
Loading…
Reference in New Issue