Changeset 29187
- Timestamp:
- 07/16/2014 03:39:05 PM (10 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-editor.php
r29177 r29187 504 504 $version = 'ver=' . $GLOBALS['wp_version']; 505 505 $dashicons = includes_url( "css/dashicons$suffix.css?$version" ); 506 $mediaelement = includes_url( "js/mediaelement/mediaelementplayer.min.css?$version" );507 $wpmediaelement = includes_url( "js/mediaelement/wp-mediaelement.css?$version" );508 506 509 507 // WordPress default stylesheet and dashicons 510 508 $mce_css = array( 511 509 $dashicons, 512 $mediaelement,513 $wpmediaelement,514 510 self::$baseurl . '/skins/wordpress/wp-content.css?' . $version 515 511 ); -
trunk/src/wp-includes/js/mce-view.js
r29184 r29187 70 70 }, 71 71 unbind: function() {}, 72 setContent: function( html, callback, option ) { 72 getNodes: function( callback ) { 73 var nodes = []; 74 73 75 _.each( tinymce.editors, function( editor ) { 74 var self = this;75 76 if ( editor.plugins.wpview ) { 76 77 $( editor.getBody() ) 77 78 .find( '[data-wpview-text="' + this.encodedText + '"]' ) 78 .each( function ( i, element ) { 79 var contentWrap = $( element ).find( '.wpview-content' ), 80 wrap = element; 81 82 if ( contentWrap.length && option !== 'wrap' ) { 83 element = contentWrap = contentWrap[0]; 79 .each( function ( i, node ) { 80 if ( callback ) { 81 callback( editor, node ); 84 82 } 85 83 86 if ( _.isString( html ) ) { 87 if ( option === 'replace' ) { 88 element = editor.dom.replace( editor.dom.createFragment( html ), wrap ); 89 } else { 90 editor.dom.setHTML( element, html ); 91 } 92 } else { 93 if ( option === 'replace' ) { 94 element = editor.dom.replace( html, wrap ); 95 } else { 96 $( element ).empty().append( html ); 97 } 98 } 99 100 if ( _.isFunction( callback ) ) { 101 callback( self, editor, $( element ).find( '.wpview-content' )[0] ); 84 nodes.push( node ); 85 } ); 86 } 87 }, this ); 88 89 return nodes; 90 }, 91 setContent: function( html, callback, option ) { 92 var self = this; 93 94 this.getNodes( function ( editor, element ) { 95 var contentWrap = $( element ).find( '.wpview-content' ), 96 wrap = element; 97 98 if ( contentWrap.length && option !== 'wrap' ) { 99 element = contentWrap = contentWrap[0]; 100 } 101 102 if ( _.isString( html ) ) { 103 if ( option === 'replace' ) { 104 element = editor.dom.replace( editor.dom.createFragment( html ), wrap ); 105 } else { 106 editor.dom.setHTML( element, html ); 107 } 108 } else { 109 if ( option === 'replace' ) { 110 element = editor.dom.replace( html, wrap ); 111 } else { 112 $( element ).empty().append( html ); 113 } 114 } 115 116 if ( _.isFunction( callback ) ) { 117 callback( self, editor, $( element ).find( '.wpview-content' )[0] ); 118 } 119 } ); 120 }, 121 122 /* jshint scripturl: true */ 123 createIframe: function ( content ) { 124 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 125 126 if ( content.indexOf( '<script' ) !== -1 ) { 127 this.getNodes( function ( editor, node ) { 128 var dom = editor.dom, 129 iframe, iframeDoc, i, resize; 130 131 node = $( node ).find( '.wpview-content' )[0]; 132 133 node.innerHTML = ''; 134 135 iframe = dom.add( node, 'iframe', { 136 src: tinymce.Env.ie ? 'javascript:""' : '', 137 frameBorder: '0', 138 allowTransparency: 'true', 139 scrolling: 'no', 140 style: { 141 width: '100%', 142 display: 'block' 102 143 } 103 144 } ); 104 } 105 }, this ); 106 }, 107 108 /* jshint scripturl: true */ 109 createIframe: function ( content ) { 110 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 111 iframe, iframeDoc, i, resize, 112 dom = tinymce.DOM; 113 114 if ( content.indexOf( '<script' ) !== -1 ) { 115 iframe = dom.create( 'iframe', { 116 src: tinymce.Env.ie ? 'javascript:""' : '', 117 frameBorder: '0', 118 allowTransparency: 'true', 119 scrolling: 'no', 120 style: { 121 width: '100%', 122 display: 'block' 123 } 124 } ); 125 126 this.setContent( iframe ); 127 iframeDoc = iframe.contentWindow.document; 128 129 iframeDoc.open(); 130 iframeDoc.write( 131 '<!DOCTYPE html>' + 132 '<html>' + 133 '<head>' + 134 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + 135 '</head>' + 136 '<body style="padding: 0; margin: 0;" class="' + dom.doc.body.className + '">' + 137 content + 138 '</body>' + 139 '</html>' 140 ); 141 iframeDoc.close(); 142 143 resize = function() { 144 $( iframe ).height( $( iframeDoc.body ).height() ); 145 }; 146 147 if ( MutationObserver ) { 148 new MutationObserver( _.debounce( function() { 149 resize(); 150 }, 100 ) ) 151 .observe( iframeDoc.body, { 152 attributes: true, 153 childList: true, 154 subtree: true 155 } ); 156 } else { 157 for ( i = 1; i < 6; i++ ) { 158 setTimeout( resize, i * 700 ); 159 } 160 } 145 146 iframeDoc = iframe.contentWindow.document; 147 148 iframeDoc.open(); 149 iframeDoc.write( 150 '<!DOCTYPE html>' + 151 '<html>' + 152 '<head>' + 153 '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />' + 154 '</head>' + 155 '<body style="padding: 0; margin: 0;" class="' + /* editor.getBody().className + */ '">' + 156 content + 157 '</body>' + 158 '</html>' 159 ); 160 iframeDoc.close(); 161 162 resize = function() { 163 $( iframe ).height( $( iframeDoc.body ).height() ); 164 }; 165 166 if ( MutationObserver ) { 167 new MutationObserver( _.debounce( function() { 168 resize(); 169 }, 100 ) ) 170 .observe( iframeDoc.body, { 171 attributes: true, 172 childList: true, 173 subtree: true 174 } ); 175 } else { 176 for ( i = 1; i < 6; i++ ) { 177 setTimeout( resize, i * 700 ); 178 } 179 } 180 }); 161 181 } else { 162 182 this.setContent( content ); … … 479 499 */ 480 500 wp.mce.av = { 481 loaded: false,482 483 501 View: { 484 502 overlay: true, … … 538 556 539 557 /** 540 * Pass data to the View's Underscore template and return the compiled output558 * Return parsed response 541 559 * 542 560 * @returns {string} … … 544 562 getHtml: function() { 545 563 if ( ! this.parsed ) { 546 return ' ';564 return ' '; 547 565 } 548 566 return this.parsed; … … 640 658 _.bindAll( this, 'createIframe', 'setNode', 'fetch' ); 641 659 $( this ).on( 'ready', this.setNode ); 660 }, 661 662 /** 663 * Return parsed response 664 * 665 * @returns {string} 666 */ 667 getHtml: function() { 668 if ( ! this.parsed ) { 669 return ''; 670 } 671 return this.parsed; 642 672 } 643 673 } ),
Note: See TracChangeset
for help on using the changeset viewer.