Changeset 24749
- Timestamp:
- 07/19/2013 01:39:48 AM (11 years ago)
- Location:
- trunk/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/autosave.js
r24747 r24749 247 247 function autosave_enable_buttons() { 248 248 jQuery(document).trigger('autosave-enable-buttons'); 249 if ( ! wp.heartbeat. connectionLost) {249 if ( ! wp.heartbeat.hasConnectionError() ) { 250 250 // delay that a bit to avoid some rare collisions while the DOM is being updated. 251 251 setTimeout(function(){ -
trunk/wp-includes/js/heartbeat.js
r24705 r24749 41 41 userActiveEvents, 42 42 winBlurTimeout, 43 frameBlurTimeout = -1; 44 45 this.autostart = true; 46 this.connectionLost = false; 43 frameBlurTimeout = -1, 44 hasConnectionError = false; 45 46 /** 47 * Returns a boolean that's indicative of whether or not there is a connection error 48 * 49 * @returns boolean 50 * @private 51 */ 52 this.hasConnectionError = function() { 53 return hasConnectionError; 54 }; 47 55 48 56 if ( typeof( window.heartbeatSettings ) == 'object' ) { … … 122 130 } 123 131 124 if ( trigger && ! self. connectionLost) {125 self.connectionLost= true;132 if ( trigger && ! self.hasConnectionError() ) { 133 hasConnectionError = true; 126 134 $(document).trigger( 'heartbeat-connection-lost', [error] ); 127 135 } 128 } else if ( self. connectionLost) {136 } else if ( self.hasConnectionError() ) { 129 137 errorcount = 0; 130 self.connectionLost= false;138 hasConnectionError = false; 131 139 $(document).trigger( 'heartbeat-connection-restored' ); 132 140 } … … 153 161 // If nothing to send (nothing is expecting a response), 154 162 // schedule the next tick and bail 155 if ( empty && ! self. connectionLost) {163 if ( empty && ! self.hasConnectionError() ) { 156 164 connecting = false; 157 165 next(); … … 180 188 181 189 // Clear error state 182 if ( self. connectionLost)190 if ( self.hasConnectionError() ) 183 191 errorstate(); 184 192 … … 206 214 self.error( jqXHR, textStatus, error ); 207 215 }); 208 } ;216 } 209 217 210 218 function next() { … … 333 341 // Check for user activity every 30 seconds. 334 342 window.setInterval( function(){ checkUserActive(); }, 30000 ); 335 336 if ( this.autostart ) { 337 $(document).ready( function() { 338 // Start one tick (15 sec) after DOM ready 339 running = true; 340 tick = time(); 341 next(); 342 }); 343 } 343 $(document).ready( function() { 344 // Start one tick (15 sec) after DOM ready 345 running = true; 346 tick = time(); 347 next(); 348 }); 344 349 345 350 this.hasFocus = function() { 346 351 return hasFocus; 347 } 352 }; 348 353 349 354 /** … … 401 406 return tempInterval ? tempInterval / 1000 : interval / 1000; 402 407 }; 403 404 // Start. Has no effect if heartbeat is already running405 this.start = function() {406 if ( running )407 return false;408 409 running = true;410 connect();411 return true;412 };413 414 // Stop. If a XHR is in progress, abort it415 this.stop = function() {416 if ( self.xhr && self.xhr.readyState != 4 )417 self.xhr.abort();418 419 // Reset the error state420 errorstate();421 running = false;422 return true;423 }424 408 425 409 /** … … 448 432 } 449 433 return false; 450 } 434 }; 451 435 452 436 /** … … 458 442 this.isQueued = function( handle ) { 459 443 return queue[handle]; 460 } 461 } 444 }; 445 }; 462 446 463 447 $.extend( Heartbeat.prototype, {
Note: See TracChangeset
for help on using the changeset viewer.