Ensure autosave is run before showing preview for new posts/pages.

git-svn-id: http://svn.automattic.com/wordpress/trunk@11466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz
2009-05-27 11:04:00 +00:00
parent a4a448741e
commit 6b559e2124
7 changed files with 56 additions and 78 deletions

View File

@@ -4,7 +4,7 @@ jQuery(document).ready( function($) {
$('#title').blur( function() { if ( ($("#post_ID").val() > 0) || ($("#title").val().length == 0) ) return; autosave(); } );
var stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(), dotabkey = true;
var stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html();
function updateVisibility() {
if ( $('#post-visibility-select input:radio:checked').val() != 'public' ) {
@@ -182,33 +182,4 @@ jQuery(document).ready( function($) {
return s;
}
});
// preview
$('#post-preview').click(function(e){
if ( 1 > $('#post_ID').val() && autosaveFirst ) {
autosaveDelayPreview = true;
autosave();
return false;
}
$('input#wp-preview').val('dopreview');
$('form#post').attr('target', 'wp-preview').submit().attr('target', '');
$('input#wp-preview').val('');
return false;
});
// This code is meant to allow tabbing from Title to Post if tinyMCE is defined.
if ( typeof tinyMCE != 'undefined' ) {
$('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
if (e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
if ( ($("#post_ID").val() < 1) && ($("#title").val().length > 0) ) { autosave(); }
if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
e.preventDefault();
dotabkey = false;
tinyMCE.activeEditor.focus();
return false;
}
}
});
}
});

File diff suppressed because one or more lines are too long

View File

@@ -210,7 +210,7 @@ var commentsBox, tagCloud;
})(jQuery);
jQuery(document).ready( function($) {
var noSyncChecks = false, syncChecks, catAddAfter, dotabkey = true, stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(), sticky = '';
var noSyncChecks = false, syncChecks, catAddAfter, stamp = $('#timestamp').html(), visibility = $('#post-visibility-display').html(), sticky = '';
// for Press This
if ( typeof autosave != 'function' )
@@ -475,43 +475,14 @@ jQuery(document).ready( function($) {
});
// Custom Fields
jQuery('#the-list').wpList( { addAfter: function( xml, s ) {
$('#the-list').wpList( { addAfter: function( xml, s ) {
$('table#list-table').show();
if ( jQuery.isFunction( autosave_update_post_ID ) ) {
if ( $.isFunction( autosave_update_post_ID ) ) {
autosave_update_post_ID(s.parsed.responses[0].supplemental.postid);
}
}, addBefore: function( s ) {
s.data += '&post_id=' + jQuery('#post_ID').val();
s.data += '&post_id=' + $('#post_ID').val();
return s;
}
});
// preview
$('#post-preview').click(function(e){
if ( 1 > $('#post_ID').val() && autosaveFirst ) {
autosaveDelayPreview = true;
autosave();
return false;
}
$('input#wp-preview').val('dopreview');
$('form#post').attr('target', 'wp-preview').submit().attr('target', '');
$('input#wp-preview').val('');
return false;
});
// This code is meant to allow tabbing from Title to Post if tinyMCE is defined.
if ( typeof tinyMCE != 'undefined' ) {
$('#title')[$.browser.opera ? 'keypress' : 'keydown'](function (e) {
if (e.which == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
if ( ($("#post_ID").val() < 1) && ($("#title").val().length > 0) ) { autosave(); }
if ( tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() && dotabkey ) {
e.preventDefault();
dotabkey = false;
tinyMCE.activeEditor.focus();
return false;
}
}
});
}
});

File diff suppressed because one or more lines are too long