diff --git src/wp-includes/js/mce-view.js src/wp-includes/js/mce-view.js
index 1e8a1de..5caf801 100644
|
|
|
window.wp = window.wp || {}; |
| 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 ) ) { |
| … |
… |
window.wp = window.wp || {}; |
| 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 ); |
| … |
… |
window.wp = window.wp || {}; |
| 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's |
| 559 | | * associated attachments. |
| 560 | | * |
| 561 | | * @param {Event} e |
| 562 | | * @param {HTMLElement} node |
| 563 | | */ |
| 564 | | setNode: function(e, node) { |
| 565 | | this.node = node; |
| 566 | 545 | this.fetch(); |
| 567 | 546 | }, |
| 568 | 547 | |
| … |
… |
window.wp = window.wp || {}; |
| 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 | /** |
| … |
… |
window.wp = window.wp || {}; |
| 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; |
| 590 | | |
| 591 | | this.unsetPlayer(); |
| | 564 | render: function() { |
| | 565 | var html = this.getHtml(), self = this; |
| 592 | 566 | |
| 593 | 567 | _.each( tinymce.editors, function( editor ) { |
| 594 | 568 | var doc; |
| 595 | 569 | if ( editor.plugins.wpview ) { |
| 596 | 570 | doc = editor.getDoc(); |
| 597 | | $( doc ).find( '[data-wpview-text="' + t + '"]' ).each(function(i, elem) { |
| | 571 | $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) { |
| 598 | 572 | var node = $( elem ); |
| 599 | | node.html( html ); |
| 600 | | self.node = elem; |
| 601 | | }); |
| 602 | | } |
| 603 | | }, this ); |
| 604 | 573 | |
| 605 | | if ( ! this.data.tracks ) { |
| 606 | | return; |
| 607 | | } |
| | 574 | // The <ins> is used to mark the end of the wrapper div. Needed when comparing |
| | 575 | // the content as string for preventing extra undo levels. |
| | 576 | node.html( html ).append( '<ins data-wpview-end="1"></ins>' ); |
| 608 | 577 | |
| 609 | | p = new WPPlaylistView({ |
| 610 | | el: $( self.node ).find( '.wp-playlist' ).get(0), |
| 611 | | metadata: this.data |
| 612 | | }); |
| | 578 | if ( ! self.data.tracks ) { |
| | 579 | return; |
| | 580 | } |
| 613 | 581 | |
| 614 | | this.player = p.player; |
| | 582 | self.players.push( new WPPlaylistView({ |
| | 583 | el: $( elem ).find( '.wp-playlist' ).get(0), |
| | 584 | metadata: self.data |
| | 585 | }).player ); |
| | 586 | }); |
| | 587 | } |
| | 588 | }, this ); |
| 615 | 589 | }, |
| 616 | 590 | |
| 617 | 591 | /** |
| … |
… |
window.wp = window.wp || {}; |
| 695 | 669 | this.data = options; |
| 696 | 670 | |
| 697 | 671 | return this.template( options ); |
| | 672 | }, |
| | 673 | |
| | 674 | unbind: function() { |
| | 675 | this.unsetPlayers(); |
| 698 | 676 | } |
| 699 | 677 | }); |
| 700 | 678 | _.extend( wp.mce.media.PlaylistView.prototype, wp.media.mixin ); |
diff --git src/wp-includes/js/media-audiovideo.js src/wp-includes/js/media-audiovideo.js
index da91a9c..47f6d36 100644
|
|
|
|
| 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 | |
diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php
index 202fd07..a3300e5 100644
|
|
|
|
| 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 }}" |
diff --git src/wp-includes/media.php src/wp-includes/media.php
index e9b4a1d..fe5b63b 100644
|
|
|
function wp_playlist_shortcode( $attr ) { |
| 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> |
| … |
… |
function wp_audio_shortcode( $attr, $content = '' ) { |
| 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 |