Ticket #27899: 27899.2.diff
| File 27899.2.diff, 5.9 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/js/mce-view.js
451 451 firefox = this.ua.is( 'ff' ), 452 452 className = '.wp-' + this.shortcode.tag + '-shortcode'; 453 453 454 if ( this.player ) {455 this.unsetPlayer();456 }457 458 454 media = $( node ).find( className ); 459 455 460 456 if ( ! this.isCompatible( media ) ) { … … 495 491 }, 496 492 497 493 unbind: function() { 498 var self = this; 499 this.pauseAllPlayers(); 500 _.each( this.players, function (player) { 501 self.removePlayer( player ); 502 } ); 503 this.players = []; 494 this.unsetPlayers(); 504 495 } 505 496 }); 506 497 _.extend( wp.mce.media.View.prototype, wp.media.mixin ); … … 547 538 template: media.template('editor-playlist'), 548 539 549 540 initialize: function( options ) { 541 this.players = []; 550 542 this.data = {}; 551 543 this.attachments = []; 552 544 this.shortcode = options.shortcode; 553 _.bindAll( this, 'setPlayer' );554 $(this).on('ready', this.setNode);555 },556 557 /**558 * Set the element context for the view, and then fetch the playlist's559 * associated attachments.560 *561 * @param {Event} e562 * @param {HTMLElement} node563 */564 setNode: function(e, node) {565 this.node = node;566 545 this.fetch(); 567 546 }, 568 547 … … 571 550 */ 572 551 fetch: function() { 573 552 this.attachments = wp.media.playlist.attachments( this.shortcode ); 574 this. attachments.more().done( this.setPlayer);553 this.dfd = this.attachments.more().done( _.bind( this.render, this ) ); 575 554 }, 576 555 577 556 /** … … 582 561 * @global WPPlaylistView 583 562 * @global tinymce.editors 584 563 */ 585 setPlayer: function() { 586 var p, 587 html = this.getHtml(), 588 t = this.encodedText, 589 self = this; 564 render: function() { 565 var html = this.getHtml(), self = this; 590 566 591 this.unsetPlayer ();567 this.unsetPlayers(); 592 568 593 569 _.each( tinymce.editors, function( editor ) { 594 570 var doc; 595 571 if ( editor.plugins.wpview ) { 596 572 doc = editor.getDoc(); 597 $( doc ).find( '[data-wpview-text="' + t + '"]' ).each(function(i, elem) {573 $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { 598 574 var node = $( elem ); 599 node.html( html ); 600 self.node = elem; 575 576 // The <ins> is used to mark the end of the wrapper div. Needed when comparing 577 // the content as string for preventing extra undo levels. 578 node.html( html ).append( '<ins data-wpview-end="1"></ins>' ); 579 580 if ( ! self.data.tracks ) { 581 return; 582 } 583 584 self.players.push( new WPPlaylistView({ 585 el: $( elem ).find( '.wp-playlist' ).get(0), 586 metadata: self.data 587 }).player ); 601 588 }); 602 589 } 603 590 }, this ); 604 605 if ( ! this.data.tracks ) {606 return;607 }608 609 p = new WPPlaylistView({610 el: $( self.node ).find( '.wp-playlist' ).get(0),611 metadata: this.data612 });613 614 this.player = p.player;615 591 }, 616 592 617 593 /** -
src/wp-includes/js/media-audiovideo.js
162 162 * 163 163 * Examples: modal closes, shortcode properties are removed, etc. 164 164 */ 165 unsetPlayer : function() {166 if ( this.player ) {165 unsetPlayers : function() { 166 if ( this.players && this.players.length ) { 167 167 wp.media.mixin.pauseAllPlayers(); 168 wp.media.mixin.removePlayer( this.player ); 169 this.player = false; 168 _.each( this.players, function (player) { 169 wp.media.mixin.removePlayer( player ); 170 } ); 171 this.players = []; 170 172 } 171 173 } 172 174 }; … … 705 707 media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({ 706 708 initialize: function() { 707 709 _.bindAll(this, 'success'); 708 709 this.listenTo( this.controller, 'close', media.mixin.unsetPlayer );710 this.players = []; 711 this.listenTo( this.controller, 'close', media.mixin.unsetPlayers ); 710 712 this.on( 'ready', this.setPlayer ); 711 this.on( 'media:setting:remove', media.mixin.unsetPlayer , this );713 this.on( 'media:setting:remove', media.mixin.unsetPlayers, this ); 712 714 this.on( 'media:setting:remove', this.render ); 713 715 this.on( 'media:setting:remove', this.setPlayer ); 714 716 this.events = _.extend( this.events, { … … 764 766 * @global MediaElementPlayer 765 767 */ 766 768 setPlayer : function() { 767 if ( ! this.player && this.media ) {768 this.player = new MediaElementPlayer( this.media, this.settings);769 if ( ! this.players.length && this.media ) { 770 this.players.push( new MediaElementPlayer( this.media, this.settings ) ); 769 771 } 770 772 }, 771 773 -
src/wp-includes/media-template.php
16 16 function wp_underscore_audio_template() { 17 17 $audio_types = wp_get_audio_extensions(); 18 18 ?> 19 <audio controls 19 <audio style="visibility: hidden" 20 controls 20 21 class="wp-audio-shortcode" 21 22 width="{{ _.isUndefined( data.model.width ) ? 400 : data.model.width }}" 22 23 preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}" -
src/wp-includes/media.php
1353 1353 echo (int) $theme_width; 1354 1354 ?>"<?php if ( 'video' === $safe_type ): 1355 1355 echo ' height="', (int) $theme_height, '"'; 1356 else: 1357 echo ' style="visibility: hidden"'; 1356 1358 endif; ?>></<?php echo $safe_type ?>> 1357 1359 <div class="wp-playlist-next"></div> 1358 1360 <div class="wp-playlist-prev"></div> … … 1555 1557 'loop' => $loop, 1556 1558 'autoplay' => $autoplay, 1557 1559 'preload' => $preload, 1558 'style' => 'width: 100% ',1560 'style' => 'width: 100%; visibility: hidden;', 1559 1561 ); 1560 1562 1561 1563 // These ones should just be omitted altogether if they are blank