| | 517 | |
| | 518 | media.view.BulkSelectionControl = media.View.extend({ |
| | 519 | initialize: function() { |
| | 520 | media.View.prototype.initialize.apply( this, arguments ); |
| | 521 | this.views.add( new media.view.BulkSelectionButton({ |
| | 522 | text: 'Bulk Edit', |
| | 523 | controller: this.options.controller |
| | 524 | }) ); |
| | 525 | this.$el.css( 'display', 'inline' ); |
| | 526 | this.listenTo( this.options.controller, 'bulk-edit:activate', this.bulkEditActivate ); |
| | 527 | this.listenTo( this.options.controller, 'bulk-edit:deactivate', this.bulkEditDeactivate ); |
| | 528 | }, |
| | 529 | |
| | 530 | bulkEditActivate: function() { |
| | 531 | |
| | 532 | }, |
| | 533 | |
| | 534 | bulkEditDeactivate: function() { |
| | 535 | |
| | 536 | } |
| | 537 | }); |
| | 538 | |
| | 539 | |
| | 540 | media.view.BulkSelectionButton = media.view.Button.extend({ |
| | 541 | initialize: function() { |
| | 542 | this.$el.html( 'Bulk Edit' ); |
| | 543 | media.view.Button.prototype.initialize.apply( this, arguments ); |
| | 544 | }, |
| | 545 | |
| | 546 | click: function() { |
| | 547 | media.view.Button.prototype.click.apply( this, arguments ); |
| | 548 | var activeModes = this.controller.options.mode; |
| | 549 | if ( _.contains( activeModes, 'edit' ) ) { |
| | 550 | activeModes = _.without( activeModes, 'edit' ); |
| | 551 | activeModes.push( 'bulk-edit' ); |
| | 552 | this.$el.addClass( 'button-primary'); |
| | 553 | } else { |
| | 554 | activeModes = _.without( activeModes, 'bulk-edit' ); |
| | 555 | activeModes.push( 'edit' ); |
| | 556 | this.$el.removeClass( 'button-primary'); |
| | 557 | this.controller.state().get('selection').reset(); |
| | 558 | } |
| | 559 | this.controller.options.mode = activeModes; |
| | 560 | } |
| | 561 | }); |
| | 562 | |