Ticket #28842: 28842.10.diff
| File 28842.10.diff, 14.2 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/css/media-views.css
729 729 -webkit-box-sizing: border-box; 730 730 -moz-box-sizing: border-box; 731 731 box-sizing: border-box; 732 opacity: 1; 732 733 } 733 734 735 .media-frame.mode-select .attachment { 736 opacity: 0.65; 737 -webkit-transition: opacity 250ms; 738 transition: opacity 250ms; 739 } 740 741 .media-frame.mode-select .attachment.selected { 742 opacity: 1; 743 } 744 734 745 .attachment:focus { 735 746 -webkit-box-shadow: 736 747 inset 0 0 0 5px #fff, … … 741 752 outline: none; 742 753 } 743 754 755 .media-frame.mode-grid .attachment:focus { 756 -webkit-box-shadow: 757 inset 0 0 0 6px #f1f1f1, 758 inset 0 0 1px 7px #5b9dd9; 759 box-shadow: 760 inset 0 0 0 6px #f1f1f1, 761 inset 0 0 1px 7px #5b9dd9; 762 } 763 744 764 .selected.attachment { 745 765 -webkit-box-shadow: 746 766 inset 0 0 0 5px #fff, … … 750 770 inset 0 0 0 7px #ccc; 751 771 } 752 772 773 .media-frame.mode-grid .selected.attachment { 774 -webkit-box-shadow: 775 inset 0 0 0 6px #f1f1f1, 776 inset 0 0 0 7px #ccc; 777 box-shadow: 778 inset 0 0 0 6px #f1f1f1, 779 inset 0 0 0 7px #ccc; 780 } 781 753 782 .attachment-preview { 754 783 position: relative; 755 784 -webkit-box-shadow: … … 922 951 } 923 952 924 953 .selected.attachment:focus, 925 .attachment.details, 926 .media-frame.mode-grid .selected.attachment { 954 .attachment.details { 927 955 -webkit-box-shadow: 928 956 inset 0 0 0 3px #fff, 929 957 inset 0 0 0 7px #1e8cbe; … … 932 960 inset 0 0 0 7px #1e8cbe; 933 961 } 934 962 963 .media-frame.mode-grid .selected.attachment:focus { 964 -webkit-box-shadow: 965 inset 0 0 0 3px #f1f1f1, 966 inset 0 0 0 7px #1e8cbe; 967 box-shadow: 968 inset 0 0 0 3px #f1f1f1, 969 inset 0 0 0 7px #1e8cbe; 970 } 971 935 972 .attachment.details .check, 936 973 .attachment.selected .check:focus, 937 974 .media-frame.mode-grid .attachment.selected .check { … … 944 981 0 0 0 2px #1e8cbe; 945 982 } 946 983 947 .media-frame.mode-grid .attachment .check {948 display: block;949 }950 951 .media-frame.mode-grid .attachment .check div {952 background-position: 21px 0;953 }954 955 984 .attachment.details .check div, 956 985 .media-frame.mode-grid .attachment.selected .check div { 957 986 background-position: -21px 0; … … 997 1026 .attachments-browser .media-toolbar-primary > .media-button-group, 998 1027 .attachments-browser .media-toolbar-secondary > .media-button, 999 1028 .attachments-browser .media-toolbar-secondary > .media-button-group { 1000 margin -top: 10px;1029 margin: 11px 0; 1001 1030 } 1002 1031 1003 1032 .attachments-browser .attachments, … … 2453 2482 2454 2483 /* Regions we don't use at all */ 2455 2484 .media-frame.mode-grid .media-frame-title, 2456 .media-frame.mode-grid .media-frame-toolbar,2457 2485 .media-frame.mode-grid .media-frame-router, 2458 2486 .media-frame.mode-grid .media-frame-menu { 2459 2487 display: none; … … 2488 2516 padding: 2px; 2489 2517 } 2490 2518 2519 .media-frame.mode-select .attachments { 2520 padding: 2px; 2521 } 2522 2491 2523 /** 2492 2524 * Copied styles from the Add theme toolbar. 2493 2525 * … … 2511 2543 border: none; 2512 2544 } 2513 2545 2546 .media-frame.mode-select .attachments-browser .media-toolbar.fixed { 2547 position: fixed; 2548 top: 28px; 2549 left: 182px; 2550 right: 20px; 2551 width: auto; 2552 } 2553 2514 2554 .media-frame.mode-grid input[type="search"] { 2515 2555 margin: 1px; 2516 2556 padding: 3px 5px; … … 2539 2579 margin-top: 15px; 2540 2580 } 2541 2581 2582 .attachments-browser .media-toolbar-secondary > .select-mode-toggle-button { 2583 margin-right: 10px; 2584 } 2585 2542 2586 .media-frame.mode-grid .attachments-browser { 2543 2587 padding: 0; 2544 2588 } -
src/wp-includes/js/media-grid.js
62 62 multiple: 'add', 63 63 state: 'library', 64 64 uploader: true, 65 mode: [ 'grid' ]65 mode: [ 'grid', 'edit' ] 66 66 }); 67 67 68 $(document).on( 'click', '.add-new-h2', _.bind( this.addNewClickHandler, this ) ); 68 this.$window = $( window ); 69 this.$adminBar = $( '#wpadminbar' ); 70 this.$window.on( 'scroll', _.debounce( _.bind( this.fixPosition, this ), 15 ) ); 71 $( document ).on( 'click', '.add-new-h2', _.bind( this.addNewClickHandler, this ) ); 69 72 70 73 // Ensure core and media grid view UI is enabled. 71 74 this.$el.addClass('wp-core-ui'); … … 96 99 // Call 'initialize' directly on the parent class. 97 100 media.view.MediaFrame.prototype.initialize.apply( this, arguments ); 98 101 102 this.on( 'all', function () { console.log( arguments ); } ); 103 99 104 // Append the frame view directly the supplied container. 100 105 this.$el.appendTo( this.options.container ); 101 106 … … 130 135 multiple: options.multiple, 131 136 title: options.title, 132 137 content: 'browse', 138 toolbar: 'select', 133 139 contentUserSetting: false, 134 140 filterable: 'all' 135 141 }) … … 146 152 this.on( 'edit:attachment', this.openEditAttachmentModal, this ); 147 153 }, 148 154 155 fixPosition: function() { 156 var $browser; 157 if ( ! this.isModeActive( 'select' ) ) { 158 return; 159 } 160 161 $browser = this.$('.attachments-browser'); 162 163 if ( $browser.offset().top < this.$window.scrollTop() + this.$adminBar.height() ) { 164 $browser.find('.media-toolbar').addClass( 'fixed' ); 165 } else { 166 $browser.find('.media-toolbar').removeClass( 'fixed' ); 167 } 168 }, 169 149 170 /** 150 171 * Click handler for the `Add New` button. 151 172 */ … … 542 563 } 543 564 }); 544 565 545 /** 546 * Controller for bulk selection. 547 */ 548 media.view.BulkSelection = media.View.extend({ 549 className: 'bulk-select', 550 566 media.view.SelectModeToggleButton = media.view.Button.extend({ 551 567 initialize: function() { 552 this.model = new Backbone.Model({ 553 currentAction: '' 568 media.view.Button.prototype.initialize.apply( this, arguments ); 569 this.listenTo( this.controller, 'select:activate select:deactivate', this.toggleBulkEditHandler ); 570 }, 554 571 555 }); 572 click: function() { 573 media.view.Button.prototype.click.apply( this, arguments ); 574 if ( this.controller.isModeActive( 'select' ) ) { 575 this.controller.deactivateMode( 'select' ).activateMode( 'edit' ); 576 } else { 577 this.controller.deactivateMode( 'edit' ).activateMode( 'select' ); 578 } 579 }, 556 580 557 this.views.add( new media.view.Label({ 558 value: l10n.bulkActionsLabel, 559 attributes: { 560 'for': 'bulk-select-dropdown' 561 } 562 }) ); 581 render: function() { 582 media.view.Button.prototype.render.apply( this, arguments ); 583 this.$el.addClass( 'select-mode-toggle-button' ); 584 return this; 585 }, 563 586 564 this.views.add( 565 new media.view.BulkSelectionActionDropdown({ 566 controller: this 567 }) 568 ); 587 toggleBulkEditHandler: function() { 588 var toolbar = this.controller.content.get().toolbar, children; 569 589 570 this.views.add( 571 new media.view.BulkSelectionActionButton({ 572 disabled: true, 573 text: l10n.apply, 574 controller: this 575 }) 576 ); 590 children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *'); 591 592 if ( this.controller.isModeActive( 'select' ) ) { 593 this.model.set( 'text', l10n.cancelSelection ); 594 children.not( '.delete-selected-button' ).hide(); 595 toolbar.$( '.select-mode-toggle-button' ).show(); 596 toolbar.$( '.delete-selected-button' ).removeClass( 'hidden' ); 597 } else { 598 this.model.set( 'text', l10n.bulkSelect ); 599 toolbar.$( '.delete-selected-button' ).addClass( 'hidden' ); 600 children.not( '.spinner, .delete-selected-button' ).show(); 601 this.controller.state().get( 'selection' ).reset(); 602 } 577 603 } 578 604 }); 579 605 580 /** 581 * Bulk Selection dropdown view. 582 * 583 * @constructor 584 * @augments wp.media.View 585 * @augments wp.Backbone.View 586 * @augments Backbone.View 587 */ 588 media.view.BulkSelectionActionDropdown = media.View.extend({ 589 tagName: 'select', 590 id: 'bulk-select-dropdown', 591 606 media.view.DeleteSelectedButton = media.view.Button.extend({ 592 607 initialize: function() { 593 608 media.view.Button.prototype.initialize.apply( this, arguments ); 594 this.listenTo( this.controller.controller.state().get( 'selection' ), 'add remove reset', _.bind( this.enabled, this ) ); 595 this.$el.append( $('<option></option>').val( '' ).html( l10n.bulkActions ) ) 596 .append( $('<option></option>').val( 'delete' ).html( l10n.deletePermanently ) ); 597 this.$el.prop( 'disabled', true ); 598 this.$el.on( 'change', _.bind( this.changeHandler, this ) ); 609 this.listenTo( this.controller, 'selection:toggle', this.toggleDisabled ); 599 610 }, 600 611 601 /** 602 * Change handler for the dropdown. 603 * 604 * Sets the bulk selection controller's currentAction. 605 */ 606 changeHandler: function() { 607 this.controller.model.set( { 'currentAction': this.$el.val() } ); 612 toggleDisabled: function() { 613 this.$el.attr( 'disabled', ! this.controller.state().get( 'selection' ).length ); 608 614 }, 609 615 610 /** 611 * Enable or disable the dropdown if attachments have been selected. 612 */ 613 enabled: function() { 614 var disabled = ! this.controller.controller.state().get('selection').length; 615 this.$el.prop( 'disabled', disabled ); 616 render: function() { 617 media.view.Button.prototype.render.apply( this, arguments ); 618 this.$el.addClass( 'delete-selected-button hidden' ); 619 return this; 616 620 } 617 621 }); 618 622 619 623 /** 620 * Bulk Selection dropdown view.621 *622 * @constructor623 *624 * @augments wp.media.view.Button625 * @augments wp.media.View626 * @augments wp.Backbone.View627 * @augments Backbone.View628 */629 media.view.BulkSelectionActionButton = media.view.Button.extend({630 tagName: 'button',631 632 initialize: function() {633 media.view.Button.prototype.initialize.apply( this, arguments );634 635 this.listenTo( this.controller.model, 'change', this.enabled, this );636 this.listenTo( this.controller.controller.state().get( 'selection' ), 'add remove reset', _.bind( this.enabled, this ) );637 },638 /**639 * Button click handler.640 */641 click: function() {642 var selection = this.controller.controller.state().get('selection');643 media.view.Button.prototype.click.apply( this, arguments );644 645 if ( 'delete' === this.controller.model.get( 'currentAction' ) ) {646 // Currently assumes delete is the only action647 if ( confirm( l10n.warnBulkDelete ) ) {648 while ( selection.length > 0 ) {649 selection.at(0).destroy();650 }651 }652 }653 654 this.enabled();655 },656 /**657 * Enable or disable the button depending if a bulk action is selected658 * in the bulk select dropdown, and if attachments have been selected.659 */660 enabled: function() {661 var currentAction = this.controller.model.get( 'currentAction' ),662 selection = this.controller.controller.state().get('selection'),663 disabled = ! currentAction || ! selection.length;664 this.$el.prop( 'disabled', disabled );665 }666 });667 668 /**669 624 * A filter dropdown for month/dates. 670 625 */ 671 626 media.view.DateFilter = media.view.AttachmentFilters.extend({ -
src/wp-includes/js/media-views.js
1792 1792 deactivateMode: function( mode ) { 1793 1793 // Bail if the mode isn't active. 1794 1794 if ( ! this.isModeActive( mode ) ) { 1795 return ;1795 return this; 1796 1796 } 1797 1797 this.activeModes.remove( this.activeModes.where( { id: mode } ) ); 1798 1798 this.$el.removeClass( 'mode-' + mode ); … … 4821 4821 4822 4822 // In the grid view, bubble up an edit:attachment event to the controller. 4823 4823 if ( this.controller.isModeActive( 'grid' ) ) { 4824 // Pass the current target to restore focus when closing 4825 this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); 4824 if ( this.controller.isModeActive( 'edit' ) ) { 4825 // Pass the current target to restore focus when closing 4826 this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); 4826 4827 4827 // Don't scroll the view and don't attempt to submit anything. 4828 event.stopPropagation(); 4829 return; 4828 // Don't scroll the view and don't attempt to submit anything. 4829 event.stopPropagation(); 4830 return; 4831 } 4832 4833 if ( this.controller.isModeActive( 'select' ) ) { 4834 method = 'toggle'; 4835 } 4830 4836 } 4831 4837 4832 4838 if ( event.shiftKey ) { … … 4839 4845 method: method 4840 4846 }); 4841 4847 4848 this.controller.trigger( 'selection:toggle' ); 4849 4842 4850 // Don't scroll the view and don't attempt to submit anything. 4843 4851 event.stopPropagation(); 4844 4852 }, … … 5784 5792 priority: -90 5785 5793 }).render() ); 5786 5794 5787 // BulkSelection is a <div> with subviews, including screen reader text5788 this.toolbar.set( 'bulkSelection', new media.view.BulkSelection({5789 controller: this.controller,5790 priority: -705791 }).render() );5792 5793 5795 // DateFilter is a <select>, screen reader text needs to be rendered before 5794 5796 this.toolbar.set( 'dateFilterLabel', new media.view.Label({ 5795 5797 value: l10n.filterByDate, … … 5803 5805 model: this.collection.props, 5804 5806 priority: -75 5805 5807 }).render() ); 5808 5809 // BulkSelection is a <div> with subviews, including screen reader text 5810 this.toolbar.set( 'selectModeToggleButton', new media.view.SelectModeToggleButton({ 5811 text: l10n.bulkSelect, 5812 controller: this.controller, 5813 priority: -70 5814 }).render() ); 5815 5816 this.toolbar.set( 'deleteSelectedButton', new media.view.DeleteSelectedButton({ 5817 style: 'primary', 5818 disabled: true, 5819 text: l10n.deleteSelected, 5820 controller: this.controller, 5821 priority: -60, 5822 click: function() { 5823 while ( this.controller.state().get( 'selection' ).length > 0 ) { 5824 this.controller.state().get( 'selection' ).at( 0 ).destroy(); 5825 } 5826 } 5827 }).render() ); 5806 5828 } 5807 5829 5808 5830 this.toolbar.set( 'spinner', new media.view.Spinner({ -
src/wp-includes/media.php
2936 2936 'warnBulkDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), 2937 2937 'bulkActions' => __( 'Bulk Actions' ), 2938 2938 'bulkActionsLabel' => __( 'Select bulk action' ), 2939 'bulkSelect' => __( 'Bulk Select' ), 2940 'cancelSelection' => __( 'Cancel Selection' ), 2941 'deleteSelected' => __( 'Delete Selected' ), 2939 2942 'deletePermanently' => __( 'Delete Permanently' ), 2940 2943 'apply' => __( 'Apply' ), 2941 2944 'filterByDate' => __( 'Filter by date' ),