Make WordPress Core

Changeset 29089


Ignore:
Timestamp:
07/11/2014 06:38:51 AM (11 years ago)
Author:
wonderboymusic
Message:

Media Grid:

  • Don't store multiple references to the Edit Attachments frame.
  • Fix keyboard navigation event delegation and proxy.
  • Remove redundant function calls.

See #24716.

File:
1 edited

Legend:

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

    r29087 r29089  
    238238         */
    239239        editAttachment: function( model ) {
    240             var self    = this,
    241                 library = this.state().get('library');
    242 
    243240            // Create a new EditAttachment frame, passing along the library and the attachment model.
    244             this.editAttachmentFrame = wp.media( {
     241            wp.media( {
    245242                frame:       'edit-attachments',
    246243                gridRouter:  this.gridRouter,
    247                 library:     library,
     244                library:     this.state().get('library'),
    248245                model:       model
    249             } );
    250 
    251             // Listen to keyboard events on the modal
    252             $( 'body' ).on( 'keydown.media-modal', function( e ) {
    253                 self.editAttachmentFrame.keyEvent( e );
    254246            } );
    255247        },
     
    461453                });
    462454
     455                this.modal.on( 'open', function () {
     456                    $( 'body' ).on( 'keydown.media-modal', _.bind( self.keyEvent, self ) );
     457                } );
     458
    463459                // Completely destroy the modal DOM element when closing it.
    464460                this.modal.close = function() {
     
    619615            // The right arrow key
    620616            if ( event.keyCode === 39 ) {
    621                 if ( ! this.hasNext() ) {
    622                     return;
    623                 }
    624617                this.nextMediaItem();
    625618            }
    626619            // The left arrow key
    627620            if ( event.keyCode === 37 ) {
    628                 if ( ! this.hasPrevious() ) {
    629                     return;
    630                 }
    631621                this.previousMediaItem();
    632622            }
Note: See TracChangeset for help on using the changeset viewer.