Ticket #22323: 22323.diff
File 22323.diff, 2.7 KB (added by , 11 years ago) |
---|
-
wp-includes/js/media-views.js
191 191 192 192 this.get('selection').on( 'selection:single', this.buildDetails, this ); 193 193 this.get('selection').on( 'selection:unsingle', this.clearDetails, this ); 194 this.get('library').on( 'add remove reset', this.refresh, this ); 195 this.refresh(); 194 196 }, 195 197 196 198 deactivate: function() { … … 202 204 wp.Uploader.queue.off( 'add', this.selectUpload, this ); 203 205 this.get('selection').off( 'selection:single', this.buildDetails, this ); 204 206 this.get('selection').off( 'selection:unsingle', this.clearDetails, this ); 207 this.get('library').off( 'add remove reset', this.refresh, this ); 205 208 }, 206 209 207 210 toolbar: function() { … … 230 233 }, 231 234 232 235 content: function() { 233 var frame = this.frame; 236 var frame = this.frame, 237 library = this.get('library'), 238 view; 234 239 235 240 // Content. 236 frame.content( new media.view.AttachmentsBrowser({ 237 controller: frame, 238 collection: this.get('library'), 239 model: this 240 }).render() ); 241 if ( library.length ) { 242 view = new media.view.AttachmentsBrowser({ 243 controller: frame, 244 collection: library, 245 model: this 246 }); 247 } else { 248 library.more(); 249 view = new media.view.UploaderInline({ 250 controller: frame 251 }); 252 } 253 254 frame.content( view.render() ); 241 255 }, 242 256 243 257 selectUpload: function( attachment ) { … … 281 295 } 282 296 283 297 return this; 298 }, 299 300 refresh: function() { 301 this.frame.$el.toggleClass( 'hide-sidebar hide-toolbar', ! this.get('library').length ); 302 this.content(); 284 303 } 304 285 305 }); 286 306 287 307 … … 309 329 } 310 330 311 331 media.controller.Library.prototype.initialize.apply( this, arguments ); 312 },313 314 activate: function() {315 this.get('library').on( 'add remove reset', this.refresh, this );316 media.controller.Library.prototype.activate.apply( this, arguments );317 this.refresh();318 },319 320 deactivate: function() {321 this.get('library').off( 'add remove reset', this.refresh, this );322 media.controller.Library.prototype.deactivate.apply( this, arguments );323 },324 325 refresh: function() {326 this.frame.$el.toggleClass( 'hide-sidebar hide-toolbar', ! this.get('library').length );327 this.content();328 },329 330 content: function() {331 var frame = this.frame,332 upload;333 334 if ( this.get('library').length ) {335 media.controller.Library.prototype.content.apply( this, arguments );336 } else {337 upload = new media.view.UploaderInline({338 controller: frame339 }).render();340 341 frame.content( upload );342 }343 332 } 333 344 334 }); 345 335 346 336 // wp.media.controller.Gallery