From ee1a3278ea7a506bc2c90329f338a11965282e5d Mon Sep 17 00:00:00 2001 From: Lance Willett Date: Tue, 8 Oct 2013 17:55:46 +0000 Subject: [PATCH] Twenty Fourteen: provide keyboard support for the primary navigation, props joedolson. See #25054. git-svn-id: https://develop.svn.wordpress.org/trunk@25731 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-content/themes/twentyfourteen/js/theme.js | 12 ++++++++++++ src/wp-content/themes/twentyfourteen/style.css | 14 +++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/wp-content/themes/twentyfourteen/js/theme.js b/src/wp-content/themes/twentyfourteen/js/theme.js index ee0993dedd..d9160886e2 100644 --- a/src/wp-content/themes/twentyfourteen/js/theme.js +++ b/src/wp-content/themes/twentyfourteen/js/theme.js @@ -117,4 +117,16 @@ } ); + /* Accessibility hover styles for menu. */ + $( '.primary-navigation li' ).hover( function() { + $( this ).addClass( 'a11y-focus' ); + }, function() { + $( this ).delay( '250' ).removeClass( 'a11y-focus' ); + } + ); + $( '.primary-navigation li a' ).on( 'focus blur', function() { + $( this ).parents().toggleClass( 'a11y-focus' ); + } + ); + } )( jQuery ); \ No newline at end of file diff --git a/src/wp-content/themes/twentyfourteen/style.css b/src/wp-content/themes/twentyfourteen/style.css index c532ab59c3..22a85e4960 100644 --- a/src/wp-content/themes/twentyfourteen/style.css +++ b/src/wp-content/themes/twentyfourteen/style.css @@ -685,11 +685,10 @@ body { } .primary-navigation ul ul { background-color: rgba(0, 0, 0, 0.9); - display: none; float: left; position: absolute; top: 48px; - left: 0; + left: -999em; z-index: 99999; } .primary-navigation li li { @@ -698,7 +697,7 @@ body { line-height: 1.6363636363; } .primary-navigation ul ul ul { - left: 100%; + left: -999em; top: 0; } .primary-navigation ul ul a { @@ -715,8 +714,13 @@ body { .primary-navigation ul ul a:hover { color: #8c8c8c; } -.primary-navigation ul li:hover > ul { - display: block; +.primary-navigation ul li:hover > ul, +.primary-navigation ul li.a11y-focus > ul { + left: auto; +} +.primary-navigation ul ul li:hover > ul, +.primary-navigation ul ul li.a11y-focus > ul { + left: 100%; } .primary-navigation li.current_page_item > a, .primary-navigation li.current-menu-item > a {