Make WordPress Core

Changeset 29068


Ignore:
Timestamp:
07/10/2014 05:48:09 PM (10 years ago)
Author:
wonderboymusic
Message:

Avoid JS errors after [29057].

See #24716.

File:
1 edited

Legend:

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

    r29066 r29068  
    141141            this.render();
    142142
     143            this.gridRouter = new media.view.Frame.Router( this );
     144
    143145            // Set up the Backbone router after a brief delay
    144146            _.delay( function(){
    145                 wp.media.mediarouter = new media.view.Frame.Router( self );
    146147                // Verify pushState support and activate
    147148                if ( window.history && window.history.pushState ) {
     
    154155
    155156            // 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 ) );
    159163            }, 1000 ) );
    160164        },
     
    241245            // Create a new EditAttachment frame, passing along the library and the attachment model.
    242246            this.editAttachmentFrame = new media.view.Frame.EditAttachments({
    243                 library:        library,
    244                 model:          model
     247                router:  this.gridRouter,
     248                library: library,
     249                model:   model
    245250            });
    246251
     
    300305
    301306        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
    303313            this.model.on( 'change:sizes change:uploading', this.render, this );
    304314            this.model.on( 'change:title', this._syncTitle, this );
     
    404414            });
    405415
     416            this.gridRouter = this.options.gridRouter;
    406417            this.library = this.options.library;
    407418            if ( this.options.model ) {
     
    476487            this.content.set( view );
    477488            // 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 ) );
    479490        },
    480491
     
    587598
    588599        resetRoute: function() {
    589             wp.media.mediarouter.navigate( wp.media.mediarouter.baseUrl( '' ) );
    590             return;
     600            this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) );
    591601        }
    592602    });
Note: See TracChangeset for help on using the changeset viewer.