- );
- }
-}
-
-function autosave_loading() {
- jQuery('.autosave-message').html(autosaveL10n.savingText);
-}
-
-function autosave_enable_buttons() {
- jQuery(document).trigger('autosave-enable-buttons');
- if ( ! wp.heartbeat || ! wp.heartbeat.hasConnectionError() ) {
- // delay that a bit to avoid some rare collisions while the DOM is being updated.
- setTimeout(function(){
- var parent = jQuery('#submitpost');
- parent.find(':button, :submit').removeAttr('disabled');
- parent.find('.spinner').hide();
- }, 500);
- }
-}
-
-function autosave_disable_buttons() {
- jQuery(document).trigger('autosave-disable-buttons');
- jQuery('#submitpost').find(':button, :submit').prop('disabled', true);
- // Re-enable 5 sec later. Just gives autosave a head start to avoid collisions.
- setTimeout( autosave_enable_buttons, 5000 );
-}
-
-function delayed_autosave() {
- setTimeout(function(){
- if ( blockSave )
- return;
- autosave();
- }, 200);
-}
-
-autosave = function() {
- var post_data = wp.autosave.getPostData(),
- compareString,
- successCallback;
-
- blockSave = true;
-
- // post_data.content cannot be retrieved at the moment
- if ( ! post_data.autosave )
- return false;
-
- // No autosave while thickbox is open (media buttons)
- if ( jQuery("#TB_window").css('display') == 'block' )
- return false;
-
- compareString = wp.autosave.getCompareString( post_data );
-
- // Nothing to save or no change.
- if ( compareString == autosaveLast )
- return false;
-
- autosaveLast = compareString;
- jQuery(document).triggerHandler('wpcountwords', [ post_data["content"] ]);
-
- // Disable buttons until we know the save completed.
- autosave_disable_buttons();
-
- if ( post_data["auto_draft"] == '1' ) {
- successCallback = autosave_saved_new; // new post
- } else {
- successCallback = autosave_saved; // pre-existing post
- }