mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-13 19:11:41 +01:00
b191013198
* 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
50 lines
1.3 KiB
JavaScript
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;
|