Make WordPress Core


Ignore:
Timestamp:
12/06/2006 05:33:52 AM (17 years ago)
Author:
ryan
Message:

Autosave fix up for duplicate drafts from andy. fixes #3379

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/autosave.js.php

    r4535 r4614  
    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}
     
    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;
     
    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
     
    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');
     
    95114    if(form.post_title.value.length==0 || form.content.value.length==0 || form.post_title.value+form.content.value == autosaveLast)
    96115        return;
     116
     117    autosave_disable_buttons();
    97118
    98119    autosaveLast = form.post_title.value+form.content.value;
Note: See TracChangeset for help on using the changeset viewer.