Ticket #24716: 24716.21.diff
File 24716.21.diff, 1.3 KB (added by , 10 years ago) |
---|
-
src/wp-includes/js/media-grid.js
340 340 'click': 'collapse', 341 341 'click .delete-media-item': 'deleteMediaItem', 342 342 'click .left': 'previousMediaItem', 343 'click .right': 'nextMediaItem' 343 'click .right': 'nextMediaItem', 344 'keydown': 'keyEvent' 344 345 }, 345 346 346 347 initialize: function() { … … 377 378 378 379 this.modal.content( this ); 379 380 this.modal.open(); 381 // Ensure modal gains focus, otherwise keyboard events lost 382 $( '.attachment-fields input:first' ).focus(); 383 380 384 } 381 385 }, 382 386 … … 482 486 return; 483 487 this.modal.close(); 484 488 this.options.gridController.trigger( 'edit:attachment:next', this.model ); 489 }, 490 /** 491 * Respond to the keyboard events: right arrow, left arrow. 492 */ 493 keyEvent: function( event ) { 494 // The right arrow key 495 if ( event.keyCode === 39 ) { 496 if ( ! this.options.hasNext ) { return; } 497 _.once( this.nextMediaItem() ); 498 } 499 500 // The left arrow key 501 if ( event.keyCode === 37 ) { 502 if ( ! this.options.hasPrevious ) { return; } 503 _.once( this.previousMediaItem() ); 504 } 485 505 } 486 506 487 507 });