Changeset 22332 for trunk/wp-includes/js/media-views.js
- Timestamp:
- 10/30/2012 09:09:45 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22324 r22332 132 132 133 133 if ( ! this.get('gutter') ) 134 this.set( 'gutter', 6);134 this.set( 'gutter', 8 ); 135 135 136 136 this.on( 'activate', this.activate, this ); … … 148 148 if ( this.get('multiple') ) 149 149 wp.Uploader.queue.on( 'add', this.selectUpload, this ); 150 151 this.get('selection').on( 'add remove', this.toggleDetails, this );152 150 }, 153 151 … … 158 156 159 157 wp.Uploader.queue.off( 'add', this.selectUpload, this ); 160 this.get('selection').off( 'add remove', this.toggleDetails, this );161 158 }, 162 159 … … 235 232 }, 236 233 237 toggle Details: function( model ) {234 toggleSelection: function( model ) { 238 235 var details = this.get('details'), 239 selection = this.get('selection'); 240 241 if ( selection.has( model ) ) 236 selection = this.get('selection'), 237 selected = selection.has( model ); 238 239 if ( ! selection ) 240 return; 241 242 if ( ! selected ) 243 selection.add( model ); 244 245 // If the model is not the same as the details model, 246 // it now becomes the details model. If the model is 247 // in the selection, it is not removed. 248 if ( details !== model ) { 242 249 this.set( 'details', model ); 243 else if ( selection.length ) 250 return; 251 } 252 253 // The model is the details model. 254 // Removed it from the selection. 255 selection.remove( model ); 256 257 // Show the last selected item, or clear the details view. 258 if ( selection.length ) 244 259 this.set( 'details', selection.last() ); 245 260 else 246 261 this.unset('details'); 262 247 263 } 248 264 }); … … 1073 1089 this.select(); 1074 1090 1075 return this; 1091 // Update the model's details view. 1092 this.controller.state().on( 'change:details', this.details, this ); 1093 this.details(); 1094 1095 return this; 1096 }, 1097 1098 destroy: function() { 1099 this.controller.state().off( 'change:details', this.details, this ); 1076 1100 }, 1077 1101 … … 1082 1106 1083 1107 toggleSelection: function( event ) { 1084 var selection = this.controller.state().get('selection'); 1085 1086 if ( ! selection ) 1087 return; 1088 1089 selection[ selection.has( this.model ) ? 'remove' : 'add' ]( this.model ); 1108 this.controller.state().toggleSelection( this.model ); 1090 1109 }, 1091 1110 … … 1118 1137 1119 1138 this.$el.removeClass('selected'); 1139 }, 1140 1141 details: function() { 1142 var details = this.controller.state().get('details'); 1143 this.$el.toggleClass( 'details', details === this.model ); 1120 1144 }, 1121 1145
Note: See TracChangeset
for help on using the changeset viewer.