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

git-svn-id: https://develop.svn.wordpress.org/trunk@8170 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-06-23 16:05:10 +00:00
parent df80e9fbc2
commit 5757d74348
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(