Changeset 38158
- Timestamp:
- 07/26/2016 11:12:14 PM (8 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/mce-view.js
r38157 r38158 354 354 this.getNodes( function( editor, node ) { 355 355 this.unbindNode.call( this, editor, node ); 356 $( node ).trigger( 'wp-mce-view-unbind' );357 356 }, true ); 358 357 }, … … 395 394 } ) 396 395 .each( function() { 397 callback.call( self, editor, this );396 callback.call( self, editor, this, this /* back compat */ ); 398 397 } ); 399 398 } ); … … 430 429 431 430 $viewNode = editor.$( 432 '<div class="wpview " data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '" contenteditable="false"></div>'431 '<div class="wpview wpview-wrap" data-wpview-text="' + this.encodedText + '" data-wpview-type="' + this.type + '" contenteditable="false"></div>' 433 432 ); 434 433 … … 486 485 */ 487 486 setIframes: function( head, body, callback, rendered ) { 488 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 489 self = this; 487 var self = this; 490 488 491 489 this.getNodes( function( editor, node ) { … … 517 515 // or the iframe will fail especially when switching Text => Visual. 518 516 setTimeout( function() { 519 var iframe, iframe Doc, observer, i, block;517 var iframe, iframeWin, iframeDoc, MutationObserver, observer, i, block; 520 518 521 519 editor.undoManager.transact( function() { … … 548 546 } 549 547 550 iframe Doc = iframe.contentWindow.document;551 548 iframeWin = iframe.contentWindow; 549 iframeDoc = iframeWin.document; 552 550 iframeDoc.open(); 553 551 … … 613 611 } 614 612 615 $( iframe.contentWindow ).on( 'load', resize ); 613 $( iframeWin ).on( 'load', resize ); 614 615 MutationObserver = iframeWin.MutationObserver || iframeWin.WebKitMutationObserver || iframeWin.MozMutationObserver; 616 616 617 617 if ( MutationObserver ) { … … 623 623 subtree: true 624 624 } ); 625 626 $( node ).one( 'wp-mce-view-unbind', function() {627 observer.disconnect();628 } );629 625 } else { 630 626 for ( i = 1; i < 6; i++ ) { … … 632 628 } 633 629 } 634 635 function classChange() {636 iframeDoc.body.className = editor.getBody().className;637 }638 639 editor.on( 'wp-body-class-change', classChange );640 641 $( node ).one( 'wp-mce-view-unbind', function() {642 editor.off( 'wp-body-class-change', classChange );643 } );644 630 645 631 callback && callback.call( self, editor, node ); … … 727 713 remove: function( editor, node ) { 728 714 this.unbindNode.call( this, editor, node ); 729 $( node ).trigger( 'wp-mce-view-unbind' );730 715 editor.dom.remove( node ); 731 716 editor.focus(); -
trunk/src/wp-includes/js/tinymce/plugins/wpview/plugin.js
r37597 r38158 32 32 } 33 33 34 editor.on( 'init', function() { 35 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 36 37 if ( MutationObserver ) { 38 new MutationObserver( function() { 39 editor.fire( 'wp-body-class-change' ); 40 } ) 41 .observe( editor.getBody(), { 42 attributes: true, 43 attributeFilter: ['class'] 44 } ); 45 } 46 47 // Pass on body class name changes from the editor to the wpView iframes. 48 editor.on( 'wp-body-class-change', function() { 49 var className = editor.getBody().className; 50 51 editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) { 52 // Make sure it is a local iframe 53 // jshint scripturl: true 54 if ( ! iframe.src || iframe.src === 'javascript:""' ) { 55 try { 56 iframe.contentWindow.document.body.className = className; 57 } catch( er ) {} 58 } 59 }); 60 } ); 61 }); 62 34 63 // Scan new content for matching view patterns and replace them with markers. 35 64 editor.on( 'beforesetcontent', function( event ) {
Note: See TracChangeset
for help on using the changeset viewer.