with subviews, including screen reader text
- this.toolbar.set( 'selectModeToggleButton', new wp.media.view.SelectModeToggleButton({
- text: l10n.bulkSelect,
- controller: this.controller,
- priority: -70
- }).render() );
-
- this.toolbar.set( 'deleteSelectedButton', new wp.media.view.DeleteSelectedButton({
- filters: Filters,
- style: 'primary',
- disabled: true,
- text: mediaTrash ? l10n.trashSelected : l10n.deleteSelected,
- controller: this.controller,
- priority: -60,
- click: function() {
- var changed = [], removed = [],
- selection = this.controller.state().get( 'selection' ),
- library = this.controller.state().get( 'library' );
-
- if ( ! selection.length ) {
- return;
- }
-
- if ( ! mediaTrash && ! window.confirm( l10n.warnBulkDelete ) ) {
- return;
- }
-
- if ( mediaTrash &&
- 'trash' !== selection.at( 0 ).get( 'status' ) &&
- ! window.confirm( l10n.warnBulkTrash ) ) {
-
- return;
- }
-
- selection.each( function( model ) {
- if ( ! model.get( 'nonces' )['delete'] ) {
- removed.push( model );
- return;
- }
-
- if ( mediaTrash && 'trash' === model.get( 'status' ) ) {
- model.set( 'status', 'inherit' );
- changed.push( model.save() );
- removed.push( model );
- } else if ( mediaTrash ) {
- model.set( 'status', 'trash' );
- changed.push( model.save() );
- removed.push( model );
- } else {
- model.destroy({wait: true});
- }
- } );
-
- if ( changed.length ) {
- selection.remove( removed );
-
- $.when.apply( null, changed ).then( _.bind( function() {
- library._requery( true );
- this.controller.trigger( 'selection:action:done' );
- }, this ) );
- } else {
- this.controller.trigger( 'selection:action:done' );
- }
- }
- }).render() );
-
- if ( mediaTrash ) {
- this.toolbar.set( 'deleteSelectedPermanentlyButton', new wp.media.view.DeleteSelectedPermanentlyButton({
- filters: Filters,
- style: 'primary',
- disabled: true,
- text: l10n.deleteSelected,
- controller: this.controller,
- priority: -55,
- click: function() {
- var removed = [], selection = this.controller.state().get( 'selection' );
-
- if ( ! selection.length || ! window.confirm( l10n.warnBulkDelete ) ) {
- return;
- }
-
- selection.each( function( model ) {
- if ( ! model.get( 'nonces' )['delete'] ) {
- removed.push( model );
- return;
- }
-
- model.destroy();
- } );
-
- selection.remove( removed );
- this.controller.trigger( 'selection:action:done' );
- }
- }).render() );
- }
-
- } else if ( this.options.date ) {
- // DateFilter is a