<!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>[42415] trunk/src/wp-includes/js: Docs: Improve JSDoc for `media/views/attachments.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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42415">42415</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42415","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>atimmer</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-12-21 14:26:17 +0000 (Thu, 21 Dec 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Docs: Improve JSDoc for `media/views/attachments.js`.

Props maartenleenders, herregroen, jipmoors, ireneyoast.
Fixes <a href="https://core.trac.wordpress.org/ticket/42832">#42832</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesjsmediaviewsattachmentsjs">trunk/src/wp-includes/js/media/views/attachments.js</a></li>
<li><a href="#trunksrcwpincludesjsmediaviewsjs">trunk/src/wp-includes/js/media-views.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesjsmediaviewsattachmentsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/media/views/attachments.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/media/views/attachments.js       2017-12-21 02:39:21 UTC (rev 42414)
+++ trunk/src/wp-includes/js/media/views/attachments.js 2017-12-21 14:26:17 UTC (rev 42415)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,16 +2,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $ = jQuery,
</span><span class="cx" style="display: block; padding: 0 10px">        Attachments;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * wp.media.view.Attachments
- *
- * @memberOf wp.media.view
- *
- * @class
- * @augments wp.media.View
- * @augments wp.Backbone.View
- * @augments Backbone.View
- */
</del><span class="cx" style="display: block; padding: 0 10px"> Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
</span><span class="cx" style="display: block; padding: 0 10px">        tagName:   'ul',
</span><span class="cx" style="display: block; padding: 0 10px">        className: 'attachments',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,9 +10,44 @@
</span><span class="cx" style="display: block; padding: 0 10px">                tabIndex: -1
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Represents the overview of attachments in the Media Library.
+        *
+        * The constructor binds events to the collection this view represents when
+        * adding or removing attachments or resetting the entire collection.
+        *
+        * @since 3.5.0
+        *
+        * @constructs
+        * @memberof wp.media.view
+        *
+        * @augments wp.media.View
+        *
+        * @listens collection:add
+        * @listens collection:remove
+        * @listens collection:reset
+        * @listens controller:library:selection:add
+        * @listens scrollElement:scroll
+        * @listens this:ready
+        * @listens controller:open
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         initialize: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.el.id = _.uniqueId('__attachments-view-');
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                /**
+                * @param refreshSensitivity The time in milliseconds to throttle the scroll
+                *                           handler.
+                * @param refreshThreshold   The amount of pixels that should be scrolled before
+                *                           loading more attachments from the server.
+                * @param AttachmentView     The view class to be used for models in the
+                *                           collection.
+                * @param sortable           A jQuery sortable options object
+                *                           ( http://api.jqueryui.com/sortable/ ).
+                * @param resize             A boolean indicating whether or not to listen to
+                *                           resize events.
+                * @param idealColumnWidth   The width in pixels which a column should have when
+                *                           calculating the total number of columns.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 _.defaults( this.options, {
</span><span class="cx" style="display: block; padding: 0 10px">                        refreshSensitivity: wp.media.isTouchDevice ? 300 : 200,
</span><span class="cx" style="display: block; padding: 0 10px">                        refreshThreshold:   3,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,6 +67,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        });
</span><span class="cx" style="display: block; padding: 0 10px">                }, this );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                /*
+                * Find the view to be removed, delete it and call the remove function to clear
+                * any set event handlers.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 this.collection.on( 'remove', function( attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        var view = this._viewsByCid[ attachment.cid ];
</span><span class="cx" style="display: block; padding: 0 10px">                        delete this._viewsByCid[ attachment.cid ];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -69,24 +98,63 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        this.on( 'ready', this.bindEvents );
</span><span class="cx" style="display: block; padding: 0 10px">                        this.controller.on( 'open', this.setColumns );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Call this.setColumns() after this view has been rendered in the DOM so
-                       // attachments get proper width applied.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Call this.setColumns() after this view has been rendered in the
+                        * DOM so attachments get proper width applied.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         _.defer( this.setColumns, this );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Listens to the resizeEvent on the window.
+        *
+        * Adjusts the amount of columns accordingly. First removes any existing event
+        * handlers to prevent duplicate listeners.
+        *
+        * @since 4.0.0
+        *
+        * @listens window:resize
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         bindEvents: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$window.off( this.resizeEvent ).on( this.resizeEvent, _.debounce( this.setColumns, 50 ) );
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Focuses the first item in the collection.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         attachmentFocus: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$( 'li:first' ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Restores focus to the selected item in the collection.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         restoreFocus: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$( 'li.selected:first' ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Handles events for arrow key presses.
+        *
+        * Focuses the attachment in the direction of the used arrow key if it exists.
+        *
+        * @since 4.0.0
+        *
+        * @param {KeyboardEvent} event The keyboard event that triggered this function.
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         arrowEvent: function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var attachments = this.$el.children( 'li' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        perRow = this.columns,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -97,7 +165,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Left arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Left arrow = 37.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 37 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( 0 === index ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -105,7 +173,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index - 1 ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Up arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Up arrow = 38.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 38 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( 1 === row ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -113,7 +181,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index - perRow ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Right arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Right arrow = 39.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 39 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( attachments.length === index ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -121,7 +189,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index + 1 ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Down arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Down arrow = 40.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 40 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( Math.ceil( attachments.length / perRow ) === row ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -130,18 +198,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Clears any set event handlers.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         dispose: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.collection.props.off( null, null, this );
</span><span class="cx" style="display: block; padding: 0 10px">                if ( this.options.resize ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.$window.off( this.resizeEvent );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /**
-                * call 'dispose' directly on the parent class
-                */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Call 'dispose' directly on the parent class.
</ins><span class="cx" style="display: block; padding: 0 10px">                 View.prototype.dispose.apply( this, arguments );
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Calculates the amount of columns.
+        *
+        * Calculates the amount of columns and sets it on the data-columns attribute
+        * of .media-frame-content.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         setColumns: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var prev = this.columns,
</span><span class="cx" style="display: block; padding: 0 10px">                        width = this.$el.width();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -155,6 +238,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Initializes jQuery sortable on the attachment list.
+        *
+        * Fails gracefully if jQuery sortable doesn't exist or isn't passed in the
+        * options.
+        *
+        * @since 3.5.0
+        *
+        * @fires collection:reset
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         initSortable: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var collection = this.collection;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,8 +261,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        // If the `collection` has a `comparator`, disable sorting.
</span><span class="cx" style="display: block; padding: 0 10px">                        disabled: !! collection.comparator,
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Change the position of the attachment as soon as the
-                       // mouse pointer overlaps a thumbnail.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Change the position of the attachment as soon as the mouse pointer overlaps a
+                        * thumbnail.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         tolerance: 'pointer',
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Record the initial `index` of the dragged model.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -175,8 +272,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ui.item.data('sortableIndexStart', ui.item.index());
</span><span class="cx" style="display: block; padding: 0 10px">                        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Update the model's index in the collection.
-                       // Do so silently, as the view is already accurate.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Update the model's index in the collection. Do so silently, as the view
+                        * is already accurate.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         update: function( event, ui ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                var model = collection.at( ui.item.data('sortableIndexStart') ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        comparator = collection.comparator;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -200,14 +299,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Fire the `reset` event to ensure other collections sync.
</span><span class="cx" style="display: block; padding: 0 10px">                                collection.trigger( 'reset', collection );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // If the collection is sorted by menu order,
-                               // update the menu order.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         // If the collection is sorted by menu order, update the menu order.
</ins><span class="cx" style="display: block; padding: 0 10px">                                 collection.saveMenuOrder();
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }, this.options.sortable ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If the `orderby` property is changed on the `collection`,
-               // check to see if we have a `comparator`. If so, disable sorting.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * If the `orderby` property is changed on the `collection`, check to see if we
+                * have a `comparator`. If so, disable sorting.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 collection.props.on( 'change:orderby', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.$el.sortable( 'option', 'disabled', !! collection.comparator );
</span><span class="cx" style="display: block; padding: 0 10px">                }, this );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,12 +316,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">                this.refreshSortable();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Disables jQuery sortable if collection has a comparator or collection.orderby
+        * equals menuOrder.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         refreshSortable: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! this.options.sortable || ! $.fn.sortable ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If the `collection` has a `comparator`, disable sorting.
</del><span class="cx" style="display: block; padding: 0 10px">                 var collection = this.collection,
</span><span class="cx" style="display: block; padding: 0 10px">                        orderby = collection.props.get('orderby'),
</span><span class="cx" style="display: block; padding: 0 10px">                        enabled = 'menuOrder' === orderby || ! collection.comparator;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -230,8 +337,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Creates a new view for an attachment and adds it to _viewsByCid.
+        *
+        * @since 3.5.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param {wp.media.model.Attachment} attachment
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @returns {wp.media.View}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *
+        * @returns {wp.media.View} The created view.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        createAttachmentView: function( attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var view = new this.options.AttachmentView({
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,33 +356,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return this._viewsByCid[ attachment.cid ] = view;
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Prepares view for display.
+        *
+        * Creates views for every attachment in collection if the collection is not
+        * empty, otherwise clears all views and loads more attachments.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         prepare: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Create all of the Attachment views, and replace
-               // the list in a single DOM operation.
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( this.collection.length ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.views.set( this.collection.map( this.createAttachmentView, this ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               // If there are no elements, clear the views and load some.
</del><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.views.unset();
</span><span class="cx" style="display: block; padding: 0 10px">                        this.collection.more().done( this.scroll );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Triggers the scroll function to check if we should query for additional
+        * attachments right away.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         ready: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Trigger the scroll event to check if we're within the
-               // threshold to query for additional attachments.
</del><span class="cx" style="display: block; padding: 0 10px">                 this.scroll();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Handles scroll events.
+        *
+        * Shows the spinner if we're close to the bottom. Loads more attachments from
+        * server if we're {refreshThreshold} times away from the bottom.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         scroll: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var view = this,
</span><span class="cx" style="display: block; padding: 0 10px">                        el = this.options.scrollElement,
</span><span class="cx" style="display: block; padding: 0 10px">                        scrollTop = el.scrollTop,
</span><span class="cx" style="display: block; padding: 0 10px">                        toolbar;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // The scroll event occurs on the document, but the element
-               // that should be checked is the document body.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * The scroll event occurs on the document, but the element that should be
+                * checked is the document body.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( el === document ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        el = document.body;
</span><span class="cx" style="display: block; padding: 0 10px">                        scrollTop = $(document).scrollTop();
</span></span></pre></div>
<a id="trunksrcwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/media-views.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/media-views.js   2017-12-21 02:39:21 UTC (rev 42414)
+++ trunk/src/wp-includes/js/media-views.js     2017-12-21 14:26:17 UTC (rev 42415)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6620,16 +6620,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">        $ = jQuery,
</span><span class="cx" style="display: block; padding: 0 10px">        Attachments;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * wp.media.view.Attachments
- *
- * @memberOf wp.media.view
- *
- * @class
- * @augments wp.media.View
- * @augments wp.Backbone.View
- * @augments Backbone.View
- */
</del><span class="cx" style="display: block; padding: 0 10px"> Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{
</span><span class="cx" style="display: block; padding: 0 10px">        tagName:   'ul',
</span><span class="cx" style="display: block; padding: 0 10px">        className: 'attachments',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6638,9 +6628,44 @@
</span><span class="cx" style="display: block; padding: 0 10px">                tabIndex: -1
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Represents the overview of attachments in the Media Library.
+        *
+        * The constructor binds events to the collection this view represents when
+        * adding or removing attachments or resetting the entire collection.
+        *
+        * @since 3.5.0
+        *
+        * @constructs
+        * @memberof wp.media.view
+        *
+        * @augments wp.media.View
+        *
+        * @listens collection:add
+        * @listens collection:remove
+        * @listens collection:reset
+        * @listens controller:library:selection:add
+        * @listens scrollElement:scroll
+        * @listens this:ready
+        * @listens controller:open
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         initialize: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.el.id = _.uniqueId('__attachments-view-');
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                /**
+                * @param refreshSensitivity The time in milliseconds to throttle the scroll
+                *                           handler.
+                * @param refreshThreshold   The amount of pixels that should be scrolled before
+                *                           loading more attachments from the server.
+                * @param AttachmentView     The view class to be used for models in the
+                *                           collection.
+                * @param sortable           A jQuery sortable options object
+                *                           ( http://api.jqueryui.com/sortable/ ).
+                * @param resize             A boolean indicating whether or not to listen to
+                *                           resize events.
+                * @param idealColumnWidth   The width in pixels which a column should have when
+                *                           calculating the total number of columns.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 _.defaults( this.options, {
</span><span class="cx" style="display: block; padding: 0 10px">                        refreshSensitivity: wp.media.isTouchDevice ? 300 : 200,
</span><span class="cx" style="display: block; padding: 0 10px">                        refreshThreshold:   3,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6660,6 +6685,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        });
</span><span class="cx" style="display: block; padding: 0 10px">                }, this );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                /*
+                * Find the view to be removed, delete it and call the remove function to clear
+                * any set event handlers.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 this.collection.on( 'remove', function( attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        var view = this._viewsByCid[ attachment.cid ];
</span><span class="cx" style="display: block; padding: 0 10px">                        delete this._viewsByCid[ attachment.cid ];
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6687,24 +6716,63 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        this.on( 'ready', this.bindEvents );
</span><span class="cx" style="display: block; padding: 0 10px">                        this.controller.on( 'open', this.setColumns );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Call this.setColumns() after this view has been rendered in the DOM so
-                       // attachments get proper width applied.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Call this.setColumns() after this view has been rendered in the
+                        * DOM so attachments get proper width applied.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         _.defer( this.setColumns, this );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Listens to the resizeEvent on the window.
+        *
+        * Adjusts the amount of columns accordingly. First removes any existing event
+        * handlers to prevent duplicate listeners.
+        *
+        * @since 4.0.0
+        *
+        * @listens window:resize
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         bindEvents: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$window.off( this.resizeEvent ).on( this.resizeEvent, _.debounce( this.setColumns, 50 ) );
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Focuses the first item in the collection.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         attachmentFocus: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$( 'li:first' ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Restores focus to the selected item in the collection.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         restoreFocus: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.$( 'li.selected:first' ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Handles events for arrow key presses.
+        *
+        * Focuses the attachment in the direction of the used arrow key if it exists.
+        *
+        * @since 4.0.0
+        *
+        * @param {KeyboardEvent} event The keyboard event that triggered this function.
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         arrowEvent: function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var attachments = this.$el.children( 'li' ),
</span><span class="cx" style="display: block; padding: 0 10px">                        perRow = this.columns,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6715,7 +6783,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Left arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Left arrow = 37.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 37 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( 0 === index ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6723,7 +6791,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index - 1 ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Up arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Up arrow = 38.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 38 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( 1 === row ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6731,7 +6799,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index - perRow ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Right arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Right arrow = 39.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 39 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( attachments.length === index ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6739,7 +6807,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        attachments.eq( index + 1 ).focus();
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Down arrow
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Down arrow = 40.
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( 40 === event.keyCode ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        if ( Math.ceil( attachments.length / perRow ) === row ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                return;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6748,18 +6816,33 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Clears any set event handlers.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         dispose: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                this.collection.props.off( null, null, this );
</span><span class="cx" style="display: block; padding: 0 10px">                if ( this.options.resize ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.$window.off( this.resizeEvent );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /**
-                * call 'dispose' directly on the parent class
-                */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Call 'dispose' directly on the parent class.
</ins><span class="cx" style="display: block; padding: 0 10px">                 View.prototype.dispose.apply( this, arguments );
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Calculates the amount of columns.
+        *
+        * Calculates the amount of columns and sets it on the data-columns attribute
+        * of .media-frame-content.
+        *
+        * @since 4.0.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         setColumns: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var prev = this.columns,
</span><span class="cx" style="display: block; padding: 0 10px">                        width = this.$el.width();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6773,6 +6856,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Initializes jQuery sortable on the attachment list.
+        *
+        * Fails gracefully if jQuery sortable doesn't exist or isn't passed in the
+        * options.
+        *
+        * @since 3.5.0
+        *
+        * @fires collection:reset
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         initSortable: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var collection = this.collection;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6784,8 +6879,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        // If the `collection` has a `comparator`, disable sorting.
</span><span class="cx" style="display: block; padding: 0 10px">                        disabled: !! collection.comparator,
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Change the position of the attachment as soon as the
-                       // mouse pointer overlaps a thumbnail.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Change the position of the attachment as soon as the mouse pointer overlaps a
+                        * thumbnail.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         tolerance: 'pointer',
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                        // Record the initial `index` of the dragged model.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6793,8 +6890,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                ui.item.data('sortableIndexStart', ui.item.index());
</span><span class="cx" style="display: block; padding: 0 10px">                        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Update the model's index in the collection.
-                       // Do so silently, as the view is already accurate.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 /*
+                        * Update the model's index in the collection. Do so silently, as the view
+                        * is already accurate.
+                        */
</ins><span class="cx" style="display: block; padding: 0 10px">                         update: function( event, ui ) {
</span><span class="cx" style="display: block; padding: 0 10px">                                var model = collection.at( ui.item.data('sortableIndexStart') ),
</span><span class="cx" style="display: block; padding: 0 10px">                                        comparator = collection.comparator;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6818,14 +6917,15 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Fire the `reset` event to ensure other collections sync.
</span><span class="cx" style="display: block; padding: 0 10px">                                collection.trigger( 'reset', collection );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // If the collection is sorted by menu order,
-                               // update the menu order.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         // If the collection is sorted by menu order, update the menu order.
</ins><span class="cx" style="display: block; padding: 0 10px">                                 collection.saveMenuOrder();
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><span class="cx" style="display: block; padding: 0 10px">                }, this.options.sortable ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If the `orderby` property is changed on the `collection`,
-               // check to see if we have a `comparator`. If so, disable sorting.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * If the `orderby` property is changed on the `collection`, check to see if we
+                * have a `comparator`. If so, disable sorting.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 collection.props.on( 'change:orderby', function() {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.$el.sortable( 'option', 'disabled', !! collection.comparator );
</span><span class="cx" style="display: block; padding: 0 10px">                }, this );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6834,12 +6934,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">                this.refreshSortable();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Disables jQuery sortable if collection has a comparator or collection.orderby
+        * equals menuOrder.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         refreshSortable: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! this.options.sortable || ! $.fn.sortable ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // If the `collection` has a `comparator`, disable sorting.
</del><span class="cx" style="display: block; padding: 0 10px">                 var collection = this.collection,
</span><span class="cx" style="display: block; padding: 0 10px">                        orderby = collection.props.get('orderby'),
</span><span class="cx" style="display: block; padding: 0 10px">                        enabled = 'menuOrder' === orderby || ! collection.comparator;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6848,8 +6955,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Creates a new view for an attachment and adds it to _viewsByCid.
+        *
+        * @since 3.5.0
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @param {wp.media.model.Attachment} attachment
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @returns {wp.media.View}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  *
+        * @returns {wp.media.View} The created view.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><span class="cx" style="display: block; padding: 0 10px">        createAttachmentView: function( attachment ) {
</span><span class="cx" style="display: block; padding: 0 10px">                var view = new this.options.AttachmentView({
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -6862,33 +6974,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return this._viewsByCid[ attachment.cid ] = view;
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Prepares view for display.
+        *
+        * Creates views for every attachment in collection if the collection is not
+        * empty, otherwise clears all views and loads more attachments.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         prepare: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Create all of the Attachment views, and replace
-               // the list in a single DOM operation.
</del><span class="cx" style="display: block; padding: 0 10px">                 if ( this.collection.length ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.views.set( this.collection.map( this.createAttachmentView, this ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-               // If there are no elements, clear the views and load some.
</del><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><span class="cx" style="display: block; padding: 0 10px">                        this.views.unset();
</span><span class="cx" style="display: block; padding: 0 10px">                        this.collection.more().done( this.scroll );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Triggers the scroll function to check if we should query for additional
+        * attachments right away.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         ready: function() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Trigger the scroll event to check if we're within the
-               // threshold to query for additional attachments.
</del><span class="cx" style="display: block; padding: 0 10px">                 this.scroll();
</span><span class="cx" style="display: block; padding: 0 10px">        },
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * Handles scroll events.
+        *
+        * Shows the spinner if we're close to the bottom. Loads more attachments from
+        * server if we're {refreshThreshold} times away from the bottom.
+        *
+        * @since 3.5.0
+        *
+        * @returns {void}
+        */
</ins><span class="cx" style="display: block; padding: 0 10px">         scroll: function() {
</span><span class="cx" style="display: block; padding: 0 10px">                var view = this,
</span><span class="cx" style="display: block; padding: 0 10px">                        el = this.options.scrollElement,
</span><span class="cx" style="display: block; padding: 0 10px">                        scrollTop = el.scrollTop,
</span><span class="cx" style="display: block; padding: 0 10px">                        toolbar;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // The scroll event occurs on the document, but the element
-               // that should be checked is the document body.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * The scroll event occurs on the document, but the element that should be
+                * checked is the document body.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( el === document ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        el = document.body;
</span><span class="cx" style="display: block; padding: 0 10px">                        scrollTop = $(document).scrollTop();
</span></span></pre>
</div>
</div>

</body>
</html>