Ticket #32593: 32593.patch
File 32593.patch, 2.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
501 501 } 502 502 } ); 503 503 504 if ( self.iframeHeight ) { 505 dom.add( contentNode, 'div', { style: { 506 width: '100%', 507 height: self.iframeHeight 508 } } ); 509 } 510 504 511 // Seems the browsers need a bit of time to insert/set the view nodes, 505 512 // or the iframe will fail especially when switching Text => Visual. 506 513 setTimeout( function() { … … 518 525 style: { 519 526 width: '100%', 520 527 display: 'block' 521 } 528 }, 529 height: self.iframeHeight 522 530 } ); 523 531 524 532 dom.add( contentNode, 'div', { 'class': 'wpview-overlay' } ); … … 561 569 iframeDoc.close(); 562 570 563 571 function resize() { 564 var $iframe , iframeDocHeight;572 var $iframe; 565 573 566 574 // Make sure the iframe still exists. 567 575 if ( iframe.contentWindow ) { 568 576 $iframe = $( iframe ); 569 iframeDocHeight = $( iframeDoc.body ).height();577 self.iframeHeight = $( iframeDoc.body ).height(); 570 578 571 if ( $iframe.height() !== iframeDocHeight ) {572 $iframe.height( iframeDocHeight );579 if ( $iframe.height() !== self.iframeHeight ) { 580 $iframe.height( self.iframeHeight ); 573 581 editor.nodeChanged(); 574 582 } 575 583 } 576 584 } 577 585 578 $( iframe.contentWindow ).on( 'load', resize ); 586 if ( ! self.iframeHeight ) { 587 $( iframe.contentWindow ).on( 'load', resize ); 579 588 580 if ( MutationObserver ) {581 observer = new MutationObserver( _.debounce( resize, 100 ) );589 if ( MutationObserver ) { 590 observer = new MutationObserver( _.debounce( resize, 100 ) ); 582 591 583 observer.observe( iframeDoc.body, { 584 attributes: true, 585 childList: true, 586 subtree: true 587 } ); 588 589 $( node ).one( 'wp-mce-view-unbind', function() { 590 observer.disconnect(); 591 } ); 592 } else { 593 for ( i = 1; i < 6; i++ ) { 594 setTimeout( resize, i * 700 ); 592 observer.observe( iframeDoc.body, { 593 attributes: true, 594 childList: true, 595 subtree: true 596 } ); 597 598 $( node ).one( 'wp-mce-view-unbind', function() { 599 observer.disconnect(); 600 } ); 601 } else { 602 for ( i = 1; i < 6; i++ ) { 603 setTimeout( resize, i * 700 ); 604 } 595 605 } 596 606 } 597 607