Ticket #27389: 27389.combined.2.diff
File 27389.combined.2.diff, 5.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/mce-view.js
41 41 doc = editor.getDoc(); 42 42 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { 43 43 var node = $( elem ); 44 node.html( html ) ;44 node.html( html ).append( '<span data-wp-view-end class="wp-view-end"></span>' ); 45 45 $( self ).trigger( 'ready', elem ); 46 46 }); 47 47 } … … 339 339 * @mixin 340 340 */ 341 341 wp.mce.media = { 342 loaded: false, 342 343 /** 343 344 * @global wp.shortcode 344 345 * … … 410 411 */ 411 412 wp.mce.media.View = wp.mce.View.extend({ 412 413 initialize: function( options ) { 414 this.players = {}; 413 415 this.shortcode = options.shortcode; 416 this.parsing = 0; 414 417 _.bindAll( this, 'setPlayer' ); 415 418 $(this).on( 'ready', this.setPlayer ); 416 419 }, 417 420 421 countShortcodes: function () { 422 var size = 0, self = this; 423 _.each( tinymce.editors, function( editor ) { 424 var doc; 425 if ( editor.plugins.wpview ) { 426 doc = editor.getDoc(); 427 size += $( doc ).find( '[data-wpview-text="' + self.encodedText + '"]' ).length; 428 } 429 } ); 430 431 return size; 432 }, 433 418 434 /** 419 435 * Creates the player instance for the current node 420 436 * … … 435 451 firefox = this.ua.is( 'ff' ), 436 452 className = '.wp-' + this.shortcode.tag + '-shortcode'; 437 453 438 if ( this.player ) { 439 this.unsetPlayer(); 440 } 454 this.size = this.countShortcodes(); 455 this.pauseAllPlayers(); 441 456 442 457 media = $( node ).find( className ); 443 458 … … 459 474 460 475 media = wp.media.view.MediaDetails.prepareSrc( media.get(0) ); 461 476 462 setTimeout( function() { 463 self.player = new MediaElementPlayer( media, this.mejsSettings ); 464 }, 75 ); 477 setTimeout( function () { 478 var player = new MediaElementPlayer( media, this.mejsSettings ); 479 480 wp.mce.media.loaded = true; 481 if ( self.players[ self.parsing ] ) { 482 self.removePlayer( self.players[ self.parsing ] ); 483 } 484 self.players[ self.parsing ] = player; 485 self.parsing += 1; 486 if ( self.parsing === self.size ) { 487 self.parsing = 0; 488 } 489 }, wp.mce.media.loaded ? 10 : 500 ); 465 490 }, 466 491 467 492 /** -
src/wp-includes/js/media-audiovideo.js
128 128 * MediaElement tries to pull the audio/video tag out of 129 129 * its container and re-add it to the DOM. 130 130 */ 131 removePlayer: function( ) {132 var t = this.player,featureIndex, feature;131 removePlayer: function(t) { 132 var featureIndex, feature; 133 133 134 134 // invoke features cleanup 135 135 for ( featureIndex in t.options.features ) { … … 145 145 t.$node.remove(); 146 146 } 147 147 148 if ( 'native' !== t.media.pluginType ) { 149 t.media.remove(); 150 } 148 t.media.remove(); 151 149 152 150 delete window.mejs.players[t.id]; 153 151 154 t.container.remove(); 152 if (typeof t.container == 'object') { 153 t.container.remove(); 154 } 155 155 t.globalUnbind(); 156 156 delete t.node.player; 157 157 }, … … 165 165 unsetPlayer : function() { 166 166 if ( this.player ) { 167 167 wp.media.mixin.pauseAllPlayers(); 168 wp.media.mixin.removePlayer .apply( this);168 wp.media.mixin.removePlayer( this.player ); 169 169 this.player = false; 170 170 } 171 171 } -
src/wp-includes/js/mediaelement/wp-mediaelement.css
72 72 max-width: 100%; 73 73 } 74 74 75 .wp-playlist audio {75 .wp-playlist audio, audio.wp-audio-shortcode { 76 76 display: none; 77 77 max-width: 100%; 78 78 width: 400px; -
src/wp-includes/js/tinymce/plugins/wpview/plugin.js
141 141 } 142 142 143 143 editor.on( 'BeforeAddUndo', function( event ) { 144 if ( selected && ! toRemove ) { 145 event.preventDefault(); 144 var replace, 145 previousContent, 146 content; 147 148 replace = function( content ) { 149 return content.replace(/(<div[^>]+wpview-wrap[^>]+>)([\s\S]+)(<span[^>]+data-wp-view-end[^>]+><\/span><\/div>)/mg, '$`$1$3$\'' ); 150 }; 151 152 if ( event.lastLevel ) { 153 previousContent = replace( event.lastLevel.content ); 154 content = replace( event.level.content ); 155 156 if ( content === previousContent ) { 157 event.preventDefault(); 158 } 146 159 } 147 160 }); 148 161 … … 162 175 editor.on( 'SetContent', function( event ) { 163 176 var body, padNode; 164 177 165 // don't (re-)render views if the format of the content is raw 166 // to avoid adding additional undo levels on undo/redo 167 if ( event.format !== 'raw' ) { 168 wp.mce.views.render(); 169 } 178 wp.mce.views.render(); 170 179 171 180 // Add padding <p> if the noneditable node is last 172 181 if ( event.load || ! event.set ) {