Ticket #24716: 24716.20.diff
File 24716.20.diff, 1.4 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 ); 485 } 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 } 486 499 500 // The left arrow key 501 if ( event.keyCode === 37 ) { 502 if ( ! this.options.hasPrevious ) { return; } 503 _.once( this.previousMediaItem() ); 504 } 505 }, 506 487 507 }); 488 508 489 509 media.view.GridFieldOptions = media.View.extend({