<!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>[27031] trunk/src/wp-includes/js/media-models.js: Add some JSDoc annotations to `media-models.js` to disambiguate instance properties and static class properties/methods in the base media Models.</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/27031">27031</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-01-25 07:38:12 +0000 (Sat, 25 Jan 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add some JSDoc annotations to `media-models.js` to disambiguate instance properties and static class properties/methods in the base media Models.

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

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmediamodelsjs">trunk/src/wp-includes/js/media-models.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsmediamodelsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-models.js (27030 => 27031)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-models.js 2014-01-25 01:20:04 UTC (rev 27030)
+++ trunk/src/wp-includes/js/media-models.js    2014-01-25 07:38:12 UTC (rev 27031)
</span><span class="lines">@@ -77,6 +77,8 @@
</span><span class="cx">           *
</span><span class="cx">           * Fetches a template by id.
</span><span class="cx">           * See wp.template() in `wp-includes/js/wp-util.js`.
</span><ins>+                *
+                * @borrows wp.template as template
</ins><span class="cx">            */
</span><span class="cx">          template: wp.template,
</span><span class="cx"> 
</span><span class="lines">@@ -85,6 +87,8 @@
</span><span class="cx">           *
</span><span class="cx">           * Sends a POST request to WordPress.
</span><span class="cx">           * See wp.ajax.post() in `wp-includes/js/wp-util.js`.
</span><ins>+                *
+                * @borrows wp.ajax.post as post
</ins><span class="cx">            */
</span><span class="cx">          post: wp.ajax.post,
</span><span class="cx"> 
</span><span class="lines">@@ -93,6 +97,8 @@
</span><span class="cx">           *
</span><span class="cx">           * Sends an XHR request to WordPress.
</span><span class="cx">           * See wp.ajax.send() in `wp-includes/js/wp-util.js`.
</span><ins>+                *
+                * @borrows wp.ajax.send as ajax
</ins><span class="cx">            */
</span><span class="cx">          ajax: wp.ajax.send,
</span><span class="cx"> 
</span><span class="lines">@@ -185,6 +191,7 @@
</span><span class="cx">  Attachment = media.model.Attachment = Backbone.Model.extend({
</span><span class="cx">          /**
</span><span class="cx">           * Triggered when attachment details change
</span><ins>+                * Overrides Backbone.Model.sync
</ins><span class="cx">            *
</span><span class="cx">           * @param {string} method
</span><span class="cx">           * @param {wp.media.model.Attachment} model
</span><span class="lines">@@ -271,8 +278,9 @@
</span><span class="cx">          /**
</span><span class="cx">           * Convert date strings into Date objects.
</span><span class="cx">           *
</span><del>-                * @param {Object} resp
-                * @returns {Object}
</del><ins>+                 * @param {Object} resp The raw response object, typically returned by fetch()
+                * @returns {Object} The modified response object, which is the attributes hash
+                *    to be set on the model.
</ins><span class="cx">            */
</span><span class="cx">          parse: function( resp ) {
</span><span class="cx">                  if ( ! resp ) {
</span><span class="lines">@@ -284,8 +292,8 @@
</span><span class="cx">                  return resp;
</span><span class="cx">          },
</span><span class="cx">          /**
</span><del>-                * @param {Object} data
-                * @param {Object} options
</del><ins>+                 * @param {Object} data The properties to be saved.
+                * @param {Object} options Sync options. e.g. patch, wait, success, error.
</ins><span class="cx">            *
</span><span class="cx">           * @this Backbone.Model
</span><span class="cx">           *
</span><span class="lines">@@ -309,6 +317,7 @@
</span><span class="cx">          }
</span><span class="cx">  }, {
</span><span class="cx">          /**
</span><ins>+                * @static
</ins><span class="cx">            * @param {Object} attrs
</span><span class="cx">           * @returns {wp.media.model.Attachment}
</span><span class="cx">           */
</span><span class="lines">@@ -316,6 +325,7 @@
</span><span class="cx">                  return Attachments.all.push( attrs );
</span><span class="cx">          },
</span><span class="cx">          /**
</span><ins>+                * @static
</ins><span class="cx">            * @param {string} id
</span><span class="cx">           * @param {Backbone.Model|undefined} attachment
</span><span class="cx">           * @returns {wp.media.model.Attachment}
</span><span class="lines">@@ -618,9 +628,11 @@
</span><span class="cx">                  return this.mirroring ? this.mirroring.hasMore() : false;
</span><span class="cx">          },
</span><span class="cx">          /**
</span><del>-                * @param {Object} resp
-                * @param {XMLHttpRequest} xhr
-                * @returns {Array}
</del><ins>+                 * Overrides Backbone.Collection.parse
+                *
+                * @param {Object|Array} resp The raw response Object/Array.
+                * @param {Object} xhr
+                * @returns {Array} The array of model attributes to be added to the collection
</ins><span class="cx">            */
</span><span class="cx">          parse: function( resp, xhr ) {
</span><span class="cx">                  if ( ! _.isArray( resp ) ) {
</span><span class="lines">@@ -690,6 +702,7 @@
</span><span class="cx">          }
</span><span class="cx">  }, {
</span><span class="cx">          /**
</span><ins>+                * @static
</ins><span class="cx">            * @param {Backbone.Model} a
</span><span class="cx">           * @param {Backbone.Model} b
</span><span class="cx">           * @param {Object} options
</span><span class="lines">@@ -716,13 +729,19 @@
</span><span class="cx"> 
</span><span class="cx">                  return ( 'DESC' === order ) ? compare( a, b, ac, bc ) : compare( b, a, bc, ac );
</span><span class="cx">          },
</span><del>-
</del><ins>+                /**
+                * @namespace
+                */
</ins><span class="cx">           filters: {
</span><span class="cx">                  /**
</span><ins>+                        * @static
</ins><span class="cx">                    * Note that this client-side searching is *not* equivalent
</span><span class="cx">                   * to our server-side searching.
</span><span class="cx">                   *
</span><span class="cx">                   * @param {wp.media.model.Attachment} attachment
</span><ins>+                        *
+                        * @this wp.media.model.Attachments
+                        *
</ins><span class="cx">                    * @returns {Boolean}
</span><span class="cx">                   */
</span><span class="cx">                  search: function( attachment ) {
</span><span class="lines">@@ -736,7 +755,11 @@
</span><span class="cx">                          }, this );
</span><span class="cx">                  },
</span><span class="cx">                  /**
</span><ins>+                        * @static
</ins><span class="cx">                    * @param {wp.media.model.Attachment} attachment
</span><ins>+                        *
+                        * @this wp.media.model.Attachments
+                        *
</ins><span class="cx">                    * @returns {Boolean}
</span><span class="cx">                   */
</span><span class="cx">                  type: function( attachment ) {
</span><span class="lines">@@ -744,7 +767,11 @@
</span><span class="cx">                          return ! type || -1 !== type.indexOf( attachment.get('type') );
</span><span class="cx">                  },
</span><span class="cx">                  /**
</span><ins>+                        * @static
</ins><span class="cx">                    * @param {wp.media.model.Attachment} attachment
</span><ins>+                        *
+                        * @this wp.media.model.Attachments
+                        *
</ins><span class="cx">                    * @returns {Boolean}
</span><span class="cx">                   */
</span><span class="cx">                  uploadedTo: function( attachment ) {
</span><span class="lines">@@ -759,6 +786,7 @@
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="cx">  /**
</span><ins>+        * @static
</ins><span class="cx">    * @member {wp.media.model.Attachments}
</span><span class="cx">   */
</span><span class="cx">  Attachments.all = new Attachments();
</span><span class="lines">@@ -877,6 +905,9 @@
</span><span class="cx">                  });
</span><span class="cx">          },
</span><span class="cx">          /**
</span><ins>+                * Overrides Backbone.Collection.sync
+                * Overrides wp.media.model.Attachments.sync
+                *
</ins><span class="cx">            * @param {String} method
</span><span class="cx">           * @param {Backbone.Model} model
</span><span class="cx">           * @param {Object} [options={}]
</span><span class="lines">@@ -915,15 +946,22 @@
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx">  }, {
</span><ins>+               /**
+                * @readonly
+                */
</ins><span class="cx">           defaultProps: {
</span><span class="cx">                  orderby: 'date',
</span><span class="cx">                  order:   'DESC'
</span><span class="cx">          },
</span><del>-
</del><ins>+                /**
+                * @readonly
+                */
</ins><span class="cx">           defaultArgs: {
</span><span class="cx">                  posts_per_page: 40
</span><span class="cx">          },
</span><del>-
</del><ins>+                /**
+                * @readonly
+                */
</ins><span class="cx">           orderby: {
</span><span class="cx">                  allowed:  [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in', 'menuOrder' ],
</span><span class="cx">                  valuemap: {
</span><span class="lines">@@ -932,7 +970,9 @@
</span><span class="cx">                          'menuOrder':  'menu_order ID'
</span><span class="cx">                  }
</span><span class="cx">          },
</span><del>-
</del><ins>+                /**
+                * @readonly
+                */
</ins><span class="cx">           propmap: {
</span><span class="cx">                  'search':    's',
</span><span class="cx">                  'type':      'post_mime_type',
</span><span class="lines">@@ -940,7 +980,9 @@
</span><span class="cx">                  'menuOrder': 'menu_order',
</span><span class="cx">                  'uploadedTo': 'post_parent'
</span><span class="cx">          },
</span><del>-
</del><ins>+                /**
+                * @static
+                */
</ins><span class="cx">           // Caches query objects so queries can be easily reused.
</span><span class="cx">          get: (function(){
</span><span class="cx">                  /**
</span><span class="lines">@@ -1047,6 +1089,9 @@
</span><span class="cx">           * If the workflow does not support multiple
</span><span class="cx">           * selected attachments, reset the selection.
</span><span class="cx">           *
</span><ins>+                * Overrides Backbone.Collection.add
+                * Overrides wp.media.model.Attachments.add
+                *
</ins><span class="cx">            * @param {Array} models
</span><span class="cx">           * @param {Object} options
</span><span class="cx">           * @returns {wp.media.model.Attachment[]}
</span></span></pre>
</div>
</div>

</body>
</html>