<!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>[29056] trunk/src/wp-includes: Media grid:</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/29056">29056</a></dd>
<dt>Author</dt> <dd>helen</dd>
<dt>Date</dt> <dd>2014-07-10 03:49:28 +0000 (Thu, 10 Jul 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media grid:

* Introduce the concept of bulk editing via a separate mode. Like the list view, only bulk deleting is available. The UI is a little funky, especially with the field display toggles there, but refinements will come.
* Up the max thumbnail size from 120px to 150px.
* Slide-down panel for the add new uploader. Known issue: it doesn't close again.
* Remove the toolbar region in the EditAttachment frame.
* Defer a function call so the grid fills available space.
* Give feedback when no results are found. Also needs styling.

props ericlewis. see <a href="http://core.trac.wordpress.org/ticket/24716">#24716</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludescssmediaviewscss">trunk/src/wp-includes/css/media-views.css</a></li>
<li><a href="#trunksrcwpincludesjsmediagridjs">trunk/src/wp-includes/js/media-grid.js</a></li>
<li><a href="#trunksrcwpincludesjsmediaviewsjs">trunk/src/wp-includes/js/media-views.js</a></li>
<li><a href="#trunksrcwpincludesmediatemplatephp">trunk/src/wp-includes/media-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/css/media-views.css (29055 => 29056)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/css/media-views.css        2014-07-10 01:44:20 UTC (rev 29055)
+++ trunk/src/wp-includes/css/media-views.css   2014-07-10 03:49:28 UTC (rev 29056)
</span><span class="lines">@@ -228,7 +228,6 @@
</span><span class="cx"> .media-toolbar-secondary > .media-button,
</span><span class="cx"> .media-toolbar-secondary > .media-button-group {
</span><span class="cx">  margin-right: 10px;
</span><del>-       float: left;
</del><span class="cx">   margin-top: 15px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -996,8 +995,27 @@
</span><span class="cx">  bottom: 0;
</span><span class="cx">  overflow: auto;
</span><span class="cx">  outline: none;
</span><ins>+       -webkit-transition: 1s ease-in-out;
+    transition: 1s ease-in-out;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.attachments-browser .uploader-inline:not(.hidden) + .attachments {
+       -webkit-transform: translateY( 300px );
+       -ms-transform: translateY( 300px );
+       transform: translateY( 300px );
+}
+
+.attachments-browser .uploader-inline.hidden {
+       display: block;
+       -webkit-transform: translateY( -100% );
+       -ms-transform: translateY( -100% );
+       transform: translateY( -100% );
+}
+
+.attachments-browser .uploader-inline-content {
+       top: 0;
+}
+
</ins><span class="cx"> .inline-toolbar {
</span><span class="cx">  position: absolute;
</span><span class="cx">  top: 0;
</span><span class="lines">@@ -1081,7 +1099,8 @@
</span><span class="cx">  left: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.attachments-browser.hide-sidebar .attachments {
</del><ins>+.attachments-browser.hide-sidebar .attachments,
+.attachments-browser.hide-sidebar .uploader-inline {
</ins><span class="cx">   right: 0;
</span><span class="cx">  margin-right: 0;
</span><span class="cx"> }
</span><span class="lines">@@ -2657,6 +2676,11 @@
</span><span class="cx">  left: 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.edit-attachment-frame .media-frame-content {
+       border-bottom: none;
+       bottom: 0;
+}
+
</ins><span class="cx"> /* Hiding this for the moment instead of removing it from the template. */
</span><span class="cx"> .edit-attachment-frame h3 {
</span><span class="cx">  display: none;
</span></span></pre></div>
<a id="trunksrcwpincludesjsmediagridjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-grid.js (29055 => 29056)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-grid.js   2014-07-10 01:44:20 UTC (rev 29055)
+++ trunk/src/wp-includes/js/media-grid.js      2014-07-10 03:49:28 UTC (rev 29056)
</span><span class="lines">@@ -25,7 +25,6 @@
</span><span class="cx">                  menu:    false,
</span><span class="cx">                  router:  'edit-metadata',
</span><span class="cx">                  content: 'edit-metadata',
</span><del>-                       toolbar: 'toolbar',
</del><span class="cx"> 
</span><span class="cx">                  url:     ''
</span><span class="cx">          },
</span><span class="lines">@@ -34,10 +33,6 @@
</span><span class="cx">                  media.controller._State.prototype.initialize.apply( this, arguments );
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               activate: function() {
-                       this.listenTo( this.frame, 'toolbar:render:edit-image', this.toolbar );
-               },
-
</del><span class="cx">           _postActivate: function() {
</span><span class="cx">                  this._content();
</span><span class="cx">                  this._router();
</span><span class="lines">@@ -47,30 +42,6 @@
</span><span class="cx">                  this.stopListening( this.frame );
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               toolbar: function() {
-                       var frame = this.frame,
-                               lastState = frame.lastState(),
-                               previous = lastState && lastState.id;
-
-                       frame.toolbar.set( new media.view.Toolbar({
-                               controller: frame,
-                               items: {
-                                       back: {
-                                               style: 'primary',
-                                               text:     l10n.back,
-                                               priority: 20,
-                                               click:    function() {
-                                                       if ( previous ) {
-                                                               frame.setState( previous );
-                                                       } else {
-                                                               frame.close();
-                                                       }
-                                               }
-                                       }
-                               }
-                       }) );
-               },
-
</del><span class="cx">           /**
</span><span class="cx">           * @access private
</span><span class="cx">           */
</span><span class="lines">@@ -125,12 +96,13 @@
</span><span class="cx">                          modal:     false,
</span><span class="cx">                          selection: [],
</span><span class="cx">                          library:   {},
</span><del>-                               multiple:  false,
</del><ins>+                                multiple:  'add',
</ins><span class="cx">                           state:     'library',
</span><span class="cx">                          uploader:  true,
</span><span class="cx">                          mode:      [ 'grid', 'edit' ]
</span><span class="cx">                  });
</span><span class="cx"> 
</span><ins>+                       $(document).on( 'click', '.add-new-h2', _.bind( this.addNewClickHandler, this ) );
</ins><span class="cx">                   // Ensure core and media grid view UI is enabled.
</span><span class="cx">                  this.$el.addClass('wp-core-ui media-grid-view');
</span><span class="cx"> 
</span><span class="lines">@@ -186,24 +158,33 @@
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="cx">          createStates: function() {
</span><del>-                       var options = this.options;
</del><ins>+                        var options = this.options,
+                               libraryState;
</ins><span class="cx"> 
</span><span class="cx">                  if ( this.options.states ) {
</span><span class="cx">                          return;
</span><span class="cx">                  }
</span><span class="cx"> 
</span><ins>+                       libraryState = new media.controller.Library({
+                               library:    media.query( options.library ),
+                               multiple:   options.multiple,
+                               title:      options.title,
+                               priority:   20,
+                               toolbar:    false,
+                               router:     false,
+                               content:    'browse',
+                               filterable: 'mime-types'
+                       });
+
+                       libraryState._renderTitle = function( view ) {
+                               var text = this.get('title') || '';
+                               view.$el.addClass( 'wrap' );
+                               text += '<a class="add-new-h2">Add New</a>';
+                               view.$el.html( text );
+                       };
</ins><span class="cx">                   // Add the default states.
</span><span class="cx">                  this.states.add([
</span><del>-                               new media.controller.Library({
-                                       library:    media.query( options.library ),
-                                       multiple:   options.multiple,
-                                       title:      options.title,
-                                       priority:   20,
-                                       toolbar:    false,
-                                       router:     false,
-                                       content:    'browse',
-                                       filterable: 'mime-types'
-                               })
</del><ins>+                                libraryState
</ins><span class="cx">                   ]);
</span><span class="cx">          },
</span><span class="cx"> 
</span><span class="lines">@@ -217,6 +198,10 @@
</span><span class="cx">                  this.on( 'edit:attachment:previous', this.editPreviousAttachment, this );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               addNewClickHandler: function() {
+                       this.trigger( 'show:upload:attachment' );
+               },
+
</ins><span class="cx">           editPreviousAttachment: function( currentModel ) {
</span><span class="cx">                  var library = this.state().get('library'),
</span><span class="cx">                          currentModelIndex = library.indexOf( currentModel );
</span><span class="lines">@@ -233,26 +218,17 @@
</span><span class="cx">           * Open the Edit Attachment modal.
</span><span class="cx">           */
</span><span class="cx">          editAttachment: function( model ) {
</span><del>-                       var library = this.state().get('library'), hasPrevious, hasNext;
-                       if ( library.indexOf( model ) > 0 ) {
-                               hasPrevious = true;
-                       }
-                       else {
-                               hasPrevious = false;
-                       }
-                       if ( library.indexOf( model ) < library.length - 1 ) {
-                               hasNext = true;
-                       }
-                       else {
-                               hasNext = false;
-                       }
</del><ins>+                        var library = this.state().get('library');
</ins><span class="cx"> 
</span><del>-                       new media.view.Frame.EditAttachment({
-                               hasPrevious:    hasPrevious,
-                               hasNext:        hasNext,
-                               model:          model,
-                               gridController: this
</del><ins>+                        // Create a new EditAttachment frame, passing along the library and the attachment model.
+                       this.editAttachmentFrame = new media.view.Frame.EditAttachment({
+                               library:        library,
+                               model:          model
</ins><span class="cx">                   });
</span><ins>+
+                       // Listen to events on the edit attachment frame for triggering pagination callback handlers.
+                       this.listenTo( this.editAttachmentFrame, 'edit:attachment:next', this.editNextAttachment );
+                       this.listenTo( this.editAttachmentFrame, 'edit:attachment:previous', this.editPreviousAttachment );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          /**
</span><span class="lines">@@ -363,6 +339,9 @@
</span><span class="cx">                          this.on( 'router:render', this.browseRouter, this );
</span><span class="cx">                  }
</span><span class="cx"> 
</span><ins>+                       this.options.hasPrevious = ( this.options.library.indexOf( this.options.model ) > 0 ) ? true : false;
+                       this.options.hasNext = ( this.options.library.indexOf( this.options.model ) < this.options.library.length - 1 ) ? true : false;
+
</ins><span class="cx">                   // Initialize modal container view.
</span><span class="cx">                  if ( this.options.modal ) {
</span><span class="cx">                          this.modal = new media.view.Modal({
</span><span class="lines">@@ -471,7 +450,7 @@
</span><span class="cx">                  if ( ! this.options.hasPrevious )
</span><span class="cx">                          return;
</span><span class="cx">                  this.modal.close();
</span><del>-                       this.options.gridController.trigger( 'edit:attachment:previous', this.model );
</del><ins>+                        this.trigger( 'edit:attachment:previous', this.model );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          /**
</span><span class="lines">@@ -481,9 +460,8 @@
</span><span class="cx">                  if ( ! this.options.hasNext )
</span><span class="cx">                          return;
</span><span class="cx">                  this.modal.close();
</span><del>-                       this.options.gridController.trigger( 'edit:attachment:next', this.model );
</del><ins>+                        this.trigger( 'edit:attachment:next', this.model );
</ins><span class="cx">           }
</span><del>-
</del><span class="cx">   });
</span><span class="cx"> 
</span><span class="cx">  media.view.GridFieldOptions = media.View.extend({
</span><span class="lines">@@ -514,4 +492,58 @@
</span><span class="cx">          }
</span><span class="cx">  });
</span><span class="cx"> 
</span><ins>+       media.view.BulkSelectionToggleButton = media.view.Button.extend({
+               initialize: function() {
+                       media.view.Button.prototype.initialize.apply( this, arguments );
+                       this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.toggleBulkEditHandler, this ) );
+               },
+
+               click: function() {
+                       var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;
+                       media.view.Button.prototype.click.apply( this, arguments );
+
+                       if ( bulkEditActive ) {
+                               this.controller.deactivateMode( 'bulk-edit' );
+                               this.controller.activateMode( 'edit' );
+                       } else {
+                               this.controller.deactivateMode( 'edit' );
+                               this.controller.activateMode( 'bulk-edit' );
+                       }
+               },
+
+               toggleBulkEditHandler: function() {
+                       var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;
+                       if ( bulkEditActive ) {
+                               this.$el.addClass( 'button-primary' );
+                       } else {
+                               this.$el.removeClass( 'button-primary' );
+                               this.controller.state().get('selection').reset();
+                       }
+               }
+       });
+
+       media.view.BulkDeleteButton = media.view.Button.extend({
+               initialize: function() {
+                       media.view.Button.prototype.initialize.apply( this, arguments );
+                       this.$el.hide();
+                       this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.visibility, this ) );
+               },
+
+               click: function() {
+                       media.view.Button.prototype.click.apply( this, arguments );
+                       while (this.controller.state().get('selection').length > 0) {
+                               this.controller.state().get('selection').at(0).destroy();
+                       }
+               },
+
+               visibility: function() {
+                       var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;
+                       if ( bulkEditActive ) {
+                               this.$el.show();
+                       } else {
+                               this.$el.hide();
+                       }
+               }
+       });
+
</ins><span class="cx"> }(jQuery, _, Backbone, wp));
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunksrcwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/js/media-views.js (29055 => 29056)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/js/media-views.js  2014-07-10 01:44:20 UTC (rev 29055)
+++ trunk/src/wp-includes/js/media-views.js     2014-07-10 03:49:28 UTC (rev 29056)
</span><span class="lines">@@ -665,7 +665,7 @@
</span><span class="cx">                  }
</span><span class="cx"> 
</span><span class="cx">                  if ( ! this.get('edge') ) {
</span><del>-                               this.set( 'edge', 120 );
</del><ins>+                                this.set( 'edge', 150 );
</ins><span class="cx">                   }
</span><span class="cx"> 
</span><span class="cx">                  if ( ! this.get('gutter') ) {
</span><span class="lines">@@ -1785,14 +1785,13 @@
</span><span class="cx">           * @global wp.Uploader
</span><span class="cx">           */
</span><span class="cx">          initialize: function() {
</span><del>-
</del><span class="cx">                   media.view.Frame.prototype.initialize.apply( this, arguments );
</span><span class="cx"> 
</span><span class="cx">                  _.defaults( this.options, {
</span><span class="cx">                          title:    '',
</span><span class="cx">                          modal:    true,
</span><span class="cx">                          uploader: true,
</span><del>-                               mode:     ['select']
</del><ins>+                                mode:     [ 'select' ]
</ins><span class="cx">                   });
</span><span class="cx"> 
</span><span class="cx">                  // Ensure core UI is enabled.
</span><span class="lines">@@ -1808,6 +1807,14 @@
</span><span class="cx">                          this.modal.content( this );
</span><span class="cx">                  }
</span><span class="cx"> 
</span><ins>+                       // Store active "modes" that the frame is in. Unrelated to region modes.
+                       this.activeModes = new Backbone.Collection();
+                       this.activeModes.on( 'add remove reset', _.bind( this.triggerModeEvents, this ) );
+
+                       _.each( this.options.mode, function( mode ) {
+                               this.activeModes.add( new Backbone.Model( { id: mode } ) );
+                       }, this );
+
</ins><span class="cx">                   // Force the uploader off if the upload limit has been exceeded or
</span><span class="cx">                  // if the browser isn't supported.
</span><span class="cx">                  if ( wp.Uploader.limitExceeded || ! wp.Uploader.browser.supported ) {
</span><span class="lines">@@ -1972,6 +1979,42 @@
</span><span class="cx"> 
</span><span class="cx">                  window.tb_remove = this._tb_remove;
</span><span class="cx">                  delete this._tb_remove;
</span><ins>+               },
+
+               /**
+                * Map activeMode collection events to the frame.
+                */
+               triggerModeEvents: function( model, collection, options ) {
+                       var collectionEvent,
+                               modeEventMap = {
+                                       add: 'activate',
+                                       remove: 'deactivate'
+                               },
+                               eventToTrigger;
+                       // Probably a better way to do this.
+                       _.each( options, function( value, key ) {
+                               if ( value ) {
+                                       collectionEvent = key;
+                               }
+                       } );
+
+                       if ( ! _.has( modeEventMap, collectionEvent ) )
+                               return;
+
+                       eventToTrigger = model.get('id') + ':' + modeEventMap[collectionEvent];
+                       this.trigger( eventToTrigger );
+               },
+               activateMode: function( mode ) {
+                       this.activeModes.add( [ { id: mode } ] );
+                       this.trigger( mode + ':activate' );
+               },
+               deactivateMode: function( mode ) {
+                       // Bail if the mode isn't active.
+                       if ( ! this.activeModes.where( { id: mode } ).length ) {
+                               return;
+                       }
+                       this.activeModes.remove( this.activeModes.where( { id: mode } ) );
+                       this.trigger( mode + ':deactivate' );
</ins><span class="cx">           }
</span><span class="cx">  });
</span><span class="cx"> 
</span><span class="lines">@@ -4673,7 +4716,7 @@
</span><span class="cx">                  }
</span><span class="cx"> 
</span><span class="cx">                  // In the grid view, bubble up an edit:attachment event to the controller.
</span><del>-                       if ( _.contains( this.controller.options.mode, 'grid' ) ) {
</del><ins>+                        if ( this.controller.activeModes.where( { id: 'edit' } ).length ) {
</ins><span class="cx">                           this.controller.trigger( 'edit:attachment', this.model );
</span><span class="cx">                          return;
</span><span class="cx">                  }
</span><span class="lines">@@ -5081,7 +5124,10 @@
</span><span class="cx">                  if ( this.options.resize ) {
</span><span class="cx">                          $(window).on( 'resize.attachments', this._resizeCss );
</span><span class="cx">                  }
</span><del>-                       this.css();
</del><ins>+
+                       // Call this.css() after this view has been rendered in the DOM so
+                       // attachments get proper width applied.
+                       _.defer( this.css, this );
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          dispose: function() {
</span><span class="lines">@@ -5531,7 +5577,10 @@
</span><span class="cx">                          AttachmentView: media.view.Attachment.Library
</span><span class="cx">                  });
</span><span class="cx"> 
</span><ins>+                       this.listenTo( this.controller, 'show:upload:attachment', _.bind( this.showUploader, this ) );
</ins><span class="cx">                   this.createToolbar();
</span><ins>+                       this.createUploader();
+                       this.createAttachments();
</ins><span class="cx">                   this.updateContent();
</span><span class="cx">                  if ( this.options.sidebar ) {
</span><span class="cx">                          this.createSidebar();
</span><span class="lines">@@ -5568,7 +5617,7 @@
</span><span class="cx">                  // Feels odd to bring the global media library switcher into the Attachment
</span><span class="cx">                  // browser view. Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar );
</span><span class="cx">                  // which the controller can tap into and add this view?
</span><del>-                       if ( _.contains( this.controller.options.mode, 'grid' ) ) {
</del><ins>+                        if ( this.controller.activeModes.where( { id: 'grid' } ).length ) {
</ins><span class="cx">                           LibraryViewSwitcher = media.View.extend({
</span><span class="cx">                                  className: 'view-switch media-grid-view-switch',
</span><span class="cx">                                  template: media.template( 'media-library-view-switcher')
</span><span class="lines">@@ -5578,6 +5627,18 @@
</span><span class="cx">                                  priority: -90
</span><span class="cx">                          }).render() );
</span><span class="cx"> 
</span><ins>+                               this.toolbar.set( 'bulkSelectionToggleButton', new media.view.BulkSelectionToggleButton({
+                                       text: 'Bulk Edit',
+                                       controller: this.controller,
+                                       priority: -70
+                               }).render() );
+
+                               this.toolbar.set( 'BulkDeleteButton', new media.view.BulkDeleteButton({
+                                       text: 'Bulk Delete',
+                                       controller: this.controller,
+                                       priority: -69
+                               }).render() );
+
</ins><span class="cx">                           this.toolbar.set( 'gridFieldOptions', new media.view.GridFieldOptions({
</span><span class="cx">                                  controller: this.controller,
</span><span class="cx">                                  priority: -50
</span><span class="lines">@@ -5635,48 +5696,38 @@
</span><span class="cx"> 
</span><span class="cx">          updateContent: function() {
</span><span class="cx">                  var view = this;
</span><del>-
-                       if( ! this.attachments ) {
-                               this.createAttachments();
-                       }
-
</del><span class="cx">                   if ( ! this.collection.length ) {
</span><span class="cx">                          this.toolbar.get( 'spinner' ).show();
</span><span class="cx">                          this.collection.more().done(function() {
</span><span class="cx">                                  if ( ! view.collection.length ) {
</span><del>-                                               view.createUploader();
</del><ins>+                                                view.attachmentsNoResults.$el.removeClass( 'hidden' );
+                                       } else {
+                                               view.attachmentsNoResults.$el.addClass( 'hidden' );
</ins><span class="cx">                                   }
</span><span class="cx">                                  view.toolbar.get( 'spinner' ).hide();
</span><span class="cx">                          });
</span><span class="cx">                  } else {
</span><ins>+                               this.attachmentsNoResults.$el.addClass( 'hidden' );
</ins><span class="cx">                           view.toolbar.get( 'spinner' ).hide();
</span><span class="cx">                  }
</span><span class="cx">          },
</span><span class="cx"> 
</span><del>-               removeContent: function() {
-                       _.each(['attachments','uploader'], function( key ) {
-                               if ( this[ key ] ) {
-                                       this[ key ].remove();
-                                       delete this[ key ];
-                               }
-                       }, this );
-               },
-
</del><span class="cx">           createUploader: function() {
</span><del>-                       this.removeContent();
-
</del><span class="cx">                   this.uploader = new media.view.UploaderInline({
</span><span class="cx">                          controller: this.controller,
</span><span class="cx">                          status:     false,
</span><span class="cx">                          message:    l10n.noItemsFound
</span><span class="cx">                  });
</span><span class="cx"> 
</span><ins>+                       this.uploader.$el.addClass( 'hidden' );
</ins><span class="cx">                   this.views.add( this.uploader );
</span><span class="cx">          },
</span><span class="cx"> 
</span><ins>+               showUploader: function() {
+                       this.uploader.$el.removeClass( 'hidden' );
+               },
+
</ins><span class="cx">           createAttachments: function() {
</span><del>-                       this.removeContent();
-
</del><span class="cx">                   this.attachments = new media.view.Attachments({
</span><span class="cx">                          controller:           this.controller,
</span><span class="cx">                          collection:           this.collection,
</span><span class="lines">@@ -5690,6 +5741,17 @@
</span><span class="cx">                  });
</span><span class="cx"> 
</span><span class="cx">                  this.views.add( this.attachments );
</span><ins>+
+                       this.attachmentsNoResults = new media.View({
+                               controller: this.controller
+                       });
+
+                       this.attachmentsNoResults.$el.addClass( 'hidden' );
+                       this.attachmentsNoResults.$el.html( 'No media found.' );
+
+                       this.views.add( this.attachmentsNoResults );
+
+
</ins><span class="cx">           },
</span><span class="cx"> 
</span><span class="cx">          createSidebar: function() {
</span></span></pre></div>
<a id="trunksrcwpincludesmediatemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media-template.php (29055 => 29056)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media-template.php 2014-07-10 01:44:20 UTC (rev 29055)
+++ trunk/src/wp-includes/media-template.php    2014-07-10 03:49:28 UTC (rev 29056)
</span><span class="lines">@@ -276,7 +276,6 @@
</span><span class="cx">          </div>
</span><span class="cx">          <div class="media-frame-router"></div>
</span><span class="cx">          <div class="media-frame-content"></div>
</span><del>-               <div class="media-frame-toolbar"></div>
</del><span class="cx">   </script>
</span><span class="cx"> 
</span><span class="cx">  <script type="text/html" id="tmpl-attachment-details-two-column">
</span><span class="lines">@@ -447,7 +446,7 @@
</span><span class="cx">                  <div class="{{ className }} data-{{ field }}"><#
</span><span class="cx">                          if ( 'uploadedTo' === field ) {
</span><span class="cx">                                  if ( data[ field ] ) {
</span><del>-                                       #><?php _e( 'Uploaded To: ' ) ?>{{ data.uploadedToTitle }}<#
</del><ins>+                                        #><?php _e( 'Uploaded To: ' ) ?><a href="{{ data.uploadedToLink }}">{{ data.uploadedToTitle }}</a><#
</ins><span class="cx">                                   } else {
</span><span class="cx">                                  #><?php _e( 'Unattached' ) ?><#
</span><span class="cx">                                  }
</span></span></pre>
</div>
</div>

</body>
</html>