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