Changeset 29212
- Timestamp:
- 07/17/2014 08:41:40 PM (11 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 5 edited
-
css/media-views.css (modified) (9 diffs)
-
js/media-grid.js (modified) (4 diffs)
-
js/media-views.js (modified) (4 diffs)
-
media-template.php (modified) (2 diffs)
-
media.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/css/media-views.css
r29204 r29212 914 914 915 915 .attachment.details .check, 916 .media-grid-view .attachment .check {916 .media-grid-view .attachment.selected .check { 917 917 background-color: #1e8cbe; 918 918 -webkit-box-shadow: 0 0 0 1px #fff, … … 922 922 } 923 923 924 .media-grid-view .attachment .check { 925 display: block; 926 } 927 928 .media-grid-view .attachment .check div { 929 background-position: 21px 0; 930 } 931 924 932 .attachment.details .check div, 925 .media-grid-view .attachment .check div {933 .media-grid-view .attachment.selected .check div { 926 934 background-position: -21px 0; 927 935 } 928 936 929 937 .attachment.details .check:hover div, 930 .media-grid-view .attachment .check:hover div {938 .media-grid-view .attachment.selected .check:hover div { 931 939 background-position: -60px 0; 932 940 } … … 1052 1060 } 1053 1061 1054 .attachment :hover.inline-toolbar {1062 .attachment-preview:hover ~ .inline-toolbar { 1055 1063 display: block; 1056 1064 } … … 2601 2609 } 2602 2610 2611 .media-grid-view .media-toolbar select { 2612 margin-top: 1px; 2613 font-size: inherit; 2614 } 2615 2616 .media-grid-view .attachments-browser .bulk-select { 2617 display: inline-block; 2618 } 2619 2603 2620 /** 2604 2621 * Copied styles from the Add theme toolbar. … … 2606 2623 * This should be OOCSS'd so both use a shared selector. 2607 2624 */ 2608 .media-grid-view . media-toolbar {2625 .media-grid-view .attachments-browser .media-toolbar { 2609 2626 background: #fff; 2610 2627 -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1); … … 2644 2661 } 2645 2662 2646 .media-grid-view select .attachment-filters{2663 .media-grid-view select { 2647 2664 margin: 0 10px 0 0; 2648 2665 } … … 2730 2747 } 2731 2748 2732 .media-frame.mode-bulk-edit .attachment :hover.inline-toolbar {2749 .media-frame.mode-bulk-edit .attachment-preview:hover ~ .inline-toolbar { 2733 2750 display: none; 2734 2751 } … … 2912 2929 } 2913 2930 2931 /** 2932 * Media queries for media grid. 2933 */ 2934 2914 2935 @media only screen and (max-width: 1120px) { 2915 .media-grid-view . media-toolbar-primary,2916 .media-grid-view . media-toolbar-secondary {2936 .media-grid-view .attachments-browser .media-toolbar-primary, 2937 .media-grid-view .attachments-browser .media-toolbar-secondary { 2917 2938 float: none; 2918 2939 } … … 2925 2946 } 2926 2947 } 2927 -
trunk/src/wp-includes/js/media-grid.js
r29204 r29212 185 185 186 186 createStates: function() { 187 var options = this.options, 188 libraryState; 187 var options = this.options; 189 188 190 189 if ( this.options.states ) { … … 192 191 } 193 192 194 libraryState = new media.controller.Library({195 library: media.query( options.library ),196 multiple: options.multiple,197 title: options.title,198 priority: 20,199 toolbar: false,200 router: false,201 content: 'browse',202 filterable: 'mime-types'203 });204 205 193 // Add the default states. 206 194 this.states.add([ 207 libraryState 195 new media.controller.Library({ 196 library: media.query( options.library ), 197 multiple: options.multiple, 198 title: options.title, 199 priority: 20, 200 201 router: false, 202 content: 'browse', 203 204 filterable: 'mime-types' 205 }) 208 206 ]); 209 207 }, … … 255 253 display: state.get('displaySettings'), 256 254 dragInfo: state.get('dragInfo'), 257 bulkEdit: true,258 255 sidebar: false, 259 256 … … 607 604 }); 608 605 609 media.view.BulkSelectionToggleButton = media.view.Button.extend({ 606 media.view.BulkSelection = media.View.extend({ 607 className: 'bulk-select', 608 609 initialize: function() { 610 this.model = new Backbone.Model({ 611 currentAction: '', 612 613 }); 614 615 this.views.add( 616 new media.view.BulkSelectionActionDropdown({ 617 controller: this 618 }) 619 ); 620 621 this.views.add( 622 new media.view.BulkSelectionActionButton({ 623 disabled: true, 624 text: l10n.apply, 625 controller: this 626 }) 627 ); 628 } 629 }); 630 631 media.view.BulkSelectionActionDropdown = media.View.extend({ 632 tagName: 'select', 633 634 initialize: function() { 635 media.view.Button.prototype.initialize.apply( this, arguments ); 636 this.listenTo( this.controller.controller.state().get( 'selection' ), 'add remove reset', _.bind( this.enabled, this ) ); 637 this.$el.append( $('<option></option>').val( '' ).html( l10n.bulkActions ) ) 638 .append( $('<option></option>').val( 'delete' ).html( l10n.deletePermanently ) ); 639 this.$el.prop( 'disabled', true ); 640 this.$el.on( 'change', _.bind( this.toggleChange, this ) ); 641 }, 642 643 toggleChange: function() { 644 this.controller.model.set( { 'currentAction': this.$el.val() } ); 645 }, 646 enabled: function() { 647 var disabled = ! this.controller.controller.state().get('selection').length; 648 this.$el.prop( 'disabled', disabled ); 649 } 650 }); 651 652 media.view.BulkSelectionActionButton = media.view.Button.extend({ 653 tagName: 'button', 654 610 655 initialize: function() { 611 656 media.view.Button.prototype.initialize.apply( this, arguments ); 612 this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.toggleBulkEditHandler, this ) ); 657 658 this.listenTo( this.controller.model, 'change', this.enabled, this ); 659 this.listenTo( this.controller.controller.state().get( 'selection' ), 'add remove reset', _.bind( this.enabled, this ) ); 613 660 }, 614 661 615 662 click: function() { 616 var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;663 var selection = this.controller.controller.state().get('selection'); 617 664 media.view.Button.prototype.click.apply( this, arguments ); 618 665 619 if ( bulkEditActive ) {620 this.controller.deactivateMode( 'bulk-edit' ).activateMode( 'edit' );621 } else{622 this.controller.deactivateMode( 'edit' ).activateMode( 'bulk-edit');623 }624 },625 626 toggleBulkEditHandler: function() {627 var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;628 if ( bulkEditActive ) { 629 this.$el.addClass( 'button-primary' );630 } else {631 this.$el.removeClass( 'button-primary' );632 this.controller.state().get('selection').reset();633 }666 // Currently assumes delete is the only action 667 if ( confirm( l10n.warnBulkDelete ) ) { 668 while ( selection.length > 0) { 669 selection.at(0).destroy(); 670 } 671 } 672 673 this.enabled(); 674 }, 675 676 enabled: function() { 677 var currentAction = this.controller.model.get( 'currentAction' ), 678 selection = this.controller.controller.state().get('selection'), 679 disabled = ! currentAction || ! selection.length; 680 this.$el.prop( 'disabled', disabled ); 634 681 } 635 682 }); 636 683 637 media.view.BulkDeleteButton = media.view.Button.extend({638 initialize: function() {639 media.view.Button.prototype.initialize.apply( this, arguments );640 this.$el.hide();641 this.listenTo( this.controller, 'bulk-edit:activate bulk-edit:deactivate', _.bind( this.visibility, this ) );642 },643 644 click: function() {645 media.view.Button.prototype.click.apply( this, arguments );646 while (this.controller.state().get('selection').length > 0) {647 this.controller.state().get('selection').at(0).destroy();648 }649 },650 651 visibility: function() {652 var bulkEditActive = this.controller.activeModes.where( { id: 'bulk-edit' } ).length;653 if ( bulkEditActive ) {654 this.$el.show();655 } else {656 this.$el.hide();657 }658 }659 });660 661 684 }(jQuery, _, Backbone, wp)); -
trunk/src/wp-includes/js/media-views.js
r29136 r29212 4620 4620 'change [data-setting] textarea': 'updateSetting', 4621 4621 'click .close': 'removeFromLibrary', 4622 'click .check': ' removeFromSelection',4622 'click .check': 'checkClickHandler', 4623 4623 'click a': 'preventDefault', 4624 4624 'keydown': 'toggleSelectionHandler' … … 4880 4880 } 4881 4881 4882 // In bulk edit mode (in media grid), attachments don't open the "details" 4883 // pane, so a `details` class is unnecessary on the attachment view. 4884 if ( ! this.controller.isModeActive( 'bulk-edit' ) ) { 4885 details = selection.single(); 4886 this.$el.toggleClass( 'details', details === this.model ); 4887 } 4882 details = selection.single(); 4883 this.$el.toggleClass( 'details', details === this.model ); 4888 4884 }, 4889 4885 /** … … 5016 5012 this.collection.remove( this.model ); 5017 5013 }, 5018 /** 5019 * @param {Object} event 5020 */ 5021 removeFromSelection: function( event ) { 5014 5015 /** 5016 * Add the model if it isn't in the selection, if it is in the selection, 5017 * remove it. 5018 * 5019 * @param {[type]} event [description] 5020 * @return {[type]} [description] 5021 */ 5022 checkClickHandler: function ( event ) { 5022 5023 var selection = this.options.selection; 5023 5024 if ( ! selection ) { 5024 5025 return; 5025 5026 } 5026 5027 // Stop propagation so the model isn't selected.5028 5027 event.stopPropagation(); 5029 5030 selection.remove( this.model ); 5028 if ( selection.where( { id: this.model.get( 'id' ) } ).length ) { 5029 selection.remove( this.model ); 5030 } else { 5031 selection.add( this.model ); 5032 } 5031 5033 } 5032 5034 }); … … 5658 5660 }).render() ); 5659 5661 5660 this.toolbar.set( 'bulkSelectionToggleButton', new media.view.BulkSelectionToggleButton({ 5661 text: 'Bulk Edit', 5662 controller: this.controller, 5663 priority: -70 5664 }).render() ); 5665 5666 this.toolbar.set( 'BulkDeleteButton', new media.view.BulkDeleteButton({ 5667 text: 'Bulk Delete', 5668 controller: this.controller, 5669 priority: -69 5670 }).render() ); 5662 this.toolbar.set( 'BulkSelection', new media.view.BulkSelection({ 5663 controller: this.controller, 5664 priority: -70 5665 }).render() ); 5671 5666 } 5672 5667 -
trunk/src/wp-includes/media-template.php
r29208 r29212 398 398 399 399 <script type="text/html" id="tmpl-attachment"> 400 <# if ( _.contains( data.controller.options.mode, 'grid' ) ) { #>401 <div class="inline-toolbar js--select-attachment">402 <div class="dashicons dashicons-edit edit edit-media"></div>403 </div>404 <# } #>405 400 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> 406 401 <# if ( data.uploading ) { #> … … 425 420 <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a> 426 421 <# } #> 427 428 <# if ( data.buttons.check ) { #> 429 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a> 430 <# } #> 431 </div> 422 </div> 423 <# if ( _.contains( data.controller.options.mode, 'grid' ) ) { #> 424 <div class="inline-toolbar js--select-attachment"> 425 <div class="dashicons dashicons-edit edit edit-media"></div> 426 </div> 427 <# } #> 428 <# if ( data.buttons.check ) { #> 429 <a class="check" href="#" title="<?php esc_attr_e('Deselect'); ?>" tabindex="-1"><div class="media-modal-icon"></div></a> 430 <# } #> 432 431 <# 433 432 var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; -
trunk/src/wp-includes/media.php
r29204 r29212 2897 2897 2898 2898 // Library 2899 'mediaLibraryTitle' => __( 'Media Library' ), 2900 'insertMediaTitle' => __( 'Insert Media' ), 2901 'createNewGallery' => __( 'Create a new gallery' ), 2902 'createNewPlaylist' => __( 'Create a new playlist' ), 2903 'createNewVideoPlaylist' => __( 'Create a new video playlist' ), 2904 'returnToLibrary' => __( '← Return to library' ), 2905 'allMediaItems' => __( 'All media items' ), 2906 'allMediaTypes' => __( 'All media types' ), 2907 'noItemsFound' => __( 'No items found.' ), 2908 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ), 2909 'uploadedToThisPost' => $hier ? __( 'Uploaded to this page' ) : __( 'Uploaded to this post' ), 2910 'warnDelete' => __( "You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete." ), 2899 'mediaLibraryTitle' => __( 'Media Library' ), 2900 'insertMediaTitle' => __( 'Insert Media' ), 2901 'createNewGallery' => __( 'Create a new gallery' ), 2902 'createNewPlaylist' => __( 'Create a new playlist' ), 2903 'createNewVideoPlaylist' => __( 'Create a new video playlist' ), 2904 'returnToLibrary' => __( '← Return to library' ), 2905 'allMediaItems' => __( 'All media items' ), 2906 'allMediaTypes' => __( 'All media types' ), 2907 'noItemsFound' => __( 'No items found.' ), 2908 'insertIntoPost' => $hier ? __( 'Insert into page' ) : __( 'Insert into post' ), 2909 'uploadedToThisPost' => $hier ? __( 'Uploaded to this page' ) : __( 'Uploaded to this post' ), 2910 'warnDelete' => __( "You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete." ), 2911 'warnBulkDelete' => __( "You are about to permanently delete these items.\n 'Cancel' to stop, 'OK' to delete." ), 2912 'bulkActions' => __( 'Bulk Actions' ), 2913 'deletePermanently' => __( 'Delete Permanently' ), 2914 'apply' => __( 'Apply' ), 2911 2915 2912 2916 // Library Details
Note: See TracChangeset
for help on using the changeset viewer.