From aff66a7d077f7a62add2dbe378c6e8838d14326f Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 9 Jun 2013 00:45:01 +0000 Subject: [PATCH] Autosave: properly set autosaveLast when TinyMCE is the default editor. Prevents firing autosave when there are no changes. See #23220 git-svn-id: http://core.svn.wordpress.org/trunk@24431 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/autosave.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/wp-includes/js/autosave.js b/wp-includes/js/autosave.js index e3f0c90b7b..9be07d8dee 100644 --- a/wp-includes/js/autosave.js +++ b/wp-includes/js/autosave.js @@ -2,7 +2,19 @@ var autosave, autosaveLast = '', autosavePeriodical, autosaveDelayPreview = fals jQuery(document).ready( function($) { - autosaveLast = ( $('#post #title').val() || '' ) + ( $('#post #content').val() || '' ); + if ( $('#wp-content-wrap').hasClass('tmce-active') && typeof tinymce != 'undefined' ) { + tinymce.onAddEditor.add( function( tinymce, editor ) { + if ( 'content' == editor.id ) { + editor.onLoad.add( function() { + editor.save(); + autosaveLast = ( $('#title').val() || '' ) + ( $('#content').val() || '' ); + }); + } + }); + } else { + autosaveLast = ( $('#title').val() || '' ) + ( $('#content').val() || '' ); + } + autosavePeriodical = $.schedule({time: autosaveL10n.autosaveInterval * 1000, func: function() { autosave(); }, repeat: true, protect: true}); //Disable autosave after the form has been submitted