diff --git a/wp-admin/js/page.js b/wp-admin/js/page.js index 5da0e4aaa4..6f549724c8 100644 --- a/wp-admin/js/page.js +++ b/wp-admin/js/page.js @@ -2,6 +2,8 @@ jQuery(document).ready( function() { add_postbox_toggles('page'); make_slugedit_clickable(); + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // hide advanced slug field jQuery('#pageslugdiv').hide(); diff --git a/wp-admin/js/post.js b/wp-admin/js/post.js index e2f2df8602..78b52c121e 100644 --- a/wp-admin/js/post.js +++ b/wp-admin/js/post.js @@ -62,11 +62,6 @@ jQuery(document).ready( function() { // postboxes add_postbox_toggles('post'); - // If no tags on the page, skip the tag and category stuff. - if ( !jQuery('#tags-input').size() ) { - return; - } - // Editable slugs make_slugedit_clickable(); @@ -91,6 +86,8 @@ jQuery(document).ready( function() { jQuery('#publish').click( tag_save_on_publish ); jQuery('#save-post').click( tag_save_on_publish ); + jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } ); + // auto-suggest stuff jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } ); jQuery('#newtag').keypress( tag_press_key ); diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index bf184d099d..020d54dc80 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -977,6 +977,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title', $media_button e = e || window.event; if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { if ( tinyMCE.activeEditor ) { + if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); } e = null; if ( tinyMCE.activeEditor.isHidden() ) return true; tinyMCE.activeEditor.focus(); diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index 37d817b55c..9f6e40956c 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -8,12 +8,6 @@ jQuery(function($) { //Disable autosave after the form has been submitted $("#post").submit(function() { $.cancel(autosavePeriodical); }); - - // Autosave early on for a new post. Why? Should this only be run once? - $("#content").keypress(function() { - if ( 1 === ( $(this).val().length % 15 ) && 1 > parseInt($("#post_ID").val(),10) ) - setTimeout(autosave, 5000); - }); }); // called when autosaving pre-existing post @@ -148,7 +142,7 @@ var autosave = function() { post_data["post_name"] = jQuery('#post_name').val(); // Nothing to save or no change. - if(post_data["post_title"].length==0 || post_data["content"].length==0 || post_data["post_title"] + post_data["content"] == autosaveLast) { + if( (post_data["post_title"].length==0 && post_data["content"].length==0) || post_data["post_title"] + post_data["content"] == autosaveLast) { doAutoSave = false } diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 336a24fdc3..1200174b44 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -47,7 +47,7 @@ class WP_Scripts { 'broken' => 'AJAX is teh b0rked.' ) ); - $this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080312' ); + $this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080317' ); $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306'); $this->localize( 'wp-ajax', 'WPAjaxL10n', array( @@ -141,7 +141,7 @@ class WP_Scripts { 'save' => __('Save'), 'cancel' => __('Cancel'), ) ); - $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080221' ); + $this->add( 'post', '/wp-admin/js/post.js', array('suggest', 'jquery-ui-tabs', 'wp-lists', 'postbox', 'slug'), '20080318' ); $this->localize( 'post', 'postL10n', array( 'tagsUsed' => __('Tags used on this post:'), 'add' => attribute_escape(__('Add')), @@ -150,7 +150,7 @@ class WP_Scripts { 'cancel' => __('Cancel'), 'edit' => __('Edit'), ) ); - $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080208' ); + $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080318' ); $this->localize( 'page', 'postL10n', array( 'cancel' => __('Cancel'), 'edit' => __('Edit'),