Media JS: Give the master Workspace view control over which Attachment view it uses. see #21390, #21807, #21809.

git-svn-id: https://develop.svn.wordpress.org/trunk@22045 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith 2012-09-27 06:39:12 +00:00
parent 6fff91f4d1
commit 3324270681
1 changed files with 15 additions and 3 deletions

View File

@ -374,6 +374,9 @@
className: 'media-workspace', className: 'media-workspace',
template: media.template('media-workspace'), template: media.template('media-workspace'),
// The single `Attachment` view to be used in the `Attachments` view.
AttachmentView: media.view.Attachment,
events: { events: {
'dragenter': 'maybeInitUploader', 'dragenter': 'maybeInitUploader',
'mouseenter': 'maybeInitUploader' 'mouseenter': 'maybeInitUploader'
@ -392,7 +395,9 @@
this.attachmentsView = new media.view.Attachments({ this.attachmentsView = new media.view.Attachments({
controller: this.controller, controller: this.controller,
directions: this.controller.get('multiple') ? l10n.selectMediaMultiple : l10n.selectMediaSingular, directions: this.controller.get('multiple') ? l10n.selectMediaMultiple : l10n.selectMediaSingular,
collection: this.collection collection: this.collection,
AttachmentView: this.AttachmentView
}); });
this.$content.append( this.attachmentsView.$el ); this.$content.append( this.attachmentsView.$el );
@ -451,6 +456,9 @@
* wp.media.view.Workspace.Library * wp.media.view.Workspace.Library
*/ */
media.view.Workspace.Library = media.view.Workspace.extend({ media.view.Workspace.Library = media.view.Workspace.extend({
// The single `Attachment` view to be used in the `Attachments` view.
// AttachmentView: media.view.Attachment.Library,
initialize: function() { initialize: function() {
media.view.Workspace.prototype.initialize.apply( this, arguments ); media.view.Workspace.prototype.initialize.apply( this, arguments );
@ -521,6 +529,9 @@
* wp.media.view.Workspace.Gallery * wp.media.view.Workspace.Gallery
*/ */
media.view.Workspace.Gallery = media.view.Workspace.extend({ media.view.Workspace.Gallery = media.view.Workspace.extend({
// The single `Attachment` view to be used in the `Attachments` view.
// AttachmentView: media.view.Attachment.Gallery,
initialize: function() { initialize: function() {
media.view.Workspace.prototype.initialize.apply( this, arguments ); media.view.Workspace.prototype.initialize.apply( this, arguments );
this.initToolbarView(); this.initToolbarView();
@ -581,7 +592,8 @@
_.defaults( this.options, { _.defaults( this.options, {
refreshSensitivity: 200, refreshSensitivity: 200,
refreshThreshold: 3 refreshThreshold: 3,
AttachmentView: media.view.Attachment
}); });
_.each(['add','remove'], function( method ) { _.each(['add','remove'], function( method ) {
@ -619,7 +631,7 @@
// Otherwise, create all of the Attachment views, and replace // Otherwise, create all of the Attachment views, and replace
// the list in a single DOM operation. // the list in a single DOM operation.
this.$list.html( this.collection.map( function( attachment ) { this.$list.html( this.collection.map( function( attachment ) {
return new media.view.Attachment({ return new this.options.AttachmentView({
controller: this.controller, controller: this.controller,
model: attachment model: attachment
}).render().$el; }).render().$el;