2013-11-22 17:42:09 -05:00
|
|
|
/**
|
|
|
|
* Twenty Fourteen keyboard support for image navigation.
|
|
|
|
*/
|
|
|
|
( function( $ ) {
|
2013-11-15 16:18:09 -05:00
|
|
|
$( document ).on( 'keydown.twentyfourteen', function( e ) {
|
2013-07-28 18:55:10 -04:00
|
|
|
var url = false;
|
2013-11-15 16:18:09 -05:00
|
|
|
|
|
|
|
// Left arrow key code.
|
|
|
|
if ( e.which === 37 ) {
|
2013-07-28 18:55:10 -04:00
|
|
|
url = $( '.previous-image a' ).attr( 'href' );
|
2013-11-15 16:18:09 -05:00
|
|
|
|
|
|
|
// Right arrow key code.
|
|
|
|
} else if ( e.which === 39 ) {
|
2013-07-28 18:55:10 -04:00
|
|
|
url = $( '.entry-attachment a' ).attr( 'href' );
|
|
|
|
}
|
2013-11-15 16:18:09 -05:00
|
|
|
|
2015-01-20 14:03:23 -05:00
|
|
|
if ( url && ( ! $( 'textarea, input' ).is( ':focus' ) ) ) {
|
2013-07-28 18:55:10 -04:00
|
|
|
window.location = url;
|
|
|
|
}
|
|
|
|
} );
|
2013-11-22 17:42:09 -05:00
|
|
|
} )( jQuery );
|