Changeset 22397
- Timestamp:
- 11/06/2012 01:19:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22363 r22397 185 185 186 186 activate: function() { 187 var selection = this.get('selection'); 188 187 189 // If we're in a workflow that supports multiple attachments, 188 190 // automatically select any uploading attachments. … … 190 192 wp.Uploader.queue.on( 'add', this.selectUpload, this ); 191 193 192 this.get('selection').on( 'selection:single', this.buildDetails, this ); 193 this.get('selection').on( 'selection:unsingle', this.clearDetails, this ); 194 selection.on( 'selection:single', this.buildDetails, this ); 195 selection.on( 'selection:unsingle', this.clearDetails, this ); 196 selection.on( 'add remove reset', this.updateToolbarVisibility, this ); 194 197 195 198 this._updateEmpty(); … … 200 203 201 204 deactivate: function() { 202 var toolbar = this._postLibraryToolbar;203 204 if ( toolbar )205 this.get('selection').off( 'add remove', toolbar.visibility, toolbar );206 207 205 wp.Uploader.queue.off( 'add', this.selectUpload, this ); 208 this.get('selection').off( 'selection:single', this.buildDetails, this ); 209 this.get('selection').off( 'selection:unsingle', this.clearDetails, this ); 206 207 // Unbind all event handlers that use this state as the context 208 // from the selection. 209 this.get('selection').off( null, null, this ); 210 210 this.get('library').off( 'add remove reset', this._updateEmpty, this ); 211 211 this.off( 'change:empty', this.refresh, this ); … … 213 213 214 214 toolbar: function() { 215 var frame = this.frame, 216 toolbar; 217 218 // Toolbar. 219 toolbar = this._postLibraryToolbar = new media.view.Toolbar.PostLibrary({ 220 controller: frame, 221 state: this 222 }); 223 224 frame.toolbar( toolbar ); 225 this.get('selection').on( 'add remove', toolbar.visibility, toolbar ); 215 var frame = this.frame; 216 217 frame.toolbar( new media.view.Toolbar.PostLibrary({ 218 controller: frame 219 }) ); 226 220 }, 227 221 … … 272 266 }, 273 267 268 updateToolbarVisibility: function() { 269 this.frame.toolbar().visibility(); 270 }, 271 274 272 selectUpload: function( attachment ) { 275 273 this.get('selection').add( attachment ); … … 358 356 359 357 toolbar: function() { 360 this.frame.toolbar( new media.view.Toolbar.Gallery({361 controller: this.frame,362 state: this358 var frame = this.frame; 359 frame.toolbar( new media.view.Toolbar.Gallery({ 360 controller: frame 363 361 }) ); 364 362 }, … … 409 407 toolbar: function() { 410 408 var frame = this.frame; 411 412 409 frame.toolbar( new media.view.Toolbar.GalleryAddImages({ 413 controller: frame, 414 state: this 410 controller: frame 415 411 }) ); 416 412 }, … … 873 869 media.view.Toolbar.PostLibrary = media.view.Toolbar.extend({ 874 870 initialize: function() { 875 var state = this.options.state, 876 selection = state.get('selection'), 877 controller = this.options.controller; 871 var controller = this.options.controller, 872 selection = controller.state().get('selection'); 878 873 879 874 this.options.items = { … … 902 897 click: function() { 903 898 controller.close(); 904 state.trigger( 'insert', selection );899 controller.state().trigger( 'insert', selection ); 905 900 selection.clear(); 906 901 } … … 942 937 943 938 visibility: function() { 944 var state = this.options.state, 945 selection = state.get('selection'), 946 controller = this.options.controller, 939 var selection = this.controller.state().get('selection'), 947 940 count = selection.length, 948 941 showGallery; … … 967 960 media.view.Toolbar.Gallery = media.view.Toolbar.extend({ 968 961 initialize: function() { 969 var state = this.options.state, 962 var controller = this.options.controller, 963 state = controller.state(), 970 964 editing = state.get('editing'), 971 library = state.get('library'), 972 controller = this.options.controller; 965 library = state.get('library'); 973 966 974 967 this.options.items = { … … 978 971 priority: 40, 979 972 click: function() { 973 var state = controller.state(); 980 974 controller.close(); 981 state.trigger( 'update', library);975 state.trigger( 'update', state.get('library') ); 982 976 controller.get('library').get('selection').clear(); 983 977 controller.state('library'); … … 991 985 click: function() { 992 986 controller.get('gallery:add').set( 'selection', new media.model.Selection( library.models, { 993 props: library.props.toJSON(),987 props: controller.state().get('library').props.toJSON(), 994 988 multiple: true 995 989 }) ); … … 1019 1013 media.view.Toolbar.GalleryAddImages = media.view.Toolbar.extend({ 1020 1014 initialize: function() { 1021 var state = this.options.state, 1022 editing = state.get('editing'), 1023 library = state.get('library'), 1024 controller = this.options.controller; 1015 var controller = this.options.controller; 1025 1016 1026 1017 this.options.items = { … … 1031 1022 1032 1023 click: function() { 1033 controller.get('gallery').set( 'library', state.get('selection') );1024 controller.get('gallery').set( 'library', controller.state().get('selection') ); 1034 1025 controller.state('gallery'); 1035 1026 }
Note: See TracChangeset
for help on using the changeset viewer.