Changeset 8170

Show
Ignore:
Timestamp:
06/23/08 16:05:10 (2 months ago)
Author:
ryan
Message:

Autosave when Preview is clicked. Props azaozz and DanCoulter?. fixes #6682

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/js/autosave.js

    r8037 r8170  
    22var autosavePeriodical; 
    33var autosaveOldMessage = ''; 
     4var autosaveDelayURL = null; 
     5var previewwin; 
    46 
    57jQuery(function($) { 
     
    911    //Disable autosave after the form has been submitted 
    1012    $("#post").submit(function() { $.cancel(autosavePeriodical); }); 
     13     
     14    // Autosave when the preview button is clicked.  
     15    $('#previewview a').click(function(e) { 
     16        autosave(); 
     17        autosaveDelayURL = this.href; 
     18        previewwin = window.open('','_blank'); 
     19 
     20        e.preventDefault(); 
     21        return false; 
     22    }); 
    1123}); 
    1224 
     
    97109        }, function(permalink) { 
    98110            jQuery('#previewview').html('<a target="_blank" href="'+permalink+'" tabindex="4">'+previewText+'</a>'); 
     111 
     112            // Autosave when the preview button is clicked.   
     113            jQuery('#previewview a').click(function(e) { 
     114                autosave(); 
     115                autosaveDelayURL = this.href; 
     116                previewwin = window.open('','_blank'); 
     117 
     118                e.preventDefault(); 
     119                return false; 
     120            }); 
    99121        }); 
    100122    } 
     
    126148function autosave_enable_buttons() { 
    127149    jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', ''); 
     150    if ( autosaveDelayURL ) { 
     151        previewwin.location = autosaveDelayURL; 
     152        autosaveDelayURL = null; 
     153    } 
    128154} 
    129155 
  • trunk/wp-includes/script-loader.php

    r8167 r8170  
    4747    ) ); 
    4848 
    49     $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080508' ); 
     49    $scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080622' ); 
    5050 
    5151    $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080411' );