<!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>[27655] trunk/src/wp-includes: General code cleanup and improving video sizing in the admin:</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/27655">27655</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-03-22 23:25:08 +0000 (Sat, 22 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>General code cleanup and improving video sizing in the admin:
* Abstract the setting of a primary button and its callback in `wp.media.view.MediaFrame.MediaDetails`
* Account for the existence or non-existence of `$content_width` in the TinyMCE views for video
* Make sure video models always have dimensions, even if they are the defaults
* For browsers that are not Firefox, don't use a timeout when setting the `MediaElementPlayer` instance in TinyMCE views
See <a href="http://core.trac.wordpress.org/ticket/27320">#27320</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmediaaudiovideojs">trunk/src/wp-includes/js/media-audiovideo.js</a></li>
<li><a href="#trunksrcwpincludesjstinymceskinswordpresswpcontentcss">trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css</a></li>
<li><a href="#trunksrcwpincludesmediatemplatephp">trunk/src/wp-includes/media-template.php</a></li>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsmediaaudiovideojs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-audiovideo.js (27654 => 27655)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-audiovideo.js 2014-03-22 21:21:36 UTC (rev 27654)
+++ trunk/src/wp-includes/js/media-audiovideo.js 2014-03-22 23:25:08 UTC (rev 27655)
</span><span class="lines">@@ -1,8 +1,14 @@
</span><span class="cx"> /* global _wpMediaViewsL10n, _wpmejsSettings, MediaElementPlayer, tinymce, WPPlaylistView */
</span><span class="cx">
</span><del>-(function ($, _, Backbone) {
- var media = wp.media, l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
</del><ins>+(function($, _, Backbone) {
+ var media = wp.media,
+ baseSettings = {},
+ l10n = typeof _wpMediaViewsL10n === 'undefined' ? {} : _wpMediaViewsL10n;
</ins><span class="cx">
</span><ins>+ if ( ! _.isUndefined( window._wpmejsSettings ) ) {
+ baseSettings.pluginPath = _wpmejsSettings.pluginPath;
+ }
+
</ins><span class="cx"> /**
</span><span class="cx"> * @mixin
</span><span class="cx"> */
</span><span class="lines">@@ -11,7 +17,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * Pauses every instance of MediaElementPlayer
</span><span class="cx"> */
</span><del>- pauseAllPlayers: function () {
</del><ins>+ pauseAllPlayers: function() {
</ins><span class="cx"> var p;
</span><span class="cx"> if ( window.mejs && window.mejs.players ) {
</span><span class="cx"> for ( p in window.mejs.players ) {
</span><span class="lines">@@ -24,7 +30,7 @@
</span><span class="cx"> * Utility to identify the user's browser
</span><span class="cx"> */
</span><span class="cx"> ua: {
</span><del>- is : function (browser) {
</del><ins>+ is : function( browser ) {
</ins><span class="cx"> var passes = false, ua = window.navigator.userAgent;
</span><span class="cx">
</span><span class="cx"> switch ( browser ) {
</span><span class="lines">@@ -44,7 +50,7 @@
</span><span class="cx"> passes = ua.match(/safari/gi) !== null && ua.match(/chrome/gi) === null;
</span><span class="cx"> break;
</span><span class="cx"> case 'chrome':
</span><del>- passes = ua.match(/safari/gi) && ua.match(/chrome/gi) !== null;
</del><ins>+ passes = ua.match(/safari/gi) !== null && ua.match(/chrome/gi) !== null;
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -85,7 +91,7 @@
</span><span class="cx"> * @param {jQuery} media
</span><span class="cx"> * @returns {Boolean}
</span><span class="cx"> */
</span><del>- isCompatible: function ( media ) {
</del><ins>+ isCompatible: function( media ) {
</ins><span class="cx"> if ( ! media.find( 'source' ).length ) {
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="lines">@@ -98,10 +104,10 @@
</span><span class="cx">
</span><span class="cx"> sources = media.find( 'source' );
</span><span class="cx">
</span><del>- _.find( this.compat, function (supports, browser) {
</del><ins>+ _.find( this.compat, function( supports, browser ) {
</ins><span class="cx"> if ( ua.is( browser ) ) {
</span><span class="cx"> found = true;
</span><del>- _.each( sources, function (elem) {
</del><ins>+ _.each( sources, function( elem ) {
</ins><span class="cx"> var audio = new RegExp( 'audio\/(' + supports.audio.join('|') + ')', 'gi' ),
</span><span class="cx"> video = new RegExp( 'video\/(' + supports.video.join('|') + ')', 'gi' );
</span><span class="cx">
</span><span class="lines">@@ -214,21 +220,18 @@
</span><span class="cx"> caption : ''
</span><span class="cx"> },
</span><span class="cx">
</span><del>- edit : function (data) {
</del><ins>+ edit : function( data ) {
</ins><span class="cx"> var frame, shortcode = wp.shortcode.next( 'audio', data ).shortcode;
</span><span class="cx"> frame = wp.media({
</span><span class="cx"> frame: 'audio',
</span><span class="cx"> state: 'audio-details',
</span><del>- metadata: _.defaults(
- shortcode.attrs.named,
- wp.media.audio.defaults
- )
</del><ins>+ metadata: _.defaults( shortcode.attrs.named, this.defaults )
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> return frame;
</span><span class="cx"> },
</span><span class="cx">
</span><del>- shortcode : function (model) {
</del><ins>+ shortcode : function( model ) {
</ins><span class="cx"> var self = this, content;
</span><span class="cx">
</span><span class="cx"> _.each( this.defaults, function( value, key ) {
</span><span class="lines">@@ -268,12 +271,13 @@
</span><span class="cx"> autoplay : false,
</span><span class="cx"> preload : 'metadata',
</span><span class="cx"> content : '',
</span><del>- caption : ''
</del><ins>+ caption : '',
+ width : 640,
+ height : 360
</ins><span class="cx"> },
</span><span class="cx">
</span><del>- edit : function (data) {
</del><ins>+ edit : function( data ) {
</ins><span class="cx"> var frame,
</span><del>- defaults = this.defaults,
</del><span class="cx"> shortcode = wp.shortcode.next( 'video', data ).shortcode,
</span><span class="cx"> attrs;
</span><span class="cx">
</span><span class="lines">@@ -283,13 +287,13 @@
</span><span class="cx"> frame = wp.media({
</span><span class="cx"> frame: 'video',
</span><span class="cx"> state: 'video-details',
</span><del>- metadata: _.defaults( attrs, defaults )
</del><ins>+ metadata: _.defaults( attrs, this.defaults )
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> return frame;
</span><span class="cx"> },
</span><span class="cx">
</span><del>- shortcode : function (model) {
</del><ins>+ shortcode : function( model ) {
</ins><span class="cx"> var self = this, content;
</span><span class="cx">
</span><span class="cx"> _.each( this.defaults, function( value, key ) {
</span><span class="lines">@@ -312,19 +316,20 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * wp.media.model.PostMedia
</del><ins>+ * Shared model class for audio and video. Updates the model after
+ * "Add Audio|Video Source" and "Replace Audio|Video" states return
</ins><span class="cx"> *
</span><span class="cx"> * @constructor
</span><span class="cx"> * @augments Backbone.Model
</span><del>- **/
</del><ins>+ */
</ins><span class="cx"> media.model.PostMedia = Backbone.Model.extend({
</span><span class="cx"> initialize: function() {
</span><span class="cx"> this.attachment = false;
</span><span class="cx"> },
</span><span class="cx">
</span><del>- setSource: function ( attachment ) {
</del><ins>+ setSource: function( attachment ) {
</ins><span class="cx"> this.attachment = attachment;
</span><del>- this.extension = attachment.get('filename' ).split('.').pop();
</del><ins>+ this.extension = attachment.get( 'filename' ).split('.').pop();
</ins><span class="cx">
</span><span class="cx"> if ( this.get( 'src' ) && this.extension === this.get( 'src' ).split('.').pop() ) {
</span><span class="cx"> this.unset( 'src' );
</span><span class="lines">@@ -343,31 +348,29 @@
</span><span class="cx"> this.setSource( attachment );
</span><span class="cx">
</span><span class="cx"> this.unset( 'src' );
</span><del>- _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function (ext) {
</del><ins>+ _.each( _.without( wp.media.view.settings.embedExts, this.extension ), function( ext ) {
</ins><span class="cx"> self.unset( ext );
</span><span class="cx"> } );
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * wp.media.controller.AudioDetails
</del><ins>+ * The controller for the Audio Details state
</ins><span class="cx"> *
</span><span class="cx"> * @constructor
</span><span class="cx"> * @augments wp.media.controller.State
</span><span class="cx"> * @augments Backbone.Model
</span><span class="cx"> */
</span><span class="cx"> media.controller.AudioDetails = media.controller.State.extend({
</span><del>- defaults: _.defaults({
</del><ins>+ defaults: {
</ins><span class="cx"> id: 'audio-details',
</span><span class="cx"> toolbar: 'audio-details',
</span><span class="cx"> title: l10n.audioDetailsTitle,
</span><span class="cx"> content: 'audio-details',
</span><span class="cx"> menu: 'audio-details',
</span><span class="cx"> router: false,
</span><del>- attachment: false,
- priority: 60,
- editing: false
- }, media.controller.Library.prototype.defaults ),
</del><ins>+ priority: 60
+ },
</ins><span class="cx">
</span><span class="cx"> initialize: function( options ) {
</span><span class="cx"> this.media = options.media;
</span><span class="lines">@@ -376,24 +379,22 @@
</span><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * wp.media.controller.VideoDetails
</del><ins>+ * The controller for the Video Details state
</ins><span class="cx"> *
</span><span class="cx"> * @constructor
</span><span class="cx"> * @augments wp.media.controller.State
</span><span class="cx"> * @augments Backbone.Model
</span><span class="cx"> */
</span><span class="cx"> media.controller.VideoDetails = media.controller.State.extend({
</span><del>- defaults: _.defaults({
</del><ins>+ defaults: {
</ins><span class="cx"> id: 'video-details',
</span><span class="cx"> toolbar: 'video-details',
</span><span class="cx"> title: l10n.videoDetailsTitle,
</span><span class="cx"> content: 'video-details',
</span><span class="cx"> menu: 'video-details',
</span><span class="cx"> router: false,
</span><del>- attachment: false,
- priority: 60,
- editing: false
- }, media.controller.Library.prototype.defaults ),
</del><ins>+ priority: 60
+ },
</ins><span class="cx">
</span><span class="cx"> initialize: function( options ) {
</span><span class="cx"> this.media = options.media;
</span><span class="lines">@@ -480,23 +481,17 @@
</span><span class="cx">
</span><span class="cx"> },
</span><span class="cx">
</span><del>- renderDetailsToolbar: function() {
</del><ins>+ setPrimaryButton: function(text, handler) {
</ins><span class="cx"> this.toolbar.set( new media.view.Toolbar({
</span><span class="cx"> controller: this,
</span><span class="cx"> items: {
</span><del>- select: {
</del><ins>+ button: {
</ins><span class="cx"> style: 'primary',
</span><del>- text: l10n.update,
</del><ins>+ text: text,
</ins><span class="cx"> priority: 80,
</span><del>-
- click: function() {
- var controller = this.controller,
- state = controller.state();
-
- controller.close();
-
- state.trigger( 'update', controller.media.toJSON() );
-
</del><ins>+ click: function() {
+ var controller = this.controller;
+ handler.call( this, controller, controller.state() );
</ins><span class="cx"> // Restore and reset the default state.
</span><span class="cx"> controller.setState( controller.options.state );
</span><span class="cx"> controller.reset();
</span><span class="lines">@@ -506,60 +501,27 @@
</span><span class="cx"> }) );
</span><span class="cx"> },
</span><span class="cx">
</span><ins>+ renderDetailsToolbar: function() {
+ this.setPrimaryButton( l10n.update, function( controller, state ) {
+ controller.close();
+ state.trigger( 'update', controller.media.toJSON() );
+ } );
+ },
+
</ins><span class="cx"> renderReplaceToolbar: function() {
</span><del>- this.toolbar.set( new media.view.Toolbar({
- controller: this,
- items: {
- replace: {
- style: 'primary',
- text: l10n.replace,
- priority: 80,
-
- click: function() {
- var controller = this.controller,
- state = controller.state(),
- selection = state.get( 'selection' ),
- attachment = selection.single();
-
- controller.media.changeAttachment( attachment );
-
- state.trigger( 'replace', controller.media.toJSON() );
-
- // Restore and reset the default state.
- controller.setState( controller.options.state );
- controller.reset();
- }
- }
- }
- }) );
</del><ins>+ this.setPrimaryButton( l10n.replace, function( controller, state ) {
+ var attachment = state.get( 'selection' ).single();
+ controller.media.changeAttachment( attachment );
+ state.trigger( 'replace', controller.media.toJSON() );
+ } );
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> renderAddSourceToolbar: function() {
</span><del>- this.toolbar.set( new media.view.Toolbar({
- controller: this,
- items: {
- replace: {
- style: 'primary',
- text: this.addText,
- priority: 80,
-
- click: function() {
- var controller = this.controller,
- state = controller.state(),
- selection = state.get( 'selection' ),
- attachment = selection.single();
-
- controller.media.setSource( attachment );
-
- state.trigger( 'add-source', controller.media.toJSON() );
-
- // Restore and reset the default state.
- controller.setState( controller.options.state );
- controller.reset();
- }
- }
- }
- }) );
</del><ins>+ this.setPrimaryButton( this.addText, function( controller, state ) {
+ var attachment = state.get( 'selection' ).single();
+ controller.media.setSource( attachment );
+ state.trigger( 'add-source', controller.media.toJSON() );
+ } );
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -606,9 +568,7 @@
</span><span class="cx"> createStates: function() {
</span><span class="cx"> this.states.add([
</span><span class="cx"> new media.controller.AudioDetails( {
</span><del>- media: this.media,
- editable: false,
- menu: 'audio-details'
</del><ins>+ media: this.media
</ins><span class="cx"> } ),
</span><span class="cx">
</span><span class="cx"> new media.controller.MediaLibrary( {
</span><span class="lines">@@ -677,9 +637,7 @@
</span><span class="cx"> createStates: function() {
</span><span class="cx"> this.states.add([
</span><span class="cx"> new media.controller.VideoDetails({
</span><del>- media: this.media,
- editable: false,
- menu: 'video-details'
</del><ins>+ media: this.media
</ins><span class="cx"> }),
</span><span class="cx">
</span><span class="cx"> new media.controller.MediaLibrary( {
</span><span class="lines">@@ -721,68 +679,30 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> renderSelectPosterImageToolbar: function() {
</span><del>- this.toolbar.set( new media.view.Toolbar({
- controller: this,
- items: {
- replace: {
- style: 'primary',
- text: l10n.videoSelectPosterImageTitle,
- priority: 80,
</del><ins>+ this.setPrimaryButton( l10n.videoSelectPosterImageTitle, function( controller, state ) {
+ var attachment = state.get( 'selection' ).single();
</ins><span class="cx">
</span><del>- click: function() {
- var controller = this.controller,
- state = controller.state(),
- selection = state.get( 'selection' ),
- attachment = selection.single();
-
- controller.media.set( 'poster', attachment.get( 'url' ) );
-
- state.trigger( 'set-poster-image', controller.media.toJSON() );
-
- // Restore and reset the default state.
- controller.setState( controller.options.state );
- controller.reset();
- }
- }
- }
- }) );
</del><ins>+ controller.media.set( 'poster', attachment.get( 'url' ) );
+ state.trigger( 'set-poster-image', controller.media.toJSON() );
+ } );
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> renderAddTrackToolbar: function() {
</span><del>- this.toolbar.set( new media.view.Toolbar({
- controller: this,
- items: {
- replace: {
- style: 'primary',
- text: l10n.videoAddTrackTitle,
- priority: 80,
</del><ins>+ this.setPrimaryButton( l10n.videoAddTrackTitle, function( controller, state ) {
+ var attachment = state.get( 'selection' ).single(),
+ content = controller.media.get( 'content' );
</ins><span class="cx">
</span><del>- click: function() {
- var controller = this.controller,
- state = controller.state(),
- selection = state.get( 'selection' ),
- attachment = selection.single(),
- content = controller.media.get( 'content' );
</del><ins>+ if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
+ content += [
+ '<track srclang="en" label="English"kind="subtitles" src="',
+ attachment.get( 'url' ),
+ '" />'
+ ].join('');
</ins><span class="cx">
</span><del>- if ( -1 === content.indexOf( attachment.get( 'url' ) ) ) {
- content += [
- '<track srclang="en" label="English"kind="subtitles" src="',
- attachment.get( 'url' ),
- '" />'
- ].join('');
-
- controller.media.set( 'content', content );
- }
-
- state.trigger( 'add-track', controller.media.toJSON() );
-
- // Restore and reset the default state.
- controller.setState( controller.options.state );
- controller.reset();
- }
- }
</del><ins>+ controller.media.set( 'content', content );
</ins><span class="cx"> }
</span><del>- }) );
</del><ins>+ state.trigger( 'add-track', controller.media.toJSON() );
+ } );
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -827,9 +747,8 @@
</span><span class="cx"> *
</span><span class="cx"> * @param {Event} e
</span><span class="cx"> */
</span><del>- removeSetting : function (e) {
</del><ins>+ removeSetting : function(e) {
</ins><span class="cx"> var wrap = $( e.currentTarget ).parent(), setting;
</span><del>-
</del><span class="cx"> setting = wrap.find( 'input' ).data( 'setting' );
</span><span class="cx">
</span><span class="cx"> if ( setting ) {
</span><span class="lines">@@ -844,10 +763,10 @@
</span><span class="cx"> *
</span><span class="cx"> * @fires wp.media.view.MediaDetails#media:setting:remove
</span><span class="cx"> */
</span><del>- setTracks : function () {
</del><ins>+ setTracks : function() {
</ins><span class="cx"> var tracks = '';
</span><span class="cx">
</span><del>- _.each( this.$('.content-track'), function (track) {
</del><ins>+ _.each( this.$('.content-track'), function(track) {
</ins><span class="cx"> tracks += $( track ).val();
</span><span class="cx"> } );
</span><span class="cx">
</span><span class="lines">@@ -858,7 +777,7 @@
</span><span class="cx"> /**
</span><span class="cx"> * @global MediaElementPlayer
</span><span class="cx"> */
</span><del>- setPlayer : function () {
</del><ins>+ setPlayer : function() {
</ins><span class="cx"> if ( ! this.player && this.media ) {
</span><span class="cx"> this.player = new MediaElementPlayer( this.media, this.settings );
</span><span class="cx"> }
</span><span class="lines">@@ -867,15 +786,15 @@
</span><span class="cx"> /**
</span><span class="cx"> * @abstract
</span><span class="cx"> */
</span><del>- setMedia : function () {
</del><ins>+ setMedia : function() {
</ins><span class="cx"> return this;
</span><span class="cx"> },
</span><span class="cx">
</span><del>- success : function (mejs) {
</del><ins>+ success : function(mejs) {
</ins><span class="cx"> var autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
</span><span class="cx">
</span><span class="cx"> if ( 'flash' === mejs.pluginType && autoplay ) {
</span><del>- mejs.addEventListener( 'canplay', function () {
</del><ins>+ mejs.addEventListener( 'canplay', function() {
</ins><span class="cx"> mejs.play();
</span><span class="cx"> }, false );
</span><span class="cx"> }
</span><span class="lines">@@ -884,23 +803,17 @@
</span><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * @global _wpmejsSettings
- *
</del><span class="cx"> * @returns {media.view.MediaDetails} Returns itself to allow chaining
</span><span class="cx"> */
</span><span class="cx"> render: function() {
</span><del>- var self = this, settings = {
- success : this.success
- };
</del><ins>+ var self = this;
</ins><span class="cx">
</span><del>- if ( ! _.isUndefined( window._wpmejsSettings ) ) {
- settings.pluginPath = _wpmejsSettings.pluginPath;
- }
-
</del><span class="cx"> media.view.Settings.AttachmentDisplay.prototype.render.apply( this, arguments );
</span><span class="cx"> setTimeout( function() { self.resetFocus(); }, 10 );
</span><span class="cx">
</span><del>- this.settings = settings;
</del><ins>+ this.settings = _.defaults( {
+ success : this.success
+ }, baseSettings );
</ins><span class="cx">
</span><span class="cx"> return this.setMedia();
</span><span class="cx"> },
</span><span class="lines">@@ -914,21 +827,21 @@
</span><span class="cx"> /**
</span><span class="cx"> * When multiple players in the DOM contain the same src, things get weird.
</span><span class="cx"> *
</span><del>- * @param {HTMLElement} media
</del><ins>+ * @param {HTMLElement} elem
</ins><span class="cx"> * @returns {HTMLElement}
</span><span class="cx"> */
</span><del>- prepareSrc : function (media) {
- var i = wp.media.view.MediaDetails.instances++;
- _.each( $(media).find('source'), function (source) {
</del><ins>+ prepareSrc : function( elem ) {
+ var i = media.view.MediaDetails.instances++;
+ _.each( $( elem ).find( 'source' ), function( source ) {
</ins><span class="cx"> source.src = [
</span><span class="cx"> source.src,
</span><span class="cx"> source.src.indexOf('?') > -1 ? '&' : '?',
</span><span class="cx"> '_=',
</span><span class="cx"> i
</span><span class="cx"> ].join('');
</span><del>- });
</del><ins>+ } );
</ins><span class="cx">
</span><del>- return media;
</del><ins>+ return elem;
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -1010,16 +923,16 @@
</span><span class="cx"> * @param {Object} settings
</span><span class="cx"> * @returns {Object}
</span><span class="cx"> */
</span><del>- counts : (function (settings) {
</del><ins>+ counts : (function(settings) {
</ins><span class="cx"> var counts = {};
</span><span class="cx">
</span><del>- return function () {
</del><ins>+ return function() {
</ins><span class="cx"> if ( ! _.isEmpty( counts ) ) {
</span><span class="cx"> return counts;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> var a = 0, v = 0;
</span><del>- _.each( settings.attachmentCounts, function (total, mime) {
</del><ins>+ _.each( settings.attachmentCounts, function(total, mime) {
</ins><span class="cx"> var type;
</span><span class="cx"> if ( -1 < mime.indexOf('/') ) {
</span><span class="cx"> type = mime.split('/')[0];
</span><span class="lines">@@ -1050,7 +963,7 @@
</span><span class="cx"> * @param {Object} options
</span><span class="cx"> * @returns {Array}
</span><span class="cx"> */
</span><del>- states : function (options) {
</del><ins>+ states : function(options) {
</ins><span class="cx"> return [
</span><span class="cx"> new media.controller.Library({
</span><span class="cx"> id: 'playlist',
</span><span class="lines">@@ -1093,7 +1006,7 @@
</span><span class="cx"> * @param {Object} options
</span><span class="cx"> * @returns {Array}
</span><span class="cx"> */
</span><del>- videoStates : function (options) {
</del><ins>+ videoStates : function(options) {
</ins><span class="cx"> return [
</span><span class="cx"> new media.controller.Library({
</span><span class="cx"> id: 'video-playlist',
</span><span class="lines">@@ -1183,7 +1096,7 @@
</span><span class="cx">
</span><span class="cx"> data = window.decodeURIComponent( $( node ).attr('data-wpview-text') );
</span><span class="cx"> frame = media.edit( data );
</span><del>- frame.on( 'close', function () {
</del><ins>+ frame.on( 'close', function() {
</ins><span class="cx"> frame.detach();
</span><span class="cx"> } );
</span><span class="cx"> frame.state( self.state ).on( 'update', function( selection ) {
</span><span class="lines">@@ -1219,7 +1132,7 @@
</span><span class="cx"> * @param {Event} e
</span><span class="cx"> * @param {HTMLElement} node
</span><span class="cx"> */
</span><del>- setPlayer: function (e, node) {
</del><ins>+ setPlayer: function(e, node) {
</ins><span class="cx"> // if the ready event fires on an empty node
</span><span class="cx"> if ( ! node ) {
</span><span class="cx"> return;
</span><span class="lines">@@ -1227,7 +1140,7 @@
</span><span class="cx">
</span><span class="cx"> var self = this,
</span><span class="cx"> media,
</span><del>- settings = {},
</del><ins>+ firefox = this.ua.is( 'ff' ),
</ins><span class="cx"> className = '.wp-' + this.shortcode.tag + '-shortcode';
</span><span class="cx">
</span><span class="cx"> if ( this.player ) {
</span><span class="lines">@@ -1236,10 +1149,6 @@
</span><span class="cx">
</span><span class="cx"> media = $( node ).find( className );
</span><span class="cx">
</span><del>- if ( ! _.isUndefined( window._wpmejsSettings ) ) {
- settings.pluginPath = _wpmejsSettings.pluginPath;
- }
-
</del><span class="cx"> if ( ! this.isCompatible( media ) ) {
</span><span class="cx"> media.closest( '.wpview-wrap' ).addClass( 'wont-play' );
</span><span class="cx"> if ( ! media.parent().hasClass( 'wpview-wrap' ) ) {
</span><span class="lines">@@ -1249,7 +1158,7 @@
</span><span class="cx"> return;
</span><span class="cx"> } else {
</span><span class="cx"> media.closest( '.wpview-wrap' ).removeClass( 'wont-play' );
</span><del>- if ( this.ua.is( 'ff' ) ) {
</del><ins>+ if ( firefox ) {
</ins><span class="cx"> media.prop( 'preload', 'metadata' );
</span><span class="cx"> } else {
</span><span class="cx"> media.prop( 'preload', 'none' );
</span><span class="lines">@@ -1259,9 +1168,13 @@
</span><span class="cx"> media = wp.media.view.MediaDetails.prepareSrc( media.get(0) );
</span><span class="cx">
</span><span class="cx"> // Thanks, Firefox!
</span><del>- setTimeout(function () {
- self.player = new MediaElementPlayer( media, settings );
- }, 50);
</del><ins>+ if ( firefox ) {
+ setTimeout( function() {
+ self.player = new MediaElementPlayer( media, baseSettings );
+ }, 50 );
+ } else {
+ this.player = new MediaElementPlayer( media, baseSettings );
+ }
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1270,7 +1183,10 @@
</span><span class="cx"> * @returns {string}
</span><span class="cx"> */
</span><span class="cx"> getHtml: function() {
</span><del>- var attrs = this.shortcode.attrs.named;
</del><ins>+ var attrs = _.defaults(
+ this.shortcode.attrs.named,
+ wp.media[ this.shortcode.tag ].defaults
+ );
</ins><span class="cx"> return this.template({ model: attrs });
</span><span class="cx"> }
</span><span class="cx"> });
</span><span class="lines">@@ -1332,7 +1248,7 @@
</span><span class="cx"> * @param {Event} e
</span><span class="cx"> * @param {HTMLElement} node
</span><span class="cx"> */
</span><del>- setNode: function (e, node) {
</del><ins>+ setNode: function(e, node) {
</ins><span class="cx"> this.node = node;
</span><span class="cx"> this.fetch();
</span><span class="cx"> },
</span><span class="lines">@@ -1353,7 +1269,7 @@
</span><span class="cx"> * @global WPPlaylistView
</span><span class="cx"> * @global tinymce.editors
</span><span class="cx"> */
</span><del>- setPlayer: function () {
</del><ins>+ setPlayer: function() {
</ins><span class="cx"> var p,
</span><span class="cx"> html = this.getHtml(),
</span><span class="cx"> t = this.encodedText,
</span><span class="lines">@@ -1365,7 +1281,7 @@
</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="' + t + '"]' ).each(function(i, elem) {
</ins><span class="cx"> var node = $( elem );
</span><span class="cx"> node.html( html );
</span><span class="cx"> self.node = elem;
</span><span class="lines">@@ -1414,8 +1330,8 @@
</span><span class="cx"> artists: data.artists
</span><span class="cx"> };
</span><span class="cx">
</span><del>- _.each( attachments, function (attachment) {
- var size = {}, track = {
</del><ins>+ _.each( attachments, function( attachment ) {
+ var size = {}, resize = {}, track = {
</ins><span class="cx"> src : attachment.url,
</span><span class="cx"> type : attachment.mime,
</span><span class="cx"> title : attachment.title,
</span><span class="lines">@@ -1425,15 +1341,24 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> if ( 'video' === type ) {
</span><del>- if ( ! options.width ) {
- options.width = attachment.width;
- options.height = attachment.height;
- }
</del><span class="cx"> size.width = attachment.width;
</span><span class="cx"> size.height = attachment.height;
</span><ins>+ if ( media.view.settings.contentWidth ) {
+ resize.width = media.view.settings.contentWidth - 22;
+ resize.height = Math.ceil( ( size.height * resize.width ) / size.width );
+ if ( ! options.width ) {
+ options.width = resize.width;
+ options.height = resize.height;
+ }
+ } else {
+ if ( ! options.width ) {
+ options.width = attachment.width;
+ options.height = attachment.height;
+ }
+ }
</ins><span class="cx"> track.dimensions = {
</span><span class="cx"> original : size,
</span><del>- resized : size
</del><ins>+ resized : _.isEmpty( resize ) ? size : resize
</ins><span class="cx"> };
</span><span class="cx"> } else {
</span><span class="cx"> options.width = 400;
</span><span class="lines">@@ -1483,7 +1408,7 @@
</span><span class="cx"> function init() {
</span><span class="cx"> $(document.body)
</span><span class="cx"> .on( 'click', '.wp-switch-editor', wp.media.mixin.pauseAllPlayers )
</span><del>- .on( 'click', '.add-media-source', function () {
</del><ins>+ .on( 'click', '.add-media-source', function() {
</ins><span class="cx"> media.frame.setState('add-' + media.frame.defaults.id + '-source');
</span><span class="cx"> } );
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymceskinswordpresswpcontentcss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css (27654 => 27655)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2014-03-22 21:21:36 UTC (rev 27654)
+++ trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2014-03-22 23:25:08 UTC (rev 27655)
</span><span class="lines">@@ -164,6 +164,10 @@
</span><span class="cx"> max-width: 100%;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+audio {
+ visibility: hidden;
+}
+
</ins><span class="cx"> /**
</span><span class="cx"> * WP Views
</span><span class="cx"> */
</span></span></pre></div>
<a id="trunksrcwpincludesmediatemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media-template.php (27654 => 27655)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media-template.php 2014-03-22 21:21:36 UTC (rev 27654)
+++ trunk/src/wp-includes/media-template.php 2014-03-22 23:25:08 UTC (rev 27655)
</span><span class="lines">@@ -48,14 +48,20 @@
</span><span class="cx"> function wp_underscore_video_template() {
</span><span class="cx"> $video_types = wp_get_video_extensions();
</span><span class="cx"> ?>
</span><del>-<#
-var isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
- w = ! data.model.width || data.model.width > 640 ? 640 : data.model.width,
- h = ! data.model.height ? 360 : data.model.height;
</del><ins>+<# var w, h, settings = wp.media.view.settings,
+ isYouTube = ! _.isEmpty( data.model.src ) && data.model.src.match(/youtube|youtu\.be/);
</ins><span class="cx">
</span><del>-if ( data.model.width && w !== data.model.width ) {
- h = Math.ceil( ( h * w ) / data.model.width );
-}
</del><ins>+ if ( settings.contentWidth && data.model.width >= settings.contentWidth ) {
+ w = settings.contentWidth;
+ } else {
+ w = data.model.width;
+ }
+
+ if ( w !== data.model.width ) {
+ h = Math.ceil( ( h * w ) / data.model.width );
+ } else {
+ h = data.model.height;
+ }
</ins><span class="cx"> #>
</span><span class="cx"> <div style="max-width: 100%; width: {{ w }}px">
</span><span class="cx"> <video controls
</span><span class="lines">@@ -85,13 +91,13 @@
</span><span class="cx"> if ( isYouTube ) { #>
</span><span class="cx"> <source src="{{ data.model.src }}" type="video/youtube" />
</span><span class="cx"> <# } else { #>
</span><del>- <source src="{{ data.model.src }}" type="{{ wp.media.view.settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
</del><ins>+ <source src="{{ data.model.src }}" type="{{ settings.embedMimes[ data.model.src.split('.').pop() ] }}" />
</ins><span class="cx"> <# }
</span><span class="cx"> } #>
</span><span class="cx">
</span><span class="cx"> <?php foreach ( $video_types as $type ):
</span><span class="cx"> ?><# if ( data.model.<?php echo $type ?> ) { #>
</span><del>- <source src="{{ data.model.<?php echo $type ?> }}" type="{{ wp.media.view.settings.embedMimes[ '<?php echo $type ?>' ] }}" />
</del><ins>+ <source src="{{ data.model.<?php echo $type ?> }}" type="{{ settings.embedMimes[ '<?php echo $type ?>' ] }}" />
</ins><span class="cx"> <# } #>
</span><span class="cx"> <?php endforeach; ?>
</span><span class="cx"> {{{ data.model.content }}}
</span></span></pre></div>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (27654 => 27655)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php 2014-03-22 21:21:36 UTC (rev 27654)
+++ trunk/src/wp-includes/media.php 2014-03-22 23:25:08 UTC (rev 27655)
</span><span class="lines">@@ -1197,8 +1197,8 @@
</span><span class="cx"> $default_width = 640;
</span><span class="cx"> $default_height = 360;
</span><span class="cx">
</span><del>- $theme_width = $content_width - $outer;
- $theme_height = round( ( $default_height * $theme_width ) / $default_width );
</del><ins>+ $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
+ $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width );
</ins><span class="cx">
</span><span class="cx"> $data = compact( 'type', 'style' );
</span><span class="cx">
</span><span class="lines">@@ -1585,7 +1585,7 @@
</span><span class="cx"> }
</span><span class="cx"> } else {
</span><span class="cx"> // if the video is bigger than the theme
</span><del>- if ( $width > $content_width ) {
</del><ins>+ if ( ! empty( $content_width ) && $width > $content_width ) {
</ins><span class="cx"> $height = round( ( $height * $content_width ) / $width );
</span><span class="cx"> $width = $content_width;
</span><span class="cx"> }
</span><span class="lines">@@ -2381,6 +2381,8 @@
</span><span class="cx"> if ( did_action( 'wp_enqueue_media' ) )
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ global $content_width;
+
</ins><span class="cx"> $defaults = array(
</span><span class="cx"> 'post' => null,
</span><span class="cx"> );
</span><span class="lines">@@ -2431,7 +2433,8 @@
</span><span class="cx"> 'defaultProps' => $props,
</span><span class="cx"> 'attachmentCounts' => wp_count_attachments(),
</span><span class="cx"> 'embedExts' => $exts,
</span><del>- 'embedMimes' => $ext_mimes
</del><ins>+ 'embedMimes' => $ext_mimes,
+ 'contentWidth' => $content_width,
</ins><span class="cx"> );
</span><span class="cx">
</span><span class="cx"> $post = null;
</span></span></pre>
</div>
</div>
</body>
</html>