(function($){
window.NggPaginatedGallery=function(displayed_gallery_id, container){
this.displayed_gallery_id=displayed_gallery_id;
this.container=$(container);
this.container_name=container;
this.get_displayed_gallery_obj=function(){
var index='gallery_' + this.displayed_gallery_id;
if(typeof(window.galleries[index])=='undefined'){
return false;
}else{
return window.galleries[index];
}};
this.enable_ajax_pagination=function(){
var self=this;
$('body').on('click', 'a.ngg-browser-prev, a.ngg-browser-next', function (event){
var skip=true;
$(this).parents(container).each(function(){
if($(this).data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
skip=false;
});
if(!skip){
event.preventDefault();
}else{
return;
}
window['ngg_ajax_operaton_count']++;
$('body, a').css('cursor', 'wait');
$.get({
url: $(this).attr('href'),
headers: { 'X-NGG-Pagination-Request': true },
success: function (response){
window['ngg_ajax_operaton_count']--;
if(window['ngg_ajax_operaton_count'] <=0){
window['ngg_ajax_operaton_count']=0;
$('body, a').css('cursor', 'auto');
}
if(response){
var html=$(response);
var replacement=false;
html.find(self.container_name).each(function(){
if(replacement){
return true;
}
if($(this).data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
replacement=$(this);
});
if(replacement){
self.container.each(function (){
var $this=$(this);
if($this.data('nextgen-gallery-id')!=self.displayed_gallery_id){
return true;
}
var $new_element=$(replacement.html());
var promises=$new_element.find('img').toArray().map(function(img){
return new Promise(function(resolve, reject){
var i=new Image();
i.src=img.src;
$(i).on('load', resolve);
});
});
Promise.all(promises).then(function(){
$this.html($new_element);
$(document).trigger('refreshed');
const event=new Event("nextgen_page_refreshed");
document.dispatchEvent(event);
});
return true;
});
}}
}});
});
};
var displayed_gallery=this.get_displayed_gallery_obj();
if(displayed_gallery){
if(typeof(displayed_gallery.display_settings['ajax_pagination'])!='undefined'){
if(parseInt(displayed_gallery.display_settings['ajax_pagination'])){
this.enable_ajax_pagination();
}}
}
if(typeof(window['ngg_ajax_operation_count'])=='undefined'){
window['ngg_ajax_operaton_count']=0;
}};
Object.setPrototypeOf=Object.setPrototypeOf||function(obj, proto){
obj.__proto__=proto;
return obj;
};
if(typeof window.galleries!=='undefined'){
Object.setPrototypeOf(window.galleries,
{
get_api_version: function(){
return '0.1';
},
get_from_id: function (gallery_id){
var self=this;
var retval=null;
var keys=Object.keys(this);
for (var i=1; i <=keys.length; i++){
var gallery=self[keys[i - 1]];
if(gallery.ID===gallery_id||gallery.ID==='gallery_' + gallery_id||gallery.ID===parseInt(gallery_id)){
retval=gallery;
break;
}}
return retval;
},
get_from_slug: function (slug){
var self=this;
var retval=null;
var keys=Object.keys(this);
for (var i=1; i <=keys.length; i++){
var gallery=self[keys[i - 1]];
if(gallery.slug===slug){
retval=gallery;
break;
}}
return retval;
},
get_setting: function(gallery_id, name, def){
var tmp='';
var gallery=this.get_from_id(gallery_id);
if(gallery&&typeof gallery[name]!=='undefined'){
tmp=gallery[name];
}else{
tmp=def;
}
if(tmp===1)       tmp=true;
if(tmp===0)       tmp=false;
if(tmp==='1')     tmp=true;
if(tmp==='0')     tmp=false;
if(tmp==='false') tmp=false;
if(tmp==='true')  tmp=true;
return tmp;
},
get_display_setting: function(gallery_id, name, def){
var tmp='';
var gallery=this.get_from_id(gallery_id);
if(gallery&&typeof gallery.display_settings[name]!=='undefined'){
tmp=gallery.display_settings[name];
}else{
tmp=def;
}
if(tmp===1)       tmp=true;
if(tmp===0)       tmp=false;
if(tmp==='1')     tmp=true;
if(tmp==='0')     tmp=false;
if(tmp==='false') tmp=false;
if(tmp==='true')  tmp=true;
return tmp;
},
is_widget: function(gallery_id){
var retval=false;
var gallery=this.get_from_id(gallery_id);
var slug=gallery.slug;
if(slug){
return slug.indexOf('widget-ngg-images')!==-1;
}
return retval;
}}
); }})(jQuery);
function nextgen_lightbox_filter_selector($, selector){
if(nextgen_lightbox_settings&&nextgen_lightbox_settings.context){
var context=nextgen_lightbox_settings.context;
if(context=='all_images'){
selector=selector.add($('a > img').parent());
}
else if(context=='all_images_direct'){
selector=selector.add($('a[href] > img').parent()
.filter(function(){
var href=$(this).attr('href').toLowerCase();
var ext=href.substring(href.length - 3);
var ext2=href.substring(href.length - 4);
return (ext=='jpg'||ext=='gif'||ext=='png'||ext2=='tiff'||ext2=='jpeg'||ext2=='webp');
}));
}
else if(context=='nextgen_and_wp_images'){
selector=selector.add($('a > img[class*="wp-image-"]').parent());
}
selector=selector.not('.gallery_link');
selector=selector.not('.use_imagebrowser_effect');
}
return selector;
};
(function($){
"use strict";
window.NextGEN_TikTok={
extract_id: function(url){
if(!url) return null;
url=url.trim();
var patterns=[
/tiktok\.com\/@[^\/]+\/video\/(\d+)/i,
/tiktok\.com\/v\/(\d+)/i,
/tiktok\.com\/embed\/v2\/(\d+)/i,
/tiktok\.com\/.*[?&]v=(\d+)/i,
/\/video\/(\d+)/i,
/^(\d{15,25})$/,
];
for (var i=0; i < patterns.length; i++){
var match=url.match(patterns[i]);
if(match&&match[1]){
return match[1];
}}
if(url.match(/vm\.tiktok\.com|tiktok\.com\/t\//i)){
var idMatch=url.match(/(\d{15,25})/);
if(idMatch){
return idMatch[1];
}
return null;
}
return null;
},
create_player: function(videoUrl, containerClass, videoClass){
var container=document.createElement("div");
container.className=containerClass||"ngg-tiktok-container";
var video=document.createElement("video");
video.className=videoClass||"ngg-tiktok-video";
video.controls=true;
video.autoplay=true;
video.playsInline=true;
video.muted=true;
video.loop=true;
video.preload="auto";
video.setAttribute("playsinline", "");
video.setAttribute("webkit-playsinline", "");
video.src=videoUrl;
video.addEventListener("loadedmetadata", function (){
var naturalWidth=video.videoWidth;
var naturalHeight=video.videoHeight;
if(naturalWidth&&naturalHeight){
var container=video.closest('.ngg-tiktok-container');
var displayWidth=naturalWidth;
var displayHeight=naturalHeight;
if(container){
var fancyboxContent=container.closest('#fancybox-content');
var tbWindow=container.closest('#TB_window');
var slImage=container.closest('.sl-image');
var shWrap=container.closest('#shWrap');
if(shWrap){
var wiH=window.innerHeight||0;
var dbH=document.body.clientHeight||0;
var deH=document.documentElement ? document.documentElement.clientHeight:0;
var wHeight;
if(wiH > 0){
wHeight=((wiH - dbH) > 1&&(wiH - dbH) < 30) ? dbH:wiH;
wHeight=((wHeight - deH) > 1&&(wHeight - deH) < 30) ? deH:wHeight;
}else{
wHeight=(deH > 0) ? deH:dbH;
}
if(document.getElementsByTagName("body")[0].className.match(/admin-bar/)
&& document.getElementById('wpadminbar')!==null){
wHeight=wHeight - document.getElementById('wpadminbar').offsetHeight;
}
var shHeight=wHeight - 50;
var deW=document.documentElement ? document.documentElement.clientWidth:0;
var dbW=window.innerWidth||document.body.clientWidth;
var wWidth=(deW > 1) ? deW:dbW;
if(displayHeight > shHeight){
displayWidth=displayWidth * (shHeight / displayHeight);
displayHeight=shHeight;
}
if(displayWidth > (wWidth - 16)){
displayHeight=displayHeight * ((wWidth - 16) / displayWidth);
displayWidth=wWidth - 16;
}
video.style.width=displayWidth + "px";
video.style.height=displayHeight + "px";
video.style.maxWidth="none";
video.style.maxHeight="none";
video.setAttribute("width", displayWidth);
video.setAttribute("height", displayHeight);
}else if(fancyboxContent){
setTimeout(function(){
var contentRect=fancyboxContent.getBoundingClientRect();
if(contentRect.width > 10&&contentRect.height > 10){
var maxW=contentRect.width;
var maxH=contentRect.height;
if(displayWidth > maxW||displayHeight > maxH){
var ratio=displayWidth / displayHeight > maxW / maxH
? displayWidth / maxW
: displayHeight / maxH;
displayWidth=displayWidth / ratio;
displayHeight=displayHeight / ratio;
}
video.style.width=displayWidth + "px";
video.style.height=displayHeight + "px";
video.setAttribute("width", displayWidth);
video.setAttribute("height", displayHeight);
}}, 50);
return;
}else if(tbWindow){
var pageWidth=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;
var pageHeight=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;
var x=pageWidth - 150;
var y=pageHeight - 150;
if(displayWidth > x){
displayHeight=displayHeight * (x / displayWidth);
displayWidth=x;
if(displayHeight > y){
displayWidth=displayWidth * (y / displayHeight);
displayHeight=y;
}}else if(displayHeight > y){
displayWidth=displayWidth * (y / displayHeight);
displayHeight=y;
if(displayWidth > x){
displayHeight=displayHeight * (x / displayWidth);
displayWidth=x;
}}
video.style.width=displayWidth + "px";
video.style.height=displayHeight + "px";
video.setAttribute("width", displayWidth);
video.setAttribute("height", displayHeight);
}else if(slImage){
var widthRatio=0.8;
var heightRatio=0.9;
var windowWidth=window.innerWidth;
var windowHeight=window.innerHeight;
var maxWidth=windowWidth * widthRatio;
var maxHeight=windowHeight * heightRatio;
if(displayWidth > maxWidth||displayHeight > maxHeight){
var ratio=displayWidth / displayHeight > maxWidth / maxHeight
? displayWidth / maxWidth
: displayHeight / maxHeight;
displayWidth /=ratio;
displayHeight /=ratio;
}
video.style.width=displayWidth + "px";
video.style.height=displayHeight + "px";
video.style.maxWidth=maxWidth + "px";
video.style.maxHeight=maxHeight + "px";
}}
}});
video.addEventListener("canplay", function (){
video.play().catch(function (){});
});
container.appendChild(video);
return container;
},
handle_content: function(options){
var self=this;
var playUrl=options.playUrl;
var $targetContainer=$(options.container);
if(!playUrl) return null;
var tiktokContent=null;
var applyDimensions=function (el){
if(options.width){
var w=typeof options.width==="number" ? options.width + "px":options.width;
el.style.width=w;
var inner=el.querySelector("video, iframe, .ngg-tiktok-error-content");
if(inner) inner.style.width="100%";
}
if(options.height){
var h=typeof options.height==="number" ? options.height + "px":options.height;
el.style.height=h;
var inner=el.querySelector("video, iframe, .ngg-tiktok-error-content");
if(inner) inner.style.height="100%";
}};
if(playUrl){
var decodedUrl=playUrl;
try {
decodedUrl=decodeURIComponent(playUrl);
} catch (e){}
tiktokContent=self.create_player(decodedUrl, options.containerClass, options.videoClass);
if(tiktokContent){
applyDimensions(tiktokContent);
var video=tiktokContent.querySelector("video");
if(video){
video.onerror=function (){
$(tiktokContent).remove();
var errorMsg=self.create_error("Video failed to load", options.errorClass);
applyDimensions(errorMsg);
if(typeof options.onBeforeAppend==="function") options.onBeforeAppend(errorMsg);
$targetContainer.append(errorMsg);
};}
if(typeof options.onBeforeAppend==="function") options.onBeforeAppend(tiktokContent);
$targetContainer.append(tiktokContent);
}}else{
var errorMsg=self.create_error("Video not available", options.errorClass);
applyDimensions(errorMsg);
if(typeof options.onBeforeAppend==="function") options.onBeforeAppend(errorMsg);
$targetContainer.append(errorMsg);
tiktokContent=errorMsg;
}
return tiktokContent;
},
create_error: function(message, containerClass){
var container=document.createElement("div");
container.className=containerClass||"ngg-tiktok-error";
container.innerHTML =
'<div class="ngg-tiktok-error-content">' +
'<span class="ngg-tiktok-error-icon">&#9888;</span>' +
'<span class="ngg-tiktok-error-text">' +
(message||"Video failed to load") +
"</span>" +
"</div>";
return container;
}};})(jQuery);
(function($){
"use strict";
var DEBUG=false;
var initialized=false;
var log=function(){
if(DEBUG&&window.console){
console.log.apply(console, ['[NGG Custom Lightbox TikTok]'].concat(Array.prototype.slice.call(arguments)));
}};
var getTikTokData=function($anchor){
var playUrl=$anchor.attr('data-tiktok-play-url');
var shareUrl=$anchor.attr('data-tiktok-share-url');
var embedUrl=$anchor.attr('data-tiktok-embed-url');
if(playUrl||shareUrl||embedUrl){
return {
playUrl: playUrl||'',
shareUrl: shareUrl||'',
embedUrl: embedUrl||''
};}
var imageId=$anchor.attr('data-image-id');
if(imageId&&window.ngg_tiktok_images&&window.ngg_tiktok_images[imageId]){
return window.ngg_tiktok_images[imageId];
}
return null;
};
var getVideoUrl=function($anchor){
return $anchor.attr('data-video-url')||null;
};
var getGalleryId=function($element){
var $galleryContainer=$element.closest('[data-gallery-id]');
if($galleryContainer.length){
return $galleryContainer.attr('data-gallery-id')||$galleryContainer.data('gallery-id');
}
$galleryContainer=$element.closest('.ngg-galleryoverview, .ngg-imagebrowser, .ngg-slideshow');
if($galleryContainer.length){
return $galleryContainer.attr('data-gallery-id') ||
$galleryContainer.data('gallery-id') ||
$galleryContainer.attr('data-nextgen-gallery-id') ||
$galleryContainer.data('nextgen-gallery-id');
}
return null;
};
var getTikTokSettings=function(galleryId){
if(window.NggTikTokVideo&&typeof window.NggTikTokVideo.getTikTokSettings==='function'){
return window.NggTikTokVideo.getTikTokSettings(galleryId);
}
if(window.ngg_tiktok_gallery_settings){
if(galleryId&&window.ngg_tiktok_gallery_settings['gallery_' + galleryId]){
return window.ngg_tiktok_gallery_settings['gallery_' + galleryId];
}
if(window.ngg_tiktok_gallery_settings.global){
return window.ngg_tiktok_gallery_settings.global;
}}
return { link: '0', link_target: '0' };};
var getVideoSettings=function(galleryId){
if(!window.ngg_video_gallery_settings){
return {
show_video_controls: true,
show_play_pause_controls: true,
autoplay_videos: false
};}
var settings=window.ngg_video_gallery_settings;
var galleryIdStr=galleryId ? String(galleryId):null;
if(galleryIdStr&&settings['gallery_' + galleryIdStr]){
return settings['gallery_' + galleryIdStr];
}
return settings.global||{
show_video_controls: true,
show_play_pause_controls: true,
autoplay_videos: false
};};
var showOverlay=function(contentElement){
$('#ngg-custom-lightbox-overlay').remove();
var $overlay=$('<div id="ngg-custom-lightbox-overlay"></div>').css({
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
backgroundColor: 'transparent',
zIndex: 999999,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
cursor: 'pointer'
});
var $closeBtn=$('<button type="button" class="ngg-custom-lightbox-close">&times;</button>').css({
position: 'absolute',
top: '20px',
right: '20px',
background: 'transparent',
border: 'none',
color: '#fff',
fontSize: '40px',
cursor: 'pointer',
zIndex: 1000000,
padding: '10px',
lineHeight: 1
});
var $content=$('<div class="ngg-custom-lightbox-content"></div>').css({
position: 'relative',
maxWidth: '90vw',
maxHeight: '90vh',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
});
$content.append(contentElement);
$overlay.append($closeBtn).append($content);
var closeOverlay=function(){
var $video=$overlay.find('video');
if($video.length){
$video[0].pause();
$video.attr('src', '');
}
var $iframe=$overlay.find('iframe');
if($iframe.length){
$iframe.attr('src', '');
}
$overlay.remove();
};
$closeBtn.on('click', function(e){
e.stopPropagation();
closeOverlay();
});
$overlay.on('click', function(e){
if(e.target===this){
closeOverlay();
}});
$(document).on('keydown.nggCustomLightbox', function(e){
if(e.keyCode===27){
closeOverlay();
$(document).off('keydown.nggCustomLightbox');
}});
$('body').append($overlay);
return $overlay;
};
var handleTikTokClick=function($anchor, tiktokData){
log('Handling TikTok click', tiktokData);
if(!tiktokData.playUrl&&!tiktokData.shareUrl){
return false;
}
var $container=$('<div class="ngg-tiktok-container"></div>').css({
position: 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
});
if(window.NextGEN_TikTok&&window.NextGEN_TikTok.handle_content){
window.NextGEN_TikTok.handle_content({
playUrl: tiktokData.playUrl,
shareUrl: tiktokData.shareUrl,
container: $container
});
showOverlay($container);
return true;
}
if(tiktokData.playUrl){
var $video=$('<video></video>').attr({
src: tiktokData.playUrl,
controls: true,
autoplay: true,
playsinline: true,
muted: true,
loop: true
}).css({
maxWidth: '90vw',
maxHeight: '90vh',
width: 'auto',
height: 'auto'
});
$container.append($video);
showOverlay($container);
$video.on('click', function(){
this.muted=false;
});
return true;
}
return false;
};
var handleVideoClick=function($anchor, videoUrl, galleryId){
log('Handling video click', videoUrl);
if(!videoUrl){
return false;
}
if(!window.NextGEN_Video||!window.NextGEN_Video.detect_platform(videoUrl)){
return false;
}
var videoSettings=getVideoSettings(galleryId);
var $container=$('<div class="ngg-video-container"></div>').css({
position: 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
});
if(window.NextGEN_Video.handle_content){
window.NextGEN_Video.handle_content({
videoUrl: videoUrl,
container: $container[0],
settings: videoSettings,
containerClass: 'ngg-video-container',
videoClass: 'ngg-video-player',
errorClass: 'ngg-video-error'
});
showOverlay($container);
return true;
}
return false;
};
var handleClick=function(e){
var $target=$(e.target);
var $anchor=$target.is('a') ? $target:$target.closest('a');
if(!$anchor.length){
return;
}
if(!$anchor.attr('data-image-id')){
return;
}
var tiktokData=getTikTokData($anchor);
var videoUrl=getVideoUrl($anchor);
var galleryId=getGalleryId($anchor);
if(tiktokData&&(tiktokData.playUrl||tiktokData.shareUrl)){
var tiktokSettings=getTikTokSettings(galleryId);
var linkSetting=String(tiktokSettings.link||'0');
if(linkSetting==='1'||linkSetting==='2'){
return;
}
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
handleTikTokClick($anchor, tiktokData);
return;
}
if(videoUrl&&window.NextGEN_Video&&window.NextGEN_Video.detect_platform(videoUrl)){
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
handleVideoClick($anchor, videoUrl, galleryId);
return;
}};
var init=function(){
if(initialized){
return;
}
initialized=true;
log('Initializing custom lightbox TikTok/video handler');
document.addEventListener('click', handleClick, true);
};
$(function(){
init();
});
$(window).on('refreshed', function(){
log('Refreshed event - reinitializing');
});
window.NggCustomLightboxTikTok={
showOverlay: showOverlay,
handleTikTokClick: handleTikTokClick,
handleVideoClick: handleVideoClick
};})(jQuery);
(function (){
var container, button, menu, links, i, len;
container=document.getElementById('site-navigation');
if(! container){
return;
}
button=container.getElementsByClassName('menu-toggle')[0];
if('undefined'===typeof button){
return;
}
menu=container.getElementsByTagName('ul')[0];
if('undefined'===typeof menu){
button.style.display='none';
return;
}
if(- 1===menu.className.indexOf('nav-menu') ){
menu.className +=' nav-menu';
}
button.onclick=function (){
if(- 1!==container.className.indexOf('main-small-navigation') ){
container.className=container.className.replace('main-small-navigation', 'main-navigation');
}else{
container.className=container.className.replace('main-navigation', 'main-small-navigation');
}};
links=menu.getElementsByTagName('a');
for(i=0, len=links.length; i < len; i++){
links[i].addEventListener('focus', toggleFocus, true);
links[i].addEventListener('blur', toggleFocus, true);
}
function toggleFocus(){
var self=this;
while(-1===self.className.indexOf('nav-menu') ){
if('li'===self.tagName.toLowerCase()){
if(-1!==self.className.indexOf('focus') ){
self.className=self.className.replace(' focus', '');
}else{
self.className +=' focus';
}}
self=self.parentElement;
}}
})();
(function (){
var container;
container=document.getElementById('site-navigation');
(function(container){
var touchStartFn, i,
parentLink=container.querySelectorAll('.menu-item-has-children > a, .page_item_has_children > a');
if(( 'ontouchstart' in window)&&(window.matchMedia("(min-width: 768px) ").matches) ){
touchStartFn=function(e){
var menuItem=this.parentNode, i;
if(! menuItem.classList.contains('focus') ){
e.preventDefault();
for(i=0; i < menuItem.parentNode.children.length; ++ i){
if(menuItem===menuItem.parentNode.children[i]){
continue;
}
menuItem.parentNode.children[i].classList.remove('focus');
}
menuItem.classList.add('focus');
}else{
menuItem.classList.remove('focus');
}};
for(i=0; i < parentLink.length; ++ i){
parentLink[i].addEventListener('touchstart', touchStartFn, false);
}}
}(container) );
})();
(function (){
var subMenu;
jQuery('.main-navigation ul li.menu-item-has-children a, .main-navigation ul li.page_item_has_children a').on({
'mouseover touchstart':function (){
function isElementInViewport(subMenu){
if('function'===typeof jQuery&&subMenu instanceof jQuery){
subMenu=subMenu[0];
}
if('function'===typeof subMenu.getBoundingClientRect){
var rect=subMenu.getBoundingClientRect();
if(rect.right + 2 >(window.innerWidth||document.documentElement.clientWidth) ){
return 'spacious-menu--left';
}else if(rect.left < 0){
return 'spacious-menu--right';
}else{
return false;
}}
}
subMenu=jQuery(this).next('.sub-menu, .children');
if(subMenu.length > 0){
var viewportClass=isElementInViewport(subMenu);
if(false!==viewportClass){
subMenu.addClass(viewportClass);
}}
}});
})();
(
function (){
jQuery(document).ready(function (){
var mainWrapper=document.querySelector('#header-text-nav-container .inner-wrap'),
branding=document.getElementById('header-left-section'),
headerAction=document.querySelector('.header-action'),
navigation=document.getElementById('site-navigation'),
mainWidth=mainWrapper ? mainWrapper.offsetWidth:0,
brandWidth=branding ? branding.offsetWidth:0,
navWidth=navigation ? navigation.offsetWidth:0,
headerActionWidth=headerAction ? headerAction.offsetWidth: 0,
isExtra=(brandWidth + navWidth + headerActionWidth) > mainWidth,
more=navigation ? navigation.getElementsByClassName('tg-menu-extras-wrap')[0]:'',
headerDisplayTypeFour=document.getElementsByClassName('spacious-header-display-four')[0];
if(headerDisplayTypeFour){
isExtra=(navWidth + headerActionWidth) >=mainWidth;
}
if(! navigation.classList.contains('tg-extra-menus') ){
return;
}
function Dimension(el){
var elWidth;
if(document.all){
elWidth=el.currentStyle.width + parseInt(el.currentStyle.marginLeft, 10) + parseInt(el.currentStyle.marginRight, 10) + parseInt(el.currentStyle.paddingLeft, 10) + parseInt(el.currentStyle.paddingRight, 10);
}else{
elWidth=parseInt(document.defaultView.getComputedStyle(el, '').getPropertyValue('width') ) + parseInt(document.defaultView.getComputedStyle(el, '').getPropertyValue('margin-left') ) + parseInt(document.defaultView.getComputedStyle(el, '').getPropertyValue('margin-right') );
}
return elWidth;
}
if(! isExtra){
more.parentNode.removeChild(more);
}else{
var widthToBe, buttons, buttonWidth, moreWidth;
widthToBe=mainWidth - headerActionWidth;
if(! headerDisplayTypeFour){
widthToBe=widthToBe - brandWidth;
}
buttons=navigation.getElementsByClassName('tg-header-button-wrap')[0];
buttonWidth=buttons ? Dimension(buttons):0;
moreWidth=more ? Dimension(more):0;
newNavWidth=widthToBe -(buttonWidth + moreWidth);
navigation.style.visibility='none';
navigation.style.width=newNavWidth + 'px';
function getChildNodes(node){
var children=[];
for(var child in node.childNodes){
if(typeof node!=='undefined'){
if(1===node.childNodes[child].nodeType){
children.push(node.childNodes[child]);
}}
}
return children;
}
var navUl=navigation.getElementsByClassName('nav-menu')[0],
navLi=getChildNodes(navUl);
function offset(el){
var rect=el.getBoundingClientRect(),
scrollLeft=window.pageXOffset||document.documentElement.scrollLeft,
scrollTop=window.pageYOffset||document.documentElement.scrollTop;
return { top:rect.top + scrollTop, left:rect.left + scrollLeft }}
var extraLi=[];
for(var liCount=0; liCount < navLi.length; liCount ++){
var initialPos, li, posTop;
li=navLi[liCount];
posTop=offset(li).top;
if(0===liCount){
initialPos=posTop;
}
if(posTop > initialPos){
if(! li.classList.contains('header-action')&&! li.classList.contains('tg-menu-extras-wrap')&&! li.classList.contains('tg-header-button-wrap') ){
extraLi.push(li);
}}
}
var newNavWidth=newNavWidth +(buttonWidth + moreWidth),
extraWrap=document.getElementById('tg-menu-extras');
if(! headerDisplayTypeFour){
newNavWidth=newNavWidth - 30;
}
navigation.style.width=newNavWidth + 'px';
if(null!==extraWrap){
extraLi.forEach(function(item, index, arr){
extraWrap.appendChild(item);
});
}}
});
}()
);
(function(){
var isIe=/(trident|msie)/i.test(navigator.userAgent);
if(isIe&&document.getElementById&&window.addEventListener){
window.addEventListener('hashchange', function(){
var id=location.hash.substring(1),
element;
if(!(/^[A-z0-9_-]+$/.test(id) )){
return;
}
element=document.getElementById(id);
if(element){
if(!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName) )){
element.tabIndex=-1;
}
element.focus();
}}, false);
}})();
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):jQuery&&!jQuery.fn.hoverIntent&&e(jQuery)}(function(f){"use strict";function u(e){return"function"==typeof e}var i,r,v={interval:100,sensitivity:6,timeout:0},s=0,a=function(e){i=e.pageX,r=e.pageY},p=function(e,t,n,o){if(Math.sqrt((n.pX-i)*(n.pX-i)+(n.pY-r)*(n.pY-r))<o.sensitivity)return t.off(n.event,a),delete n.timeoutId,n.isActive=!0,e.pageX=i,e.pageY=r,delete n.pX,delete n.pY,o.over.apply(t[0],[e]);n.pX=i,n.pY=r,n.timeoutId=setTimeout(function(){p(e,t,n,o)},o.interval)};f.fn.hoverIntent=function(e,t,n){function o(e){var u=f.extend({},e),r=f(this),v=((t=r.data("hoverIntent"))||r.data("hoverIntent",t={}),t[i]),t=(v||(t[i]=v={id:i}),v.timeoutId&&(v.timeoutId=clearTimeout(v.timeoutId)),v.event="mousemove.hoverIntent.hoverIntent"+i);"mouseenter"===e.type?v.isActive||(v.pX=u.pageX,v.pY=u.pageY,r.off(t,a).on(t,a),v.timeoutId=setTimeout(function(){p(u,r,v,d)},d.interval)):v.isActive&&(r.off(t,a),v.timeoutId=setTimeout(function(){var e,t,n,o,i;e=u,t=r,n=v,o=d.out,(i=t.data("hoverIntent"))&&delete i[n.id],o.apply(t[0],[e])},d.timeout))}var i=s++,d=f.extend({},v);f.isPlainObject(e)?(d=f.extend(d,e),u(d.out)||(d.out=d.over)):d=u(t)?f.extend(d,{over:e,out:t,selector:n}):f.extend(d,{over:e,out:e,selector:t});return this.on({"mouseenter.hoverIntent":o,"mouseleave.hoverIntent":o},d.selector)}});
(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.children("li.mega-menu-item:visible").find("> a.mega-menu-link, > .mega-search span[role=button]");
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=plugin.getFocusableItemsInSubmenu($submenu, false).first();
if($firstFocusable.length){
$firstFocusable.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);
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);
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;
});
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 isMobileOffCanvasHorizontal=function(){
return plugin.isHorizontalMobileSubmenuMode();
};
const getActiveHorizontalSubmenuBackLink=function(){
const $activeSubmenu=$("li.mega-toggle-on > ul.mega-sub-menu", $menu).last();
return $activeSubmenu.find("> li.mega-mobile-back:visible > a.mega-menu-link.mega-mobile-back-link").first();
};
const shouldTrapFocusInCurrentSubMenu=function(key){
return isMobileOffCanvasHorizontal()&&(key===up_arrow_key||key===down_arrow_key);
};
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_item=$menu[0].contains(document.activeElement) ? $(document.activeElement):$();
const nearest_parent_of_focused_item_li=focused_menu_item.closest(".mega-toggle-on");
const nearest_parent_of_focused_item_a=$("> a.mega-menu-link", nearest_parent_of_focused_item_li);
if(nearest_parent_of_focused_item_a.length){
plugin.hidePanel(nearest_parent_of_focused_item_a);
nearest_parent_of_focused_item_a.trigger("focus");
return true;
}
return false;
};
$lastFocusable.on('keydown.megamenu', function(e){
const key=e.key;
if(plugin.isMobileView()&&plugin.isMobileOffCanvas()&&key===tab_key&&! e.shiftKey){
e.preventDefault();
if(isMobileOffCanvasHorizontal()){
const $backLink=getActiveHorizontalSubmenuBackLink();
if($backLink.length){
$backLink.trigger('focus');
return;
}}
$firstFocusable.trigger('focus');
}
if(plugin.isMobileView()&&plugin.isMobileOffCanvas()&&key===tab_key&&e.shiftKey&&isMobileOffCanvasHorizontal()){
const $activeSubmenu=$("li.mega-toggle-on > ul.mega-sub-menu", $menu).last();
const $focusableWithoutBack=plugin.getFocusableItemsInSubmenu($activeSubmenu, false);
const $lastFocusableInSubmenu=$focusableWithoutBack.last();
if($lastFocusableInSubmenu.length){
e.preventDefault();
$lastFocusableInSubmenu.trigger('focus');
}}
});
$firstFocusable.on('keydown.megamenu', function(e){
const key=e.key;
if(plugin.isMobileView()&&plugin.isMobileOffCanvas()&&key===tab_key&&e.shiftKey){
e.preventDefault();
$lastFocusable.trigger('focus');
}});
$wrap.on("keyup.megamenu", ".max-mega-menu, .mega-menu-toggle", function(e){
const key=e.key;
const active_link=$(e.target);
if(key===tab_key){
$wrap.addClass("mega-keyboard-navigation");
plugin.bindClickEvents();
if(plugin.isDesktopView()&&active_link.is(".mega-menu-link")&&active_link.parent().parent().hasClass('max-mega-menu')){
plugin.hideAllPanels();
}}
});
$wrap.on("keydown.megamenu", "a.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_link=$(e.target);
if(isMobileOffCanvasHorizontal()&&key===tab_key&&!e.shiftKey){
const $submenu=active_link.closest("ul.mega-sub-menu");
if($submenu.length!==0){
const $focusableWithoutBack=plugin.getFocusableItemsInSubmenu($submenu, false);
if($focusableWithoutBack.length!==0&&active_link.is($focusableWithoutBack.last())){
e.preventDefault();
$lastFocusable.trigger("focus");
return;
}}
}
if(isMobileOffCanvasHorizontal()&&key===tab_key&&e.shiftKey){
const $submenu=active_link.closest("ul.mega-sub-menu");
if($submenu.length!==0&&active_link.hasClass("mega-mobile-back-link")){
e.preventDefault();
$lastFocusable.trigger("focus");
return;
}
if($submenu.length!==0){
const $focusableWithoutBack=plugin.getFocusableItemsInSubmenu($submenu, false);
const $firstFocusableInSubmenu=$focusableWithoutBack.first();
const $backLink=$submenu.find("> li.mega-mobile-back:visible > a.mega-menu-link.mega-mobile-back-link").first();
if($firstFocusableInSubmenu.length!==0&&$backLink.length!==0&&active_link.is($firstFocusableInSubmenu)){
e.preventDefault();
$backLink.trigger("focus");
return;
}}
}
if(key===space_key&&active_link.is(".mega-menu-link")){
e.preventDefault();
if(active_link.parent().is(items_with_submenus)){
togglePanelForAnchor(active_link);
}}
if(key===space_key&&active_link.is(".mega-indicator")){
e.preventDefault();
togglePanelForAnchor(active_link.parent());
}
if(key===escape_key){
const submenu_open=$(".mega-toggle-on", $menu).length!==0;
if(submenu_open&&closeNearestOpenPanelAndRefocus()){
return;
}
if(plugin.isMobileView()&&! submenu_open){
plugin.hideMobileMenu();
}}
if(key===space_key||key===enter_key){
if(active_link.is(".mega-menu-toggle-block button, .mega-menu-toggle-animated-block button")){
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);
}}
}
if(key===enter_key){
if(active_link.is(".mega-indicator")){
togglePanelForAnchor(active_link.parent());
return;
}
if(active_link.parent().is(items_with_submenus)){
if(plugin.isMobileView()&&active_link.parent().is(".mega-hide-sub-menu-on-mobile")){
return;
}
if(active_link.is("[href]")===false){
togglePanelForAnchor(active_link);
return;
}
if(active_link.parent().hasClass("mega-toggle-on")&&! active_link.closest("ul.mega-sub-menu").parent().hasClass("mega-menu-tabbed")){
return;
}else{
e.preventDefault();
plugin.showPanel(active_link);
}}
}
if(shouldTrapFocusInCurrentSubMenu(key)){
const focused_item=$menu[0].contains(document.activeElement) ? $(document.activeElement):$();
if(focused_item.length===0){
e.preventDefault();
$("> li.mega-menu-item:visible", $menu).find("> a.mega-menu-link, .mega-search span[role=button]").first().trigger('focus');
return;
}
let next_item_to_focus=focused_item.parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
if(next_item_to_focus.length===0&&focused_item.closest(".mega-menu-megamenu").length!==0){
const all_li_parents=focused_item.parentsUntil(".mega-menu-megamenu");
if(focused_item.is(all_li_parents.find("a.mega-menu-link").last())){
next_item_to_focus=all_li_parents.find(".mega-back-button:visible > a.mega-menu-link").first();
}}
if(next_item_to_focus.length===0){
next_item_to_focus=focused_item.parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
}
if(next_item_to_focus.length!==0){
e.preventDefault();
next_item_to_focus.trigger('focus');
}}
if(plugin.shouldGoToNextTopLevelItem(key)){
e.preventDefault();
const $focused_next=$(document.activeElement);
let next_top_level_item=$("> .mega-toggle-on", $menu).nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
if(next_top_level_item.length===0){
next_top_level_item=$focused_next.parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
}
if(next_top_level_item.length===0){
next_top_level_item=$focused_next.parent().parent().parent().nextAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").first();
}
plugin.hideAllPanels();
next_top_level_item.trigger('focus');
}
if(plugin.shouldGoToPreviousTopLevelItem(key)){
e.preventDefault();
const $focused_prev=$(document.activeElement);
let prev_top_level_item=$("> .mega-toggle-on", $menu).prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
if(prev_top_level_item.length===0){
prev_top_level_item=$focused_prev.parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
}
if(prev_top_level_item.length===0){
prev_top_level_item=$focused_prev.parent().parent().parent().prevAll("li.mega-menu-item:visible").find("> a.mega-menu-link, .mega-search span[role=button]").last();
}
plugin.hideAllPanels();
prev_top_level_item.trigger('focus');
}});
$wrap.on("focusout.megamenu", function(e){
if($wrap.hasClass("mega-keyboard-navigation")){
setTimeout(function(){
const menu_has_focus=$wrap[0].contains(document.activeElement);
if(! menu_has_focus){
$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();
};
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');
};
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();
};
plugin.initToggleBar=function(){
$toggle_bar.on("click", function(e){
if($(e.target).is(".mega-menu-toggle, .mega-menu-toggle-custom-block *, .mega-menu-toggle-block, .mega-menu-toggle-animated-block, .mega-menu-toggle-animated-block *, .mega-toggle-blocks-left, .mega-toggle-blocks-center, .mega-toggle-blocks-right, .mega-toggle-label, .mega-toggle-label span")){
e.preventDefault();
if($(this).hasClass("mega-menu-open")){
plugin.hideMobileMenu();
}else{
plugin.showMobileMenu();
}}
});
};
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;
if(plugin.settings.panel_width!==undefined&&! cssWidthRegex.test(plugin.settings.panel_width)&&! $(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)&&! $(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));
(function($){
"use strict";
$(function(){
$('body').on('edd_cart_item_added', function(event, data){
$('.mega-menu-edd-cart-total').html(data.total);
$('.mega-menu-edd-cart-count').html(data.cart_quantity);
});
});
$(".max-mega-menu").on("after_mega_menu_init", function(){
$('li.mega-menu-megamenu').on('open_panel', function(){
var placeholder=$(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder");
var default_src=placeholder.attr('data-default-src');
var default_alt=placeholder.attr('data-default-alt');
placeholder.attr('src', default_src);
placeholder.attr('alt', default_alt);
$('.mega-sub-menu [data-image-swap-url]', $(this)).not(['data-preloaded']).each(function(){
$('<img/>')[0].src=$(this).attr('data-image-swap-url');
$(this).attr('data-preloaded', 'true');
});
});
if(typeof $.fn.hoverIntent!=="function"){
return;
}
$('.mega-sub-menu [data-image-swap-url]').hoverIntent({
over: function (){
var placeholder=$(this).closest(".mega-menu-megamenu").find(".widget_maxmegamenu_image_swap img.mega-placeholder");
var new_src=$(this).attr('data-image-swap-url');
var new_alt=$(this).is("[data-image-swap-alt]") ? $(this).attr('data-image-swap-alt'):"";
placeholder.attr('src', new_src);
placeholder.attr('alt', new_alt);
},
out: function(){}});
});
})(jQuery);
(function($){
"use strict";
var menuSupportsSideToSide=function($menu){
return $menu.attr("data-mobile-direction")==="horizontal" &&
$menu.attr("data-effect-mobile").indexOf("slide_")===0;
};
var getMenuItemTitle=function($item){
var $link=$item.children("a.mega-menu-link").first();
var clone=$link.clone();
clone.find(".mega-indicator").remove();
return $.trim(clone.text());
};
var getBackLabel=function($menu, parentTitle){
var template=$menu.attr("data-mobile-back-text")||"Back to {parent_title}";
var safeParentTitle=parentTitle||"";
if(template.indexOf("{parent_title}")!==-1){
return template.split("{parent_title}").join(safeParentTitle);
}
return template;
};
var addBackLinks=function($menu){
$("li.mega-menu-item-has-children > ul.mega-sub-menu", $menu).each(function(){
if($("> li.mega-mobile-back", this).length){
return;
}
var $submenu=$(this);
var $item=$submenu.parent("li.mega-menu-item-has-children");
var title=getMenuItemTitle($item);
var backLabel=getBackLabel($menu, title);
var backHtml="<li class='mega-menu-item mega-mobile-back'><a href='#' class='mega-menu-link mega-mobile-back-link'>" + backLabel + "</a></li>";
$submenu.prepend(backHtml);
});
};
$(".max-mega-menu").on("after_mega_menu_init", function(){
var $menu=$(this);
if(!menuSupportsSideToSide($menu)){
return;
}
addBackLinks($menu);
$menu.on("click.megamenu", ".mega-mobile-back-link", function(e){
var menuPlugin;
var $submenu;
var $parentItem;
var $parentLink;
e.preventDefault();
e.stopPropagation();
$submenu=$(this).closest("ul.mega-sub-menu");
$parentItem=$submenu.parent("li.mega-menu-item-has-children");
$parentLink=$parentItem.children("a.mega-menu-link").first();
menuPlugin=$menu.data("maxmegamenu");
if(menuPlugin&&typeof menuPlugin.hidePanel==="function"){
menuPlugin.hidePanel($parentLink, false);
}else{
$parentItem.removeClass("mega-toggle-on");
}
$parentLink.trigger("focus");
});
});
})(jQuery);
(function($){
"use strict";
$.maxmegamenu_searchbox=function(form, options){
var plugin=this;
var form=$(form);
var $menu=form.parents('.max-mega-menu');
var $wrap=$menu.parent();
var breakpoint=$menu.attr('data-breakpoint');
var input=$('input[type=text]', form);
var icon=$('.search-icon', form);
plugin.isDesktopView=function(){
return Math.max(window.outerWidth, $(window).width()) >=breakpoint;
};
plugin.monitorView=function(){
if(typeof $menu.data("view")==='undefined'){
if(plugin.isDesktopView()){
$menu.data("view", "desktop");
}else{
$menu.data("view", "mobile");
}}
plugin.checkWidth();
$(window).on('resize', function(){
plugin.checkWidth();
});
};
plugin.checkWidth=function(){
var expanding_search=$("li.mega-menu-item .mega-search.expand-to-left input[type=text], li.mega-menu-item .mega-search.expand-to-right input[type=text]", $menu);
if($menu.data("view")==="mobile"){
var placeholder=expanding_search.attr('data-placeholder');
expanding_search.attr('placeholder', placeholder);
expanding_search.attr('aria-hidden', 'false');
}
if($menu.data("view")==="desktop"){
expanding_search.attr('placeholder', '');
expanding_search.attr('aria-hidden', 'true');
}};
plugin.close_search=function(moveFocus=true){
$menu.triggerHandler("mmm:closeSearch");
input.val("");
input.attr('placeholder', '');
input.attr('tabindex', '-1');
input.attr('aria-hidden', 'true');
form.removeClass('mega-search-open');
form.addClass('mega-search-closed');
icon.attr('aria-expanded', 'false');
if(moveFocus){
icon.trigger("focus");
}}
plugin.open_search=function(){
$menu.triggerHandler("mmm:openSearch");
input.attr('placeholder', input.attr('data-placeholder'));
input.attr('tabindex', '0');
input.attr('aria-hidden', 'false');
form.removeClass('mega-search-closed');
form.addClass('mega-search-open');
icon.attr('aria-expanded', 'true');
input.trigger("focus");
}
plugin.detect_background_click=function(){
var dragging=false;
$(document).on({
"touchmove": function(e){ dragging=true; },
"touchstart": function(e){ dragging=false; }});
$(document).on("click touchend", function(e){
if(form.parent().hasClass('mega-static')){
return;
}
if(! dragging&&! $(e.target).closest(".max-mega-menu li").length&&! $(e.target).closest(".mega-menu-toggle").length){
plugin.close_search(false);
}
dragging=false;
});
}
plugin.init_replacements_search=function(){
if($menu.data("view")==="mobile"){
input.attr('tabindex', '0');
$(".search-icon", $menu).on('click', function(e){
$(this).parents(".mega-search").submit();
});
}
if($menu.data("view")==="desktop"){
input.on('blur', function(e){
if($menu.parent().hasClass("mega-keyboard-navigation")&&input.val()==''&&! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')){
plugin.close_search();
}});
icon.on('keypress click', function(e){
var enter_key=13;
var space_key=32;
if(e.which===enter_key||e.which===space_key||e.type==='click'){
e.preventDefault();
if(form.parent().hasClass('mega-static')){
form.submit();
return;
}
if(input.val()!=''){
form.submit();
return;
}
if(form.hasClass('mega-search-open')){
plugin.close_search();
return;
}
if(form.hasClass('mega-search-closed')){
plugin.open_search();
return;
}};});
icon.on('blur', function(){
if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')&&$wrap.hasClass('mega-keyboard-navigation')){
setTimeout(function(){
if(form.find(":focus").length==0){
plugin.close_search(false);
}}, 100);
}});
$menu.on('keydown', function(e){
var escape_key=27;
if(e.which===escape_key){
if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')){
plugin.close_search();
return;
}}
});
}};
plugin.monitorView();
plugin.init_replacements_search();
plugin.detect_background_click();
};
$.fn.maxmegamenu_searchbox=function(options){
return this.each(function(){
if(undefined===$(this).data('maxmegamenu_searchbox')){
var plugin=new $.maxmegamenu_searchbox(this, options);
$(this).data('maxmegamenu_searchbox', plugin);
}});
};
$(".max-mega-menu").on("after_mega_menu_init", function(){
$(".mega-search", this).maxmegamenu_searchbox();
});
})(jQuery);
(function($){
"use strict";
$.maxmegamenu_toggle_searchbox=function(form, options){
var plugin=this;
var form=$(form);
var $wrap=form.parents('.mega-menu-wrap');
var input=$("input[type=text]", form);
var icon=$(".search-icon", form);
plugin.open_search=function(){
input.attr('placeholder', input.attr('data-placeholder'));
form.removeClass('mega-search-closed');
form.addClass('mega-search-open');
}
plugin.close_search=function(){
input.attr('placeholder', '');
form.removeClass('mega-search-open');
form.addClass('mega-search-closed');
}
plugin.init_toggle_search=function(){
input.val("");
input.on('focus', function(e){
if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-closed')&&$wrap.hasClass('mega-keyboard-navigation')){
plugin.open_search();
}});
input.on('blur', function(e){
if(! form.parent().hasClass('mega-static')&&form.hasClass('mega-search-open')&&$wrap.hasClass('mega-keyboard-navigation')){
plugin.close_search();
}});
icon.on('click', function(e){
if(form.hasClass('static')){
if(input.attr('required')=='required'&&input.val()==""){
return;
}else{
form.submit();
}}else if(form.hasClass('mega-search-closed')){
input.focus();
plugin.open_search();
}else if(input.val()==''){
plugin.close_search();
}else{
form.submit();
}});
};
plugin.init_toggle_search();
};
$.fn.maxmegamenu_toggle_searchbox=function(options){
return this.each(function(){
if(undefined===$(this).data('maxmegamenu_toggle_searchbox')){
var plugin=new $.maxmegamenu_toggle_searchbox(this, options);
$(this).data('maxmegamenu_toggle_searchbox', plugin);
}});
};
$(function(){
$(".mega-menu-toggle .mega-search").maxmegamenu_toggle_searchbox();
});
})(jQuery);
(function($){
"use strict";
$.maxmegamenu_sticky=function(menu, options){
var plugin=this;
var $menu=$(menu);
var $wrap=$menu.parent();
var breakpoint=$menu.attr('data-breakpoint');
var sticky_on_mobile=$menu.attr('data-sticky-mobile');
var sticky_on_desktop=$menu.attr('data-sticky-desktop');
var sticky_expand=$menu.attr('data-sticky-expand');
var sticky_expand_mobile=$menu.attr('data-sticky-expand-mobile');
var sticky_offset=isNaN(parseInt($menu.attr('data-sticky-offset'))) ? 0:parseInt($menu.attr('data-sticky-offset'));
var sticky_hide_until_scroll_up=$menu.attr('data-sticky-hide');
var sticky_hide_until_scroll_up_tolerance=isNaN(parseInt($menu.attr('data-sticky-hide-tolerance'))) ? 0:parseInt($menu.attr('data-sticky-hide-tolerance'));
var sticky_hide_until_scroll_up_offset=isNaN(parseInt($menu.attr('data-sticky-hide-offset'))) ? 0:parseInt($menu.attr('data-sticky-hide-offset'));
var sticky_transition=$menu.attr('data-sticky-transition');
var sticky_menu_offset_top;
var sticky_menu_offset_left;
var sticky_menu_width;
var sticky_menu_width_round_up;
var sticky_menu_height;
var is_stuck=false;
var admin_bar_height=0;
var last_scroll_top=0;
var saved_scroll_top=0;
var is_vertical=$menu.hasClass('mega-menu-vertical')||$menu.hasClass('mega-menu-accordion');
plugin.isDesktopView=function(){
var width=Math.max(document.documentElement.clientWidth||0, window.innerWidth||0);
return width > breakpoint;
};
var sticky_hide_until_scroll_up_enabled=function(){
return $menu.hasClass('mega-menu-horizontal')&&sticky_hide_until_scroll_up=="true";
}
var sticky_enabled=function(){
if(plugin.isDesktopView()){
return sticky_on_desktop==='true';
}else{
return sticky_on_mobile==='true';
}
return false;
};
plugin.calculate_menu_position=function(){
sticky_menu_offset_top=$wrap.offset().top;
if($('body').hasClass('admin-bar')&&$("#wpadminbar").is(":visible")&&$("#wpadminbar").css('top')=='0px'&&$("#wpadminbar").css('position')=='fixed'){
admin_bar_height=$('#wpadminbar').height();
sticky_menu_offset_top=sticky_menu_offset_top - admin_bar_height;
}
if(sticky_offset < 0){
sticky_menu_offset_top=sticky_menu_offset_top + sticky_offset;
}else{
sticky_menu_offset_top=sticky_menu_offset_top - sticky_offset;
}
sticky_menu_offset_left=$menu.parent().offset().left;
sticky_menu_width=window.getComputedStyle($wrap[0]).width;
sticky_menu_width_round_up=Math.ceil(parseFloat(sticky_menu_width));
sticky_menu_height=$wrap.height();
};
plugin.stick_menu=function(){
is_stuck=true;
var total_offset=parseInt(admin_bar_height, 10) + parseInt(sticky_offset, 10);
if(sticky_offset < 0){
total_offset=parseInt(admin_bar_height, 10);
}
var placeholder=$("<div />").addClass("mega-sticky-wrapper").css({
'height':sticky_menu_height + 'px',
'position' :'static'
});
$wrap.addClass('mega-sticky').wrap(placeholder).css({
'margin-top':total_offset + 'px'
});
$("body").addClass($menu.attr("id") + "-mega-sticky");
$menu.css({
'max-width':sticky_menu_width_round_up + 'px'
});
if(sticky_menu_offset_left > 0){
$menu.css({
'margin-left':sticky_menu_offset_left + 'px'
});
}
if(is_vertical||sticky_expand==='false'){
$wrap.css({
'margin-left':'0',
'margin-right':'0',
'width':sticky_menu_width_round_up + 'px',
'left':sticky_menu_offset_left + 'px'
});
$menu.css({
'margin-left':'0'
});
}
if($(window).width() <=breakpoint){
$wrap.css({
'width':sticky_menu_width_round_up + 'px'
});
if(sticky_expand_mobile==='true'){
$wrap.css({
'margin-left':'',
'margin-right':'',
'width':'',
'left':''
});
$menu.css({
'max-width':'',
'margin-left':'',
'width':'',
'left':''
});
}}
$wrap.delay(0).queue(function(next){
$(this).addClass('mega-stuck');
next();
});
};
plugin.unstick_menu=function(doing_resize){
doing_resize=doing_resize||false;
is_stuck=false;
$wrap.removeClass('mega-sticky').removeClass('mega-hide').css({
'margin':'',
'width':'',
'left': ''
});
$("body").removeClass($menu.attr("id") + "-mega-sticky");
if(! doing_resize){
$wrap.delay(0).queue(function(next){
$(this).removeClass('mega-stuck');
next();
});
}
$menu.css({
'margin-left':'',
'max-width':'',
'left':'',
'width':''
});
if($(window).width() <=breakpoint){
$menu.data('maxmegamenu').toggleBarForceWidth();
}
if(sticky_transition=='true'&&! doing_resize){
var delay=250;
}else{
var delay=0;
}
$wrap.delay(delay).queue(function(next){
$(this).unwrap();
next();
});
};
plugin.mega_sticky_on_scroll=function(){
if(! sticky_enabled()){
return;
}
var scroll_top=$(window).scrollTop();
if(scroll_top > sticky_menu_offset_top){
if(!is_stuck){
plugin.stick_menu();
}}else{
if(is_stuck){
plugin.unstick_menu();
}}
};
var mega_hide_on_scroll_up=function(){
if(sticky_hide_until_scroll_up_enabled()){
if($menu.data("view")==="mobile"&&$('.mega-menu-toggle', $wrap).hasClass('mega-menu-open')){
return;
}
var scroll_top=$(window).scrollTop();
if(scroll_top < sticky_hide_until_scroll_up_offset){
$wrap.removeClass('mega-hide');
$("body").removeClass($menu.attr("id") + "-mega-hide");
}
saved_scroll_top=last_scroll_top;
if(scroll_top < last_scroll_top){
if(saved_scroll_top - scroll_top > sticky_hide_until_scroll_up_tolerance){
$wrap.removeClass('mega-hide');
$("body").removeClass($menu.attr("id") + "-mega-hide");
}}else{
if(is_stuck&&scroll_top - saved_scroll_top > sticky_hide_until_scroll_up_tolerance){
$wrap.addClass('mega-hide');
$("body").addClass($menu.attr("id") + "-mega-hide");
}}
last_scroll_top=scroll_top;
}}
plugin.mega_sticky_on_resize=function(){
if($('input', $wrap).is(':focus')){
return;
}
if(sticky_enabled()){
if(is_stuck){
plugin.unstick_menu(true);
plugin.calculate_menu_position();
plugin.stick_menu();
}else{
plugin.calculate_menu_position();
plugin.mega_sticky_on_scroll();
}}else{
if(is_stuck){
plugin.unstick_menu();
}}
};
plugin.init=function(){
plugin.calculate_menu_position();
plugin.mega_sticky_on_scroll();
$('.mega-menu-accordion li.mega-menu-item').on('open_panel', function(){
plugin.calculate_menu_position();
});
var $window=$(window);
$window.scroll(function(){
plugin.mega_sticky_on_scroll();
mega_hide_on_scroll_up();
});
var windowWidth=$window.width();
var resizeTimer;
$window.on('resize', function(){
clearTimeout(resizeTimer);
resizeTimer=setTimeout(function(){
windowWidth=$window.width();
plugin.mega_sticky_on_resize();
}, 100);
});
};
plugin.init();
};
$.fn.maxmegamenu_sticky=function(options){
return this.each(function(){
if(undefined===$(this).data('maxmegamenu_sticky')){
var plugin=new $.maxmegamenu_sticky(this, options);
$(this).data('maxmegamenu_sticky', plugin);
}});
};
$(window).on('load', function (e){
$(".max-mega-menu[data-sticky-enabled]").maxmegamenu_sticky();
});
})(jQuery);
(function($){
$(function(){
var calculate_tabbed_sub_menu_widths=function(menu_item){
var menu=menu_item.parents('.max-mega-menu');
if($(menu.attr('data-panel-inner-width')).length > 0){
if(menu.data("view")==="desktop"){
$('> ul.mega-sub-menu', menu_item).each(function(){
var tab_content=$(this);
var parent_submenu_content_width=parseInt(tab_content.width());
var parent_submenu_left_padding=parseInt(tab_content.css('paddingLeft'));
var tabs_width=$(this).find('a.mega-menu-link').first().outerWidth();
$('> li.mega-menu-item > ul.mega-sub-menu', $(this)).each(function(){
$(this).css('width', parent_submenu_content_width - tabs_width + 'px');
$(this).css('left', parent_submenu_left_padding + tabs_width + 'px');
});
});
}else{
$('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function(){
$(this).css('width', '');
$(this).css('left', '');
});
}}
}
var calculate_tabbed_sub_menu_heights=function(menu_item){
var menu=menu_item.parents('.max-mega-menu');
var max_height=0;
if(menu.data("view")==="desktop"){
$('> ul.mega-sub-menu', menu_item).css('minHeight', '');
$('> ul.mega-sub-menu > li.mega-menu-item > ul.mega-sub-menu', menu_item).each(function(){
var tab_content=$(this);
var this_height=parseInt(tab_content.css('height'));
if(this_height > max_height){
max_height=this_height;
}});
var border_top_width=parseInt($('> ul.mega-sub-menu', menu_item).css('borderTopWidth'),10);
var border_bottom_width=parseInt($('> ul.mega-sub-menu', menu_item).css('borderBottomWidth'),10);
$('> ul.mega-sub-menu', menu_item).css('minHeight', max_height + border_bottom_width + border_top_width);
}else{
$('> ul.mega-sub-menu', menu_item).css('minHeight', '');
}}
var $window=$(window);
var windowWidth=$window.width();
$window.on('resize', function(){
if($window.width()!=windowWidth){
calculate_tabbed_sub_menu_widths($('li.mega-menu-tabbed'));
calculate_tabbed_sub_menu_heights($('li.mega-menu-tabbed'));
}});
$('li.mega-menu-tabbed, li.mega-menu-tabbed li.mega-collapse-children').on('open_panel', function(){
var menu=$(this).parents('.max-mega-menu');
var menu_item=$(this).closest(".mega-menu-tabbed");
calculate_tabbed_sub_menu_widths(menu_item);
$("> ul.mega-sub-menu", $(this)).promise().done(function(){
calculate_tabbed_sub_menu_heights(menu_item);
});
if(menu.data('view')=='desktop'){
if($('> ul.mega-sub-menu > li.mega-menu-item-has-children.mega-toggle-on', menu_item).length==0){
if($('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).length){
$('> ul.mega-sub-menu > li.mega-current-menu-item:visible', menu_item).first().addClass('mega-toggle-on');
}else if($('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).length){
$('> ul.mega-sub-menu > li.mega-current-menu-ancestor:visible', menu_item).first().addClass('mega-toggle-on');
}
if($('> ul.mega-sub-menu > li.mega-toggle-on', menu_item).length==0){
$('> ul.mega-sub-menu > li.mega-menu-item-has-children:visible', menu_item).first().addClass('mega-toggle-on');
}}
$('li.mega-menu-tabbed', menu).on('close_panel', function(){
$('li.mega-menu-tabbed .mega-toggle-on', menu).removeClass('mega-toggle-on');
});
}
$('li.mega-menu-tabbed li.mega-collapse-children').on('close_panel', function(){
var menu_item=$(this).closest('.mega-menu-tabbed');
$("> ul.mega-sub-menu", $(this)).promise().done(function(){
calculate_tabbed_sub_menu_heights(menu_item);
});
});
});
});
})(jQuery);