]> scripts.mit.edu Git - autoinstallsdev/wordpress.git/blobdiff - wp-includes/js/media-views.js
WordPress 4.0.1
[autoinstallsdev/wordpress.git] / wp-includes / js / media-views.js
index 84e1f3655dda83c6a4397fa0a2e44f4c8ab8e387..e334b20735fd024fa3c15bd07cf298b2300bdfcb 100644 (file)
                                        controller: this.controller,
                                        priority: -60,
                                        click: function() {
-                                               var model, changed = [], self = this,
+                                               var changed = [], removed = [], self = this,
                                                        selection = this.controller.state().get( 'selection' ),
                                                        library = this.controller.state().get( 'library' );
 
                                                        return;
                                                }
 
-                                               while ( selection.length > 0 ) {
-                                                       model = selection.at( 0 );
+                                               selection.each( function( model ) {
+                                                       if ( ! model.get( 'nonces' )['delete'] ) {
+                                                               removed.push( model );
+                                                               return;
+                                                       }
+
                                                        if ( media.view.settings.mediaTrash && 'trash' === model.get( 'status' ) ) {
                                                                model.set( 'status', 'inherit' );
                                                                changed.push( model.save() );
-                                                               selection.remove( model );
+                                                               removed.push( model );
                                                        } else if ( media.view.settings.mediaTrash ) {
                                                                model.set( 'status', 'trash' );
                                                                changed.push( model.save() );
-                                                               selection.remove( model );
+                                                               removed.push( model );
                                                        } else {
                                                                model.destroy();
                                                        }
-                                               }
+                                               } );
 
                                                if ( changed.length ) {
+                                                       selection.remove( removed );
+
                                                        $.when.apply( null, changed ).then( function() {
                                                                library._requery( true );
                                                                self.controller.trigger( 'selection:action:done' );