Make WordPress Core

Changeset 29420


Ignore:
Timestamp:
08/06/2014 09:43:26 PM (10 years ago)
Author:
wonderboymusic
Message:

Media Grid: expose the $.Deffered() object in media.view.AttachmentsBrowser.updateContent() so the grid can call Backbone.history.start() when models actually exist.

This is a lot better then _.delay( this.pray, 1000 ), but needs continued study.

See #29052.

Location:
trunk/src/wp-includes/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-grid.js

    r29415 r29420  
    9292            }
    9393
     94            this.gridRouter = new media.view.MediaFrame.Manage.Router();
     95
    9496            // Call 'initialize' directly on the parent class.
    9597            media.view.MediaFrame.prototype.initialize.apply( this, arguments );
     
    110112                self.gridRouter.navigate( self.gridRouter.baseUrl( url ) );
    111113            }, 1000 ) );
    112 
    113             // This is problematic.
    114             _.delay( _.bind( this.createRouter, this ), 1000 );
    115         },
    116 
    117         createRouter: function() {
    118             this.gridRouter = new media.view.MediaFrame.Manage.Router();
    119 
    120             // Verify pushState support and activate
    121             if ( window.history && window.history.pushState ) {
    122                 Backbone.history.start({
    123                     root: _wpMediaGridSettings.adminUrl,
    124                     pushState: true
    125                 });
    126             }
    127114        },
    128115
     
    211198                scrollElement: document
    212199            });
     200            this.browserView.on( 'ready', _.bind( this.bindDeferred, this ) );
    213201
    214202            this.errors = wp.Uploader.errors;
     
    218206        sidebarVisibility: function() {
    219207            this.browserView.$( '.media-sidebar' ).toggle( this.errors.length );
     208        },
     209
     210        bindDeferred: function() {
     211            this.browserView.dfd.done( _.bind( this.startHistory, this ) );
     212        },
     213
     214        startHistory: function() {
     215            // Verify pushState support and activate
     216            if ( window.history && window.history.pushState ) {
     217                Backbone.history.start( {
     218                    root: _wpMediaGridSettings.adminUrl,
     219                    pushState: true
     220                } );
     221            }
    220222        }
    221223    });
  • trunk/src/wp-includes/js/media-views.js

    r29415 r29420  
    58205820            if ( ! this.collection.length ) {
    58215821                this.toolbar.get( 'spinner' ).show();
    5822                 this.collection.more().done(function() {
     5822                this.dfd = this.collection.more().done( function() {
    58235823                    if ( ! view.collection.length ) {
    58245824                        noItemsView.$el.removeClass( 'hidden' );
     
    58275827                    }
    58285828                    view.toolbar.get( 'spinner' ).hide();
    5829                 });
     5829                } );
    58305830            } else {
    58315831                noItemsView.$el.addClass( 'hidden' );
Note: See TracChangeset for help on using the changeset viewer.