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:
parent
df80e9fbc2
commit
5757d74348
@ -1,6 +1,8 @@
|
|||||||
var autosaveLast = '';
|
var autosaveLast = '';
|
||||||
var autosavePeriodical;
|
var autosavePeriodical;
|
||||||
var autosaveOldMessage = '';
|
var autosaveOldMessage = '';
|
||||||
|
var autosaveDelayURL = null;
|
||||||
|
var previewwin;
|
||||||
|
|
||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
autosaveLast = $('#post #title').val()+$('#post #content').val();
|
autosaveLast = $('#post #title').val()+$('#post #content').val();
|
||||||
@ -8,6 +10,16 @@ jQuery(function($) {
|
|||||||
|
|
||||||
//Disable autosave after the form has been submitted
|
//Disable autosave after the form has been submitted
|
||||||
$("#post").submit(function() { $.cancel(autosavePeriodical); });
|
$("#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) {
|
function autosave_parse_response(response) {
|
||||||
@ -96,6 +108,16 @@ function autosave_update_preview_link(post_id) {
|
|||||||
getpermalinknonce: jQuery('#getpermalinknonce').val()
|
getpermalinknonce: jQuery('#getpermalinknonce').val()
|
||||||
}, function(permalink) {
|
}, function(permalink) {
|
||||||
jQuery('#previewview').html('<a target="_blank" href="'+permalink+'" tabindex="4">'+previewText+'</a>');
|
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() {
|
function autosave_enable_buttons() {
|
||||||
jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', '');
|
jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', '');
|
||||||
|
if ( autosaveDelayURL ) {
|
||||||
|
previewwin.location = autosaveDelayURL;
|
||||||
|
autosaveDelayURL = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function autosave_disable_buttons() {
|
function autosave_disable_buttons() {
|
||||||
|
@ -46,7 +46,7 @@ function wp_default_scripts( &$scripts ) {
|
|||||||
'broken' => __('An unidentified error has occurred.')
|
'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->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080411' );
|
||||||
$scripts->localize( 'wp-lists', 'wpListL10n', array(
|
$scripts->localize( 'wp-lists', 'wpListL10n', array(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user