<!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>[22809] trunk/wp-includes: Media: Move sidebar from the frame view to the attachment browser view.</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, #logmsg > ol { margin-left: 0; 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/22809">22809</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-11-22 06:30:25 +0000 (Thu, 22 Nov 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media: Move sidebar from the frame view to the attachment browser view. Prevents juggling sidebar visibility state, and makes managing sidebar contents more reasonable. see <a href="http://core.trac.wordpress.org/ticket/21390">#21390</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescssmediaviewscss">trunk/wp-includes/css/media-views.css</a></li>
<li><a href="#trunkwpincludesjsmediaeditorjs">trunk/wp-includes/js/media-editor.js</a></li>
<li><a href="#trunkwpincludesjsmediamodelsjs">trunk/wp-includes/js/media-models.js</a></li>
<li><a href="#trunkwpincludesjsmediaviewsjs">trunk/wp-includes/js/media-views.js</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/media-views.css (22808 => 22809)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/media-views.css        2012-11-22 04:58:35 UTC (rev 22808)
+++ trunk/wp-includes/css/media-views.css        2012-11-22 06:30:25 UTC (rev 22809)
</span><span class="lines">@@ -191,7 +191,7 @@
</span><span class="cx">         position: absolute;
</span><span class="cx">         top: 0;
</span><span class="cx">         right: 0;
</span><del>-        bottom: 61px;
</del><ins>+        bottom: 0;
</ins><span class="cx">         width: 267px;
</span><span class="cx">         padding: 0 16px 24px;
</span><span class="cx">         z-index: 75;
</span><span class="lines">@@ -200,10 +200,6 @@
</span><span class="cx">         overflow: auto;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.hide-sidebar .media-sidebar {
-        right: -300px;
-}
-
</del><span class="cx"> .hide-toolbar .media-sidebar {
</span><span class="cx">         bottom: 0;
</span><span class="cx"> }
</span><span class="lines">@@ -403,7 +399,7 @@
</span><span class="cx">         position: absolute;
</span><span class="cx">         top: 0;
</span><span class="cx">         left: 200px;
</span><del>-        right: 300px;
</del><ins>+        right: 0;
</ins><span class="cx">         bottom: 61px;
</span><span class="cx">         height: auto;
</span><span class="cx">         width: auto;
</span><span class="lines">@@ -411,10 +407,6 @@
</span><span class="cx">         overflow: auto;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-.media-frame.hide-sidebar .region-content {
-        right: 0;
-}
-
</del><span class="cx"> .media-frame.hide-toolbar .region-content {
</span><span class="cx">         bottom: 0;
</span><span class="cx"> }
</span><span class="lines">@@ -690,6 +682,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .attachments-browser .media-toolbar {
</span><ins>+        right: 300px;
</ins><span class="cx">         height: 50px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -704,7 +697,7 @@
</span><span class="cx">         position: absolute;
</span><span class="cx">         top: 50px;
</span><span class="cx">         left: 0;
</span><del>-        right: 0;
</del><ins>+        right: 300px;
</ins><span class="cx">         bottom: 0;
</span><span class="cx">         overflow: auto;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpincludesjsmediaeditorjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-editor.js (22808 => 22809)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-editor.js        2012-11-22 04:58:35 UTC (rev 22808)
+++ trunk/wp-includes/js/media-editor.js        2012-11-22 06:30:25 UTC (rev 22809)
</span><span class="lines">@@ -353,26 +353,16 @@
</span><span class="cx">                         } ) );
</span><span class="cx"> 
</span><span class="cx">                         workflow.on( 'insert', function( selection ) {
</span><del>-                                var state = workflow.state(),
-                                        details = state.get('details');
</del><ins>+                                var state = workflow.state();
</ins><span class="cx"> 
</span><span class="cx">                                 selection = selection || state.get('selection');
</span><span class="cx"> 
</span><del>-                                if ( ! selection || ! details )
</del><ins>+                                if ( ! selection )
</ins><span class="cx">                                         return;
</span><span class="cx"> 
</span><span class="cx">                                 selection.each( function( attachment ) {
</span><del>-                                        var detail = details[ attachment.cid ];
-
-                                        if ( detail )
-                                                detail = detail.toJSON();
-
-                                        // Reset the attachment details.
-                                        delete details[ attachment.cid ];
-
-                                        attachment = attachment.toJSON();
-
-                                        this.send.attachment( detail, attachment );
</del><ins>+                                        var display = state.display( attachment ).toJSON();
+                                        this.send.attachment( display, attachment.toJSON() );
</ins><span class="cx">                                 }, this );
</span><span class="cx">                         }, this );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesjsmediamodelsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-models.js (22808 => 22809)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-models.js        2012-11-22 04:58:35 UTC (rev 22808)
+++ trunk/wp-includes/js/media-models.js        2012-11-22 06:30:25 UTC (rev 22809)
</span><span class="lines">@@ -766,10 +766,10 @@
</span><span class="cx"> 
</span><span class="cx">                         // If single has changed, fire an event.
</span><span class="cx">                         if ( this._single !== previous ) {
</span><ins>+                                if ( previous )
+                                        previous.trigger( 'selection:unsingle', previous, this );
</ins><span class="cx">                                 if ( this._single )
</span><span class="cx">                                         this._single.trigger( 'selection:single', this._single, this );
</span><del>-                                if ( previous )
-                                        previous.trigger( 'selection:unsingle', previous, this );
</del><span class="cx">                         }
</span><span class="cx"> 
</span><span class="cx">                         // Return the single model, or the last model as a fallback.
</span></span></pre></div>
<a id="trunkwpincludesjsmediaviewsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-views.js (22808 => 22809)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-views.js        2012-11-22 04:58:35 UTC (rev 22808)
+++ trunk/wp-includes/js/media-views.js        2012-11-22 06:30:25 UTC (rev 22809)
</span><span class="lines">@@ -210,7 +210,6 @@
</span><span class="cx"> 
</span><span class="cx">                         this.menu();
</span><span class="cx">                         this.toolbar();
</span><del>-                        this.sidebar();
</del><span class="cx">                         this.content();
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="lines">@@ -238,7 +237,7 @@
</span><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        _.each(['toolbar','sidebar','content'], function( region ) {
</del><ins>+        _.each(['toolbar','content'], function( region ) {
</ins><span class="cx">                 media.controller.State.prototype[ region ] = function() {
</span><span class="cx">                         var mode = this.get( region );
</span><span class="cx">                         if ( mode )
</span><span class="lines">@@ -275,14 +274,14 @@
</span><span class="cx">                         if ( ! this.get('gutter') )
</span><span class="cx">                                 this.set( 'gutter', 8 );
</span><span class="cx"> 
</span><del>-                        if ( ! this.get('details') )
-                                this.set( 'details', [] );
</del><ins>+                        this.resetDisplays();
</ins><span class="cx"> 
</span><span class="cx">                         media.controller.State.prototype.initialize.apply( this, arguments );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 activate: function() {
</span><del>-                        var selection = this.get('selection');
</del><ins>+                        var library = this.get('library'),
+                                selection = this.get('selection');
</ins><span class="cx"> 
</span><span class="cx">                         this._excludeStateLibrary();
</span><span class="cx">                         this.buildComposite();
</span><span class="lines">@@ -294,13 +293,15 @@
</span><span class="cx">                         if ( this.get('multiple') )
</span><span class="cx">                                 wp.Uploader.queue.on( 'add', this.selectUpload, this );
</span><span class="cx"> 
</span><del>-                        selection.on( 'selection:single selection:unsingle', this.sidebar, this );
</del><span class="cx">                         selection.on( 'add remove reset', this.refreshSelection, this );
</span><span class="cx"> 
</span><span class="cx">                         this._updateEmpty();
</span><del>-                        this.get('library').on( 'add remove reset', this._updateEmpty, this );
</del><ins>+                        library.on( 'add remove reset', this._updateEmpty, this );
</ins><span class="cx">                         this.on( 'change:empty', this.refresh, this );
</span><span class="cx">                         this.refresh();
</span><ins>+
+
+                        this.on( 'insert', this._insertDisplaySettings, this );
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 deactivate: function() {
</span><span class="lines">@@ -321,17 +322,9 @@
</span><span class="cx"> 
</span><span class="cx">                 reset: function() {
</span><span class="cx">                         this.get('selection').clear();
</span><ins>+                        this.resetDisplays();
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><del>-                sidebar: function() {
-                        var sidebar = this.frame.sidebar;
-
-                        if ( this.get('selection').single() )
-                                sidebar.mode( this.get('sidebar') );
-                        else
-                                sidebar.mode('clear');
-                },
-
</del><span class="cx">                 content: function() {
</span><span class="cx">                         var frame = this.frame;
</span><span class="cx"> 
</span><span class="lines">@@ -348,11 +341,45 @@
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 refresh: function() {
</span><del>-                        this.frame.$el.toggleClass( 'hide-sidebar hide-toolbar', this.get('empty') );
</del><ins>+                        this.frame.$el.toggleClass( 'hide-toolbar', this.get('empty') );
</ins><span class="cx">                         this.content();
</span><span class="cx">                         this.refreshSelection();
</span><span class="cx">                 },
</span><span class="cx"> 
</span><ins>+                resetDisplays: function() {
+                        this._displays = [];
+                        this._defaultDisplaySettings = {
+                                align: getUserSetting( 'align', 'none' ),
+                                size:  getUserSetting( 'imgsize', 'medium' ),
+                                link:  getUserSetting( 'urlbutton', 'post' )
+                        };
+                },
+
+                display: function( attachment ) {
+                        var displays = this._displays;
+
+                        if ( ! displays[ attachment.cid ] )
+                                displays[ attachment.cid ] = new Backbone.Model( this._defaultDisplaySettings );
+
+                        return displays[ attachment.cid ];
+                },
+
+                _insertDisplaySettings: function() {
+                        var selection = this.get('selection'),
+                                display;
+
+                        // If inserting one image, set those display properties as the
+                        // default user setting.
+                        if ( selection.length !== 1 )
+                                return;
+
+                        display = this.display( selection.first() ).toJSON();
+
+                        setUserSetting( 'align', display.align );
+                        setUserSetting( 'imgsize', display.size );
+                        setUserSetting( 'urlbutton', display.link );
+                },
+
</ins><span class="cx">                 _updateEmpty: function() {
</span><span class="cx">                         var library = this.get('library'),
</span><span class="cx">                                 props = library.props;
</span><span class="lines">@@ -448,7 +475,6 @@
</span><span class="cx">                 defaults: _.defaults({
</span><span class="cx">                         id:      'upload',
</span><span class="cx">                         content: 'upload',
</span><del>-                        sidebar: 'empty',
</del><span class="cx">                         toolbar: 'empty',
</span><span class="cx"> 
</span><span class="cx">                         // The state to navigate to when files are uploading.
</span><span class="lines">@@ -488,8 +514,7 @@
</span><span class="cx">                         editing:    false,
</span><span class="cx">                         sortable:   true,
</span><span class="cx">                         searchable: false,
</span><del>-                        toolbar:    'gallery-edit',
-                        sidebar:    'settings'
</del><ins>+                        toolbar:    'gallery-edit'
</ins><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 initialize: function() {
</span><span class="lines">@@ -512,19 +537,34 @@
</span><span class="cx">                         // Watch for uploaded attachments.
</span><span class="cx">                         this.get('library').observe( wp.Uploader.queue );
</span><span class="cx"> 
</span><ins>+                        this.frame.content.on( 'activate:browse', this.gallerySettings, this );
+
</ins><span class="cx">                         media.controller.Library.prototype.activate.apply( this, arguments );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 deactivate: function() {
</span><span class="cx">                         // Stop watching for uploaded attachments.
</span><span class="cx">                         this.get('library').unobserve( wp.Uploader.queue );
</span><ins>+
+                        this.frame.content.off( null, null, this );
</ins><span class="cx">                         media.controller.Library.prototype.deactivate.apply( this, arguments );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><del>-                sidebar: function() {
-                        media.controller.Library.prototype.sidebar.apply( this, arguments );
-                        this.frame.sidebar.trigger('gallery-settings');
-                        return this;
</del><ins>+                gallerySettings: function() {
+                        var library = this.get('library');
+
+                        if ( ! library )
+                                return;
+
+                        library.gallery = library.gallery || new Backbone.Model();
+
+                        this.frame.content.view().sidebar.set({
+                                gallery: new media.view.Settings.Gallery({
+                                        controller: this,
+                                        model:      library.gallery,
+                                        priority:   40
+                                })
+                        });
</ins><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="lines">@@ -1033,7 +1073,7 @@
</span><span class="cx">         media.view.MediaFrame = media.view.Frame.extend({
</span><span class="cx">                 className: 'media-frame',
</span><span class="cx">                 template:  media.template('media-frame'),
</span><del>-                regions:   ['menu','content','sidebar','toolbar'],
</del><ins>+                regions:   ['menu','content','toolbar'],
</ins><span class="cx"> 
</span><span class="cx">                 initialize: function() {
</span><span class="cx">                         media.view.Frame.prototype.initialize.apply( this, arguments );
</span><span class="lines">@@ -1108,7 +1148,7 @@
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 iframeContent: function() {
</span><del>-                        this.$el.addClass('hide-toolbar hide-sidebar');
</del><ins>+                        this.$el.addClass('hide-toolbar');
</ins><span class="cx">                         this.content.view( new media.view.Iframe({
</span><span class="cx">                                 controller: this
</span><span class="cx">                         }).render() );
</span><span class="lines">@@ -1215,8 +1255,6 @@
</span><span class="cx">                         this.menu.on( 'activate:main', this.mainMenu, this );
</span><span class="cx">                         this.content.on( 'activate:browse', this.browseContent, this );
</span><span class="cx">                         this.content.on( 'activate:upload', this.uploadContent, this );
</span><del>-                        this.sidebar.on( 'activate:clear', this.clearSidebar, this );
-                        this.sidebar.on( 'activate:settings', this.settingsSidebar, this );
</del><span class="cx">                         this.toolbar.on( 'activate:select', this.selectToolbar, this );
</span><span class="cx"> 
</span><span class="cx">                         this.on( 'refresh:selection', this.refreshSelectToolbar, this );
</span><span class="lines">@@ -1254,52 +1292,20 @@
</span><span class="cx">                                 search:     state.get('searchable'),
</span><span class="cx">                                 upload:     state.get('upload'),
</span><span class="cx">                                 filters:    state.get('filterable'),
</span><ins>+                                display:    state.get('displaySettings'),
</ins><span class="cx"> 
</span><span class="cx">                                 AttachmentView: state.get('AttachmentView')
</span><span class="cx">                         }) );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 uploadContent: function() {
</span><del>-                        this.$el.addClass('hide-sidebar hide-toolbar');
</del><ins>+                        this.$el.addClass('hide-toolbar');
</ins><span class="cx"> 
</span><span class="cx">                         this.content.view( new media.view.UploaderInline({
</span><span class="cx">                                 controller: this
</span><span class="cx">                         }) );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><del>-                // Sidebars
-                clearSidebar: function() {
-                        this.sidebar.view( new media.view.Sidebar({
-                                controller: this
-                        }) );
-                },
-
-                settingsSidebar: function( options ) {
-                        var single = this.state().get('selection').single(),
-                                views = {};
-
-                        views.details = new media.view.Attachment.Details({
-                                controller: this,
-                                model:      single,
-                                priority:   80
-                        }).render();
-
-
-                        if ( single.get('compat') ) {
-                                views.compat = new media.view.AttachmentCompat({
-                                        controller: this,
-                                        model:      single,
-                                        priority:   120
-                                }).render();
-                        }
-
-                        this.sidebar.view( new media.view.Sidebar({
-                                controller: this,
-                                silent:     options &amp;&amp; options.silent,
-                                views:      views
-                        }) );
-                },
-
</del><span class="cx">                 // Toolbars
</span><span class="cx">                 selectToolbar: function( options ) {
</span><span class="cx">                         options = _.defaults( options || {}, {
</span><span class="lines">@@ -1370,8 +1376,9 @@
</span><span class="cx">                                         filterable: 'all',
</span><span class="cx">                                         multiple:   this.options.multiple,
</span><span class="cx">                                         menu:       'main',
</span><del>-                                        sidebar:    'attachment-settings',
</del><span class="cx"> 
</span><ins>+                                        // Show the attachment display settings.
+                                        displaySettings: true,
</ins><span class="cx">                                         // Update user settings when users adjust the
</span><span class="cx">                                         // attachment display settings.
</span><span class="cx">                                         displayUserSettings: true
</span><span class="lines">@@ -1422,10 +1429,6 @@
</span><span class="cx">                                                 'edit-selection': 'editSelectionContent'
</span><span class="cx">                                         },
</span><span class="cx"> 
</span><del>-                                        sidebar: {
-                                                'attachment-settings': 'attachmentSettingsSidebar'
-                                        },
-
</del><span class="cx">                                         toolbar: {
</span><span class="cx">                                                 'main-attachments': 'mainAttachmentsToolbar',
</span><span class="cx">                                                 'main-embed':       'mainEmbedToolbar',
</span><span class="lines">@@ -1439,8 +1442,6 @@
</span><span class="cx">                                         this[ region ].on( 'activate:' + handler, this[ callback ], this );
</span><span class="cx">                                 }, this );
</span><span class="cx">                         }, this );
</span><del>-
-                        this.sidebar.on( 'gallery-settings', this.onSidebarGallerySettings, this );
</del><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 // Menus
</span><span class="lines">@@ -1503,7 +1504,6 @@
</span><span class="cx">                                 model:      this.state()
</span><span class="cx">                         }).render();
</span><span class="cx"> 
</span><del>-                        this.$el.addClass('hide-sidebar');
</del><span class="cx">                         this.content.view( view );
</span><span class="cx">                         view.url.focus();
</span><span class="cx">                 },
</span><span class="lines">@@ -1555,30 +1555,6 @@
</span><span class="cx">                         }, options );
</span><span class="cx">                 },
</span><span class="cx"> 
</span><del>-                attachmentSettingsSidebar: function( options ) {
-                        var state = this.state(),
-                                display = state.get('details'),
-                                single = state.get('selection').single();
-
-                        this.settingsSidebar({ silent: true });
-
-                        display[ single.cid ] = display[ single.cid ] || new Backbone.Model({
-                                align: getUserSetting( 'align', 'none' ),
-                                size:  getUserSetting( 'imgsize', 'medium' ),
-                                link:  getUserSetting( 'urlbutton', 'post' )
-                        });
-
-                        this.sidebar.view().set({
-                                display: new media.view.Settings.AttachmentDisplay({
-                                        controller:   this,
-                                        model:        display[ single.cid ],
-                                        attachment:   single,
-                                        priority:     160,
-                                        userSettings: state.get('displayUserSettings')
-                                }).render()
-                        }, options );
-                },
-
</del><span class="cx">                 // Toolbars
</span><span class="cx">                 mainAttachmentsToolbar: function() {
</span><span class="cx">                         this.toolbar.view( new media.view.Toolbar.Insert({
</span><span class="lines">@@ -2242,8 +2218,9 @@
</span><span class="cx"> 
</span><span class="cx">                 unset: function( id ) {
</span><span class="cx">                         var view = this.get( id );
</span><ins>+
</ins><span class="cx">                         if ( view )
</span><del>-                                view.dispose();
</del><ins>+                                view.remove();
</ins><span class="cx"> 
</span><span class="cx">                         delete this._views[ id ];
</span><span class="cx">                         return this;
</span><span class="lines">@@ -2878,18 +2855,31 @@
</span><span class="cx">                 className: 'attachments-browser',
</span><span class="cx"> 
</span><span class="cx">                 initialize: function() {
</span><del>-                        var filters, FiltersConstructor;
-
</del><span class="cx">                         this.controller = this.options.controller;
</span><span class="cx"> 
</span><span class="cx">                         _.defaults( this.options, {
</span><span class="cx">                                 filters: false,
</span><span class="cx">                                 search:  true,
</span><span class="cx">                                 upload:  false,
</span><ins>+                                display: false,
</ins><span class="cx"> 
</span><span class="cx">                                 AttachmentView: media.view.Attachment.Library
</span><span class="cx">                         });
</span><span class="cx"> 
</span><ins>+                        this.createToolbar();
+                        this.createAttachments();
+                        this.createSidebar();
+                },
+
+                dispose: function() {
+                        this.options.selection.off( null, null, this );
+                        media.View.prototype.dispose.apply( this, arguments );
+                        return this;
+                },
+
+                createToolbar: function() {
+                        var filters, FiltersConstructor;
+
</ins><span class="cx">                         this.toolbar = new media.view.Toolbar({
</span><span class="cx">                                 controller: this.controller
</span><span class="cx">                         });
</span><span class="lines">@@ -2933,7 +2923,9 @@
</span><span class="cx">                                         text:     l10n.selectFiles
</span><span class="cx">                                 }, this.options.upload ) ).render() );
</span><span class="cx">                         }
</span><ins>+                },
</ins><span class="cx"> 
</span><ins>+                createAttachments: function() {
</ins><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">@@ -2946,6 +2938,54 @@
</span><span class="cx">                         });
</span><span class="cx"> 
</span><span class="cx">                         this.views.add( this.attachments );
</span><ins>+                },
+
+                createSidebar: function() {
+                        this.sidebar = new media.view.Sidebar({
+                                controller: this.controller
+                        });
+
+                        this.views.add( this.sidebar );
+
+                        this.options.selection.on( 'selection:single', this.createSingle, this );
+                        this.options.selection.on( 'selection:unsingle', this.disposeSingle, this );
+                },
+
+                createSingle: function() {
+                        var sidebar = this.sidebar,
+                                single = this.options.selection.single(),
+                                views = {};
+
+                        sidebar.set( 'details', new media.view.Attachment.Details({
+                                controller: this.controller,
+                                model:      single,
+                                priority:   80
+                        }) );
+
+                        if ( single.get('compat') ) {
+                                sidebar.set( 'compat', new media.view.AttachmentCompat({
+                                        controller: this.controller,
+                                        model:      single,
+                                        priority:   120
+                                }) );
+                        }
+
+                        if ( this.options.display ) {
+                                sidebar.set( 'display', new media.view.Settings.AttachmentDisplay({
+                                        controller:   this.controller,
+                                        model:        this.model.display( single ),
+                                        attachment:   single,
+                                        priority:     160,
+                                        userSettings: this.model.get('displayUserSettings')
+                                }) );
+                        }
+                },
+
+                disposeSingle: function() {
+                        var sidebar = this.sidebar;
+                        sidebar.unset('details');
+                        sidebar.unset('compat');
+                        sidebar.unset('display');
</ins><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (22808 => 22809)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-11-22 04:58:35 UTC (rev 22808)
+++ trunk/wp-includes/media.php        2012-11-22 06:30:25 UTC (rev 22809)
</span><span class="lines">@@ -1404,7 +1404,6 @@
</span><span class="cx">         &lt;script type=&quot;text/html&quot; id=&quot;tmpl-media-frame&quot;&gt;
</span><span class="cx">                 &lt;div class=&quot;media-frame-menu&quot;&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;div class=&quot;media-frame-content&quot;&gt;&lt;/div&gt;
</span><del>-                &lt;div class=&quot;media-frame-sidebar&quot;&gt;&lt;/div&gt;
</del><span class="cx">                 &lt;div class=&quot;media-frame-toolbar&quot;&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;div class=&quot;media-frame-uploader&quot;&gt;&lt;/div&gt;
</span><span class="cx">         &lt;/script&gt;
</span></span></pre>
</div>
</div>

</body>
</html>