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.

Built from https://develop.svn.wordpress.org/trunk@29420


git-svn-id: http://core.svn.wordpress.org/trunk@29198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-08-06 21:44:17 +00:00
parent 582b5144b2
commit 935f10413e
4 changed files with 21 additions and 19 deletions

View File

@ -91,6 +91,8 @@
this.options.uploader = false;
}
this.gridRouter = new media.view.MediaFrame.Manage.Router();
// Call 'initialize' directly on the parent class.
media.view.MediaFrame.prototype.initialize.apply( this, arguments );
@ -109,21 +111,6 @@
}
self.gridRouter.navigate( self.gridRouter.baseUrl( url ) );
}, 1000 ) );
// This is problematic.
_.delay( _.bind( this.createRouter, this ), 1000 );
},
createRouter: function() {
this.gridRouter = new media.view.MediaFrame.Manage.Router();
// Verify pushState support and activate
if ( window.history && window.history.pushState ) {
Backbone.history.start({
root: _wpMediaGridSettings.adminUrl,
pushState: true
});
}
},
/**
@ -210,6 +197,7 @@
scrollElement: document
});
this.browserView.on( 'ready', _.bind( this.bindDeferred, this ) );
this.errors = wp.Uploader.errors;
this.errors.on( 'add remove reset', this.sidebarVisibility, this );
@ -217,6 +205,20 @@
sidebarVisibility: function() {
this.browserView.$( '.media-sidebar' ).toggle( this.errors.length );
},
bindDeferred: function() {
this.browserView.dfd.done( _.bind( this.startHistory, this ) );
},
startHistory: function() {
// Verify pushState support and activate
if ( window.history && window.history.pushState ) {
Backbone.history.start( {
root: _wpMediaGridSettings.adminUrl,
pushState: true
} );
}
}
});

File diff suppressed because one or more lines are too long

View File

@ -5819,14 +5819,14 @@
if ( ! this.collection.length ) {
this.toolbar.get( 'spinner' ).show();
this.collection.more().done(function() {
this.dfd = this.collection.more().done( function() {
if ( ! view.collection.length ) {
noItemsView.$el.removeClass( 'hidden' );
} else {
noItemsView.$el.addClass( 'hidden' );
}
view.toolbar.get( 'spinner' ).hide();
});
} );
} else {
noItemsView.$el.addClass( 'hidden' );
view.toolbar.get( 'spinner' ).hide();

File diff suppressed because one or more lines are too long