Changeset 22363
- Timestamp:
- 11/05/2012 02:43:47 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22362 r22363 192 192 this.get('selection').on( 'selection:single', this.buildDetails, this ); 193 193 this.get('selection').on( 'selection:unsingle', this.clearDetails, this ); 194 195 this._updateEmpty(); 196 this.get('library').on( 'add remove reset', this._updateEmpty, this ); 197 this.on( 'change:empty', this.refresh, this ); 198 this.refresh(); 194 199 }, 195 200 … … 203 208 this.get('selection').off( 'selection:single', this.buildDetails, this ); 204 209 this.get('selection').off( 'selection:unsingle', this.clearDetails, this ); 210 this.get('library').off( 'add remove reset', this._updateEmpty, this ); 211 this.off( 'change:empty', this.refresh, this ); 205 212 }, 206 213 … … 231 238 232 239 content: function() { 233 var frame = this.frame; 240 var frame = this.frame, 241 library = this.get('library'), 242 view; 234 243 235 244 // Content. 236 frame.content( new media.view.AttachmentsBrowser({ 237 controller: frame, 238 collection: this.get('library'), 239 model: this 240 }).render() ); 245 if ( this.get('empty') ) { 246 // Attempt to fetch any Attachments we don't already have. 247 library.more(); 248 249 // In the meantime, render an inline uploader. 250 view = new media.view.UploaderInline({ 251 controller: frame 252 }); 253 } else { 254 // Browse our library of attachments. 255 view = new media.view.AttachmentsBrowser({ 256 controller: frame, 257 collection: library, 258 model: this 259 }); 260 } 261 262 frame.content( view.render() ); 263 }, 264 265 refresh: function() { 266 this.frame.$el.toggleClass( 'hide-sidebar hide-toolbar', this.get('empty') ); 267 this.content(); 268 }, 269 270 _updateEmpty: function() { 271 this.set( 'empty', ! this.get('library').length ); 241 272 }, 242 273 … … 310 341 311 342 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: frame 339 }).render(); 340 341 frame.content( upload ); 342 } 343 } 343 } 344 344 345 }); 345 346
Note: See TracChangeset
for help on using the changeset viewer.