var autosaveLast = '';
var autosavePeriodical;
var autosaveOldMessage = '';
+var autosaveDelayURL = null;
+var previewwin;
jQuery(function($) {
autosaveLast = $('#post #title').val()+$('#post #content').val();
//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) {
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;
+ });
});
}
}
function autosave_enable_buttons() {
jQuery("#submitpost :button:disabled, #submitpost :submit:disabled").attr('disabled', '');
+ if ( autosaveDelayURL ) {
+ previewwin.location = autosaveDelayURL;
+ autosaveDelayURL = null;
+ }
}
function autosave_disable_buttons() {
doAutoSave = false;
/* Gotta do this up here so we can check the length when tinyMCE is in use */
- if ( rich ) { tinyMCE.triggerSave(); }
-
+ if ( rich ) {
+ var ed = tinyMCE.activeEditor;
+ if ( 'mce_fullscreen' == ed.id )
+ tinyMCE.get('content').setContent(ed.getContent({format : 'raw'}), {format : 'raw'});
+ tinyMCE.get('content').save();
+ }
+
post_data["content"] = jQuery("#content").val();
if ( jQuery('#post_name').val() )
post_data["post_name"] = jQuery('#post_name').val();
autosave_disable_buttons();
var origStatus = jQuery('#original_post_status').val();
- if ( 'draft' != origStatus ) // autosave currently only turned on for drafts
- doAutoSave = false;
autosaveLast = jQuery("#title").val()+jQuery("#content").val();
goodcats = ([]);
post_data["comment_status"] = 'open';
if ( jQuery("#ping_status").attr("checked") )
post_data["ping_status"] = 'open';
- if ( jQuery("#excerpt") )
+ if ( jQuery("#excerpt").size() )
post_data["excerpt"] = jQuery("#excerpt").val();
- if ( jQuery("#post_author") )
+ if ( jQuery("#post_author").size() )
post_data["post_author"] = jQuery("#post_author").val();
// Don't run while the TinyMCE spellcheck is on. Why? Who knows.