1(function () { 2 "use strict"; 3 const n = window.VICTHEME_JS || {}; 4 5 n.stickyMenu = function () { 6 window.scrollY > 350 7 ? document.getElementById("masthead").classList.add("nav-affix") 8 : document.getElementById("masthead").classList.remove("nav-affix"); 9 }; 10 11 n.mobileMenu = { 12 init: function () { 13 this.toggleMenu(); 14 this.menuMobile(); 15 this.menuArrow(); 16 }, 17 toggleMenu: function () { 18 document.getElementById('masthead').addEventListener('click', function (event) { 19 if (event.target.closest('.toggle-menu')) { 20 const ethis = document.querySelector('.main-navigation .menu .menu-mobile'); 21 ethis.style.display = ethis.style.display === 'block' ? 'none' : 'block'; 22 document.querySelector('.ham').classList.toggle('exit'); 23 document.body.classList.toggle('vic-sticky-header-revealed'); 24 } 25 }); 26 27 document.querySelector('#masthead .main-navigation').addEventListener('click', function (event) { 28 if (event.target.closest('.menu-mobile a button')) { 29 event.preventDefault(); 30 const ethis = event.target; 31 const eparent = ethis.closest('li'); 32 const esub_menu = eparent.querySelector('> .sub-menu'); 33 esub_menu.style.display = esub_menu.style.display === 'none' ? 'block' : 'none'; 34 ethis.classList.toggle('active'); 35 } 36 }); 37 }, 38 menuMobile: function () { 39 const ethis = document.querySelector('.main-navigation .menu > ul'); 40 if (ethis) { 41 const eparent = ethis.closest('.main-navigation'); 42 const pointbreak = eparent.dataset.epointbreak || 991; 43 const windowWidth = window.innerWidth; 44 45 if (pointbreak >= windowWidth) { 46 ethis.classList.add('menu-mobile'); 47 ethis.classList.remove('menu-desktop'); 48 document.querySelector('.main-navigation .toggle-menu').style.display = 'block'; 49 document.querySelector('.main-navigation-container-items-wrapper').classList.add('vic-mobile-navigation'); 50 } else { 51 ethis.classList.add('menu-desktop'); 52 ethis.classList.remove('menu-mobile'); 53 ethis.style.display = ''; 54 document.querySelector('.main-navigation .toggle-menu').style.display = ''; 55 document.querySelector('.main-navigation-container-items-wrapper').classList.remove('vic-mobile-navigation'); 56 } 57 } 58 59 if (document.querySelector('.vic-mobile-navigation')) { 60 const navElement = document.querySelector(".vic-mobile-navigation"); 61 if (navElement) { 62 n.trapFocus(navElement); 63 } 64 } 65 }, 66 menuArrow: function () { 67 const menuItems = document.querySelectorAll('#masthead .main-navigation div.menu > ul .sub-menu'); 68 menuItems.forEach(function (subMenu) { 69 const parentLink = subMenu.parentNode.querySelector('a'); 70 const button = document.createElement('button'); 71 button.className = 'fa fa-angle-down'; 72 parentLink.appendChild(button); 73 }); 74 } 75 }; 76 77 n.trapFocus = function (element) { 78 const focusableEls = element.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled])'); 79 const firstFocusableEl = focusableEls[0]; 80 const lastFocusableEl = focusableEls[focusableEls.length - 1]; 81 82 element.addEventListener('keydown', function (e) { 83 if (e.key === 'Tab') { 84 if (e.shiftKey && document.activeElement === firstFocusableEl) { 85 e.preventDefault();
86 lastFocusableEl.focus(); 87 } else if (document.activeElement === lastFocusableEl) { 88 e.preventDefault(); 89 firstFocusableEl.focus(); 90 } 91 } 92 }); 93 }; 94 95 n.DataBackground = function () { 96 document.querySelectorAll(".data-bg").forEach(function (section) { 97 const bg = section.getAttribute("data-background"); 98 if (bg) { 99 section.style.backgroundImage = "url(" + bg + ")"; 100 } 101 }); 102 103 document.querySelectorAll('.bg-image').forEach(function (imgContainer) { 104 const img = imgContainer.querySelector('img'); 105 const src = img.getAttribute('src'); 106 imgContainer.style.backgroundImage = 'url(' + src + ')'; 107 img.style.display = 'none'; 108 }); 109 }; 110 111 n.setInstaHeight = function () { 112 document.querySelectorAll('.insta-slider-block').forEach(function (block) { 113 const imgWidth = block.querySelector('.insta-item .af-insta-height').clientWidth; 114 block.querySelectorAll('.insta-item .af-insta-height').forEach(function (item) { 115 item.style.height = imgWidth + 'px'; 116 }); 117 }); 118 }; 119 120 n.Search = function () { 121 window.addEventListener('load', function () { 122 document.querySelector(".af-search-click").addEventListener('click', function () { 123 document.getElementById("vic-search-wrap").classList.toggle("vic-search-toggle"); 124 }); 125 }); 126 }; 127 128 n.searchReveal = function () { 129 window.onload = function () { 130 const searchIcon = document.querySelector('.search-icon'); 131 const searchOverlay = document.querySelector('.search-overlay'); 132 133 if (searchIcon && searchOverlay) { 134 searchIcon.addEventListener('click', function (event) { 135 event.preventDefault(); 136 searchOverlay.classList.toggle('reveal-search'); 137 }); 138 } 139 }; 140 }; 141 142 143 n.show_hide_scroll_top = function () { 144 const scrollUp = document.getElementById("scroll-up"); 145 scrollUp.style.display = window.scrollY > window.innerHeight / 2 ? 'block' : 'none'; 146 }; 147 148 n.scroll_up = function () { 149 document.getElementById("scroll-up").addEventListener("click", function () { 150 window.scrollTo({ top: 0, behavior: 'smooth' }); 151 }); 152 }; 153 154 // Throttle function for better performance 155 function throttle(func, delay) { 156 let lastCall = 0; 157 return function(...args) { 158 const now = Date.now(); 159 if (now - lastCall >= delay) { 160 lastCall = now; 161 func.apply(this, args); 162 } 163 }; 164 } 165 166 document.addEventListener("DOMContentLoaded", function () { 167 n.mobileMenu.init(); 168 n.DataBackground(); 169 n.setInstaHeight(); 170 n.scroll_up(); 171 n.searchReveal(); 172 }); 173 174 // Throttled scroll handler for better INP/performance 175 window.addEventListener('scroll', throttle(function () { 176 n.stickyMenu(); 177 n.show_hide_scroll_top(); 178 }, 100)); 179 180 // Throttled resize handler 181 window.addEventListener('resize', throttle(function () { 182 n.mobileMenu.menuMobile(); 183 }, 150)); 184 185})();
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.