Ticket #3379: autosave-me.diff
File autosave-me.diff, 3.4 KB (added by , 18 years ago) |
---|
-
wp-includes/js/autosave.js.php
13 13 form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false); 14 14 } 15 15 if(form.attachEvent) { 16 $('save').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }); 17 $('publish').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }); 18 $('deletepost').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }); 16 form.save ? form.save.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; 17 form.submit ? form.submit.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; 18 form.publish ? form.publish.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; 19 form.deletepost ? form.deletepost.attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; }) : null; 19 20 } 20 21 } 21 22 addLoadEvent(autosave_start_timer) … … 38 39 var message; 39 40 40 41 if(isNaN(res)) { 41 message = "<?php js_escape(__('Error: ')); ?>" + response;42 message = "<?php echo js_escape(__('Error: ')); ?>" + response; 42 43 } else { 43 message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time();44 message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time(); 44 45 $('post_ID').name = "post_ID"; 45 46 $('post_ID').value = res; 46 47 // We need new nonces … … 57 58 $('hiddenaction').value = 'editpost'; 58 59 } 59 60 $('autosave').innerHTML = message; 61 autosave_enable_buttons(); 60 62 } 61 63 62 64 function autosave_loading() { 63 $('autosave').innerHTML = "<?php js_escape(__('Saving Draft...')); ?>";65 $('autosave').innerHTML = "<?php echo js_escape(__('Saving Draft...')); ?>"; 64 66 } 65 67 66 68 function autosave_saved() { … … 69 71 var message; 70 72 71 73 if(isNaN(res)) { 72 message = "<?php js_escape(__('Error: ')); ?>" + response;74 message = "<?php echo js_escape(__('Error: ')); ?>" + response; 73 75 } else { 74 message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";76 message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time() + "."; 75 77 } 76 78 $('autosave').innerHTML = message; 79 autosave_enable_buttons(); 77 80 } 78 81 82 function autosave_disable_buttons() { 83 var form = $('post'); 84 form.save ? form.save.disabled = 'disabled' : null; 85 form.submit ? form.submit.disabled = 'disabled' : null; 86 form.publish ? form.publish.disabled = 'disabled' : null; 87 form.deletepost ? form.deletepost.disabled = 'disabled' : null; 88 } 89 90 function autosave_enable_buttons() { 91 var form = $('post'); 92 form.save ? form.save.disabled = '' : null; 93 form.submit ? form.submit.disabled = '' : null; 94 form.publish ? form.publish.disabled = '' : null; 95 form.deletepost ? form.deletepost.disabled = '' : null; 96 } 97 79 98 function autosave() { 80 99 var form = $('post'); 81 100 var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content')) ? true : false; … … 95 114 if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast) 96 115 return; 97 116 117 autosave_disable_buttons(); 118 98 119 autosaveLast = form.post_title.value+form.content.value; 99 120 100 121 cats = document.getElementsByName("post_category[]");