Make WordPress Core

Ticket #27423: 27423.diff

File 27423.diff, 1.5 KB (added by wonderboymusic, 10 years ago)
  • src/wp-includes/js/media-views.js

     
    51995199                        });
    52005200
    52015201                        this._viewsByCid = {};
     5202                        this.$window = $( window );
     5203                        this.resizeEvent = 'resize.media-modal-columns';
    52025204
    52035205                        this.collection.on( 'add', function( attachment ) {
    52045206                                this.views.add( this.createAttachmentView( attachment ), {
     
    52305232                        _.bindAll( this, 'setColumns' );
    52315233
    52325234                        if ( this.options.resize ) {
    5233                                 $( window ).on( 'resize.media-modal-columns', this.setColumns );
     5235                                this.on( 'ready', this.bindEvents );
    52345236                                this.controller.on( 'open', this.setColumns );
     5237
     5238                                // Call this.setColumns() after this view has been rendered in the DOM so
     5239                                // attachments get proper width applied.
     5240                                _.defer( this.setColumns, this );
    52355241                        }
     5242                },
    52365243
    5237                         // Call this.setColumns() after this view has been rendered in the DOM so
    5238                         // attachments get proper width applied.
    5239                         _.defer( this.setColumns, this );
     5244                bindEvents: function() {
     5245                        this.$window.off( this.resizeEvent ).on( this.resizeEvent, this.setColumns );
    52405246                },
    52415247
    52425248                attachmentFocus: function() {
     
    52925298
    52935299                dispose: function() {
    52945300                        this.collection.props.off( null, null, this );
    5295                         $( window ).off( 'resize.media-modal-columns' );
     5301                        if ( this.options.resize ) {
     5302                                this.$window.off( this.resizeEvent );
     5303                        }
    52965304
    52975305                        /**
    52985306                         * call 'dispose' directly on the parent class