Revert accidental bits from r22919. see #22628

git-svn-id: http://core.svn.wordpress.org/trunk@22923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-11-29 16:58:08 +00:00
parent 53bdcd5b63
commit 5f7f9c5520
2 changed files with 38 additions and 42 deletions

View File

@ -726,8 +726,7 @@
margin-top: 10px; margin-top: 10px;
} }
.attachments-browser .attachments, .attachments-browser .attachments {
.attachments-browser .uploader-inline {
position: absolute; position: absolute;
top: 50px; top: 50px;
left: 0; left: 0;
@ -932,7 +931,7 @@
display: block; display: block;
} }
.media-frame .uploader-inline { .region-content.uploader-inline {
margin: 20px; margin: 20px;
padding: 20px; padding: 20px;
text-align: center; text-align: center;
@ -1374,7 +1373,6 @@
} }
.attachments-browser .attachments, .attachments-browser .attachments,
.attachments-browser .uploader-inline,
.attachments-browser .media-toolbar { .attachments-browser .media-toolbar {
right: 180px; right: 180px;
} }

View File

@ -262,7 +262,6 @@
describe: false, describe: false,
toolbar: 'main-attachments', toolbar: 'main-attachments',
sidebar: 'settings', sidebar: 'settings',
content: 'browse',
searchable: true, searchable: true,
filterable: false, filterable: false,
uploads: true uploads: true
@ -305,11 +304,19 @@
selection.on( 'add remove reset', this.refreshSelection, this ); selection.on( 'add remove reset', this.refreshSelection, this );
this._updateEmpty();
library.on( 'add remove reset', this._updateEmpty, this );
this.on( 'change:empty', this.refresh, this );
this.refresh(); this.refresh();
this.on( 'insert', this._insertDisplaySettings, this ); this.on( 'insert', this._insertDisplaySettings, this );
}, },
deactivate: function() { deactivate: function() {
this.off( 'change:empty', this.refresh, this );
this.get('library').off( 'add remove reset', this._updateEmpty, this );
// Unbind all event handlers that use this state as the context // Unbind all event handlers that use this state as the context
// from the selection. // from the selection.
this.get('selection').off( null, null, this ); this.get('selection').off( null, null, this );
@ -327,7 +334,23 @@
this.resetDisplays(); this.resetDisplays();
}, },
content: function() {
var frame = this.frame;
if ( this.get('empty') ) {
// Attempt to fetch any Attachments we don't already have.
this.get('library').more();
// In the meantime, render an inline uploader.
frame.content.mode('upload');
} else {
// Browse our library of attachments.
frame.content.mode('browse');
}
},
refresh: function() { refresh: function() {
this.frame.$el.toggleClass( 'hide-toolbar', this.get('empty') );
this.content(); this.content();
this.refreshSelection(); this.refreshSelection();
}, },
@ -366,6 +389,17 @@
setUserSetting( 'urlbutton', display.link ); setUserSetting( 'urlbutton', display.link );
}, },
_updateEmpty: function() {
var library = this.get('library'),
props = library.props;
// If we're filtering the library, bail.
if ( this.get('filterable') && ( props.get('type') || props.get('parent') ) )
return;
this.set( 'empty', ! library.length && ! library.props.get('search') );
},
refreshSelection: function() { refreshSelection: function() {
var selection = this.get('selection'), var selection = this.get('selection'),
mode = this.frame.content.mode(); mode = this.frame.content.mode();
@ -1268,8 +1302,6 @@
browseContent: function() { browseContent: function() {
var state = this.state(); var state = this.state();
this.$el.removeClass('hide-toolbar');
// Browse our library of attachments. // Browse our library of attachments.
this.content.view( new media.view.AttachmentsBrowser({ this.content.view( new media.view.AttachmentsBrowser({
controller: this, controller: this,
@ -2978,10 +3010,8 @@
}); });
this.createToolbar(); this.createToolbar();
this.updateContent(); this.createAttachments();
this.createSidebar(); this.createSidebar();
this.collection.on( 'add remove reset', this.updateContent, this );
}, },
dispose: function() { dispose: function() {
@ -3029,39 +3059,7 @@
} }
}, },
updateContent: function() {
var view = this;
if( ! this.attachments )
this.createAttachments();
if ( ! this.collection.length ) {
this.collection.more().done( function() {
if ( ! view.collection.length )
view.createUploader();
});
}
},
createUploader: function() {
if ( this.attachments ) {
this.attachments.remove();
delete this.attachments;
}
this.uploader = new media.view.UploaderInline({
controller: this.controller
});
this.views.add( this.uploader );
},
createAttachments: function() { createAttachments: function() {
if ( this.uploader ) {
this.uploader.remove();
delete this.uploader;
}
this.attachments = new media.view.Attachments({ this.attachments = new media.view.Attachments({
controller: this.controller, controller: this.controller,
collection: this.collection, collection: this.collection,