diff --git a/src/wp-includes/css/media-views.css b/src/wp-includes/css/media-views.css
index 0f57613..58f8b3f 100644
a
|
b
|
video#inline-media-node { |
2601 | 2601 | margin-top: 0; |
2602 | 2602 | } |
2603 | 2603 | |
| 2604 | .media-grid-view .attachments-browser .bulk-select { |
| 2605 | display: inline-block; |
| 2606 | } |
| 2607 | |
2604 | 2608 | /** |
2605 | 2609 | * Copied styles from the Add theme toolbar. |
2606 | 2610 | * |
… |
… |
video#inline-media-node { |
2644 | 2648 | margin: 0 20px 0 0; |
2645 | 2649 | } |
2646 | 2650 | |
2647 | | .media-grid-view select.attachment-filters { |
| 2651 | .media-grid-view select { |
2648 | 2652 | margin: 0 10px 0 0; |
2649 | 2653 | } |
2650 | 2654 | |
diff --git a/src/wp-includes/js/media-grid.js b/src/wp-includes/js/media-grid.js
index 3521bbc..760beb2 100644
a
|
b
|
|
638 | 638 | } |
639 | 639 | }); |
640 | 640 | |
641 | | media.view.BulkSelectionToggleButton = media.view.Button.extend({ |
| 641 | media.view.BulkSelection = media.View.extend({ |
| 642 | className: 'bulk-select', |
| 643 | |
| 644 | initialize: function() { |
| 645 | this.model = new Backbone.Model({ |
| 646 | currentAction: '', |
| 647 | |
| 648 | }); |
| 649 | |
| 650 | this.views.add( |
| 651 | new media.view.BulkSelectionActionDropdown({ |
| 652 | controller: this |
| 653 | }) |
| 654 | ); |
| 655 | |
| 656 | this.views.add( |
| 657 | new media.view.BulkSelectionActionButton({ |
| 658 | disabled: true, |
| 659 | text: l10n.apply, |
| 660 | controller: this |
| 661 | }) |
| 662 | ); |
| 663 | } |
| 664 | }); |
| 665 | |
| 666 | media.view.BulkSelectionActionDropdown = media.View.extend({ |
| 667 | tagName: 'select', |
| 668 | |
642 | 669 | initialize: function() { |
643 | 670 | media.view.Button.prototype.initialize.apply( this, arguments ); |
644 | | this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.toggleBulkEditHandler, this ) ); |
| 671 | this.listenTo( this.controller.controller.state().get( 'selection' ), 'add remove reset', _.bind( this.enabled, this ) ); |
| 672 | this.$el.append( $('<option></option>').val( '' ).html( l10n.bulkActions ) ) |
| 673 | .append( $('<option></option>').val( 'delete' ).html( l10n.deletePermanently ) ); |
| 674 | this.$el.prop( 'disabled', true ); |
| 675 | this.$el.on( 'change', _.bind( this.toggleChange, this ) ); |
| 676 | }, |
| 677 | |
| 678 | toggleChange: function() { |
| 679 | this.controller.model.set( { 'currentAction': this.$el.val() } ); |
645 | 680 | }, |
646 | 681 | |
647 | 682 | click: function() { |
… |
… |
|
655 | 690 | } |
656 | 691 | }, |
657 | 692 | |
658 | | toggleBulkEditHandler: function() { |
659 | | var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length; |
660 | | if ( bulkEditActive ) { |
661 | | this.$el.addClass( 'button-primary' ); |
662 | | } else { |
663 | | this.$el.removeClass( 'button-primary' ); |
664 | | this.controller.state().get('selection').reset(); |
665 | | } |
| 693 | enabled: function() { |
| 694 | var disabled = ! this.controller.controller.state().get('selection').length; |
| 695 | this.$el.prop( 'disabled', disabled ); |
666 | 696 | } |
667 | 697 | }); |
668 | 698 | |
669 | | media.view.BulkDeleteButton = media.view.Button.extend({ |
| 699 | media.view.BulkSelectionActionButton = media.view.Button.extend({ |
| 700 | tagName: 'button', |
| 701 | |
670 | 702 | initialize: function() { |
671 | 703 | media.view.Button.prototype.initialize.apply( this, arguments ); |
672 | | this.$el.hide(); |
673 | | this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.visibility, this ) ); |
| 704 | |
| 705 | this.listenTo( this.controller.model, 'change', this.enabled, this ); |
674 | 706 | }, |
675 | 707 | |
676 | 708 | click: function() { |
| 709 | var selection = this.controller.controller.state().get('selection'); |
677 | 710 | media.view.Button.prototype.click.apply( this, arguments ); |
678 | | while (this.controller.state().get('selection').length > 0) { |
679 | | this.controller.state().get('selection').at(0).destroy(); |
| 711 | while ( selection.length > 0) { |
| 712 | selection.at(0).destroy(); |
680 | 713 | } |
| 714 | this.enabled(); |
681 | 715 | }, |
682 | 716 | |
683 | | visibility: function() { |
684 | | var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length; |
685 | | if ( bulkEditActive ) { |
686 | | this.$el.show(); |
687 | | } else { |
688 | | this.$el.hide(); |
689 | | } |
| 717 | enabled: function() { |
| 718 | var currentAction = this.controller.model.get( 'currentAction' ), |
| 719 | selection = this.controller.controller.state().get('selection'), |
| 720 | disabled = ! currentAction || ! selection.length; |
| 721 | this.$el.prop( 'disabled', disabled ); |
690 | 722 | } |
691 | 723 | }); |
692 | 724 | |
diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
index 0f3246e..0f089b1 100644
a
|
b
|
|
5657 | 5657 | priority: -90 |
5658 | 5658 | }).render() ); |
5659 | 5659 | |
5660 | | this.toolbar.set( 'bulkSelectionToggleButton', new media.view.BulkSelectionToggleButton({ |
5661 | | text: 'Bulk Edit', |
| 5660 | this.toolbar.set( 'BulkSelection', new media.view.BulkSelection({ |
5662 | 5661 | controller: this.controller, |
5663 | 5662 | priority: -70 |
5664 | 5663 | }).render() ); |
5665 | | |
5666 | | this.toolbar.set( 'BulkDeleteButton', new media.view.BulkDeleteButton({ |
5667 | | text: 'Bulk Delete', |
5668 | | controller: this.controller, |
5669 | | priority: -69 |
5670 | | }).render() ); |
5671 | 5664 | } |
5672 | 5665 | |
5673 | 5666 | filters = this.options.filters; |
diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index a7000b8..f8b9d00 100644
a
|
b
|
function wp_enqueue_media( $args = array() ) { |
2908 | 2908 | 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ), |
2909 | 2909 | 'uploadedToThisPost' => $hier ? __( 'Uploaded to this page' ) : __( 'Uploaded to this post' ), |
2910 | 2910 | 'warnDelete' => __( "You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete." ), |
| 2911 | 'bulkActions' => __( 'Bulk Actions' ), |
| 2912 | 'deletePermanently' => __( 'Delete Permanently' ), |
| 2913 | 'apply' => __( 'Apply' ), |
| 2914 | |
2911 | 2915 | |
2912 | 2916 | // From URL |
2913 | 2917 | 'insertFromUrlTitle' => __( 'Insert from URL' ), |