Skip to content

Issue with Submenus in 2014: Refreshing new_functions.patch for 30575 #8820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions src/wp-content/themes/twentyfourteen/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,34 @@
} );
} );

/**
* Enable hover for dropdown menu for touch devices
*
* @see trac ticket #30575
*/
function touchDropdown() {
if ( 781 > _window.width() ) {
$( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', function() {
$( this ).parents().toggleClass( 'focus' );
} );
if ( 'ontouchstart' in window ) {
$( document.body ).off( 'touchstart.twentyfourteen' );
}
} else {
if ( 'ontouchstart' in window ) {
$( document.body ).on( 'touchstart.twentyfourteen', '.menu-item-has-children > a, .page_item_has_children > a', function( e ) {
var el = $( this ).parent( 'li' );

if ( ! el.hasClass( 'focus' ) ) {
e.preventDefault();
el.toggleClass( 'focus' );
el.siblings( '.focus' ).removeClass( 'focus' );
}
} );
}
}
}

/**
* Add or remove ARIA attributes.
*
Expand All @@ -107,16 +135,18 @@
button.attr( 'aria-expanded', 'false' );
menu.attr( 'aria-expanded', 'false' );
button.attr( 'aria-controls', 'primary-menu' );
$( '.menu-item-has-children' ).attr( 'aria-haspopup', 'false' );
} else {
button.removeAttr( 'aria-expanded' );
menu.removeAttr( 'aria-expanded' );
button.removeAttr( 'aria-controls' );
$( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
}
}

_window
.on( 'load.twentyfourteen', onResizeARIA )
.on( 'resize.twentyfourteen', function() {
.on( 'load.twentyfourteen resize.twentyfourteen', function() {
touchDropdown();
onResizeARIA();
} );

Expand Down
Loading