Auto add preview link after autosaving a new post or page. Props filosofo. see #5847

git-svn-id: https://develop.svn.wordpress.org/trunk@6953 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-02-21 06:19:46 +00:00
parent 6aacdf4c91
commit a738abba3d
5 changed files with 29 additions and 2 deletions
+18
View File
@@ -46,9 +46,26 @@ function autosave_update_post_ID(response) {
message = autosaveL10n.failText;
}
jQuery('#autosave').html(message);
autosave_update_preview_link(res);
autosave_enable_buttons();
}
function autosave_update_preview_link(post_id) {
// Add preview button if not already there
if ( ! jQuery('#previewview > *').get()[0] ) {
var post_type = jQuery('#post_type').val();
var previewText = 'page' == post_type ? autosaveL10n.previewPageText : autosaveL10n.previewPostText;
jQuery.post(autosaveL10n.requestFile, {
action: "get-permalink",
post_id: post_id,
getpermalinknonce: jQuery('#getpermalinknonce').val()
}, function(permalink) {
jQuery('#previewview').html('<a target="_blank" href="'+permalink+'">'+previewText+'</a>');
});
}
}
function autosave_loading() {
jQuery('#autosave').html(autosaveL10n.savingText);
}
@@ -63,6 +80,7 @@ function autosave_saved(response) {
message = autosaveL10n.saveText.replace(/%time%/g, autosave_cur_time());
}
jQuery('#autosave').html(message);
autosave_update_preview_link(res);
autosave_enable_buttons();
}
+4 -2
View File
@@ -42,11 +42,13 @@ class WP_Scripts {
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080206');
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('jquery', 'schedule'), '20080220');
$this->localize( 'autosave', 'autosaveL10n', array(
'autosaveInterval' => apply_filters('autosave_interval', '120'),
'errorText' => __('Error: %response%'),
'failText' => __('Error: Autosave Failed.'),
'previewPageText' => __('Preview this Page'),
'previewPostText' => __('Preview this Post'),
'saveText' => __('Saved at %time%.'),
'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
'savingText' => __('Saving Draft...')
@@ -484,4 +486,4 @@ function wp_prototype_before_jquery( $js_array ) {
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
?>
?>