Ticket #29841: 29841.2.patch
File 29841.2.patch, 5.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
43 43 return ''; 44 44 }, 45 45 loadingPlaceholder: function() { 46 return '' +46 return ( 47 47 '<div class="loading-placeholder">' + 48 48 '<div class="dashicons dashicons-admin-media"></div>' + 49 49 '<div class="wpview-loading"><ins></ins></div>' + 50 '</div>'; 50 '</div>' 51 ); 51 52 }, 52 53 render: function( force ) { 53 if ( force || ! this.rendered() ) { 54 var self = this; 55 56 if ( ( ! this.loadingPlaceholder || ! this.loadingPlaceholder() ) && ! this.getHtml() ) { 57 return; 58 } 59 60 if ( force ) { 54 61 this.unbind(); 62 this.setContent( this.getHtml() || this.loadingPlaceholder() ); 63 } 55 64 56 this.setContent( 57 '<p class="wpview-selection-before">\u00a0</p>' + 58 '<div class="wpview-body" contenteditable="false">' + 59 '<div class="toolbar mce-arrow-down">' + 60 ( _.isFunction( views[ this.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) + 61 '<div class="dashicons dashicons-no remove"></div>' + 62 '</div>' + 63 '<div class="wpview-content wpview-type-' + this.type + '">' + 64 ( this.getHtml() || this.loadingPlaceholder() ) + 65 '</div>' + 66 ( this.overlay ? '<div class="wpview-overlay"></div>' : '' ) + 67 '</div>' + 68 '<p class="wpview-selection-after">\u00a0</p>', 69 'wrap' 70 ); 65 this.getEditors( function( editor ) { 66 $( editor.getBody() ) 67 .find( '[data-wpview-marked="' + self.encodedText + '"]' ) 68 .each( function ( i, node ) { 69 if ( $( node ).text() !== decodeURIComponent( self.encodedText ) ) { 70 editor.dom.setAttrib( 'data-wpview-marked', null ); 71 } 71 72 72 $( this ).trigger( 'ready' ); 73 editor.dom.replace( 74 editor.dom.createFragment( 75 '<div class="wpview-wrap" data-wpview-text="' + self.encodedText + '" data-wpview-type="' + self.type + '">' + 76 '<p class="wpview-selection-before">\u00a0</p>' + 77 '<div class="wpview-body" contenteditable="false">' + 78 '<div class="toolbar mce-arrow-down">' + 79 ( _.isFunction( views[ self.type ].edit ) ? '<div class="dashicons dashicons-edit edit"></div>' : '' ) + 80 '<div class="dashicons dashicons-no remove"></div>' + 81 '</div>' + 82 '<div class="wpview-content wpview-type-' + self.type + '">' + 83 ( self.getHtml() || self.loadingPlaceholder() ) + 84 '</div>' + 85 ( self.overlay ? '<div class="wpview-overlay"></div>' : '' ) + 86 '</div>' + 87 '<p class="wpview-selection-after">\u00a0</p>' + 88 '</div>' 89 ), 90 node 91 ); 92 } ); 93 } ); 73 94 74 this.rendered( true ); 75 } 95 $( this ).trigger( 'ready' ); 76 96 }, 77 97 unbind: function() {}, 78 98 getEditors: function( callback ) { … … 110 130 }, 111 131 setContent: function( html, option ) { 112 132 this.getNodes( function ( editor, node, content ) { 113 var el = ( option === 'wrap' || option === 'replace' ) ? node : content, 114 insert = html; 115 116 if ( _.isString( insert ) ) { 117 insert = editor.dom.createFragment( insert ); 118 } 119 120 if ( option === 'replace' ) { 121 editor.dom.replace( insert, el ); 122 } else { 123 el.innerHTML = ''; 124 el.appendChild( insert ); 125 } 133 content.innerHTML = ''; 134 content.appendChild( _.isString( html ) ? editor.dom.createFragment( html ) : html ); 126 135 } ); 127 136 }, 128 137 /* jshint scripturl: true */ … … 254 263 '<p>' + message + '</p>' + 255 264 '</div>' 256 265 ); 257 },258 rendered: function( value ) {259 var notRendered;260 261 this.getNodes( function( editor, node ) {262 if ( value != null ) {263 $( node ).data( 'rendered', value === true );264 } else {265 notRendered = notRendered || ! $( node ).data( 'rendered' );266 }267 } );268 269 return ! notRendered;270 266 } 271 267 } ); 272 268 … … 432 428 instances[ encodedText ] = instance; 433 429 } 434 430 435 return wp.html.string({ 436 tag: 'div', 437 438 attrs: { 439 'class': 'wpview-wrap', 440 'data-wpview-text': encodedText, 441 'data-wpview-type': viewType 442 }, 443 444 content: '\u00a0' 445 }); 431 return '<p data-wpview-marked="' + encodedText + '">' + text + '</p>'; 446 432 }, 447 433 448 434 /** … … 681 667 } 682 668 } ) 683 669 .done( function( response ) { 684 if ( response ) { 685 self.parsed = response; 686 self.setIframes( response.head, response.body ); 687 self.deferredListen(); 688 } else { 689 self.fail( true ); 690 } 670 self.parsed = response; 671 self.render(); 691 672 } ) 692 673 .fail( function( response ) { 693 674 self.fail( response || true ); … … 742 723 743 724 unbind: function() { 744 725 this.stopPlayers( 'remove' ); 726 }, 727 728 getHtml: function() { 729 return this.parsed ? '\u00a0' : ''; 745 730 } 746 731 }, 747 732 … … 891 876 url: match[2] 892 877 } 893 878 }; 894 } 879 }, 880 View: _.extend( {}, wp.mce.embedMixin.View, { 881 loadingPlaceholder: false 882 } ) 895 883 } ) ); 896 884 897 885 }(jQuery));