WordPress/wp-includes/js/media/views/attachment-filters/all.js

91 lines
1.6 KiB
JavaScript
Raw Normal View History

/*globals wp */
/**
* wp.media.view.AttachmentFilters.All
*
* @class
* @augments wp.media.view.AttachmentFilters
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var l10n = wp.media.view.l10n,
All;
All = wp.media.view.AttachmentFilters.extend({
createFilters: function() {
var filters = {};
_.each( wp.media.view.settings.mimeTypes || {}, function( text, key ) {
filters[ key ] = {
text: text,
props: {
status: null,
type: key,
uploadedTo: null,
orderby: 'date',
order: 'DESC'
}
};
});
filters.all = {
text: l10n.allMediaItems,
props: {
status: null,
type: null,
uploadedTo: null,
orderby: 'date',
order: 'DESC'
},
priority: 10
};
if ( wp.media.view.settings.post.id ) {
filters.uploaded = {
text: l10n.uploadedToThisPost,
props: {
status: null,
type: null,
uploadedTo: wp.media.view.settings.post.id,
orderby: 'menuOrder',
order: 'ASC'
},
priority: 20
};
}
filters.unattached = {
text: l10n.unattached,
props: {
status: null,
uploadedTo: 0,
type: null,
orderby: 'menuOrder',
order: 'ASC'
},
priority: 50
};
if ( wp.media.view.settings.mediaTrash &&
this.controller.isModeActive( 'grid' ) ) {
filters.trash = {
text: l10n.trash,
props: {
uploadedTo: null,
status: 'trash',
type: null,
orderby: 'date',
order: 'DESC'
},
priority: 50
};
}
this.filters = filters;
}
});
module.exports = All;