Make WordPress Core

Ticket #22323: 22323.diff

File 22323.diff, 2.7 KB (added by rzen, 11 years ago)
  • wp-includes/js/media-views.js

     
    191191
    192192                        this.get('selection').on( 'selection:single', this.buildDetails, this );
    193193                        this.get('selection').on( 'selection:unsingle', this.clearDetails, this );
     194                        this.get('library').on( 'add remove reset', this.refresh, this );
     195                        this.refresh();
    194196                },
    195197
    196198                deactivate: function() {
     
    202204                        wp.Uploader.queue.off( 'add', this.selectUpload, this );
    203205                        this.get('selection').off( 'selection:single', this.buildDetails, this );
    204206                        this.get('selection').off( 'selection:unsingle', this.clearDetails, this );
     207                        this.get('library').off( 'add remove reset', this.refresh, this );
    205208                },
    206209
    207210                toolbar: function() {
     
    230233                },
    231234
    232235                content: function() {
    233                         var frame = this.frame;
     236                        var frame = this.frame,
     237                                library = this.get('library'),
     238                                view;
    234239
    235240                        // 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() );
    241255                },
    242256
    243257                selectUpload: function( attachment ) {
     
    281295                        }
    282296
    283297                        return this;
     298                },
     299
     300                refresh: function() {
     301                        this.frame.$el.toggleClass( 'hide-sidebar hide-toolbar', ! this.get('library').length );
     302                        this.content();
    284303                }
     304
    285305        });
    286306
    287307
     
    309329                        }
    310330
    311331                        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                         }
    343332                }
     333
    344334        });
    345335
    346336        // wp.media.controller.Gallery