Changeset 29068
- Timestamp:
- 07/10/2014 05:48:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-grid.js
r29066 r29068 141 141 this.render(); 142 142 143 this.gridRouter = new media.view.Frame.Router( this ); 144 143 145 // Set up the Backbone router after a brief delay 144 146 _.delay( function(){ 145 wp.media.mediarouter = new media.view.Frame.Router( self );146 147 // Verify pushState support and activate 147 148 if ( window.history && window.history.pushState ) { … … 154 155 155 156 // Update the URL when entering search string (at most once per second) 156 $( '#media-search-input' ).on( 'input', _.debounce( function() { 157 var $val = $( this ).val(); 158 wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( ( '' === $val ) ? '' : ( '?search=' + $val ) ) ); 157 $( '#media-search-input' ).on( 'input', _.debounce( function(e) { 158 var val = $( e.currentTarget ).val(), url = ''; 159 if ( val ) { 160 url += '?search=' + val; 161 } 162 self.gridRouter.navigate( self.gridRouter.baseUrl( url ) ); 159 163 }, 1000 ) ); 160 164 }, … … 241 245 // Create a new EditAttachment frame, passing along the library and the attachment model. 242 246 this.editAttachmentFrame = new media.view.Frame.EditAttachments({ 243 library: library, 244 model: model 247 router: this.gridRouter, 248 library: library, 249 model: model 245 250 }); 246 251 … … 300 305 301 306 initialize: function() { 302 this.$el.attr('aria-label', this.model.attributes.title).attr('aria-checked', false); 307 if ( ! this.model ) { 308 return; 309 } 310 311 this.$el.attr('aria-label', this.model.get( 'title' ) ).attr( 'aria-checked', false ); 312 303 313 this.model.on( 'change:sizes change:uploading', this.render, this ); 304 314 this.model.on( 'change:title', this._syncTitle, this ); … … 404 414 }); 405 415 416 this.gridRouter = this.options.gridRouter; 406 417 this.library = this.options.library; 407 418 if ( this.options.model ) { … … 476 487 this.content.set( view ); 477 488 // Update browser url when navigating media details 478 wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( '?item=' + this.model.id ) );489 this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) ); 479 490 }, 480 491 … … 587 598 588 599 resetRoute: function() { 589 wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( '' ) ); 590 return; 600 this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) ); 591 601 } 592 602 });
Note: See TracChangeset
for help on using the changeset viewer.