mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-15 23:25:50 +01:00
Autosave when title has content and loses focus. props ryan. see #5749
git-svn-id: http://svn.automattic.com/wordpress/trunk@7394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
12c62fa4d4
commit
0ebd2b681a
@ -2,6 +2,8 @@ jQuery(document).ready( function() {
|
|||||||
add_postbox_toggles('page');
|
add_postbox_toggles('page');
|
||||||
make_slugedit_clickable();
|
make_slugedit_clickable();
|
||||||
|
|
||||||
|
jQuery('#title').blur( function() { if ( (jQuery("#post_ID").val() > 0) || (jQuery("#title").val().length == 0) ) return; autosave(); } );
|
||||||
|
|
||||||
// hide advanced slug field
|
// hide advanced slug field
|
||||||
jQuery('#pageslugdiv').hide();
|
jQuery('#pageslugdiv').hide();
|
||||||
|
|
||||||
|
@ -62,11 +62,6 @@ jQuery(document).ready( function() {
|
|||||||
// postboxes
|
// postboxes
|
||||||
add_postbox_toggles('post');
|
add_postbox_toggles('post');
|
||||||
|
|
||||||
// If no tags on the page, skip the tag and category stuff.
|
|
||||||
if ( !jQuery('#tags-input').size() ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Editable slugs
|
// Editable slugs
|
||||||
make_slugedit_clickable();
|
make_slugedit_clickable();
|
||||||
|
|
||||||
@ -91,6 +86,8 @@ jQuery(document).ready( function() {
|
|||||||
jQuery('#publish').click( tag_save_on_publish );
|
jQuery('#publish').click( tag_save_on_publish );
|
||||||
jQuery('#save-post').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
|
// auto-suggest stuff
|
||||||
jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } );
|
jQuery('#newtag').suggest( 'admin-ajax.php?action=ajax-tag-search', { delay: 500, minchars: 2 } );
|
||||||
jQuery('#newtag').keypress( tag_press_key );
|
jQuery('#newtag').keypress( tag_press_key );
|
||||||
|
@ -977,6 +977,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title', $media_button
|
|||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
|
if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
|
||||||
if ( tinyMCE.activeEditor ) {
|
if ( tinyMCE.activeEditor ) {
|
||||||
|
if ( (jQuery("#post_ID").val() < 1) && (jQuery("#title").val().length > 0) ) { autosave(); }
|
||||||
e = null;
|
e = null;
|
||||||
if ( tinyMCE.activeEditor.isHidden() ) return true;
|
if ( tinyMCE.activeEditor.isHidden() ) return true;
|
||||||
tinyMCE.activeEditor.focus();
|
tinyMCE.activeEditor.focus();
|
||||||
|
@ -8,12 +8,6 @@ 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 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
|
// called when autosaving pre-existing post
|
||||||
@ -148,7 +142,7 @@ var autosave = function() {
|
|||||||
post_data["post_name"] = jQuery('#post_name').val();
|
post_data["post_name"] = jQuery('#post_name').val();
|
||||||
|
|
||||||
// Nothing to save or no change.
|
// 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
|
doAutoSave = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class WP_Scripts {
|
|||||||
'broken' => 'AJAX is teh b0rked.'
|
'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->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
|
||||||
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
|
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
|
||||||
@ -141,7 +141,7 @@ class WP_Scripts {
|
|||||||
'save' => __('Save'),
|
'save' => __('Save'),
|
||||||
'cancel' => __('Cancel'),
|
'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(
|
$this->localize( 'post', 'postL10n', array(
|
||||||
'tagsUsed' => __('Tags used on this post:'),
|
'tagsUsed' => __('Tags used on this post:'),
|
||||||
'add' => attribute_escape(__('Add')),
|
'add' => attribute_escape(__('Add')),
|
||||||
@ -150,7 +150,7 @@ class WP_Scripts {
|
|||||||
'cancel' => __('Cancel'),
|
'cancel' => __('Cancel'),
|
||||||
'edit' => __('Edit'),
|
'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(
|
$this->localize( 'page', 'postL10n', array(
|
||||||
'cancel' => __('Cancel'),
|
'cancel' => __('Cancel'),
|
||||||
'edit' => __('Edit'),
|
'edit' => __('Edit'),
|
||||||
|
Loading…
Reference in New Issue
Block a user