Changeset 22594
- Timestamp:
- 11/15/2012 02:36:06 AM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/css/media-views.css
r22570 r22594 812 812 } 813 813 814 .media-selection .clear-selection { 815 display: block; 814 .media-selection .selection-info a { 815 display: block; 816 float: left; 817 padding: 1px 8px; 818 margin: 1px 8px 1px -8px; 819 line-height: 16px; 816 820 text-decoration: none; 817 line-height: 16px; 821 border-right: 1px solid #dfdfdf; 822 color: #21759B; 823 } 824 825 .media-selection .selection-info a:hover { 826 background: #21759B; 827 color: #fff; 828 border-color: transparent; 829 } 830 831 .media-selection .selection-info a:last-child { 832 border-right: 0; 833 } 834 835 .media-selection .selection-info .clear-selection { 836 color: red; 837 } 838 839 .media-selection .selection-info .clear-selection:hover { 840 background: red; 818 841 } 819 842 … … 826 849 } 827 850 828 . media-selection .selected.attachment{851 .attachment.selection.selected { 829 852 box-shadow: none; 830 853 } 831 854 832 .media-selection .details.attachment { 855 .attachment.selection.details { 856 box-shadow: 857 0 0 0 1px #fff, 858 0 0 0 4px #1e8cbe; 859 } 860 861 .media-selection .attachment.selection.details { 833 862 box-shadow: 834 863 0 0 0 1px #fff, -
trunk/wp-includes/js/media-views.js
r22583 r22594 373 373 374 374 refreshSelection: function() { 375 var selection = this.get('selection'), 376 mode = this.frame.content.mode(); 377 375 378 this.frame.toolbar.view().refresh(); 376 this.trigger( 'refresh:selection', this, this.get('selection') ); 379 this.trigger( 'refresh:selection', this, selection ); 380 381 if ( ! selection.length && 'browse' !== mode && 'upload' !== mode ) 382 this.content(); 377 383 }, 378 384 379 385 selectUpload: function( attachment ) { 380 386 this.get('selection').add( attachment ); 381 },382 383 toggleSelection: function( model ) {384 var selection = this.get('selection');385 386 if ( ! model )387 return;388 389 if ( selection.has( model ) ) {390 // If the model is the single model, remove it.391 // If it is not the same as the single model,392 // it now becomes the single model.393 selection[ selection.single() === model ? 'remove' : 'single' ]( model );394 } else {395 selection.add( model ).single();396 }397 398 return this;399 387 }, 400 388 … … 519 507 // The single `Attachment` view to be used in the `Attachments` view. 520 508 if ( ! this.get('AttachmentView') ) 521 this.set( 'AttachmentView', media.view.Attachment. Gallery );509 this.set( 'AttachmentView', media.view.Attachment.EditLibrary ); 522 510 media.controller.Library.prototype.initialize.apply( this, arguments ); 523 511 }, … … 868 856 controller: this, 869 857 collection: state.get('library'), 858 selection: state.get('selection'), 870 859 model: state, 871 860 sortable: state.get('sortable'), … … 981 970 multiple: this.options.multiple, 982 971 menu: 'main', 972 sidebar: 'attachment-settings', 983 973 984 974 // Update user settings when users adjust the … … 1059 1049 var handlers = { 1060 1050 menu: { 1061 batch: 'batchMenu',1062 gallery: 'galleryMenu'1051 'batch': 'batchMenu', 1052 'gallery': 'galleryMenu' 1063 1053 }, 1064 1054 1065 1055 content: { 1066 embed: 'embedContent' 1056 'embed': 'embedContent', 1057 'edit-selection': 'editSelectionContent' 1067 1058 }, 1068 1059 … … 1084 1075 _.each( regionHandlers, function( callback, handler ) { 1085 1076 this[ region ].on( 'activate:' + handler, this[ callback ], this ); 1086 }, this );1087 }, this );1088 1089 _.each(['library', 'upload'], function( id ) {1090 this.get( id ).on( 'refresh:selection', function( state, selection ) {1091 var sidebar = this.sidebar;1092 1093 if ( ! selection.length )1094 sidebar.mode('clear');1095 else if ( selection.length === 1 )1096 sidebar.mode('attachment-settings');1097 else1098 sidebar.mode('settings');1099 1077 }, this ); 1100 1078 }, this ); … … 1205 1183 }, 1206 1184 1185 editSelectionContent: function() { 1186 var state = this.state(), 1187 selection = state.get('selection'), 1188 view; 1189 1190 view = new media.view.AttachmentsBrowser({ 1191 controller: this, 1192 collection: selection, 1193 selection: selection, 1194 model: state, 1195 sortable: true, 1196 search: false, 1197 1198 AttachmentView: media.view.Attachment.EditSelection 1199 }).render(); 1200 1201 view.toolbar.set( 'backToLibrary', { 1202 text: l10n.returnToLibrary, 1203 priority: -100, 1204 1205 click: function() { 1206 this.controller.content.mode('browse'); 1207 } 1208 }); 1209 1210 // Browse our library of attachments. 1211 this.content.view( view ); 1212 }, 1213 1207 1214 // Sidebars 1208 1215 onSidebarGallerySettings: function( options ) { … … 1762 1769 controller: controller, 1763 1770 collection: selection, 1764 priority: -40 1771 priority: -40, 1772 1773 editable: function() { 1774 this.controller.content.mode('edit-selection'); 1775 } 1765 1776 }).render(), 1766 1777 … … 1772 1783 click: function() { 1773 1784 controller.close(); 1774 controller.state().trigger( 'insert', selection ); 1775 selection.clear(); 1785 controller.state().trigger( 'insert', selection ).reset(); 1776 1786 } 1777 1787 }, … … 1783 1793 return selection.where({ type: 'image' }); 1784 1794 }) 1785 },1786 1787 batch: {1788 text: l10n.batchInsert,1789 priority: 60,1790 click: selectionToLibrary('batch-edit')1791 1795 } 1792 1796 }); … … 1801 1805 this.get('insert').model.set( 'disabled', ! selection.length ); 1802 1806 1803 // Check if every attachment in the selection is an image.1807 // Check if any attachment in the selection is an image. 1804 1808 this.get('gallery').$el.toggle( count > 1 && selection.any( function( attachment ) { 1805 1809 return 'image' === attachment.get('type'); 1806 1810 }) ); 1807 1808 // Batch insert shows for multiple selected attachments.1809 this.get('batch').$el.toggle( count > 1 );1810 1811 // Insert only shows for single attachments.1812 this.get('insert').$el.toggle( count <= 1 );1813 1811 } 1814 1812 }); … … 2076 2074 'change [data-setting] input': 'updateSetting', 2077 2075 'change [data-setting] select': 'updateSetting', 2078 'change [data-setting] textarea': 'updateSetting' 2076 'change [data-setting] textarea': 'updateSetting', 2077 'click .close': 'removeFromLibrary' 2079 2078 }, 2080 2079 … … 2148 2147 2149 2148 toggleSelection: function( event ) { 2150 this.controller.state().toggleSelection( this.model ); 2149 var selection = this.options.selection, 2150 model = this.model; 2151 2152 if ( ! selection ) 2153 return; 2154 2155 if ( selection.has( model ) ) { 2156 // If the model is the single model, remove it. 2157 // If it is not the same as the single model, 2158 // it now becomes the single model. 2159 selection[ selection.single() === model ? 'remove' : 'single' ]( model ); 2160 } else { 2161 selection.add( model ).single(); 2162 } 2151 2163 }, 2152 2164 2153 2165 selected: function() { 2154 var selection = this. controller.state().get('selection');2166 var selection = this.options.selection; 2155 2167 if ( selection ) 2156 2168 return selection.has( this.model ); … … 2158 2170 2159 2171 select: function( model, collection ) { 2160 var selection = this. controller.state().get('selection');2172 var selection = this.options.selection; 2161 2173 2162 2174 // Check if a selection exists and if it's the collection provided. … … 2170 2182 2171 2183 deselect: function( model, collection ) { 2172 var selection = this. controller.state().get('selection');2184 var selection = this.options.selection; 2173 2185 2174 2186 // Check if a selection exists and if it's the collection provided. … … 2182 2194 2183 2195 details: function( model, collection ) { 2184 var selection = this. controller.state().get('selection'),2196 var selection = this.options.selection, 2185 2197 details; 2186 2198 … … 2221 2233 2222 2234 this.model.save( $setting.data('setting'), event.target.value ); 2235 }, 2236 2237 removeFromLibrary: function( event ) { 2238 // Stop propagation so the model isn't selected. 2239 event.stopPropagation(); 2240 2241 this.collection.remove( this.model ); 2223 2242 } 2224 2243 }); … … 2232 2251 2233 2252 /** 2234 * wp.media.view.Attachment. Gallery2235 */ 2236 media.view.Attachment. Gallery = media.view.Attachment.extend({2253 * wp.media.view.Attachment.EditLibrary 2254 */ 2255 media.view.Attachment.EditLibrary = media.view.Attachment.extend({ 2237 2256 buttons: { 2238 2257 close: true 2239 },2240 2241 events: (function() {2242 var events = _.clone( media.view.Attachment.prototype.events );2243 events['click .close'] = 'removeFromGallery';2244 return events;2245 }()),2246 2247 removeFromGallery: function( event ) {2248 // Stop propagation so the model isn't selected.2249 event.stopPropagation();2250 2251 this.controller.state().get('library').remove( this.model );2252 2258 } 2253 2259 }); … … 2389 2395 return new this.options.AttachmentView({ 2390 2396 controller: this.controller, 2391 model: attachment 2397 model: attachment, 2398 collection: this.collection, 2399 selection: this.options.selection 2392 2400 }).render().$el; 2393 2401 }, this ) ); … … 2405 2413 view = new this.options.AttachmentView({ 2406 2414 controller: this.controller, 2407 model: attachment 2415 model: attachment, 2416 collection: this.collection, 2417 selection: this.options.selection 2408 2418 }).render(); 2409 2419 … … 2522 2532 controller: this.controller, 2523 2533 collection: this.collection, 2534 selection: this.options.selection, 2524 2535 model: this.model, 2525 2536 sortable: this.options.sortable, … … 2604 2615 2605 2616 events: { 2617 'click .edit-selection': 'edit', 2606 2618 'click .clear-selection': 'clear' 2607 2619 }, … … 2609 2621 initialize: function() { 2610 2622 _.defaults( this.options, { 2623 editable: false, 2611 2624 clearable: true 2612 2625 }); … … 2616 2629 controller: this.controller, 2617 2630 collection: this.collection, 2631 selection: this.collection, 2618 2632 sortable: true, 2619 2633 model: new Backbone.Model({ … … 2656 2670 }, 2657 2671 2672 edit: function( event ) { 2673 event.preventDefault(); 2674 if ( this.options.editable ) 2675 this.options.editable.call( this, this.collection ); 2676 }, 2677 2658 2678 clear: function( event ) { 2659 2679 event.preventDefault(); … … 2667 2687 */ 2668 2688 media.view.Attachment.Selection = media.view.Attachment.extend({ 2689 className: 'attachment selection', 2690 2669 2691 // On click, just select the model, instead of removing the model from 2670 2692 // the selection. 2671 2693 toggleSelection: function() { 2672 this.controller.state().get('selection').single( this.model ); 2694 this.options.selection.single( this.model ); 2695 } 2696 }); 2697 2698 media.view.Attachment.EditSelection = media.view.Attachment.Selection.extend({ 2699 buttons: { 2700 close: true 2673 2701 } 2674 2702 }); -
trunk/wp-includes/media.php
r22580 r22594 1356 1356 'createNewGallery' => __( 'Create a new gallery' ), 1357 1357 'insertIntoPost' => __( 'Insert into post' ), 1358 'returnToLibrary' => __( '← Return to library' ), 1358 1359 1359 1360 // Embed … … 1523 1524 <div class="selection-info"> 1524 1525 <span class="count"></span> 1526 <# if ( data.editable ) { #> 1527 <a class="edit-selection" href="#"><?php _e('Edit'); ?></a> 1528 <# } #> 1525 1529 <# if ( data.clearable ) { #> 1526 1530 <a class="clear-selection" href="#"><?php _e('Clear'); ?></a>
Note: See TracChangeset
for help on using the changeset viewer.