jQuery(function($){
// An object to store the IDs we'll be assigning to the three drop-down lists later.
var menu_ids = { main: 'js-nav-main' }
var $menuWrapper = $('.nav--primary > .menu-name-main-menu');
// Assigns the ID attribute to the target dropdown menu
$menuWrapper.find('> .menu').attr('id', menu_ids.main);
// Assigns the data-menu attributes to the toggle links (the data-menu attributes are
// set to the ID values for the associated drop-down menus)
//$menuWrapper.prepend('');
// Click functionality for the toggle-menu elements
$('.toggle-menu').click(function (e) {
e.preventDefault();
// Setting the $drop_down variable using the clicked element's data-menu attribute value
var togglingMenuId = $(this).attr('data-menu');
var $drop_down = $(togglingMenuId);
if ($(this).hasClass('toggle-expanded')) {
$(this).removeClass('toggle-expanded');
}
else {
$(this).addClass('toggle-expanded');
}
$drop_down.toggle();
});
var $subNav = $menuWrapper.find("> ul > li");
$subNav.append('');
$subNav.find("span").bind('click', function () {
var $targ = $(this).prev(),
was_vis = $targ.is(':visible');
//Clean up before we start again
$menuWrapper.find('> ul > li > div').slideUp('fast');
$menuWrapper.find('.expanded').removeClass('expanded');
if (!was_vis) {
$targ.slideDown('fast');
$targ.parent().addClass('expanded');
}
else {
$targ.parent().removeClass('expanded');
}
});
// Any time the window is resized, re-set the is_mobile boolean
$(window).bind('resize orientationchange', function () {
});
}); // end jQuery