Media: Make the upload state a dedicated screen, instead of including its own library view. see #21390.

git-svn-id: http://core.svn.wordpress.org/trunk@22781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Daryl Koopersmith 2012-11-21 18:29:53 +00:00
parent 5ee8582b7a
commit b5335a5d24

View File

@ -444,29 +444,37 @@
// wp.media.controller.Upload // wp.media.controller.Upload
// --------------------------- // ---------------------------
media.controller.Upload = media.controller.Library.extend({ media.controller.Upload = media.controller.State.extend({
defaults: _.defaults({ defaults: _.defaults({
id: 'upload', id: 'upload',
upload: { text: l10n.uploadMoreFiles }, content: 'upload',
searchable: false, sidebar: 'empty',
sortable: true toolbar: 'empty',
}, media.controller.Library.prototype.defaults ),
// The state to navigate to when files are uploading.
libraryState: 'library'
}, media.controller.State.prototype.defaults ),
initialize: function() { initialize: function() {
var library = this.get('library'); media.controller.State.prototype.initialize.apply( this, arguments );
},
// If a `library` attribute isn't provided, create a new activate: function() {
// `Attachments` collection that observes (and thereby receives wp.Uploader.queue.on( 'add', this.uploading, this );
// all uploading) attachments. media.controller.State.prototype.activate.apply( this, arguments );
if ( ! library ) { },
library = new Attachments();
library.observe( wp.Uploader.queue );
this.set( 'library', library );
}
media.controller.Library.prototype.initialize.apply( this, arguments ); deactivate: function() {
wp.Uploader.queue.off( null, null, this );
media.controller.State.prototype.deactivate.apply( this, arguments );
},
uploading: function( attachment ) {
var library = this.get('libraryState');
this.frame.get( library ).get('selection').add( attachment );
this.frame.state( library );
} }
}); });
// wp.media.controller.Gallery // wp.media.controller.Gallery
@ -1175,24 +1183,22 @@
}, },
createStates: function() { createStates: function() {
var options = this.options, var options = this.options;
attributes;
attributes = {
multiple: this.options.multiple,
menu: 'main',
toolbar: 'select'
};
// Add the default states. // Add the default states.
this.states.add([ this.states.add([
// Main states. // Main states.
new media.controller.Library( _.defaults({ new media.controller.Library( _.defaults({
selection: options.selection, selection: options.selection,
library: media.query( options.library ) library: media.query( options.library ),
multiple: this.options.multiple,
menu: 'main',
toolbar: 'select'
}, attributes ) ), }, attributes ) ),
new media.controller.Upload( attributes ) new media.controller.Upload({
menu: 'main'
})
]); ]);
}, },
@ -1245,7 +1251,8 @@
}, },
uploadContent: function() { uploadContent: function() {
// In the meantime, render an inline uploader. this.$el.addClass('hide-sidebar hide-toolbar');
this.content.view( new media.view.UploaderInline({ this.content.view( new media.view.UploaderInline({
controller: this controller: this
}) ); }) );
@ -1342,37 +1349,28 @@
}, },
createStates: function() { createStates: function() {
var options = this.options, var options = this.options;
main, gallery;
main = {
multiple: this.options.multiple,
menu: 'main',
sidebar: 'attachment-settings',
// Update user settings when users adjust the
// attachment display settings.
displayUserSettings: true
};
gallery = {
multiple: true,
menu: 'gallery',
toolbar: 'gallery-add',
excludeState: 'gallery-edit'
};
// Add the default states. // Add the default states.
this.states.add([ this.states.add([
// Main states. // Main states.
new media.controller.Library( _.defaults({ new media.controller.Library({
selection: options.selection, selection: options.selection,
library: media.query( options.library ), library: media.query( options.library ),
editable: true, editable: true,
filterable: 'all' filterable: 'all',
}, main ) ), multiple: this.options.multiple,
menu: 'main',
sidebar: 'attachment-settings',
new media.controller.Upload( main ), // Update user settings when users adjust the
// attachment display settings.
displayUserSettings: true
}),
new media.controller.Upload({
menu: 'main'
}),
// Embed states. // Embed states.
new media.controller.Embed(), new media.controller.Embed(),
@ -1384,15 +1382,21 @@
menu: 'gallery' menu: 'gallery'
}), }),
new media.controller.Library( _.defaults({ new media.controller.Library({
id: 'gallery-library', id: 'gallery-library',
library: media.query({ type: 'image' }), library: media.query({ type: 'image' }),
filterable: 'uploaded' filterable: 'uploaded',
}, gallery ) ), multiple: true,
menu: 'gallery',
toolbar: 'gallery-add',
excludeState: 'gallery-edit'
}),
new media.controller.Upload( _.defaults({ new media.controller.Upload({
id: 'gallery-upload' id: 'gallery-upload',
}, gallery ) ) menu: 'gallery',
libraryState: 'gallery-edit'
})
]); ]);
}, },