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

git-svn-id: http://svn.automattic.com/wordpress/trunk@8170 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-06-23 16:05:10 +00:00
parent 9198dc7dbc
commit 9e951d1505
2 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,8 @@
var autosaveLast = '';
var autosavePeriodical;
var autosaveOldMessage = '';
var autosaveDelayURL = null;
var previewwin;
jQuery(function($) {
autosaveLast = $('#post #title').val()+$('#post #content').val();
@ -8,6 +10,16 @@ jQuery(function($) {
//Disable autosave after the form has been submitted
$("#post").submit(function() { $.cancel(autosavePeriodical); });
// Autosave when the preview button is clicked.
$('#previewview a').click(function(e) {
autosave();
autosaveDelayURL = this.href;
previewwin = window.open('','_blank');
e.preventDefault();
return false;
});
});
function autosave_parse_response(response) {
@ -96,6 +108,16 @@ function autosave_update_preview_link(post_id) {
getpermalinknonce: jQuery('#getpermalinknonce').val()
}, function(permalink) {
jQuery('#previewview').html('<a target="_blank" href="'+permalink+'" tabindex="4">'+previewText+'</a>');
// Autosave when the preview button is clicked.
jQuery('#previewview a').click(function(e) {
autosave();
autosaveDelayURL = this.href;
previewwin = window.open('','_blank');
e.preventDefault();
return false;
});
});
}
}
@ -125,6 +147,10 @@ function autosave_loading() {
function autosave_enable_buttons() {
jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', '');
if ( autosaveDelayURL ) {
previewwin.location = autosaveDelayURL;
autosaveDelayURL = null;
}
}
function autosave_disable_buttons() {

View File

@ -46,7 +46,7 @@ function wp_default_scripts( &$scripts ) {
'broken' => __('An unidentified error has occurred.')
) );
$scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080508' );
$scripts->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080622' );
$scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080411' );
$scripts->localize( 'wp-lists', 'wpListL10n', array(