WordPress/wp-includes/js/media/views/button/delete-selected.js
Scott Taylor b191013198 Media JS files:
* In media manifests, ditch IIFEs and global injection, these get dynamically scoped via Browserify
* Remove the `debug` option from `browserify:media`
* Add `jshint:media` to `jshint:corejs`
* Add a trailing newline to all new module files

Props iseulde.
See #28510.

Built from https://develop.svn.wordpress.org/trunk@31385


git-svn-id: http://core.svn.wordpress.org/trunk@31366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-09 16:01:29 +00:00

50 lines
1.3 KiB
JavaScript

/**
* A button that handles bulk Delete/Trash logic
*
* @constructor
* @augments wp.media.view.Button
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var Button = require( '../button.js' ),
l10n = wp.media.view.l10n,
DeleteSelected;
DeleteSelected = Button.extend({
initialize: function() {
Button.prototype.initialize.apply( this, arguments );
if ( this.options.filters ) {
this.listenTo( this.options.filters.model, 'change', this.filterChange );
}
this.listenTo( this.controller, 'selection:toggle', this.toggleDisabled );
},
filterChange: function( model ) {
if ( 'trash' === model.get( 'status' ) ) {
this.model.set( 'text', l10n.untrashSelected );
} else if ( wp.media.view.settings.mediaTrash ) {
this.model.set( 'text', l10n.trashSelected );
} else {
this.model.set( 'text', l10n.deleteSelected );
}
},
toggleDisabled: function() {
this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length );
},
render: function() {
Button.prototype.render.apply( this, arguments );
if ( this.controller.isModeActive( 'select' ) ) {
this.$el.addClass( 'delete-selected-button' );
} else {
this.$el.addClass( 'delete-selected-button hidden' );
}
this.toggleDisabled();
return this;
}
});
module.exports = DeleteSelected;