<!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>[27642] trunk/src/wp-includes/js/media-audiovideo.js: Add JSDoc blocks to `media-audiovideo.js`.</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/27642">27642</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-03-20 22:22:25 +0000 (Thu, 20 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add JSDoc blocks to `media-audiovideo.js`.

See <a href="http://core.trac.wordpress.org/ticket/27016">#27016</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmediaaudiovideojs">trunk/src/wp-includes/js/media-audiovideo.js</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 (27641 => 27642)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-audiovideo.js     2014-03-20 17:20:22 UTC (rev 27641)
+++ trunk/src/wp-includes/js/media-audiovideo.js        2014-03-20 22:22:25 UTC (rev 27642)
</span><span class="lines">@@ -820,6 +820,13 @@
</span><span class="cx">                  }, this.options );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Remove a setting's UI when the model unsets it
+                *
+                * @fires wp.media.view.MediaDetails#media:setting:remove
+                *
+                * @param {Event} e
+                */
</ins><span class="cx">           removeSetting : function (e) {
</span><span class="cx">                  var wrap = $( e.currentTarget ).parent(), setting;
</span><span class="cx"> 
</span><span class="lines">@@ -833,6 +840,10 @@
</span><span class="cx">                  wrap.remove();
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                *
+                * @fires wp.media.view.MediaDetails#media:setting:remove
+                */
</ins><span class="cx">           setTracks : function () {
</span><span class="cx">                  var tracks = '';
</span><span class="cx"> 
</span><span class="lines">@@ -844,6 +855,9 @@
</span><span class="cx">                  this.trigger( 'media:setting:remove', this );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * @global MediaElementPlayer
+                */
</ins><span class="cx">           setPlayer : function () {
</span><span class="cx">                  if ( ! this.player && this.media ) {
</span><span class="cx">                          this.player = new MediaElementPlayer( this.media, this.settings );
</span><span class="lines">@@ -869,6 +883,11 @@
</span><span class="cx">                  this.mejs = mejs;
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * @global _wpmejsSettings
+                *
+                * @returns {media.view.MediaDetails} Returns itself to allow chaining
+                */
</ins><span class="cx">           render: function() {
</span><span class="cx">                  var self = this, settings = {
</span><span class="cx">                          success : this.success
</span><span class="lines">@@ -985,6 +1004,11 @@
</span><span class="cx">  _.extend( wp.media.playlist, {
</span><span class="cx">          /**
</span><span class="cx">           * Determine how many audio and video files the user has uploaded
</span><ins>+                *
+                * @global wp.media.view.settings
+                *
+                * @param {Object} settings
+                * @returns {Object}
</ins><span class="cx">            */
</span><span class="cx">          counts : (function (settings) {
</span><span class="cx">                  var counts = {};
</span><span class="lines">@@ -1107,7 +1131,23 @@
</span><span class="cx">          }
</span><span class="cx">  } );
</span><span class="cx"> 
</span><ins>+       /**
+        * Tiny MCE Views
+        *
+        */
+
+       /**
+        * These are base methods that are shared by each shortcode's MCE controller
+        *
+        * @mixin
+        */
</ins><span class="cx">   wp.mce.media = {
</span><ins>+               /**
+                * @global wp.shortcode
+                *
+                * @param {string} content
+                * @returns {Object}
+                */
</ins><span class="cx">           toView:  function( content ) {
</span><span class="cx">                  var match = wp.shortcode.next( this.shortcode, content );
</span><span class="cx"> 
</span><span class="lines">@@ -1124,6 +1164,16 @@
</span><span class="cx">                  };
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Called when a TinyMCE view is clicked for editing.
+                * - Parses the shortcode out of the element's data attribute
+                * - Calls the `edit` method on the shortcode model
+                * - Launches the model window
+                * - Bind's an `update` callback which updates the element's data attribute
+                *   re-renders the view
+                *
+                * @param {HTMLElement} node
+                */
</ins><span class="cx">           edit: function( node ) {
</span><span class="cx">                  var media = wp.media[ this.shortcode ],
</span><span class="cx">                          self = this,
</span><span class="lines">@@ -1146,6 +1196,13 @@
</span><span class="cx">          }
</span><span class="cx">  };
</span><span class="cx"> 
</span><ins>+       /**
+        * Base View class for audio and video shortcodes
+        *
+        * @constructor
+        * @augments wp.mce.View
+        * @mixes wp.media.mixin
+        */
</ins><span class="cx">   wp.mce.media.View = wp.mce.View.extend({
</span><span class="cx">          initialize: function( options ) {
</span><span class="cx">                  this.shortcode = options.shortcode;
</span><span class="lines">@@ -1153,6 +1210,15 @@
</span><span class="cx">                  $(this).on( 'ready', this.setPlayer );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Creates the player instance for the current node
+                *
+                * @global MediaElementPlayer
+                * @global _wpmejsSettings
+                *
+                * @param {Event} e
+                * @param {HTMLElement} node
+                */
</ins><span class="cx">           setPlayer: function (e, node) {
</span><span class="cx">                  // if the ready event fires on an empty node
</span><span class="cx">                  if ( ! node ) {
</span><span class="lines">@@ -1198,6 +1264,11 @@
</span><span class="cx">                  }, 50);
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Pass data to the View's Underscore template and return the compiled output
+                *
+                * @returns {string}
+                */
</ins><span class="cx">           getHtml: function() {
</span><span class="cx">                  var attrs = this.shortcode.attrs.named;
</span><span class="cx">                  return this.template({ model: attrs });
</span><span class="lines">@@ -1205,6 +1276,11 @@
</span><span class="cx">  });
</span><span class="cx">  _.extend( wp.mce.media.View.prototype, wp.media.mixin );
</span><span class="cx"> 
</span><ins>+       /**
+        * TinyMCE handler for the video shortcode
+        *
+        * @mixes wp.mce.media
+        */
</ins><span class="cx">   wp.mce.video = _.extend( {}, wp.mce.media, {
</span><span class="cx">          shortcode: 'video',
</span><span class="cx">          state: 'video-details',
</span><span class="lines">@@ -1213,9 +1289,13 @@
</span><span class="cx">                  template:  media.template('editor-video')
</span><span class="cx">          })
</span><span class="cx">  } );
</span><del>-
</del><span class="cx">   wp.mce.views.register( 'video', wp.mce.video );
</span><span class="cx"> 
</span><ins>+       /**
+        * TinyMCE handler for the audio shortcode
+        *
+        * @mixes wp.mce.media
+        */
</ins><span class="cx">   wp.mce.audio = _.extend( {}, wp.mce.media, {
</span><span class="cx">          shortcode: 'audio',
</span><span class="cx">          state: 'audio-details',
</span><span class="lines">@@ -1224,9 +1304,15 @@
</span><span class="cx">                  template:  media.template('editor-audio')
</span><span class="cx">          })
</span><span class="cx">  } );
</span><del>-
</del><span class="cx">   wp.mce.views.register( 'audio', wp.mce.audio );
</span><span class="cx"> 
</span><ins>+       /**
+        * Base View class for playlist shortcodes
+        *
+        * @constructor
+        * @augments wp.mce.View
+        * @mixes wp.media.mixin
+        */
</ins><span class="cx">   wp.mce.media.PlaylistView = wp.mce.View.extend({
</span><span class="cx">          className: 'editor-playlist',
</span><span class="cx">          template:  media.template('editor-playlist'),
</span><span class="lines">@@ -1239,16 +1325,34 @@
</span><span class="cx">                  $(this).on('ready', this.setNode);
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Set the element context for the view, and then fetch the playlist's
+                *   associated attachments.
+                *
+                * @param {Event} e
+                * @param {HTMLElement} node
+                */
</ins><span class="cx">           setNode: function (e, node) {
</span><span class="cx">                  this.node = node;
</span><span class="cx">                  this.fetch();
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Asynchronously fetch the shortcode's attachments
+                */
</ins><span class="cx">           fetch: function() {
</span><span class="cx">                  this.attachments = wp.media[ this.shortcode.tag ].attachments( this.shortcode );
</span><span class="cx">                  this.attachments.more().done( this.setPlayer );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Get the HTML for the view (which also set's the data), replace the
+                *   current HTML, and then invoke the WPPlaylistView instance to render
+                *   the playlist in the editor
+                *
+                * @global WPPlaylistView
+                * @global tinymce.editors
+                */
</ins><span class="cx">           setPlayer: function () {
</span><span class="cx">                  var p,
</span><span class="cx">                          html = this.getHtml(),
</span><span class="lines">@@ -1277,6 +1381,12 @@
</span><span class="cx">                  this.player = p._player;
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               /**
+                * Set the data that will be used to compile the Underscore template,
+                *  compile the template, and then return it.
+                *
+                * @returns {string}
+                */
</ins><span class="cx">           getHtml: function() {
</span><span class="cx">                  var data = this.shortcode.attrs.named,
</span><span class="cx">                          model = wp.media[ this.shortcode.tag ],
</span><span class="lines">@@ -1343,22 +1453,33 @@
</span><span class="cx">  });
</span><span class="cx">  _.extend( wp.mce.media.PlaylistView.prototype, wp.media.mixin );
</span><span class="cx"> 
</span><ins>+       /**
+        * TinyMCE handler for the playlist shortcode
+        *
+        * @mixes wp.mce.media
+        */
</ins><span class="cx">   wp.mce.playlist = _.extend( {}, wp.mce.media, {
</span><span class="cx">          shortcode: 'playlist',
</span><span class="cx">          state: 'playlist-edit',
</span><span class="cx">          View: wp.mce.media.PlaylistView
</span><span class="cx">  } );
</span><del>-
</del><span class="cx">   wp.mce.views.register( 'playlist', wp.mce.playlist );
</span><span class="cx"> 
</span><ins>+       /**
+        * TinyMCE handler for the video-playlist shortcode
+        *
+        * @mixes wp.mce.media
+        */
</ins><span class="cx">   wp.mce['video-playlist'] = _.extend( {}, wp.mce.media, {
</span><span class="cx">          shortcode: 'video-playlist',
</span><span class="cx">          state: 'video-playlist-edit',
</span><span class="cx">          View: wp.mce.media.PlaylistView
</span><span class="cx">  } );
</span><del>-
</del><span class="cx">   wp.mce.views.register( 'video-playlist', wp.mce['video-playlist'] );
</span><span class="cx"> 
</span><ins>+       /**
+        * Event binding
+        */
</ins><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></span></pre>
</div>
</div>

</body>
</html>