Avoid JS errors after [29057].

See #24716.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28854 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-10 17:49:15 +00:00
parent 7f4716e1c3
commit 1a2963fabd
2 changed files with 21 additions and 11 deletions

View File

@ -140,9 +140,10 @@
this.bindHandlers(); this.bindHandlers();
this.render(); this.render();
this.gridRouter = new media.view.Frame.Router( this );
// Set up the Backbone router after a brief delay // Set up the Backbone router after a brief delay
_.delay( function(){ _.delay( function(){
wp.media.mediarouter = new media.view.Frame.Router( self );
// Verify pushState support and activate // Verify pushState support and activate
if ( window.history && window.history.pushState ) { if ( window.history && window.history.pushState ) {
Backbone.history.start({ Backbone.history.start({
@ -153,9 +154,12 @@
}, 250); }, 250);
// Update the URL when entering search string (at most once per second) // Update the URL when entering search string (at most once per second)
$( '#media-search-input' ).on( 'input', _.debounce( function() { $( '#media-search-input' ).on( 'input', _.debounce( function(e) {
var $val = $( this ).val(); var val = $( e.currentTarget ).val(), url = '';
wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( ( '' === $val ) ? '' : ( '?search=' + $val ) ) ); if ( val ) {
url += '?search=' + val;
}
self.gridRouter.navigate( self.gridRouter.baseUrl( url ) );
}, 1000 ) ); }, 1000 ) );
}, },
@ -240,6 +244,7 @@
// Create a new EditAttachment frame, passing along the library and the attachment model. // Create a new EditAttachment frame, passing along the library and the attachment model.
this.editAttachmentFrame = new media.view.Frame.EditAttachments({ this.editAttachmentFrame = new media.view.Frame.EditAttachments({
router: this.gridRouter,
library: library, library: library,
model: model model: model
}); });
@ -299,7 +304,12 @@
template: wp.template( 'attachment-details-two-column' ), template: wp.template( 'attachment-details-two-column' ),
initialize: function() { initialize: function() {
this.$el.attr('aria-label', this.model.attributes.title).attr('aria-checked', false); if ( ! this.model ) {
return;
}
this.$el.attr('aria-label', this.model.get( 'title' ) ).attr( 'aria-checked', false );
this.model.on( 'change:sizes change:uploading', this.render, this ); this.model.on( 'change:sizes change:uploading', this.render, this );
this.model.on( 'change:title', this._syncTitle, this ); this.model.on( 'change:title', this._syncTitle, this );
this.model.on( 'change:caption', this._syncCaption, this ); this.model.on( 'change:caption', this._syncCaption, this );
@ -403,6 +413,7 @@
state: 'edit-attachment' state: 'edit-attachment'
}); });
this.gridRouter = this.options.gridRouter;
this.library = this.options.library; this.library = this.options.library;
if ( this.options.model ) { if ( this.options.model ) {
this.model = this.options.model; this.model = this.options.model;
@ -475,7 +486,7 @@
}); });
this.content.set( view ); this.content.set( view );
// Update browser url when navigating media details // Update browser url when navigating media details
wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( '?item=' + this.model.id ) ); this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) );
}, },
/** /**
@ -586,8 +597,7 @@
}, },
resetRoute: function() { resetRoute: function() {
wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( '' ) ); this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) );
return;
} }
}); });

File diff suppressed because one or more lines are too long