wp/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js
changeset 5 5e2f62d02dcd
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
       
     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 );