From b52ee7959bf30610bf3b3a612a296efc09039abf Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Fri, 15 Nov 2013 21:18:00 +0000 Subject: [PATCH] Twenty Fourteen: fix an issue with keyboard navigation where you couldn't navigate to the previous image. Props obenland, see #25946. git-svn-id: https://develop.svn.wordpress.org/trunk@26226 602fd350-edb4-49c9-b593-d223f7449a82 --- .../twentyfourteen/js/keyboard-image-navigation.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js b/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js index 93260d9bb8..736c378ed8 100644 --- a/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js +++ b/src/wp-content/themes/twentyfourteen/js/keyboard-image-navigation.js @@ -1,12 +1,16 @@ -jQuery( document ).ready( function( $ ) { - $( document ).keydown( function( e ) { +jQuery( function( $ ) { + $( document ).on( 'keydown.twentyfourteen', function( e ) { var url = false; - if ( e.which === 37 ) { // Left arrow key code + + // Left arrow key code. + if ( e.which === 37 ) { url = $( '.previous-image a' ).attr( 'href' ); - } - else if ( e.which === 39 ) { // Right arrow key code + + // Right arrow key code. + } else if ( e.which === 39 ) { url = $( '.entry-attachment a' ).attr( 'href' ); } + if ( url && ( !$( 'textarea, input' ).is( ':focus' ) ) ) { window.location = url; }