1if (typeof debounce === 'undefined') { 2 function debounce(fn, wait) { 3 let t; 4 return (...args) => { 5 clearTimeout(t); 6 t = setTimeout(() => fn.apply(this, args), wait); 7 }; 8 } 9} 10 11/** 12 * @class 13 * @function ThemeHeader 14 */ 15 16if (!customElements.get('theme-header')) { 17 class ThemeHeader extends HTMLElement { 18 constructor() { 19 super(); 20 21 } 22 connectedCallback() { 23 this.container = document.getElementById('wrapper'); 24 this.header_section = document.querySelector('.header-section'); 25 this.menu = document.getElementById('mobile-menu'); 26 this.toggle = this.querySelector('.mobile-toggle'); 27 this.cc = document.querySelector('.click-capture'); 28 this.close = this.menu.querySelector('.thb-close'); 29 30 31 // Setup Mobile Menu 32 this.setupMenuAnimation(); 33 this.setupSubMenuEvents(); 34 this.setupEventListeners(); 35 36 // Sticky Header 37 if (!this.classList.contains('fixed')) { 38 this.header_section.classList.add('has-height'); 39 } 40 41 // Sticky Header Class 42 window.addEventListener('scroll', this.setStickyClass.bind(this), { 43 passive: true 44 }); 45 46 // Set Header Height 47 window.addEventListener('scroll', this.setHeaderHeight.bind(this), { 48 passive: true 49 }); 50 51 window.dispatchEvent(new Event('scroll')); 52 53 54 } 55 setupMenuAnimation() { 56 this.menutl = gsap.timeline({ 57 paused: true, 58 onStart: () => { 59 this.container.classList.add('open-cc'); 60 gsap.set(this.menu, { 61 visibility: "visible" 62 }); 63 }, 64 onReverseComplete: () => { 65 this.container.classList.remove('open-cc'); 66 gsap.set(this.menu, { 67 clearProps: "transform" 68 }); 69 } 70 }); 71 72 this.menutl 73 .to(this.menu, { 74 x: "0%", 75 duration: 0.25 76 }, "start") 77 .fromTo(this.menu.querySelectorAll('h6, .searchform, .mobile-menu>li,.mobile-secondary-menu>li, .social-links, .thb-close'), { 78 x: "-30", 79 opacity: 0 80 }, { 81 duration: 0.25, 82 x: "0", 83 opacity: 1, 84 stagger: 0.05 85 }, "start+=0.2"); 86 } 87 88 setupSubMenuEvents() { 89 this.submenuToggles = this.menu.querySelectorAll('.mobile-menu li.menu-item-has-children > .link-container .asdasadS'); 90 91 this.submenuToggles.forEach((toggle) => { 92 toggle.addEventListener('click', (e) => { 93 e.preventDefault(); 94 95 const isAlreadyActive = toggle.parentElement.classList.contains('active'); 96 97 // Remove 'active' from all toggles 98 this.submenuToggles.forEach((el) => { 99 el.parentElement.classList.remove('active'); 100 el.parentElement.nextElementSibling.style.display = 'none'; // Hide submenu 101 }); 102 103 // If it wasnât active before, activate it 104 if (!isAlreadyActive) { 105 toggle.parentElement.classList.add('active'); 106 toggle.parentElement.nextElementSibling.style.display = 'block'; // Show submenu 107 } 108 }); 109 }); 110 } 111 openDrawer() { 112 this.menutl.timeScale(1).play(); 113 } 114 closeDrawer() { 115 this.menutl.timeScale(1.5).reverse(); 116 } 117 118 setupEventListeners() { 119 this.toggle.addEventListener('click', this.openDrawer.bind(this)); 120 this.cc.addEventListener('click', this.closeDrawer.bind(this)); 121 this.close.addEventListener('click', this.closeDrawer.bind(this)); 122 123 document.addEventListener('keyup', (e) => { 124 if (e.code) { 125 if (e.code.toUpperCase() === 'ESCAPE') { 126 this.closeDrawer(); 127 } 128 } 129 }); 130 } 131 132 setStickyClass() { 133 let offset = parseInt(this.getBoundingClientRect().top, 10) + document.documentElement.scrollTop; 134 this.classList.toggle('hover', window.scrollY > 0); 135 } 136 137 setHeaderHeight() { 138 let h = this.clientHeight; 139 document.documentElement.style.setProperty('--header-height', h + 'px'); 140 } 141 } 142 customElements.define('theme-header', ThemeHeader); 143} 144/** 145 * @class 146 * @function FullMenu 147 */ 148if (!customElements.get('full-menu')) { 149 class FullMenu extends HTMLElement { 150 constructor() { 151 super(); 152 153 this.submenus = this.querySelectorAll('.thb-full-menu>.menu-item-has-children:not(.menu-item-has-megamenu)>.sub-menu'); 154 this.megamenus = this.querySelectorAll('.thb-full-menu>.menu-item-has-megamenu'); 155 156 if (!this.submenus.length) { 157 return; 158 } 159 const _this = this; 160 // resize on initial load 161 window.addEventListener('resize', debounce(function () { 162 _this.resizeSubMenus(); 163 _this.resizeMegaMenus(); 164 }, 100)); 165 166 } 167 connectedCallback() { 168 if (!this.submenus.length) { 169 return; 170 } 171 document.fonts.ready.then(function () { 172 window.dispatchEvent(new Event('resize')); 173 }); 174 175 } 176 resizeMegaMenus() {
177 this.megamenus.forEach((megamenu) => { 178 179 let sub_submenu = megamenu.querySelector('.mega-menu-columns'); 180 sub_submenu.parentElement.style.marginLeft = 0; 181 let total = sub_submenu.getBoundingClientRect().left + sub_submenu.offsetWidth; 182 183 if (total > window.innerWidth) { 184 sub_submenu.parentElement.style.marginLeft = (window.innerWidth - total) - 50 + 'px'; 185 } else if (total < window.innerWidth && sub_submenu.getBoundingClientRect().left < 0) { 186 sub_submenu.parentElement.style.marginLeft = -1 * (sub_submenu.getBoundingClientRect().left - 50) + 'px'; 187 } else { 188 sub_submenu.parentElement.style.marginLeft = 0; 189 } 190 }); 191 } 192 resizeSubMenus() { 193 this.submenus.forEach((submenu) => { 194 let sub_submenus = submenu.querySelectorAll(':scope >.menu-item-has-children>.sub-menu'); 195 196 sub_submenus.forEach((sub_submenu) => { 197 let w = sub_submenu.offsetWidth, 198 l = sub_submenu.parentElement.getBoundingClientRect().left + sub_submenu.parentElement.offsetWidth, 199 total = w + l; 200 201 if (total > window.innerWidth) { 202 sub_submenu.parentElement.classList.add('left-submenu'); 203 } else if (sub_submenu.parentElement.classList.contains('left-submenu')) { 204 sub_submenu.parentElement.classList.remove('left-submenu'); 205 } 206 }); 207 }); 208 } 209 } 210 customElements.define('full-menu', FullMenu); 211}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.