if('undefined'===typeof BG_SHCE_USE_EFFECTS){
BG_SHCE_USE_EFFECTS='0';
}
if('undefined'===typeof BG_SHCE_TOGGLE_SPEED){
BG_SHCE_TOGGLE_SPEED='0';
}
if('undefined'===typeof BG_SHCE_TOGGLE_OPTIONS){
BG_SHCE_TOGGLE_OPTIONS='swing';
}
if('undefined'===typeof BG_SHCE_TOGGLE_EFFECT){
BG_SHCE_TOGGLE_EFFECT='';
}
function bgExpandCollapsedContent(){
var bgCollapseExpandItems=document.querySelectorAll('input[bg_collapse_expand]');
for(i=0; i<bgCollapseExpandItems.length; i++){
var showHideButton=document.getElementById('bg-showmore-action-'+bgCollapseExpandItems[i].value);
var hiddenContent=document.getElementById('bg-showmore-hidden-'+bgCollapseExpandItems[i].value);
if(showHideButton&&hiddenContent){
if(window.addEventListener){
showHideButton.addEventListener('click', function(event){bgExpandCollapsedContentAction(event, this);});
}else{
window.attachEvent("onclick", function(event){bgExpandCollapsedContentAction(event, this);});
}}
if(jQuery(showHideButton).parent().prop("tagName")==='LI' &&
jQuery(showHideButton).parent().parent().prop("tagName")==='UL'){
jQuery(showHideButton).parent().parent().css('margin-bottom',0);
}}
}
function bgExpandCollapsedContentAction(event, thisObj){
event.preventDefault();
var bgUniqId=thisObj.id.replace('bg-showmore-action-', '');
var showHideButton=document.getElementById('bg-showmore-action-'+bgUniqId);
var hiddenContent=document.getElementById('bg-showmore-hidden-'+bgUniqId);
var showLessText=document.getElementById('bg-show-less-text-'+bgUniqId).value;
var showMoreText=document.getElementById('bg-show-more-text-'+bgUniqId).value;
var text=jQuery(showHideButton).text();
if(BG_SHCE_USE_EFFECTS==='1'){
jQuery(hiddenContent).toggle(BG_SHCE_TOGGLE_EFFECT, BG_SHCE_TOGGLE_OPTIONS, parseInt(BG_SHCE_TOGGLE_SPEED)+1);
}else{
jQuery(hiddenContent).toggle(parseInt(BG_SHCE_TOGGLE_SPEED));
}
if(showLessText===''){
jQuery(showHideButton).toggle();
if(jQuery(showHideButton).parent().prop("tagName")==='LI'){
jQuery(showHideButton).parent().toggle();
}}else{
jQuery(showHideButton).text(text==showMoreText ? showLessText:showMoreText
);
jQuery(showHideButton).toggleClass("bg-close");
}
if('undefined'!==typeof gmspAllMaps){
gmspResizeMaps('recenterHidden');
}}
function bgSelectedEffect(){
var effectOpts=jQuery('#bg_shce_effect > option');
if(effectOpts.length > 0){
var i=0;
while(i < effectOpts.length){
if(effectOpts[i].value===BG_SHCE_TOGGLE_EFFECT){
effectOpts[i].selected=true;
}
i++;
}}
if(BG_SHCE_USE_EFFECTS==='1'){
jQuery('.bg-effects').show();
}}
jQuery(document).ready(function(){
bgExpandCollapsedContent();
bgSelectedEffect();
});
;(function(factory){
'use strict';
if(typeof define==='function'&&define.amd){
define(['jquery'], factory);
}else if(typeof module==='object'&&module.exports){
module.exports=factory(require('jquery'));
}else if(jQuery&&!jQuery.fn.hoverIntent){
factory(jQuery);
}})(function($){
'use strict';
var _cfg={
interval: 100,
sensitivity: 6,
timeout: 0
};
var INSTANCE_COUNT=0;
var cX, cY;
var track=function(ev){
cX=ev.pageX;
cY=ev.pageY;
};
var compare=function(ev,$el,s,cfg){
if(Math.sqrt((s.pX-cX)*(s.pX-cX) + (s.pY-cY)*(s.pY-cY)) < cfg.sensitivity){
$el.off(s.event,track);
delete s.timeoutId;
s.isActive=true;
ev.pageX=cX; ev.pageY=cY;
delete s.pX; delete s.pY;
return cfg.over.apply($el[0],[ev]);
}else{
s.pX=cX; s.pY=cY;
s.timeoutId=setTimeout(function(){compare(ev, $el, s, cfg);} , cfg.interval);
}};
var delay=function(ev,$el,s,out){
var data=$el.data('hoverIntent');
if(data){
delete data[s.id];
}
return out.apply($el[0],[ev]);
};
var isFunction=function(value){
return typeof value==='function';
};
$.fn.hoverIntent=function(handlerIn,handlerOut,selector){
var instanceId=INSTANCE_COUNT++;
var cfg=$.extend({}, _cfg);
if($.isPlainObject(handlerIn)){
cfg=$.extend(cfg, handlerIn);
if(!isFunction(cfg.out)){
cfg.out=cfg.over;
}}else if(isFunction(handlerOut)){
cfg=$.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector });
}else{
cfg=$.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut });
}
var handleHover=function(e){
var ev=$.extend({},e);
var $el=$(this);
var hoverIntentData=$el.data('hoverIntent');
if(!hoverIntentData){ $el.data('hoverIntent', (hoverIntentData={})); }
var state=hoverIntentData[instanceId];
if(!state){ hoverIntentData[instanceId]=state={ id: instanceId };}
if(state.timeoutId){ state.timeoutId=clearTimeout(state.timeoutId); }
var mousemove=state.event='mousemove.hoverIntent.hoverIntent'+instanceId;
if(e.type==='mouseenter'){
if(state.isActive){ return; }
state.pX=ev.pageX; state.pY=ev.pageY;
$el.off(mousemove,track).on(mousemove,track);
state.timeoutId=setTimeout(function(){compare(ev,$el,state,cfg);} , cfg.interval);
}else{ // "mouseleave"
if(!state.isActive){ return; }
$el.off(mousemove,track);
state.timeoutId=setTimeout(function(){delay(ev,$el,state,cfg.out);} , cfg.timeout);
}};
return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector);
};});
;(function ($, w){
"use strict";
var methods=(function (){
var c={
bcClass: 'sf-breadcrumb',
menuClass: 'sf-js-enabled',
anchorClass: 'sf-with-ul',
menuArrowClass: 'sf-arrows'
},
ios=(function (){
var ios=/^(?![\w\W]*Windows Phone)[\w\W]*(iPhone|iPad|iPod)/i.test(navigator.userAgent);
if(ios){
$('html').css('cursor', 'pointer').on('click', $.noop);
}
return ios;
})(),
wp7=(function (){
var style=document.documentElement.style;
return ('behavior' in style&&'fill' in style&&/iemobile/i.test(navigator.userAgent));
})(),
unprefixedPointerEvents=(function (){
return (!!w.PointerEvent);
})(),
toggleMenuClasses=function ($menu, o, add){
var classes=c.menuClass,
method;
if(o.cssArrows){
classes +=' ' + c.menuArrowClass;
}
method=(add) ? 'addClass':'removeClass';
$menu[method](classes);
},
setPathToCurrent=function ($menu, o){
return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels)
.addClass(o.hoverClass + ' ' + c.bcClass)
.filter(function (){
return ($(this).children(o.popUpSelector).hide().show().length);
}).removeClass(o.pathClass);
},
toggleAnchorClass=function ($li, add){
var method=(add) ? 'addClass':'removeClass';
$li.children('a')[method](c.anchorClass);
},
toggleTouchAction=function ($menu){
var msTouchAction=$menu.css('ms-touch-action');
var touchAction=$menu.css('touch-action');
touchAction=touchAction||msTouchAction;
touchAction=(touchAction==='pan-y') ? 'auto':'pan-y';
$menu.css({
'ms-touch-action': touchAction,
'touch-action': touchAction
});
},
getMenu=function ($el){
return $el.closest('.' + c.menuClass);
},
getOptions=function ($el){
return getMenu($el).data('sfOptions');
},
over=function (){
var $this=$(this),
o=getOptions($this);
clearTimeout(o.sfTimer);
$this.siblings().superfish('hide').end().superfish('show');
},
close=function (o){
o.retainPath=($.inArray(this[0], o.$path) > -1);
this.superfish('hide');
if(!this.parents('.' + o.hoverClass).length){
o.onIdle.call(getMenu(this));
if(o.$path.length){
$.proxy(over, o.$path)();
}}
},
out=function (){
var $this=$(this),
o=getOptions($this);
if(ios){
$.proxy(close, $this, o)();
}else{
clearTimeout(o.sfTimer);
o.sfTimer=setTimeout($.proxy(close, $this, o), o.delay);
}},
touchHandler=function (e){
var $this=$(this),
o=getOptions($this),
$ul=$this.siblings(e.data.popUpSelector);
if(o.onHandleTouch.call($ul)===false){
return this;
}
if($ul.length > 0&&$ul.is(':hidden')){
$this.one('click.superfish', false);
if(e.type==='MSPointerDown'||e.type==='pointerdown'){
$this.trigger('focus');
}else{
$.proxy(over, $this.parent('li'))();
}}
},
applyHandlers=function ($menu, o){
var targets='li:has(' + o.popUpSelector + ')';
if($.fn.hoverIntent&&!o.disableHI){
$menu.hoverIntent(over, out, targets);
}else{
$menu
.on('mouseenter.superfish', targets, over)
.on('mouseleave.superfish', targets, out);
}
var touchevent='MSPointerDown.superfish';
if(unprefixedPointerEvents){
touchevent='pointerdown.superfish';
}
if(!ios){
touchevent +=' touchend.superfish';
}
if(wp7){
touchevent +=' mousedown.superfish';
}
$menu
.on('focusin.superfish', 'li', over)
.on('focusout.superfish', 'li', out)
.on(touchevent, 'a', o, touchHandler);
};
return {
hide: function (instant){
if(this.length){
var $this=this,
o=getOptions($this);
if(!o){
return this;
}
var not=(o.retainPath===true) ? o.$path:'',
$ul=$this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector),
speed=o.speedOut;
if(instant){
$ul.show();
speed=0;
}
o.retainPath=false;
if(o.onBeforeHide.call($ul)===false){
return this;
}
$ul.stop(true, true).animate(o.animationOut, speed, function (){
var $this=$(this);
o.onHide.call($this);
});
}
return this;
},
show: function (){
var o=getOptions(this);
if(!o){
return this;
}
var $this=this.addClass(o.hoverClass),
$ul=$this.children(o.popUpSelector);
if(o.onBeforeShow.call($ul)===false){
return this;
}
$ul.stop(true, true).animate(o.animation, o.speed, function (){
o.onShow.call($ul);
});
return this;
},
destroy: function (){
return this.each(function (){
var $this=$(this),
o=$this.data('sfOptions'),
$hasPopUp;
if(!o){
return false;
}
$hasPopUp=$this.find(o.popUpSelector).parent('li');
clearTimeout(o.sfTimer);
toggleMenuClasses($this, o);
toggleAnchorClass($hasPopUp);
toggleTouchAction($this);
$this.off('.superfish').off('.hoverIntent');
$hasPopUp.children(o.popUpSelector).attr('style', function (i, style){
if(typeof style!=='undefined'){
return style.replace(/display[^;]+;?/g, '');
}});
o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass);
$this.find('.' + o.hoverClass).removeClass(o.hoverClass);
o.onDestroy.call($this);
$this.removeData('sfOptions');
});
},
init: function (op){
return this.each(function (){
var $this=$(this);
if($this.data('sfOptions')){
return false;
}
var o=$.extend({}, $.fn.superfish.defaults, op),
$hasPopUp=$this.find(o.popUpSelector).parent('li');
o.$path=setPathToCurrent($this, o);
$this.data('sfOptions', o);
toggleMenuClasses($this, o, true);
toggleAnchorClass($hasPopUp, true);
toggleTouchAction($this);
applyHandlers($this, o);
$hasPopUp.not('.' + c.bcClass).superfish('hide', true);
o.onInit.call(this);
});
}};})();
$.fn.superfish=function (method, args){
if(methods[method]){
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if(typeof method==='object'||! method){
return methods.init.apply(this, arguments);
}else{
return $.error('Method ' +  method + ' does not exist on jQuery.fn.superfish');
}};
$.fn.superfish.defaults={
popUpSelector: 'ul,.sf-mega',
hoverClass: 'sfHover',
pathClass: 'overrideThisToUse',
pathLevels: 1,
delay: 800,
animation: {opacity: 'show'},
animationOut: {opacity: 'hide'},
speed: 'normal',
speedOut: 'fast',
cssArrows: true,
disableHI: false,
onInit: $.noop,
onBeforeShow: $.noop,
onShow: $.noop,
onBeforeHide: $.noop,
onHide: $.noop,
onIdle: $.noop,
onDestroy: $.noop,
onHandleTouch: $.noop
};})(jQuery, window);
jQuery(function ($){
'use strict';
$('.js-superfish').superfish({
'delay': 100,
'animation':   {'opacity': 'show', 'height': 'show'},
'dropShadows': false
});
});
jQuery(document).ready(function($){
if($('.mobile-primary-toggle').length||$('.mobile-secondary-toggle').length){
if(dynamik_sf_enabled){
var sf=$('ul.js-superfish');
}
$('.responsive-primary-menu-container .responsive-menu-icon').click(function(){
if(dynamik_sf_enabled&&dynamik_reveal_sub_pages){
sf.superfish('destroy');
}
$('.nav-primary').slideToggle();
$('#nav').slideToggle();
});
$('.responsive-secondary-menu-container .responsive-menu-icon').click(function(){
if(dynamik_sf_enabled&&dynamik_reveal_sub_pages){
sf.superfish('destroy');
}
$('.nav-secondary').slideToggle();
$('#subnav').slideToggle();
});
$(window).resize(function(){
if(dynamik_sf_enabled&&dynamik_reveal_sub_pages){
if(window.innerWidth <=media_query_mobile_width){
sf.superfish('destroy');
}else{
sf.superfish('init');
}}
if(window.innerWidth > media_query_mobile_width){
$('.nav-primary').removeAttr('style');
$('#nav').removeAttr('style');
$('.nav-secondary').removeAttr('style');
$('#subnav').removeAttr('style');
}});
}
if($('#dropdown-nav select').length||$('#dropdown-subnav select').length){
$('#dropdown-nav select').change(function(){
window.location=$(this).find('option:selected').val();
});
$('#dropdown-subnav select').change(function(){
window.location=$(this).find('option:selected').val();
});
}});
jQuery(document).ready(function($){
var site_header=$('.site-header');
if(site_header.length){
$(window).resize(function(){
if(window.outerWidth > dynamik_fixed_header_min_width){
$('body').addClass('dynamik-fixed-header');
}else{
$('body').removeClass('dynamik-fixed-header');
}});
$(window).resize();
var adminbar_height=$('#wpadminbar').length ? $('#wpadminbar').outerHeight():0;
var header_top_pos=$('.site-header').offset().top;
var header_height=$('.site-header').outerHeight();
$(function(){
var scrolled=false;
$(window).scroll(function(){
if($(this).scrollTop() > (header_top_pos + header_height - adminbar_height)&&$('body').hasClass('dynamik-fixed-header')){
$('body').addClass('dynamik-scrolled').css('padding-top', header_height);
$('.site-header').addClass('dynamik-fixed-site-header');
if(scrolled==false&&dynamik_fixed_header_fade){
$('.site-header').hide().fadeIn(200);
}
scrolled=true;
}else{
$('body').removeClass('dynamik-scrolled').css('padding-top', '');
$('.site-header').removeClass('dynamik-fixed-site-header');
scrolled=false;
}});
});
}});
jQuery(".ja-video-button").click(function(){
jQuery('.video-popup').show("medium");
});
jQuery(".close-popup a").click(function(){
jQuery('.video-popup').hide("slow");
jQuery(".pretty-video video").each(function (){ this.pause() });
});
/*
jQuery(document).ready(function(){
jQuery("a").not('[href="#usa"]').not('[href="#canada"]').click(function(event){
if(this.hash!==""){
event.preventDefault();
var hash=this.hash;
jQuery('html, body').animate({
scrollTop: jQuery(hash).offset().top
}, 800, function(){
window.location.hash=hash;
});
}});
});
*/
jQuery(document).ready(function(){
jQuery(window).scroll(function(){
var scrollTop=jQuery(window).scrollTop();
if(scrollTop > 1500){
jQuery('.back-to-top').fadeIn('slow');
}
if(scrollTop < 1500){
jQuery('.back-to-top').fadeOut('slow');
}});
});
jQuery(".dropd").click(function(){
if(!jQuery(this).hasClass("dd-active")){
jQuery('.dropdown-content').slideDown("fast");
jQuery(this).addClass("dd-active");
}else{
jQuery('.dropdown-content').slideUp("fast");
jQuery(this).removeClass("dd-active");
}});
jQuery(".type-selects").click(function(){
jQuery('.dropdown-content').slideUp("fast");
jQuery(".dropd").removeClass("dd-active");
});
jQuery(".vid-select").click(function(){
jQuery(".not-vid-block").hide("fast");
jQuery(".vid-block").fadeIn("slow");
});
jQuery(".csd-select").click(function(){
jQuery(".not-csd-block").hide("fast");
jQuery(".csd-block").fadeIn("slow");
});
jQuery(".whp-select").click(function(){
jQuery(".not-whp-block").hide("fast");
jQuery(".whp-block").fadeIn("slow");
});
jQuery(".dsh-select").click(function(){
jQuery(".not-dsh-block").hide("fast");
jQuery(".dsh-block").fadeIn("slow");
});
jQuery(".ire-select").click(function(){
jQuery(".not-ire-block").hide("fast");
jQuery(".ire-block").fadeIn("slow");
});
jQuery(".inf-select").click(function(){
jQuery(".not-inf-block").hide("fast");
jQuery(".inf-block").fadeIn("slow");
});
jQuery(".ebook-select").click(function(){
jQuery(".not-ebook-block").hide("fast");
jQuery(".ebook-block").fadeIn("slow");
});
jQuery(".all-select").click(function(){
jQuery(".show-all-blocks").fadeIn("slow");
});
jQuery(".edu-select").click(function(){
jQuery(".res-item").hide("fast");
jQuery(".edu-block").fadeIn("slow");
});
jQuery(".gov-select").click(function(){
jQuery(".res-item").hide("fast");
jQuery(".gov-block").fadeIn("slow");
});
jQuery(".hlt-select").click(function(){
jQuery(".res-item").hide("fast");
jQuery(".hlt-block").fadeIn("slow");
});
jQuery(".fin-select").click(function(){
jQuery(".res-item").hide("fast");
jQuery(".fin-block").fadeIn("slow");
});
jQuery(document).ready(function(){
jQuery(".owl-carousel").owlCarousel({
loop:true,
autoplay:true,
autoplayTimeout:4000,
autoplayHoverPause:true,
margin:30,
nav:true,
navText: ['<i class="fal fa-long-arrow-left"></i>','<i class="fal fa-long-arrow-right"></i>'],
responsive:{
0:{
items:1
},
500:{
items:2
},
700:{
items:3
}}
});
});
var testima=0;
jQuery(window).scroll(function(){
if(jQuery('.info-counters')[0]){
var oTop=jQuery('.info-counters').offset().top - window.innerHeight;
if(testima==0&&jQuery(window).scrollTop() > oTop){
jQuery('.counter-value').each(function(){
var $this=jQuery(this),
countTo=$this.attr('data-count');
jQuery({
countNum: $this.text()
}).animate({
countNum: countTo
},
{
duration: 600,
easing: 'swing',
step: function(){
$this.text(Math.floor(this.countNum));
},
complete: function(){
$this.text(this.countNum);
}});
});
a=1;
}}
});
(function($){
"use strict";
let instanceCounter=0;
$.maxmegamenu=function(menu, options){
const plugin=this;
const $menu=$(menu);
const $wrap=$menu.parent();
const $toggle_bar=$menu.siblings(".mega-menu-toggle");
const menuId=$menu.attr("id");
const instanceId=menuId + '-' + (++instanceCounter);
const docEventNamespace='.megamenu-' + instanceId;
const items_with_submenus=$([
"li.mega-menu-megamenu.mega-menu-item-has-children",
"li.mega-menu-flyout.mega-menu-item-has-children",
"li.mega-menu-tabbed > ul.mega-sub-menu > li.mega-menu-item-has-children",
"li.mega-menu-flyout li.mega-menu-item-has-children"
].join(","), $menu);
const collapse_children_parents=$("li.mega-menu-megamenu li.mega-menu-item-has-children.mega-collapse-children > a.mega-menu-link", $menu);
const tab_key="Tab";
const escape_key="Escape";
const enter_key="Enter";
const space_key=" ";
const left_arrow_key="ArrowLeft";
const up_arrow_key="ArrowUp";
const right_arrow_key="ArrowRight";
const down_arrow_key="ArrowDown";
const defaults={
event:                $menu.attr("data-event"),
effect:               $menu.attr("data-effect"),
effect_speed:         parseInt($menu.attr("data-effect-speed")),
effect_mobile:        $menu.attr("data-effect-mobile"),
effect_speed_mobile:  parseInt($menu.attr("data-effect-speed-mobile")),
panel_width:          $menu.attr("data-panel-width"),
panel_inner_width:    $menu.attr("data-panel-inner-width"),
mobile_force_width:   $menu.attr("data-mobile-force-width"),
mobile_overlay:       $menu.attr("data-mobile-overlay"),
mobile_state:         $menu.attr("data-mobile-state"),
mobile_direction:     $menu.attr("data-mobile-direction"),
second_click:         $menu.attr("data-second-click"),
vertical_behaviour:   $menu.attr("data-vertical-behaviour"),
document_click:       $menu.attr("data-document-click"),
breakpoint:           $menu.attr("data-breakpoint"),
unbind_events:        $menu.attr("data-unbind"),
hover_intent_timeout: $menu.attr("data-hover-intent-timeout") ?? 300,
hover_intent_interval: $menu.attr("data-hover-intent-interval") ?? 100
};
plugin.settings={};
let html_body_class_timeout;
plugin.addAnimatingClass=function(element){
if(plugin.settings.effect==="disabled"){
return;
}
$(".mega-animating", $wrap).removeClass("mega-animating");
const timeout=plugin.settings.effect_speed + parseInt(plugin.settings.hover_intent_timeout, 10);
element.addClass("mega-animating");
setTimeout(function(){
element.removeClass("mega-animating");
}, timeout);
};
plugin.hideAllPanels=function(){
$(".mega-toggle-on > a.mega-menu-link", $menu).each(function(){
plugin.hidePanel($(this), false);
});
};
plugin.expandMobileSubMenus=function(){
if(plugin.settings.mobile_direction!=='vertical'){
return;
}
$(".mega-menu-item-has-children.mega-expand-on-mobile > a.mega-menu-link", $menu).each(function(){
plugin.showPanel($(this), true);
});
if(plugin.settings.mobile_state==='expand_all'){
$(".mega-menu-item-has-children:not(.mega-toggle-on) > a.mega-menu-link", $menu).each(function(){
plugin.showPanel($(this), true);
});
}
if(plugin.settings.mobile_state==='expand_active'){
const activeItemSelectors=[
"li.mega-current-menu-ancestor.mega-menu-item-has-children > a.mega-menu-link",
"li.mega-current-menu-item.mega-menu-item-has-children > a.mega-menu-link",
"li.mega-current-menu-parent.mega-menu-item-has-children > a.mega-menu-link",
"li.mega-current_page_ancestor.mega-menu-item-has-children > a.mega-menu-link",
"li.mega-current_page_item.mega-menu-item-has-children > a.mega-menu-link"
];
$menu.find(activeItemSelectors.join(', ')).each(function(){
plugin.showPanel($(this), true);
});
}};
plugin.hideSiblingPanels=function(anchor, immediate){
anchor.parent().parent().find(".mega-toggle-on").children("a.mega-menu-link").each(function(){
plugin.hidePanel($(this), immediate);
});
};
plugin.isDesktopView=function(){
const width=Math.max(document.documentElement.clientWidth||0, window.innerWidth||0);
return width > plugin.settings.breakpoint;
};
plugin.isMobileView=function(){
return !plugin.isDesktopView();
};
plugin.isHorizontalMobileSubmenuMode=function(){
return plugin.isMobileView()&&plugin.isMobileOffCanvas()&&plugin.settings.mobile_direction==="horizontal";
};
plugin.getFocusableItemsInSubmenu=function($submenu, include_back_link=true){
let $focusable=$submenu
.find("a.mega-menu-link, button.mega-menu-link, .mega-search span[role=button]")
.filter(":visible");
if(!include_back_link){
$focusable=$focusable.not(".mega-mobile-back-link");
}
return $focusable;
};
plugin.focusFirstItemInOpenedSubmenu=function($item){
if(! plugin.isHorizontalMobileSubmenuMode()||! $wrap.hasClass("mega-keyboard-navigation")){
return;
}
const $submenu=$item.children("ul.mega-sub-menu");
if(!$submenu.length){
return;
}
const $firstFocusable=$submenu
.find("a.mega-menu-link, button.mega-menu-link, .mega-search span[role=button]")
.not(".mega-mobile-back-link")
.filter(":visible")
.first();
if($firstFocusable.length){
$firstFocusable.trigger("focus");
}else{
$submenu.find("> li.mega-mobile-back:visible > button.mega-menu-link.mega-mobile-back-link").first().trigger("focus");
}};
plugin.deferFocusFirstItemInOpenedSubmenu=function($item){
const delay=Math.min(120, parseInt(plugin.settings.effect_speed_mobile, 10)||0);
setTimeout(function(){
plugin.focusFirstItemInOpenedSubmenu($item);
setTimeout(function(){
const focusedInSubmenu=$item.find("ul.mega-sub-menu").has(document.activeElement).length!==0;
if(!focusedInSubmenu){
plugin.focusFirstItemInOpenedSubmenu($item);
}}, 40);
}, delay);
};
plugin.showPanel=function(anchor, immediate){
if(typeof anchor==='number'||(typeof anchor==='string'&&anchor.trim()!==''&&!isNaN(anchor)) ){
anchor=$("li.mega-menu-item-" + anchor, $menu).find("a.mega-menu-link").first();
}else if(anchor.is("li.mega-menu-item")){
anchor=anchor.find("a.mega-menu-link").first();
}
const $item=anchor.parent();
const isDesktop=plugin.isDesktopView();
const isMobile = !isDesktop;
$item.triggerHandler("before_open_panel");
$item.find("[aria-expanded]").first().attr("aria-expanded", "true");
$(".mega-animating", $wrap).removeClass("mega-animating");
if(isMobile&&$item.hasClass("mega-hide-sub-menu-on-mobile")){
return;
}
if(isDesktop&&($menu.hasClass("mega-menu-horizontal")||$menu.hasClass("mega-menu-vertical"))&&!$item.hasClass("mega-collapse-children")){
plugin.hideSiblingPanels(anchor, true);
}
if((isMobile&&$wrap.hasClass("mega-keyboard-navigation"))||plugin.settings.vertical_behaviour==="accordion"){
plugin.hideSiblingPanels(anchor, false);
}
plugin.calculateDynamicSubmenuWidths(anchor);
if(plugin.shouldUseSlideAnimation(anchor, immediate)){
const speed=isMobile ? plugin.settings.effect_speed_mobile:plugin.settings.effect_speed;
anchor.siblings(".mega-sub-menu").css("display", "none").animate({"height":"show", "paddingTop":"show", "paddingBottom":"show", "minHeight":"show"}, speed, function(){
$(this).css("display", "");
});
}
$item.addClass("mega-toggle-on").triggerHandler("open_panel");
plugin.deferFocusFirstItemInOpenedSubmenu($item);
};
plugin.shouldUseSlideAnimation=function(anchor, immediate){
if(immediate===true){
return false;
}
if(anchor.parent().hasClass("mega-collapse-children")){
return true;
}
const isDesktop=plugin.isDesktopView();
if(isDesktop&&plugin.settings.effect==="slide"){
return true;
}
if(!isDesktop){
if(plugin.settings.effect_mobile==="slide"){
return true;
}
if(plugin.isMobileOffCanvas()){
return plugin.settings.mobile_direction!=="horizontal";
}}
return false;
};
plugin.hidePanel=function(anchor, immediate){
if(typeof anchor==='number'||(typeof anchor==='string'&&anchor.trim()!==''&&!isNaN(anchor)) ){
anchor=$("li.mega-menu-item-" + anchor, $menu).find("a.mega-menu-link").first();
}else if(anchor.is("li.mega-menu-item")){
anchor=anchor.find("a.mega-menu-link").first();
}
const $item=anchor.parent();
const $submenu=anchor.siblings(".mega-sub-menu");
const isMobile=plugin.isMobileView();
$item.triggerHandler("before_close_panel");
$item.find("[aria-expanded]").first().attr("aria-expanded", "false");
if(plugin.shouldUseSlideAnimation(anchor)){
const speed=isMobile ? plugin.settings.effect_speed_mobile:plugin.settings.effect_speed;
$submenu.animate({"height":"hide", "paddingTop":"hide", "paddingBottom":"hide", "minHeight":"hide"}, speed, function(){
$submenu.css("display", "");
$item.removeClass("mega-toggle-on").triggerHandler("close_panel");
});
return;
}
if(immediate){
$submenu.css("display", "none").delay(plugin.settings.effect_speed).queue(function(){
$(this).css("display", "").dequeue();
});
}
$submenu.find(".widget_media_video video").each(function(){
if(this.player){
this.player.pause();
}});
$item.removeClass("mega-toggle-on").triggerHandler("close_panel");
plugin.addAnimatingClass($item);
};
plugin.calculateDynamicSubmenuWidths=function(anchor){
const $item=anchor.parent();
const $submenu=anchor.siblings(".mega-sub-menu");
const isDesktop=plugin.isDesktopView();
const isTopLevelMegamenu=$item.hasClass("mega-menu-megamenu")&&$item.parent().hasClass("max-mega-menu");
if(isTopLevelMegamenu&&plugin.settings.panel_width){
if(isDesktop){
const submenu_offset=$menu.offset();
if(plugin.settings.panel_width==='100vw'){
const target_offset=$('body').offset();
$submenu.css({
left: (target_offset.left - submenu_offset.left) + "px"
});
}else{
const $panel_width_el=plugin.settings.panel_width==='$menu' ? $menu:plugin.settings.panel_width==='$wrap' ? $wrap:$(plugin.settings.panel_width);
if($panel_width_el.length > 0){
$submenu.css({
width: $panel_width_el.outerWidth(),
left: ($panel_width_el.offset().left - submenu_offset.left) + "px"
});
}}
}else{
$submenu.css({
width: "",
left: ""
});
}}
if(isTopLevelMegamenu&&plugin.settings.panel_inner_width){
const $panel_inner_width_el=plugin.settings.panel_inner_width==='$menu' ? $menu:plugin.settings.panel_inner_width==='$wrap' ? $wrap:$(plugin.settings.panel_inner_width);
if($panel_inner_width_el.length > 0){
const target_width=parseInt($panel_inner_width_el.width(), 10);
$submenu.css({
"paddingLeft": "",
"paddingRight": ""
});
const submenu_width=parseInt($submenu.innerWidth(), 10);
if(isDesktop&&target_width > 0&&target_width < submenu_width){
$submenu.css({
"paddingLeft": (submenu_width - target_width) / 2 + "px",
"paddingRight": (submenu_width - target_width) / 2 + "px"
});
}}
}};
plugin.bindClickEvents=function(){
plugin.unbindClickEvents();
let dragging=false;
$(document).on({
["touchmove" + docEventNamespace]: function(){ dragging=true; },
["touchstart" + docEventNamespace]: function(){ dragging=false; }});
$(document).on("click" + docEventNamespace + " touchend" + docEventNamespace, function(e){
if(!dragging&&plugin.settings.document_click==="collapse"&&! $(e.target).closest(".mega-menu-wrap").length){
plugin.hideAllPanels();
plugin.hideMobileMenu();
}
dragging=false;
});
collapse_children_parents.off("click.megamenu touchend.megamenu");
const clickable_parents=$("> a.mega-menu-link", items_with_submenus).add(collapse_children_parents);
clickable_parents.on("touchend.megamenu", function(e){
if(plugin.settings.event==="hover_intent"){
plugin.unbindHoverIntentEvents();
}
if(plugin.settings.event==="hover"){
plugin.unbindHoverEvents();
}});
clickable_parents.on("click.megamenu", function(e){
if($(e.target).hasClass('mega-indicator')){
return;
}
if(plugin.isDesktopView()&&$(this).parent().hasClass("mega-toggle-on")&&$(this).closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed")){
if(plugin.settings.second_click==="go"){
return;
}else{
e.preventDefault();
return;
}}
if(dragging){
return;
}
if(plugin.isMobileView()&&$(this).parent().hasClass("mega-hide-sub-menu-on-mobile")){
return;
}
if((plugin.settings.second_click==="go"||$(this).parent().hasClass("mega-click-click-go"))&&$(this).attr("href")!==undefined){
if(!$(this).parent().hasClass("mega-toggle-on")){
e.preventDefault();
plugin.showPanel($(this));
}}else{
e.preventDefault();
if($(this).parent().hasClass("mega-toggle-on")){
plugin.hidePanel($(this), false);
}else{
plugin.showPanel($(this));
}}
});
if(plugin.settings.second_click==="disabled"){
clickable_parents.off("click.megamenu");
}
$(".mega-close-after-click:not(.mega-menu-item-has-children) > a.mega-menu-link", $menu).on("click.megamenu", function(){
plugin.hideAllPanels();
plugin.hideMobileMenu();
});
$("button.mega-close", $wrap).on("click.megamenu", function(e){
plugin.hideMobileMenu();
});
};
plugin.bindHoverEvents=function(){
items_with_submenus.on({
"mouseenter.megamenu":function(){
plugin.unbindClickEvents();
if(! $(this).hasClass("mega-toggle-on")){
plugin.showPanel($(this).children("a.mega-menu-link"));
}},
"mouseleave.megamenu":function(){
if($(this).hasClass("mega-toggle-on")&&! $(this).hasClass("mega-disable-collapse")&&! $(this).parent().parent().hasClass("mega-menu-tabbed")){
plugin.hidePanel($(this).children("a.mega-menu-link"), false);
}}
});
};
plugin.bindHoverIntentEvents=function(){
items_with_submenus.hoverIntent({
over: function (){
plugin.unbindClickEvents();
if(! $(this).hasClass("mega-toggle-on")){
plugin.showPanel($(this).children("a.mega-menu-link"));
}},
out: function (){
if($(this).hasClass("mega-toggle-on")&&! $(this).hasClass("mega-disable-collapse")&&! $(this).parent().parent().hasClass("mega-menu-tabbed")){
plugin.hidePanel($(this).children("a.mega-menu-link"), false);
}},
timeout: plugin.settings.hover_intent_timeout,
interval: plugin.settings.hover_intent_interval
});
};
plugin.isMobileOffCanvas=function(){
return plugin.settings.effect_mobile==='slide_left'||plugin.settings.effect_mobile==='slide_right';
};
plugin.shouldGoToNextTopLevelItem=function(key){
return(( key===right_arrow_key&&plugin.isDesktopView())||(key===down_arrow_key&&plugin.isMobileView()) )&&$menu.hasClass("mega-menu-horizontal");
};
plugin.shouldGoToPreviousTopLevelItem=function(key){
return(( key===left_arrow_key&&plugin.isDesktopView())||(key===up_arrow_key&&plugin.isMobileView()) )&&$menu.hasClass("mega-menu-horizontal");
};
plugin.bindKeyboardEvents=function(){
const $firstFocusable=$menu.find("a.mega-menu-link").first();
const $lastFocusable=$wrap.find("button.mega-close").first();
const focusableLinkSelector="> a.mega-menu-link, > button.mega-menu-link, > .mega-search span[role=button]";
const getActiveSubmenuBackLink=function(){
const $activeSubmenu=$("li.mega-toggle-on:not(.mega-collapse-children) > ul.mega-sub-menu", $menu).last();
return $activeSubmenu.find("> li.mega-mobile-back:visible > button.mega-menu-link.mega-mobile-back-link").first();
};
const togglePanelForAnchor=function(anchor){
if(!anchor||!anchor.length) return;
if(anchor.parent().hasClass("mega-toggle-on")&&!anchor.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed")){
plugin.hidePanel(anchor);
}else{
plugin.showPanel(anchor);
}};
const closeNearestOpenPanelAndRefocus=function(){
const $focused=$menu[0].contains(document.activeElement) ? $(document.activeElement):$();
const $parentAnchor=$("> a.mega-menu-link", $focused.closest(".mega-toggle-on"));
if($parentAnchor.length){
plugin.hidePanel($parentAnchor);
$parentAnchor.trigger("focus");
return true;
}
return false;
};
const handleTabKey=function(e, $active, isOffCanvasHorizontal, isMobileOffCanvas){
if($active.is($lastFocusable)&&isMobileOffCanvas){
if(!e.shiftKey){
e.preventDefault();
const $backLink=isOffCanvasHorizontal ? getActiveSubmenuBackLink():$();
($backLink.length ? $backLink:$firstFocusable).trigger('focus');
}else if(isOffCanvasHorizontal){
const $last=plugin.getFocusableItemsInSubmenu($("li.mega-toggle-on:not(.mega-collapse-children) > ul.mega-sub-menu", $menu).last(), false
).last();
if($last.length){ e.preventDefault(); $last.trigger('focus'); }}
return;
}
if(isMobileOffCanvas&&e.shiftKey&&$active.is($firstFocusable)){
e.preventDefault();
$lastFocusable.trigger('focus');
return;
}
if(isOffCanvasHorizontal){
const $submenu=$active.parentsUntil($menu, "ul.mega-sub-menu")
.filter(function(){
const $p=$(this).parent();
return $p.hasClass("mega-toggle-on")&&!$p.hasClass("mega-collapse-children");
})
.first();
if($submenu.length){
if(!e.shiftKey){
const $items=plugin.getFocusableItemsInSubmenu($submenu, false);
if($items.length&&$active.is($items.last())){
e.preventDefault();
$lastFocusable.trigger('focus');
}}else if($active.hasClass("mega-mobile-back-link")){
e.preventDefault();
$lastFocusable.trigger('focus');
}else{
const $items=plugin.getFocusableItemsInSubmenu($submenu, false);
const $backLink=$submenu.find("> li.mega-mobile-back:visible > button.mega-menu-link.mega-mobile-back-link").first();
if($items.length&&$backLink.length&&$active.is($items.first())){
e.preventDefault();
$backLink.trigger('focus');
}}
}}
};
const handleToggleBarTrigger=function(e){
e.preventDefault();
if($toggle_bar.hasClass("mega-menu-open")){
plugin.hideMobileMenu();
}else{
plugin.showMobileMenu();
html_body_class_timeout=setTimeout(function(){
$menu.find("a.mega-menu-link").first().trigger('focus');
}, plugin.settings.effect_speed_mobile);
}};
const handleSpaceKey=function(e, $active){
if($active.is("a.mega-menu-link")){
e.preventDefault();
if($active.parent().is(items_with_submenus)) togglePanelForAnchor($active);
}else if($active.is(".mega-indicator")){
e.preventDefault();
togglePanelForAnchor($active.parent());
}};
const handleEscapeKey=function(){
const submenu_open=$(".mega-toggle-on", $menu).length!==0;
if(submenu_open&&closeNearestOpenPanelAndRefocus()) return;
if(plugin.isMobileView()&&!submenu_open) plugin.hideMobileMenu();
};
const handleEnterKey=function(e, $active){
if($active.is(".mega-indicator")){
togglePanelForAnchor($active.parent());
return;
}
if($active.parent().is(items_with_submenus)){
if(plugin.isMobileView()&&$active.parent().is(".mega-hide-sub-menu-on-mobile")) return;
if(!$active.is("[href]")){ togglePanelForAnchor($active); return; }
if($active.parent().hasClass("mega-toggle-on")&&!$active.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed")) return;
e.preventDefault();
plugin.showPanel($active);
}};
const handleArrowUpDown=function(e, goingDown){
e.preventDefault();
const $activeSubmenu=$("li.mega-toggle-on:not(.mega-collapse-children) > ul.mega-sub-menu", $menu).last();
if($activeSubmenu.length){
const $backLink=$activeSubmenu.find("> li.mega-mobile-back:visible > button.mega-menu-link.mega-mobile-back-link").first();
const $items=plugin.getFocusableItemsInSubmenu($activeSubmenu, false);
const focusOrder=[];
if($backLink.length) focusOrder.push($backLink[0]);
$items.each(function(){ focusOrder.push(this); });
if($lastFocusable.length) focusOrder.push($lastFocusable[0]);
const idx=focusOrder.indexOf(document.activeElement);
const nextIdx=(idx < 0)
? (goingDown ? 0:focusOrder.length - 1)
: (idx + (goingDown ? 1:-1) + focusOrder.length) % focusOrder.length;
$(focusOrder[nextIdx]).trigger('focus');
}else{
const $topLinks=$menu.children("li.mega-menu-item:visible").find(focusableLinkSelector);
const idx=$topLinks.index(document.activeElement);
if(idx >=0){
const nextIdx=(idx + (goingDown ? 1:-1) + $topLinks.length) % $topLinks.length;
$topLinks.eq(nextIdx).trigger('focus');
}}
};
const handleArrowLeftRight=function(e, goingToNext){
e.preventDefault();
const $topLinks=$menu.children("li.mega-menu-item:visible").find(focusableLinkSelector);
const $topLink=$(document.activeElement)
.closest($menu.children("li.mega-menu-item"))
.find(focusableLinkSelector).first();
const idx=$topLinks.index($topLink);
const nextIdx=goingToNext ? idx + 1:idx - 1;
if(idx >=0&&nextIdx >=0){
plugin.hideAllPanels();
$topLinks.eq(nextIdx).trigger('focus');
}};
$wrap.on("keyup.megamenu", ".max-mega-menu, .mega-menu-toggle", function(e){
if(e.key!==tab_key) return;
$wrap.addClass("mega-keyboard-navigation");
plugin.bindClickEvents();
const $target=$(e.target);
if(plugin.isDesktopView()&&$target.is(".mega-menu-link")&&$target.parent().parent().hasClass('max-mega-menu')){
plugin.hideAllPanels();
}});
$wrap.on("keydown.megamenu", "a.mega-menu-link, button.mega-menu-link, .mega-indicator, .mega-menu-toggle-block, .mega-menu-toggle-animated-block button, button.mega-close", function(e){
if(!$wrap.hasClass("mega-keyboard-navigation")) return;
const key=e.key;
const $active=$(e.target);
const isOffCanvasHorizontal=plugin.isHorizontalMobileSubmenuMode();
const isMobileOffCanvas=plugin.isMobileView()&&plugin.isMobileOffCanvas();
switch (key){
case tab_key:
handleTabKey(e, $active, isOffCanvasHorizontal, isMobileOffCanvas);
break;
case space_key:
if($active.is(".mega-menu-toggle-block button, .mega-menu-toggle-animated-block button")){
handleToggleBarTrigger(e);
}else{
handleSpaceKey(e, $active);
}
break;
case enter_key:
if($active.is(".mega-menu-toggle-block button, .mega-menu-toggle-animated-block button")){
handleToggleBarTrigger(e);
}else{
handleEnterKey(e, $active);
}
break;
case escape_key:
handleEscapeKey();
break;
case up_arrow_key:
case down_arrow_key:
if(isOffCanvasHorizontal){
handleArrowUpDown(e, key===down_arrow_key);
}
break;
case left_arrow_key:
case right_arrow_key:
const goingToNext=plugin.shouldGoToNextTopLevelItem(key);
const goingToPrev=plugin.shouldGoToPreviousTopLevelItem(key);
if(goingToNext||goingToPrev){
handleArrowLeftRight(e, goingToNext);
}
break;
}});
$wrap.on("focusout.megamenu", function(e){
if($wrap.hasClass("mega-keyboard-navigation")){
setTimeout(function(){
if(!$wrap[0].contains(document.activeElement)){
$wrap.removeClass("mega-keyboard-navigation");
plugin.hideAllPanels();
plugin.hideMobileMenu();
}}, 10);
}});
};
plugin.unbindAllEvents=function(){
$(document).off(docEventNamespace);
$("ul.mega-sub-menu, li.mega-menu-item, li.mega-menu-row, li.mega-menu-column, a.mega-menu-link, .mega-indicator", $menu).off();
};
plugin.unbindClickEvents=function(){
if($wrap.hasClass('mega-keyboard-navigation')){
return;
}
$(document).off(docEventNamespace);
$("> a.mega-menu-link", items_with_submenus).not(collapse_children_parents).off("click.megamenu touchend.megamenu");
};
plugin.unbindHoverEvents=function(){
items_with_submenus.off("mouseenter.megamenu mouseleave.megamenu");
};
plugin.unbindHoverIntentEvents=function(){
items_with_submenus.off("mouseenter mouseleave").removeProp("hoverIntent_t").removeProp("hoverIntent_s");
};
plugin.unbindKeyboardEvents=function(){
$wrap.off("keyup.megamenu keydown.megamenu focusout.megamenu");
};
plugin.unbindMegaMenuEvents=function(){
if(plugin.settings.event==="hover_intent"){
plugin.unbindHoverIntentEvents();
}
if(plugin.settings.event==="hover"){
plugin.unbindHoverEvents();
}
plugin.unbindClickEvents();
plugin.unbindKeyboardEvents();
};
plugin.bindMegaMenuEvents=function(){
plugin.unbindMegaMenuEvents();
const isDesktop=plugin.isDesktopView();
if(isDesktop&&plugin.settings.event==="hover_intent"){
plugin.bindHoverIntentEvents();
}
if(isDesktop&&plugin.settings.event==="hover"){
plugin.bindHoverEvents();
}
plugin.bindClickEvents();
plugin.bindKeyboardEvents();
};
plugin.checkWidth=function(){
if(plugin.isMobileView()&&$menu.data("view")==="desktop"){
plugin.switchToMobile();
}
if(plugin.isDesktopView()&&$menu.data("view")==="mobile"){
plugin.switchToDesktop();
}
plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
};
plugin.reverseRightAlignedItems=function(){
if(! $("body").hasClass("rtl")&&$menu.hasClass("mega-menu-horizontal")&&$menu.css("display")!=='flex'){
$menu.append($menu.children("li.mega-item-align-right").get().reverse());
}};
plugin.addClearClassesToMobileItems=function(){
$(".mega-menu-row", $menu).each(function(){
$("> .mega-sub-menu > .mega-menu-column:not(.mega-hide-on-mobile)", $(this)).filter(":even").addClass("mega-menu-clear");
});
};
plugin.initDesktop=function(){
$menu.data("view", "desktop");
plugin.bindMegaMenuEvents();
plugin.initIndicators();
$menu.trigger("mmm:switchToDesktop");
};
plugin.initMobile=function(){
plugin.switchToMobile();
};
plugin.switchToDesktop=function(){
$menu.data("view", "desktop");
plugin.bindMegaMenuEvents();
plugin.reverseRightAlignedItems();
plugin.hideAllPanels();
plugin.hideMobileMenu(true);
$menu.removeAttr('role');
$menu.removeAttr('aria-modal');
$menu.removeAttr('aria-hidden');
$menu.trigger("mmm:switchToDesktop");
};
plugin.switchToMobile=function(){
$menu.data("view", "mobile");
if(plugin.isMobileOffCanvas()&&$toggle_bar.is(":visible")){
$menu.attr('role', 'dialog');
$menu.attr('aria-modal', 'true');
$menu.attr('aria-hidden', 'true');
}
plugin.bindMegaMenuEvents();
plugin.initIndicators();
plugin.reverseRightAlignedItems();
plugin.addClearClassesToMobileItems();
plugin.hideAllPanels();
plugin.expandMobileSubMenus();
$menu.trigger("mmm:switchToMobile");
};
plugin.initToggleBar=function(){
$toggle_bar.on("click", function(e){
const isToggleTrigger=$(e.target).closest(".mega-menu-toggle-block, button.mega-toggle-animated, .mega-menu-toggle-custom-block", this).length;
if(isToggleTrigger){
e.preventDefault();
if($(this).hasClass("mega-menu-open")){
plugin.hideMobileMenu();
}else{
plugin.showMobileMenu();
}}else if(e.target===this&&plugin.isMobileOffCanvas()){
plugin.hideMobileMenu();
}});
};
plugin.initIndicators=function(){
$menu.off('click.megamenu', '.mega-indicator');
$menu.on('click.megamenu', '.mega-indicator', function(e){
e.preventDefault();
e.stopPropagation();
if($(this).closest(".mega-menu-item").hasClass("mega-toggle-on")){
if(! $(this).closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed")||plugin.isMobileView()){
plugin.hidePanel($(this).parent(), false);
}}else{
plugin.showPanel($(this).parent(), false);
}});
};
plugin.hideMobileMenu=function(force=false){
if(! $toggle_bar.is(":visible")&&! force){
return;
}
$menu.attr("aria-hidden", "true");
clearTimeout(html_body_class_timeout);
html_body_class_timeout=setTimeout(function(){
$("body").removeClass(menuId + "-mobile-open");
$("html").removeClass(menuId + "-off-canvas-open");
}, plugin.settings.effect_speed_mobile);
if($wrap.hasClass("mega-keyboard-navigation")){
$(".mega-menu-toggle-block button, button.mega-toggle-animated", $toggle_bar).first().trigger('focus');
}
$(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "false");
if(plugin.settings.effect_mobile==="slide"&&! force){
$menu.animate({"height":"hide"}, plugin.settings.effect_speed_mobile, function(){
$menu.css({
width: "",
left: "",
display: ""
});
$toggle_bar.removeClass("mega-menu-open");
});
}else{
$menu.css({
width: "",
left: "",
display: ""
});
$toggle_bar.removeClass("mega-menu-open");
}
$menu.triggerHandler("mmm:hideMobileMenu");
};
plugin.showMobileMenu=function(){
if(! $toggle_bar.is(":visible")){
return;
}
clearTimeout(html_body_class_timeout);
$("body").addClass(menuId + "-mobile-open");
plugin.expandMobileSubMenus();
if(plugin.isMobileOffCanvas()){
$("html").addClass(menuId + "-off-canvas-open");
}
if(plugin.settings.effect_mobile==="slide"){
$menu.animate({"height":"show"}, plugin.settings.effect_speed_mobile, function(){
$(this).css("display", "");
});
}
$(".mega-toggle-label, .mega-toggle-animated", $toggle_bar).attr("aria-expanded", "true");
$toggle_bar.addClass("mega-menu-open");
plugin.toggleBarForceWidth();
$menu.attr("aria-hidden", "false");
$menu.triggerHandler("mmm:showMobileMenu");
};
plugin.toggleBarForceWidth=function(){
const $force_width_el=$(plugin.settings.mobile_force_width);
if($force_width_el.length&&(plugin.settings.effect_mobile==="slide"||plugin.settings.effect_mobile==="disabled") ){
const submenu_offset=$toggle_bar.offset();
const target_offset=$force_width_el.offset();
$menu.css({
width: $force_width_el.outerWidth(),
left: (target_offset.left - submenu_offset.left) + "px"
});
}};
plugin.doConsoleChecks=function(){
if(plugin.settings.mobile_force_width!=="false"&&! $(plugin.settings.mobile_force_width).length&&(plugin.settings.effect_mobile==="slide"||plugin.settings.effect_mobile==="disabled") ){
console.warn('Max Mega Menu #' + $wrap.attr('id') + ': Mobile Force Width element (' + plugin.settings.mobile_force_width + ') not found');
}
const cssWidthRegex=/^((\d+(\.\d+)?(px|%|em|rem|vw|vh|ch|ex|cm|mm|in|pt|pc))|auto)$/i;
const resolveWidthEl=(val)=> val==='$menu' ? $menu:val==='$wrap' ? $wrap:$(val);
if(plugin.settings.panel_width!==undefined&&! cssWidthRegex.test(plugin.settings.panel_width)&&! resolveWidthEl(plugin.settings.panel_width).length){
console.warn('Max Mega Menu #' + $wrap.attr('id') + ': Panel Width (Outer) element (' + plugin.settings.panel_width + ') not found');
}
if(plugin.settings.panel_inner_width!==undefined&&! cssWidthRegex.test(plugin.settings.panel_inner_width)&&! resolveWidthEl(plugin.settings.panel_inner_width).length){
console.warn('Max Mega Menu #' + $wrap.attr('id') + ': Panel Width (Inner) element (' + plugin.settings.panel_inner_width + ') not found');
}};
plugin.init=function(){
$menu.triggerHandler("before_mega_menu_init");
plugin.settings=$.extend({}, defaults, options);
if(window.console){
plugin.doConsoleChecks();
}
$menu.removeClass("mega-no-js");
plugin.initToggleBar();
if(plugin.settings.unbind_events==="true"){
plugin.unbindAllEvents();
}
if(document.readyState==='complete'){
plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
}else{
$(window).on("load", function(){
plugin.calculateDynamicSubmenuWidths($("> li.mega-menu-megamenu > a.mega-menu-link", $menu));
});
}
if(plugin.isDesktopView()){
plugin.initDesktop();
}else{
plugin.initMobile();
}
$(window).on("resize", function(){
plugin.checkWidth();
});
$menu.triggerHandler("after_mega_menu_init");
};
plugin.init();
};
$.fn.maxmegamenu=function(options){
return this.each(function(){
if(undefined===$(this).data("maxmegamenu")){
const plugin=new $.maxmegamenu(this, options);
$(this).data("maxmegamenu", plugin);
}});
};
$(function(){
$(".max-mega-menu").maxmegamenu();
});
}(jQuery));