Ticket #31669: 31669.3.patch
File 31669.3.patch, 3.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
77 77 */ 78 78 unbind: function() { 79 79 _.each( instances, function( instance ) { 80 instance.unbind ();80 instance.unbindAll(); 81 81 } ); 82 82 }, 83 83 … … 307 307 } 308 308 309 309 // We're about to rerender all views of this instance, so unbind rendered views. 310 force && this.unbind ();310 force && this.unbindAll(); 311 311 312 312 // Replace any left over markers. 313 313 this.replaceMarkers(); 314 314 315 315 if ( this.getContent() ) { 316 316 this.setContent( this.getContent(), function( editor, node ) { 317 $( node ).data( 'rendered', true ).trigger( 'wp-mce-view-bind' ); 317 $( node ).data( 'rendered', true ); 318 this.bind.apply( this, arguments ); 318 319 }, force ? null : false ); 319 320 } else { 320 321 this.setLoader(); … … 322 323 }, 323 324 324 325 /** 326 * Binds a given node after its content is added to the DOM. 327 */ 328 bind: function() {}, 329 330 /** 331 * Unbinds a given node before its content is removed from the DOM. 332 */ 333 unbind: function() {}, 334 335 /** 325 336 * Unbinds all view nodes tied to this view instance. 326 337 * Runs before their content is removed from the DOM. 327 338 */ 328 unbind : function() {339 unbindAll: function() { 329 340 this.getNodes( function( editor, node ) { 341 this.unbind.apply( this, arguments ); 330 342 $( node ).trigger( 'wp-mce-view-unbind' ); 331 343 }, true ); 332 344 }, … … 461 473 * @param {Boolean} rendered Only set for (un)rendered nodes. Optional. 462 474 */ 463 475 setIframes: function( head, body, callback, rendered ) { 464 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 476 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 477 self = this; 465 478 466 479 this.getNodes( function( editor, node, content ) { 467 480 // Seems Firefox needs a bit of time to insert/set the view nodes, … … 582 595 editor.off( 'wp-body-class-change', classChange ); 583 596 } ); 584 597 585 callback && callback.apply( this, arguments );598 callback && callback.apply( self, arguments ); 586 599 }, 50 ); 587 600 }, rendered ); 588 601 }, … … 663 676 * @param {HTMLElement} node The view node to remove. 664 677 */ 665 678 remove: function( editor, node ) { 679 this.unbind.call( this, editor, node, $( node ).find( '.wpview-content' ).get( 0 ) ); 666 680 $( node ).trigger( 'wp-mce-view-unbind' ); 667 681 editor.dom.remove( node ); 668 682 } -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
169 169 editor.on( 'BeforeSetContent', function( event ) { 170 170 var node; 171 171 172 if ( event.format === 'raw' ) { 173 wp.mce.views.unbind(); 174 } 175 172 176 if ( ! event.content ) { 173 177 return; 174 178 }