<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[28272] branches/3.9: Refinements for asynchronous rendering in `wp.mce.media.PlaylistView`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/28272">28272</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2014-05-06 04:48:28 +0000 (Tue, 06 May 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Refinements for asynchronous rendering in `wp.mce.media.PlaylistView`.
Merges <a href="http://core.trac.wordpress.org/changeset/28182">[28182]</a> to the 3.9 branch.
props gcorne, wonderboymusic.
fixes <a href="http://core.trac.wordpress.org/ticket/27899">#27899</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches39srcwpincludesjsmceviewjs">branches/3.9/src/wp-includes/js/mce-view.js</a></li>
<li><a href="#branches39srcwpincludesjsmediaaudiovideojs">branches/3.9/src/wp-includes/js/media-audiovideo.js</a></li>
<li><a href="#branches39srcwpincludesmediatemplatephp">branches/3.9/src/wp-includes/media-template.php</a></li>
<li><a href="#branches39srcwpincludesmediaphp">branches/3.9/src/wp-includes/media.php</a></li>
</ul>
<h3>Property Changed</h3>
<ul>
<li><a href="#branches39">branches/3.9/</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<span class="cx">Index: branches/3.9
</span><span class="cx">===================================================================
</span><del>--- branches/3.9 2014-05-06 04:44:56 UTC (rev 28271)
</del><ins>+++ branches/3.9 2014-05-06 04:48:28 UTC (rev 28272)
</ins><a id="branches39"></a>
<div class="propset"><h4>Property changes: branches/3.9</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx"> /branches/3.1:18031
</span><span class="cx"> /branches/3.3:20543
</span><span class="cx"> /branches/3.4:21757
</span><del>-/trunk:18512,28158,28161,28163,28165-28166,28168,28171-28174,28176-28181,28184-28187,28189-28191,28193-28195,28203,28219,28223,28266,28269
</del><ins>+/trunk:18512,28158,28161,28163,28165-28166,28168,28171-28174,28176-28182,28184-28187,28189-28191,28193-28195,28203,28219,28223,28266,28269
</ins><span class="cx">\ No newline at end of property
</span><a id="branches39srcwpincludesjsmceviewjs"></a>
<div class="modfile"><h4>Modified: branches/3.9/src/wp-includes/js/mce-view.js (28271 => 28272)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.9/src/wp-includes/js/mce-view.js 2014-05-06 04:44:56 UTC (rev 28271)
+++ branches/3.9/src/wp-includes/js/mce-view.js 2014-05-06 04:48:28 UTC (rev 28272)
</span><span class="lines">@@ -451,10 +451,6 @@
</span><span class="cx"> firefox = this.ua.is( 'ff' ),
</span><span class="cx"> className = '.wp-' + this.shortcode.tag + '-shortcode';
</span><span class="cx">
</span><del>- if ( this.player ) {
- this.unsetPlayer();
- }
-
</del><span class="cx"> media = $( node ).find( className );
</span><span class="cx">
</span><span class="cx"> if ( ! this.isCompatible( media ) ) {
</span><span class="lines">@@ -495,12 +491,7 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> unbind: function() {
</span><del>- var self = this;
- this.pauseAllPlayers();
- _.each( this.players, function (player) {
- self.removePlayer( player );
- } );
- this.players = [];
</del><ins>+ this.unsetPlayers();
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx"> _.extend( wp.mce.media.View.prototype, wp.media.mixin );
</span><span class="lines">@@ -547,22 +538,10 @@
</span><span class="cx"> template: media.template('editor-playlist'),
</span><span class="cx">
</span><span class="cx"> initialize: function( options ) {
</span><ins>+ this.players = [];
</ins><span class="cx"> this.data = {};
</span><span class="cx"> this.attachments = [];
</span><span class="cx"> this.shortcode = options.shortcode;
</span><del>- _.bindAll( this, 'setPlayer' );
- $(this).on('ready', this.setNode);
- },
-
- /**
- * Set the element context for the view, and then fetch the playlist's
- * associated attachments.
- *
- * @param {Event} e
- * @param {HTMLElement} node
- */
- setNode: function(e, node) {
- this.node = node;
</del><span class="cx"> this.fetch();
</span><span class="cx"> },
</span><span class="cx">
</span><span class="lines">@@ -571,7 +550,7 @@
</span><span class="cx"> */
</span><span class="cx"> fetch: function() {
</span><span class="cx"> this.attachments = wp.media.playlist.attachments( this.shortcode );
</span><del>- this.attachments.more().done( this.setPlayer );
</del><ins>+ this.dfd = this.attachments.more().done( _.bind( this.render, this ) );
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -582,36 +561,31 @@
</span><span class="cx"> * @global WPPlaylistView
</span><span class="cx"> * @global tinymce.editors
</span><span class="cx"> */
</span><del>- setPlayer: function() {
- var p,
- html = this.getHtml(),
- t = this.encodedText,
- self = this;
</del><ins>+ render: function() {
+ var html = this.getHtml(), self = this;
</ins><span class="cx">
</span><del>- this.unsetPlayer();
-
</del><span class="cx"> _.each( tinymce.editors, function( editor ) {
</span><span class="cx"> var doc;
</span><span class="cx"> if ( editor.plugins.wpview ) {
</span><span class="cx"> doc = editor.getDoc();
</span><del>- $( doc ).find( '[data-wpview-text="' + t + '"]' ).each(function(i, elem) {
</del><ins>+ $( doc ).find( '[data-wpview-text="' + this.encodedText + '"]' ).each(function (i, elem) {
</ins><span class="cx"> var node = $( elem );
</span><del>- node.html( html );
- self.node = elem;
</del><ins>+
+ // The <ins> is used to mark the end of the wrapper div. Needed when comparing
+ // the content as string for preventing extra undo levels.
+ node.html( html ).append( '<ins data-wpview-end="1"></ins>' );
+
+ if ( ! self.data.tracks ) {
+ return;
+ }
+
+ self.players.push( new WPPlaylistView({
+ el: $( elem ).find( '.wp-playlist' ).get(0),
+ metadata: self.data
+ }).player );
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx"> }, this );
</span><del>-
- if ( ! this.data.tracks ) {
- return;
- }
-
- p = new WPPlaylistView({
- el: $( self.node ).find( '.wp-playlist' ).get(0),
- metadata: this.data
- });
-
- this.player = p.player;
</del><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -695,6 +669,10 @@
</span><span class="cx"> this.data = options;
</span><span class="cx">
</span><span class="cx"> return this.template( options );
</span><ins>+ },
+
+ unbind: function() {
+ this.unsetPlayers();
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx"> _.extend( wp.mce.media.PlaylistView.prototype, wp.media.mixin );
</span></span></pre></div>
<a id="branches39srcwpincludesjsmediaaudiovideojs"></a>
<div class="modfile"><h4>Modified: branches/3.9/src/wp-includes/js/media-audiovideo.js (28271 => 28272)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.9/src/wp-includes/js/media-audiovideo.js 2014-05-06 04:44:56 UTC (rev 28271)
+++ branches/3.9/src/wp-includes/js/media-audiovideo.js 2014-05-06 04:48:28 UTC (rev 28272)
</span><span class="lines">@@ -162,11 +162,13 @@
</span><span class="cx"> *
</span><span class="cx"> * Examples: modal closes, shortcode properties are removed, etc.
</span><span class="cx"> */
</span><del>- unsetPlayer : function() {
- if ( this.player ) {
</del><ins>+ unsetPlayers : function() {
+ if ( this.players && this.players.length ) {
</ins><span class="cx"> wp.media.mixin.pauseAllPlayers();
</span><del>- wp.media.mixin.removePlayer( this.player );
- this.player = false;
</del><ins>+ _.each( this.players, function (player) {
+ wp.media.mixin.removePlayer( player );
+ } );
+ this.players = [];
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="lines">@@ -705,10 +707,10 @@
</span><span class="cx"> media.view.MediaDetails = media.view.Settings.AttachmentDisplay.extend({
</span><span class="cx"> initialize: function() {
</span><span class="cx"> _.bindAll(this, 'success');
</span><del>-
- this.listenTo( this.controller, 'close', media.mixin.unsetPlayer );
</del><ins>+ this.players = [];
+ this.listenTo( this.controller, 'close', media.mixin.unsetPlayers );
</ins><span class="cx"> this.on( 'ready', this.setPlayer );
</span><del>- this.on( 'media:setting:remove', media.mixin.unsetPlayer, this );
</del><ins>+ this.on( 'media:setting:remove', media.mixin.unsetPlayers, this );
</ins><span class="cx"> this.on( 'media:setting:remove', this.render );
</span><span class="cx"> this.on( 'media:setting:remove', this.setPlayer );
</span><span class="cx"> this.events = _.extend( this.events, {
</span><span class="lines">@@ -764,8 +766,8 @@
</span><span class="cx"> * @global MediaElementPlayer
</span><span class="cx"> */
</span><span class="cx"> setPlayer : function() {
</span><del>- if ( ! this.player && this.media ) {
- this.player = new MediaElementPlayer( this.media, this.settings );
</del><ins>+ if ( ! this.players.length && this.media ) {
+ this.players.push( new MediaElementPlayer( this.media, this.settings ) );
</ins><span class="cx"> }
</span><span class="cx"> },
</span><span class="cx">
</span></span></pre></div>
<a id="branches39srcwpincludesmediatemplatephp"></a>
<div class="modfile"><h4>Modified: branches/3.9/src/wp-includes/media-template.php (28271 => 28272)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.9/src/wp-includes/media-template.php 2014-05-06 04:44:56 UTC (rev 28271)
+++ branches/3.9/src/wp-includes/media-template.php 2014-05-06 04:48:28 UTC (rev 28272)
</span><span class="lines">@@ -16,7 +16,8 @@
</span><span class="cx"> function wp_underscore_audio_template() {
</span><span class="cx"> $audio_types = wp_get_audio_extensions();
</span><span class="cx"> ?>
</span><del>-<audio controls
</del><ins>+<audio style="visibility: hidden"
+ controls
</ins><span class="cx"> class="wp-audio-shortcode"
</span><span class="cx"> width="{{ _.isUndefined( data.model.width ) ? 400 : data.model.width }}"
</span><span class="cx"> preload="{{ _.isUndefined( data.model.preload ) ? 'none' : data.model.preload }}"
</span></span></pre></div>
<a id="branches39srcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: branches/3.9/src/wp-includes/media.php (28271 => 28272)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.9/src/wp-includes/media.php 2014-05-06 04:44:56 UTC (rev 28271)
+++ branches/3.9/src/wp-includes/media.php 2014-05-06 04:48:28 UTC (rev 28272)
</span><span class="lines">@@ -1353,6 +1353,8 @@
</span><span class="cx"> echo (int) $theme_width;
</span><span class="cx"> ?>"<?php if ( 'video' === $safe_type ):
</span><span class="cx"> echo ' height="', (int) $theme_height, '"';
</span><ins>+ else:
+ echo ' style="visibility: hidden"';
</ins><span class="cx"> endif; ?>></<?php echo $safe_type ?>>
</span><span class="cx"> <div class="wp-playlist-next"></div>
</span><span class="cx"> <div class="wp-playlist-prev"></div>
</span><span class="lines">@@ -1555,7 +1557,7 @@
</span><span class="cx"> 'loop' => $loop,
</span><span class="cx"> 'autoplay' => $autoplay,
</span><span class="cx"> 'preload' => $preload,
</span><del>- 'style' => 'width: 100%',
</del><ins>+ 'style' => 'width: 100%; visibility: hidden;',
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> // These ones should just be omitted altogether if they are blank
</span></span></pre>
</div>
</div>
</body>
</html>