WordPress/wp-includes/js/media/views/button/delete-selected-permanently.js

46 lines
1.2 KiB
JavaScript

/**
* wp.media.view.DeleteSelectedPermanentlyButton
*
* When MEDIA_TRASH is true, a button that handles bulk Delete Permanently logic
*
* @class
* @augments wp.media.view.DeleteSelectedButton
* @augments wp.media.view.Button
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var Button = wp.media.view.Button,
DeleteSelected = require( './delete-selected.js' ),
DeleteSelectedPermanently;
DeleteSelectedPermanently = DeleteSelected.extend({
initialize: function() {
DeleteSelected.prototype.initialize.apply( this, arguments );
this.listenTo( this.controller, 'select:activate', this.selectActivate );
this.listenTo( this.controller, 'select:deactivate', this.selectDeactivate );
},
filterChange: function( model ) {
this.canShow = ( 'trash' === model.get( 'status' ) );
},
selectActivate: function() {
this.toggleDisabled();
this.$el.toggleClass( 'hidden', ! this.canShow );
},
selectDeactivate: function() {
this.toggleDisabled();
this.$el.addClass( 'hidden' );
},
render: function() {
Button.prototype.render.apply( this, arguments );
this.selectActivate();
return this;
}
});
module.exports = DeleteSelectedPermanently;