]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js
WordPress 4.3
[autoinstalls/wordpress.git] / wp-content / themes / twentyfourteen / js / keyboard-image-navigation.js
1 /**
2  * Twenty Fourteen keyboard support for image navigation.
3  */
4 ( function( $ ) {
5         $( document ).on( 'keydown.twentyfourteen', function( e ) {
6                 var url = false;
7
8                 // Left arrow key code.
9                 if ( e.which === 37 ) {
10                         url = $( '.previous-image a' ).attr( 'href' );
11
12                 // Right arrow key code.
13                 } else if ( e.which === 39 ) {
14                         url = $( '.entry-attachment a' ).attr( 'href' );
15                 }
16
17                 if ( url && ( ! $( 'textarea, input' ).is( ':focus' ) ) ) {
18                         window.location = url;
19                 }
20         } );
21 } )( jQuery );