// jQuery( document ).ready( function ( $ ) {
// 'use strict';
// /**
// * The actual plugin for mobile dropdown
// */
// var mobileDropdown = (function () {
// var settings = {
// heightHeader: 80,
// heightAdminbar: 50
// };
// // The selector variables.
// var selector = {
// menuIcon: $( ".menu-toggle" ),
// dropdownArrow: $( "span.dropdown-arrow" ),
// menuNav: $('.main-navigation'),
// wavesButtonSelector: '.button'
// };
// var events = function () {
// // When header is clicked.
// selector.menuIcon.on( 'click', openMenu );
// // Dropdown menu links
// $('li.menu-item-has-children').on( 'click', $(this).closest('span.dropdown-arrow'), openDropdownMenu );
// };
// var openMenu = function ( event ) {
// var headerHeight = settings.heightHeader;
// var adminbarHeight = settings.heightAdminbar;
// // No need for this when you are not logged in.
// if ( ! $("body").hasClass("admin-bar") ) {
// adminbarHeight = 0;
// }
// // Change button state
// $( this ).toggleClass( 'is-opened' );
// // Open the main menu.
// selector.menuNav.toggleClass( 'is-extended' ).removeClass('init');
// // selector.menuNav.height( $(window).height() - headerHeight - adminbarHeight );
// $('body').toggleClass( 'is-menu-opened' );
// };
// var openDropdownMenu = function ( event ) {
// event.stopImmediatePropagation(); // Fix issue with double clicking.
// $(this).toggleClass( "is-extended" );
// };
// var buildDropdownArrow = function () {
// $('.menu-item-has-children').each(function() {
// $(this).append("");
// });
// };
// /**
// * Run the dropdown menu.
// */
// var initialiseDropdown = function() {
// buildDropdownArrow();
// events();
// };
// return {
// init: initialiseDropdown
// };
// })();
// mobileDropdown.init();
// });
( function( $ ) {
// var container = document.getElementById( 'site-navigation' );
var dropdownToggle = $( '', {
'class': 'dropdown-toggle',
'aria-expanded': false
} ).append( $( '', {
'class': 'screen-reader-text',
text: "expand child menu"
} ) );
$("#site-navigation").find( '.menu-item-has-children > a' ).after( dropdownToggle );
// Toggle buttons and submenu items with active children menu items.
$("#site-navigation").find( '.current-menu-ancestor > button' ).addClass( 'toggled-on' );
$("#site-navigation").find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );
// Add menu items with submenus to aria-haspopup="true".
$("#site-navigation").find( '.menu-item-has-children' ).attr( 'aria-haspopup', 'true' );
$("#site-navigation").find( '.dropdown-toggle' ).click( function( e ) {
var _this = $( this )
e.preventDefault();
_this.toggleClass( 'toggled-on' );
_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );
// jscs:disable
_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );
} );
$('button.menu-toggle').on('click', function() {
if ( $('#site-navigation').hasClass('toggled') ) {
$('#site-navigation').removeClass('toggled');
$(this).attr( 'aria-expanded', 'false' );
$('.menu-primary-container').attr('aria-expanded', 'false');
$('.menu-primary-container').css('display', 'none');
} else {
$('#site-navigation').addClass('toggled');
$(this).attr( 'aria-expanded', 'true' );
$('.menu-primary-container').attr('aria-expanded', 'true');
$('.menu-primary-container').css('display', 'block');
}
});
} )( jQuery );