Ticket #24756: 24756-4.patch
File 24756-4.patch, 4.4 KB (added by , 12 years ago) |
---|
-
wp-includes/js/autosave.js
524 524 init: function( settings ) { 525 525 var self = this; 526 526 527 // Check if the browser supports sessionStorage and editor.js is loaded528 if ( ! this.checkStorage() || typeof switchEditors == 'undefined')527 // Check if the browser supports sessionStorage and it's not disabled 528 if ( ! this.checkStorage() ) 529 529 return; 530 530 531 531 // Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. … … 538 538 if ( !this.blog_id ) 539 539 this.blog_id = typeof window.autosaveL10n != 'undefined' ? window.autosaveL10n.blog_id : 0; 540 540 541 this.checkPost();542 541 $(document).ready( function(){ self.run(); } ); 543 542 }, 544 543 545 544 // Run on DOM ready 546 545 run: function() { 547 var self = this , post_data;546 var self = this; 548 547 549 // Set the comparison string 550 if ( !this.lastsaveddata ) { 551 post_data = wp.autosave.getPostData(); 548 // Check if the local post data is different than the loaded post data. 549 this.checkPost(); 552 550 553 if ( post_data.content && $('#wp-content-wrap').hasClass('tmce-active') )554 this.lastsaveddata = post_data.post_title + ': ' + switchEditors.pre_wpautop( post_data.content );555 else556 this.lastsaveddata = post_data.post_title + ': ' + post_data.content;557 }558 559 551 // Set the schedule 560 552 this.schedule = $.schedule({ 561 553 time: 15 * 1000, … … 605 597 * @return void 606 598 */ 607 599 checkPost: function() { 608 var self = this, post_data = this.getData(), content, check_data, strip_tags = false, notice,600 var self = this, post_data = this.getData(), content, post_title, excerpt, notice, 609 601 post_id = $('#post_ID').val() || 0, cookie = wpCookies.get( 'wp-saving-post-' + post_id ); 610 602 611 603 if ( ! post_data ) … … 625 617 if ( $('#has-newer-autosave').length ) 626 618 return; 627 619 628 // cookie == 'check' means the post was not saved properly, always show #local-storage-notice 629 if ( cookie != 'check' ) { 630 content = $('#content').val(); 631 check_data = $.extend( {}, post_data ); 620 content = $('#content').val() || ''; 621 post_title = $('#title').val() || ''; 622 excerpt = $('#excerpt').val() || ''; 632 623 633 if ( $('#wp-content-wrap').hasClass('tmce-active'))634 624 if ( $('#wp-content-wrap').hasClass('tmce-active') && typeof switchEditors != 'undefined' ) 625 content = switchEditors.pre_wpautop( content ); 635 626 636 if ( this.compare( content, check_data.content ) && this.compare( $('#title').val(), check_data.post_title ) && this.compare( $('#excerpt').val(), check_data.excerpt ) ) 637 return; 627 // cookie == 'check' means the post was not saved properly, always show #local-storage-notice 628 if ( cookie != 'check' && this.compare( content, post_data.content ) && this.compare( title, post_data.post_title ) && this.compare( excerpt, post_data.excerpt ) ) { 629 return; 638 630 } 639 631 640 632 this.restore_post_data = post_data; 641 this.undo_post_data = wp.autosave.getPostData(); 633 this.undo_post_data = { 634 content: content, 635 post_title: post_title, 636 excerpt: excerpt 637 }; 642 638 643 639 notice = $('#local-storage-notice'); 644 640 $('.wrap h2').first().after( notice.addClass('updated').show() ); … … 674 670 $('#excerpt').val( post_data.excerpt || '' ); 675 671 editor = typeof tinymce != 'undefined' && tinymce.get('content'); 676 672 677 if ( editor && ! editor.isHidden() ) {673 if ( editor && ! editor.isHidden() && typeof switchEditors != 'undefined' ) { 678 674 // Make sure there's an undo level in the editor 679 675 editor.undoManager.add(); 680 676 editor.setContent( post_data.content ? switchEditors.wpautop( post_data.content ) : '' ); -
wp-includes/script-loader.php
103 103 'dismiss' => __('Dismiss'), 104 104 ) ); 105 105 106 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response' , 'editor'), false, 1 );106 $scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), false, 1 ); 107 107 108 108 $scripts->add( 'heartbeat', "/wp-includes/js/heartbeat$suffix.js", array('jquery'), false, 1 ); 109 109 did_action( 'init' ) && $scripts->localize( 'heartbeat', 'heartbeatSettings',