{"version":3,"file":"MegaMenu.min.js","sources":["MegaMenu.js"],"sourcesContent":["(function (w, $) {\n\n const assetId = '~/theme/v1/Views/Menu/MegaMenu.min.js';\n\n if (!w.umwAssets || !w.umwAssets[assetId]) {\n console.error('No context found for ' + assetId);\n return;\n }\n\n for (let ctx of w.umwAssets[assetId]) {\n\n const prefixClass = \"uc203-full-width\";\n\n const classes = {\n control: \"js-\" + prefixClass,\n lvl1Item: \"js-\" + prefixClass + \"-lvl1-item\",\n popup: prefixClass + \"-popup\",\n lvl1ItemContaisSublevel: prefixClass + \"-lvl1-item.has-submenu\",\n lvl1ItemHovered: prefixClass + \"-lvl1-item-hovered\",\n };\n\n const beforeMegaMenuLvl1Mouseenter = new $.Event(\"megamenu:lvl1:beforemouseenter\");\n const beforeMegaMenuLvl1Mouseleave = new $.Event(\"megamenu:lvl1:beforemouseleave\");\n const desktopHeaderContainer = document.querySelector('.site-header-desktop'); //Global for this control. Is part of Default.aspx\n\n const $control = $(\".\" + classes.control);\n const $lvl1Item = $(\".\" + classes.lvl1Item, $control);\n const hoverDelay = 250;\n let hoverTimerId;\n\n $control.on(\"mouseenter\", \".\" + classes.lvl1Item, function(e) {\n\n $control.trigger(beforeMegaMenuLvl1Mouseenter, [hoverTimerId, hoverDelay]);\n\n if (beforeMegaMenuLvl1Mouseenter.isDefaultPrevented()) {\n return;\n }\n\n clearInterval(hoverTimerId);\n\n hoverTimerId = setTimeout(function() {\n $lvl1Item.removeClass(classes.lvl1ItemHovered);\n \n $(e.currentTarget).addClass(classes.lvl1ItemHovered);\n \n if($(e.currentTarget).hasClass('has-submenu')) {\n const hoveredLevel1PopupContainer = e.currentTarget.querySelector('.' + classes.popup);\n const heightHeaderAndMegaMenu = desktopHeaderContainer.clientHeight + hoveredLevel1PopupContainer.clientHeight;\n if (heightHeaderAndMegaMenu > window.innerHeight) {\n hoveredLevel1PopupContainer.classList.add('scrollable');\n hoveredLevel1PopupContainer.style.height = `calc(${window.innerHeight * .9 - desktopHeaderContainer.clientHeight}px)`;\n }\n $('body').addClass('uc203-hovered');\n } else {\n $('body').removeClass('uc203-hovered');\n }\n },\n hoverDelay);\n });\n\n $control.on(\"mouseleave\", \".\" + classes.lvl1Item, function(e) {\n\n $control.trigger(beforeMegaMenuLvl1Mouseleave, [hoverTimerId, hoverDelay]);\n\n if (beforeMegaMenuLvl1Mouseleave.isDefaultPrevented()) {\n return;\n }\n\n clearInterval(hoverTimerId);\n\n hoverTimerId = setTimeout(function () {\n $lvl1Item.removeClass(classes.lvl1ItemHovered);\n $('body').removeClass('uc203-hovered');\n },\n hoverDelay);\n });\n }\n\n})(window, jQuery);"],"names":["w","$","assetId","umwAssets","let","ctx","prefixClass","classes","control","lvl1Item","popup","lvl1ItemContaisSublevel","lvl1ItemHovered","beforeMegaMenuLvl1Mouseenter","Event","beforeMegaMenuLvl1Mouseleave","desktopHeaderContainer","document","querySelector","$control","$lvl1Item","hoverDelay","hoverTimerId","on","e","trigger","isDefaultPrevented","clearInterval","setTimeout","hoveredLevel1PopupContainer","removeClass","currentTarget","addClass","hasClass","clientHeight","window","innerHeight","classList","add","style","height","console","error","jQuery"],"mappings":"AAAA,CAAA,SAAWA,EAAGC,GAEV,IAAMC,EAAU,wCAEhB,GAAKF,EAAEG,WAAcH,EAAEG,UAAUD,GAKjC,IAAKE,IAAIC,KAAOL,EAAEG,UAAUD,GAAU,CAElC,IAAMI,EAAc,mBAEpB,MAAMC,EAAU,CACZC,QAAS,MAAQF,EACjBG,SAAU,MAAQH,EAAc,aAChCI,MAAOJ,EAAc,SACrBK,wBAAyBL,EAAc,yBACvCM,gBAAiBN,EAAc,oBACnC,EAEMO,EAA+B,IAAIZ,EAAEa,MAAM,gCAAgC,EAC3EC,EAA+B,IAAId,EAAEa,MAAM,gCAAgC,EAC3EE,EAAyBC,SAASC,cAAc,sBAAsB,EAEtEC,EAAWlB,EAAE,IAAMM,EAAQC,OAAO,EAClCY,EAAYnB,EAAE,IAAMM,EAAQE,SAAUU,CAAQ,EA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