/**
* This script adds the accessibility-ready responsive menus Genesis Framework child themes.
*
* @author StudioPress
* @link https://github.com/copyblogger/responsive-menus
* @version 1.1.2
* @license GPL-2.0+
*/
var genesisMenuParams=typeof genesis_responsive_menu==='undefined'?'':genesis_responsive_menu,genesisMenusUnchecked=genesisMenuParams.menuClasses,genesisMenus={},menusToCombine=[];(function(document,$,undefined){'use strict';$.each(genesisMenusUnchecked,function(group){genesisMenus[group]=[];$.each(this,function(key,value){var menuString=value,$menu=$(value);if($menu.length>1){$.each($menu,function(key,value){var newString=menuString+'-'+key;$(this).addClass(newString.replace('.',''));genesisMenus[group].push(newString);if('combine'===group){menusToCombine.push(newString)}})}else if($menu.length==1){genesisMenus[group].push(menuString);if('combine'===group){menusToCombine.push(menuString)}}})});if(typeof genesisMenus.others=='undefined'){genesisMenus.others=[]}
if(menusToCombine.length==1){genesisMenus.others.push(menusToCombine[0]);genesisMenus.combine=null;menusToCombine=null}
var genesisMenu={},mainMenuButtonClass='menu-toggle',subMenuButtonClass='sub-menu-toggle',responsiveMenuClass='genesis-responsive-menu';genesisMenu.init=function(){if($(_getAllMenusArray()).length==0){return}
var menuIconClass=typeof genesisMenuParams.menuIconClass!=='undefined'?genesisMenuParams.menuIconClass:'dashicons-before dashicons-menu',subMenuIconClass=typeof genesisMenuParams.subMenuIconClass!=='undefined'?genesisMenuParams.subMenuIconClass:'dashicons-before dashicons-arrow-down-alt2',toggleButtons={submenu:$('',{'class':subMenuButtonClass,'aria-expanded':!1,'aria-pressed':!1,'role':'button'}).append($('',{'class':'screen-reader-text','text':genesisMenuParams.subMenu}))};_addResponsiveMenuClass();_addMenuButtons(toggleButtons);$('.'+mainMenuButtonClass).addClass(menuIconClass);$('.'+subMenuButtonClass).addClass(subMenuIconClass);$('.'+mainMenuButtonClass).on('click.genesisMenu-mainbutton',_mainmenuToggle).each(_addClassID);$('.'+subMenuButtonClass).on('click.genesisMenu-subbutton',_submenuToggle);$(window).on('resize.genesisMenu',_doResize).triggerHandler('resize.genesisMenu')};function _addMenuButtons(toggleButtons){$(_getMenuSelectorString(genesisMenus)).find('.sub-menu').before(toggleButtons.submenu);if(menusToCombine!==null){var menusToToggle=genesisMenus.others.concat(menusToCombine[0]);$(_getMenuSelectorString(menusToToggle)).before(toggleButtons.menu)}else{$(_getMenuSelectorString(genesisMenus.others)).before(toggleButtons.menu)}}
function _addResponsiveMenuClass(){$(_getMenuSelectorString(genesisMenus)).addClass(responsiveMenuClass)}
function _doResize(){var buttons=$('button[id^="genesis-mobile-"]').attr('id');if(typeof buttons==='undefined'){return}
_maybeClose(buttons);_superfishToggle(buttons);_changeSkipLink(buttons);_combineMenus(buttons)}
function _addClassID(){var $this=$(this),nav=$this.next('nav'),id='class';$this.attr('id','genesis-mobile-'+$(nav).attr(id).match(/nav-\w*\b/))}
function _combineMenus(buttons){if(menusToCombine==null){return}
var primaryMenu=menusToCombine[0],combinedMenus=$(menusToCombine).filter(function(index){if(index>0){return index}});if('none'!==_getDisplayValue(buttons)){$.each(combinedMenus,function(key,value){$(value).find('.menu > li').addClass('moved-item-'+value.replace('.','')).appendTo(primaryMenu+' ul.genesis-nav-menu')});$(_getMenuSelectorString(combinedMenus)).hide()}else{$(_getMenuSelectorString(combinedMenus)).show();$.each(combinedMenus,function(key,value){$('.moved-item-'+value.replace('.','')).appendTo(value+' ul.genesis-nav-menu').removeClass('moved-item-'+value.replace('.',''))})}}
function _mainmenuToggle(){var $this=$(this);_toggleAria($this,'aria-pressed');_toggleAria($this,'aria-expanded');$this.toggleClass('activated');$this.next('nav').slideToggle('fast')}
function _submenuToggle(){var $this=$(this),others=$this.closest('.menu-item').siblings();_toggleAria($this,'aria-pressed');_toggleAria($this,'aria-expanded');$this.toggleClass('activated');$this.next('.sub-menu').slideToggle('fast');others.find('.'+subMenuButtonClass).removeClass('activated').attr('aria-pressed','false');others.find('.sub-menu').slideUp('fast')}
function _superfishToggle(buttons){var _superfish=$('.'+responsiveMenuClass+' .js-superfish'),$args='destroy';if(typeof _superfish.superfish!=='function'){return}
if('none'===_getDisplayValue(buttons)){$args={'delay':100,'animation':{'opacity':'show','height':'show'},'dropShadows':!1,'speed':'fast'}}
_superfish.superfish($args)}
function _changeSkipLink(buttons){var menuToggleList=_getAllMenusArray();if(!$(menuToggleList).length>0){return}
$.each(menuToggleList,function(key,value){var newValue=value.replace('.',''),startLink='genesis-'+newValue,endLink='genesis-mobile-'+newValue;if('none'==_getDisplayValue(buttons)){startLink='genesis-mobile-'+newValue;endLink='genesis-'+newValue}
var $item=$('.genesis-skip-link a[href="#'+startLink+'"]');if(menusToCombine!==null&&value!==menusToCombine[0]){$item.toggleClass('skip-link-hidden')}
if($item.length>0){var link=$item.attr('href');link=link.replace(startLink,endLink);$item.attr('href',link)}else{return}})}
function _maybeClose(buttons){if('none'!==_getDisplayValue(buttons)){return!0}
$('.'+mainMenuButtonClass+', .'+responsiveMenuClass+' .sub-menu-toggle').removeClass('activated').attr('aria-expanded',!1).attr('aria-pressed',!1);$('.'+responsiveMenuClass+', '+responsiveMenuClass+' .sub-menu').attr('style','')}
function _getDisplayValue($id){var element=document.getElementById($id),style=window.getComputedStyle(element);return style.getPropertyValue('display')}
function _toggleAria($this,attribute){$this.attr(attribute,function(index,value){return'false'===value})}
function _getMenuSelectorString(itemArray){var itemString=$.map(itemArray,function(value,key){return value});return itemString.join(',')}
function _getAllMenusArray(){var menuList=[];if(menusToCombine!==null){$.each(menusToCombine,function(key,value){menuList.push(value.valueOf())})}
$.each(genesisMenus.others,function(key,value){menuList.push(value.valueOf())});if(menuList.length>0){return menuList}else{return null}}
$(document).ready(function(){if(_getAllMenusArray()!==null){genesisMenu.init()}})})(document,jQuery)