From 88e774f7a018fbf99262229261c238934e85dbb7 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: https://develop.svn.wordpress.org/trunk@24431 602fd350-edb4-49c9-b593-d223f7449a82 --- 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