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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28875 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-11 06:39:14 +00:00
parent dfd3c19cec
commit 6d67479072
2 changed files with 7 additions and 17 deletions

View File

@ -237,21 +237,13 @@
* Open the Edit Attachment modal. * Open the Edit Attachment modal.
*/ */
editAttachment: function( model ) { editAttachment: function( model ) {
var self = this,
library = this.state().get('library');
// 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 = wp.media( { wp.media( {
frame: 'edit-attachments', frame: 'edit-attachments',
gridRouter: this.gridRouter, gridRouter: this.gridRouter,
library: library, library: this.state().get('library'),
model: model model: model
} ); } );
// Listen to keyboard events on the modal
$( 'body' ).on( 'keydown.media-modal', function( e ) {
self.editAttachmentFrame.keyEvent( e );
} );
}, },
/** /**
@ -460,6 +452,10 @@
title: this.options.title title: this.options.title
}); });
this.modal.on( 'open', function () {
$( 'body' ).on( 'keydown.media-modal', _.bind( self.keyEvent, self ) );
} );
// Completely destroy the modal DOM element when closing it. // Completely destroy the modal DOM element when closing it.
this.modal.close = function() { this.modal.close = function() {
self.modal.remove(); self.modal.remove();
@ -618,16 +614,10 @@
} }
// The right arrow key // The right arrow key
if ( event.keyCode === 39 ) { if ( event.keyCode === 39 ) {
if ( ! this.hasNext() ) {
return;
}
this.nextMediaItem(); this.nextMediaItem();
} }
// The left arrow key // The left arrow key
if ( event.keyCode === 37 ) { if ( event.keyCode === 37 ) {
if ( ! this.hasPrevious() ) {
return;
}
this.previousMediaItem(); this.previousMediaItem();
} }
}, },

File diff suppressed because one or more lines are too long