1var nectar_core = nectar_core || {}; 2 3document.addEventListener('DOMContentLoaded', function() { 4 //darkmode_init(); 5 6 // Toggle Main Menu - Vanilla JavaScript (jQuery-free) 7 function fadeToggle(element, duration, callback) { 8 if (!element) return; 9 10 // Map duration to Tailwind duration class 11 var durationClass = 'duration-300'; // Default to 300ms 12 if (duration === 200) durationClass = 'duration-200'; 13 else if (duration === 500) durationClass = 'duration-500'; 14 else if (duration === 700) durationClass = 'duration-700'; 15 16 // Ensure transition classes are present 17 element.classList.add('transition-opacity', durationClass); 18 19 // Check if element is visible (using consolidated method) and not transparent 20 var isVisible = isElementVisible(element) && !element.classList.contains('opacity-0'); 21 22 if (isVisible) { 23 // Fade out: add opacity-0 24 element.classList.add('opacity-0'); 25 setTimeout(function() { 26 // After fade completes, hide the element 27 element.classList.add('hidden'); 28 element.classList.remove('opacity-0'); 29 if (callback) callback(); 30 }, duration); 31 } else { 32 // Fade in: remove hidden, set opacity-0, then fade to opacity-100 33 element.classList.remove('hidden'); 34 element.classList.add('opacity-0'); 35 element.offsetHeight; // Force reflow 36 element.classList.remove('opacity-0'); 37 element.classList.add('opacity-100'); 38 setTimeout(function() { 39 if (callback) callback(); 40 }, duration); 41 } 42 } 43 44 function isElementVisible(element) { 45 var computedStyle = window.getComputedStyle(element); 46 return computedStyle.display !== 'none' && 47 element.offsetWidth > 0 && 48 element.offsetHeight > 0; 49 } 50 51 function toggleMenu() { 52 var menu = document.querySelector('nav.over'); 53 var button = document.querySelector('.main-nav .menu-nav-button'); 54 var closeButton = document.querySelector('.navigation-close-button'); 55 56 if (!menu || !button) return; 57 58 fadeToggle(menu, 300, function() { 59 var isNowVisible = isElementVisible(menu); 60 button.setAttribute('aria-expanded', isNowVisible); 61 if (closeButton) { 62 closeButton.setAttribute('aria-expanded', isNowVisible); 63 } 64 }); 65 } 66 67 // Handle menu button - click event handles mouse and Enter key 68 var menuButton = document.querySelector('.main-nav .menu-nav-button'); 69 if (menuButton) { 70 menuButton.addEventListener('click', function(e) { 71 e.preventDefault(); 72 toggleMenu(); 73 }); 74 75 // Handle Space key explicitly (Enter is handled by click event) 76 menuButton.addEventListener('keydown', function(e) { 77 if (e.key === ' ' || e.keyCode === 32) { 78 e.preventDefault(); 79 toggleMenu(); 80 } 81 }); 82 } 83 84 // Handle close button 85 var closeButton = document.querySelector('.navigation-close-button'); 86 if (closeButton) { 87 closeButton.addEventListener('click', function(e) { 88 e.preventDefault(); 89 toggleMenu(); 90 }); 91 92 // Handle Space key explicitly (Enter is handled by click event) 93 closeButton.addEventListener('keydown', function(e) { 94 if (e.key === ' ' || e.keyCode === 32) { 95 e.preventDefault(); 96 toggleMenu(); 97 } 98 }); 99 } 100 101 // Hide Header on scroll down 102 var didScroll; 103 var lastScrollTop = 0; 104 var delta = 5; 105 var mainNav = document.querySelector('.main-nav'); 106 var navbarHeight = mainNav ? mainNav.offsetHeight : 0; 107 108 window.addEventListener('scroll', function(event) { 109 didScroll = true; 110 }); 111 112 // Check every 250 ms if user scrolled 113 setInterval(function() { 114 if (didScroll) { 115 hasScrolled(); 116 didScroll = false; 117 } 118 }, 250); 119 120 function hasScrolled() { 121 var st = window.pageYOffset || document.documentElement.scrollTop; 122 123 // Make sure they scroll more than delta 124 if (Math.abs(lastScrollTop - st) <= delta) { 125 return; 126 } 127 128 // If they scrolled down and are past the navbar, add class .nav-up. 129 // This is necessary so you never see what is "behind" the navbar. 130 if (st > lastScrollTop && st > navbarHeight) { 131 // Scroll Down 132 if (mainNav) { 133 mainNav.classList.remove('nav-down'); 134 mainNav.classList.add('nav-up'); 135 } 136 } else { 137 // Scroll Up 138 if (st + window.innerHeight < document.documentElement.scrollHeight) { 139 if (mainNav) { 140 mainNav.classList.remove('nav-up'); 141 mainNav.classList.add('nav-down'); 142 } 143 } 144 } 145 146 lastScrollTop = st; 147 } 148 149 // Search Button Form Toggle 150 var searchButton = document.querySelector('.search-button'); 151 if (searchButton) { 152 searchButton.addEventListener('click', function() { 153 var searchBar = document.querySelector('#search-bar'); 154 var searchInput = document.querySelector('#s'); 155 var flyFade = document.querySelector('.fly-fade'); 156 157 if (searchBar) { 158 // Ensure transition classes are present 159 searchBar.classList.add('transition-opacity', 'duration-300'); 160 161 // Toggle visibility with Tailwind classes 162 var isVisible = !searchBar.classList.contains('hidden') && 163 !searchBar.classList.contains('opacity-0'); 164 165 if (isVisible) { 166 // Fade out 167 searchBar.classList.add('opacity-0'); 168 setTimeout(function() { 169 searchBar.classList.add('hidden'); 170 searchBar.classList.remove('opacity-0', 'showing'); 171 }, 300); 172 } else { 173 // Fade in 174 searchBar.classList.remove('hidden'); 175 searchBar.classList.add('opacity-0'); 176 searchBar.offsetHeight; // Force reflow 177 searchBar.classList.remove('opacity-0'); 178 searchBar.classList.add('opacity-100', 'showing'); 179 } 180 181 if (searchInput) { 182 searchInput.value = ''; 183 searchInput.focus(); 184 } 185 186 if (flyFade) { 187 flyFade.classList.toggle('fly-fade-trans'); 188 } 189 } 190 }); 191 } 192 193 // Search Close Button 194 var searchCloseButton = document.querySelector('.search-close-button'); 195 if (searchCloseButton) { 196 searchCloseButton.addEventListener('click', function() { 197 var searchBar = document.querySelector('#search-bar'); 198 if (searchBar) { 199 searchBar.classList.remove('showing', 'opacity-100'); 200 searchBar.classList.add('hidden', 'opacity-0'); 201 } 202 }); 203 } 204 205 // Close Sticky Ad Button 206 var topFoldInterfaceButton = document.querySelector('#top_fold_interface button'); 207 if (topFoldInterfaceButton) { 208 topFoldInterfaceButton.addEventListener('click', function() { 209 var body = document.body; 210 var topFold = document.querySelector('#top_fold'); 211 212 if (body) { 213 body.classList.remove('stickyadunit'); 214 body.classList.add('stickyadunit--removed'); 215 } 216 217 if (topFold) { 218 topFold.classList.add('natural-height'); 219 } 220 }); 221 } 222 223}); 224 225function setCookie(name, value, days) { 226 var expires = ""; 227 if (days) { 228 var date = new Date(); 229 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 230 expires = "; expires=" + date.toUTCString(); 231 } 232 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 233} 234 235function getCookie(name) { 236 var nameEQ = name + "="; 237 var ca = document.cookie.split(';'); 238 for (var i = 0; i < ca.length; i++) { 239 var c = ca[i]; 240 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 241 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 242 } 243 return null; 244} 245
246function eraseCookie(name) { 247 document.cookie = name + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; 248}
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.