Make WordPress Core

Ticket #3379: autosave-me.diff

File autosave-me.diff, 3.4 KB (added by andy, 18 years ago)
  • wp-includes/js/autosave.js.php

     
    1313                form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
    1414        }
    1515        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;
    1920        }
    2021}
    2122addLoadEvent(autosave_start_timer)
     
    3839        var message;
    3940       
    4041        if(isNaN(res)) {
    41                 message = "<?php js_escape(__('Error: ')); ?>" + response;
     42                message = "<?php echo js_escape(__('Error: ')); ?>" + response;
    4243        } else {
    43                 message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time();
     44                message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time();
    4445                $('post_ID').name = "post_ID";
    4546                $('post_ID').value = res;
    4647                // We need new nonces
     
    5758                $('hiddenaction').value = 'editpost';
    5859        }
    5960        $('autosave').innerHTML = message;
     61        autosave_enable_buttons();
    6062}
    6163
    6264function autosave_loading() {
    63         $('autosave').innerHTML = "<?php js_escape(__('Saving Draft...')); ?>";
     65        $('autosave').innerHTML = "<?php echo js_escape(__('Saving Draft...')); ?>";
    6466}
    6567
    6668function autosave_saved() {
     
    6971        var message;
    7072       
    7173        if(isNaN(res)) {
    72                 message = "<?php js_escape(__('Error: ')); ?>" + response;
     74                message = "<?php echo js_escape(__('Error: ')); ?>" + response;
    7375        } else {
    74                 message = "<?php js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
     76                message = "<?php echo js_escape(__('Saved at ')); ?>" + autosave_cur_time() + ".";
    7577        }
    7678        $('autosave').innerHTML = message;
     79        autosave_enable_buttons();
    7780}
    78        
     81
     82function 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
     90function 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
    7998function autosave() {
    8099        var form = $('post');
    81100        var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content')) ? true : false;
     
    95114        if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast)
    96115                return;
    97116
     117        autosave_disable_buttons();
     118
    98119        autosaveLast = form.post_title.value+form.content.value;
    99120
    100121        cats = document.getElementsByName("post_category[]");