1(function () { 2 'use strict'; 3 var header = document.querySelector('.site-header'); 4 if (header) { 5 var onScrollHeader = function () { 6 header.classList.toggle('is-scrolled', window.scrollY > 10); 7 }; 8 window.addEventListener('scroll', onScrollHeader, { passive: true }); 9 onScrollHeader(); 10 } 11 var searchWrap = document.querySelector('.header-search'); 12 var searchBtn = document.querySelector('.search-toggle-btn'); 13 if (searchWrap && searchBtn) { 14 searchBtn.addEventListener('click', function (e) { 15 e.stopPropagation(); 16 var isOpen = searchWrap.classList.toggle('is-open'); 17 if (isOpen) { 18 var input = searchWrap.querySelector('input[type="search"]'); 19 if (input) input.focus(); 20 } 21 }); 22 document.addEventListener('click', function (e) { 23 if (!searchWrap.contains(e.target)) { 24 searchWrap.classList.remove('is-open'); 25 } 26 }); 27 } 28 var mobileToggle = document.querySelector('.mobile-menu-toggle'); 29 var mainNav = document.querySelector('.main-navigation'); 30 var backdrop = document.querySelector('.mobile-nav-backdrop'); 31 function closeMobileNav() { 32 if (mainNav) { 33 mainNav.classList.remove('is-open'); 34 var expandedItems = mainNav.querySelectorAll('.menu-item-has-children.is-expanded'); 35 expandedItems.forEach(function (item) { 36 item.classList.remove('is-expanded'); 37 }); 38 } 39 if (mobileToggle) { 40 mobileToggle.classList.remove('is-active'); 41 mobileToggle.setAttribute('aria-expanded', 'false'); 42 mobileToggle.blur(); 43 } 44 if (backdrop) backdrop.classList.remove('is-visible'); 45 } 46 function openMobileNav() { 47 if (mainNav) mainNav.classList.add('is-open'); 48 if (mobileToggle) { 49 mobileToggle.classList.add('is-active'); 50 mobileToggle.setAttribute('aria-expanded', 'true'); 51 } 52 if (backdrop) backdrop.classList.add('is-visible'); 53 } 54 if (mobileToggle && mainNav) { 55 mobileToggle.addEventListener('click', function (e) { 56 e.stopPropagation(); 57 var isOpen = mainNav.classList.contains('is-open'); 58 if (isOpen) { 59 closeMobileNav(); 60 } else { 61 openMobileNav(); 62 } 63 }); 64 if (backdrop) { 65 backdrop.addEventListener('click', closeMobileNav); 66 } 67 var parentLinks = mainNav.querySelectorAll('.menu-item-has-children > a'); 68 parentLinks.forEach(function (link) { 69 link.addEventListener('click', function (e) { 70 if (window.innerWidth <= 900) { 71 e.preventDefault(); 72 link.parentElement.classList.toggle('is-expanded'); 73 } 74 }); 75 }); 76 document.addEventListener('keydown', function (e) { 77 if (e.key === 'Escape' && mainNav.classList.contains('is-open')) { 78 closeMobileNav(); 79 } 80 }); 81 window.addEventListener('resize', function () { 82 if (window.innerWidth > 900 && mainNav.classList.contains('is-open')) { 83 closeMobileNav(); 84 } 85 }); 86 } 87 var noHoverSupport = window.matchMedia('(hover: none)').matches; 88 if (noHoverSupport) { 89 var desktopDropdownLinks = document.querySelectorAll( 90 '.main-navigation > .menu > .menu-item-has-children:not(.menu-item-more) > a' 91 ); 92 desktopDropdownLinks.forEach(function (link) { 93 link.addEventListener('click', function (e) { 94 if (window.innerWidth <= 900) return; 95 var parent = link.parentElement; 96 if (!parent.classList.contains('is-tap-open')) { 97 e.preventDefault(); 98 desktopDropdownLinks.forEach(function (l) { 99 l.parentElement.classList.remove('is-tap-open'); 100 }); 101 parent.classList.add('is-tap-open'); 102 } 103 }); 104 }); 105 document.addEventListener('click', function (e) { 106 if (!e.target.closest('.main-navigation > .menu > .menu-item-has-children')) { 107 desktopDropdownLinks.forEach(function (l) { 108 l.parentElement.classList.remove('is-tap-open'); 109 }); 110 } 111 }); 112 } 113 (function () { 114 var nav = document.querySelector('.main-navigation'); 115 var menu = nav ? nav.querySelector('.menu') : null; 116 if (!nav || !menu) return; 117 var originalItems = Array.prototype.slice.call(menu.children); 118 var moreItem, moreList; 119 var HN_MORE_ICON_SVG =
120 '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" ' + 121 'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">' + 122 '<circle cx="12" cy="12" r="3"/>' + 123 '<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82A1.65 1.65 0 0 0 3 13.09H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>' + 124 '</svg>'; 125 function buildMoreItem() { 126 var label = ( typeof hnNavigationData !== 'undefined' && hnNavigationData.moreLabel ) 127 ? hnNavigationData.moreLabel 128 : 'Lainnya'; 129 moreItem = document.createElement('li'); 130 moreItem.className = 'menu-item menu-item-has-children menu-item-more'; 131 var link = document.createElement('a'); 132 link.href = '#'; 133 link.setAttribute('aria-haspopup', 'true'); 134 link.setAttribute('aria-expanded', 'false'); 135 var iconSpan = document.createElement('span'); 136 iconSpan.className = 'menu-icon'; 137 iconSpan.innerHTML = HN_MORE_ICON_SVG; 138 link.appendChild(iconSpan); 139 var textSpan = document.createElement('span'); 140 textSpan.className = 'menu-text'; 141 textSpan.textContent = label; 142 link.appendChild(textSpan); 143 var caretSpan = document.createElement('span'); 144 caretSpan.className = 'menu-caret'; 145 caretSpan.textContent = 'â¾'; 146 link.appendChild(caretSpan); 147 link.addEventListener('click', function (e) { 148 e.preventDefault(); 149 e.stopPropagation(); 150 var isOpen = moreItem.classList.toggle('is-open'); 151 link.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); 152 }); 153 moreList = document.createElement('ul'); 154 moreList.className = 'sub-menu'; 155 moreItem.appendChild(link); 156 moreItem.appendChild(moreList); 157 } 158 function restoreAll() { 159 originalItems.forEach(function (item) { 160 item.classList.remove('menu-item-more-child'); 161 menu.appendChild(item); 162 }); 163 } 164 function recalc() { 165 if (window.innerWidth <= 900) { 166 restoreAll(); 167 return; 168 } 169 restoreAll(); 170 var containerWidth = nav.clientWidth; 171 var totalWidth = 0; 172 originalItems.forEach(function (item) { totalWidth += item.offsetWidth; }); 173 if (totalWidth <= containerWidth) return; 174 if (!moreItem) buildMoreItem(); 175 menu.appendChild(moreItem); 176 var moreWidth = moreItem.offsetWidth; 177 menu.removeChild(moreItem); 178 var used = 0, visible = [], overflow = []; 179 originalItems.forEach(function (item) { 180 used += item.offsetWidth; 181 if (used + moreWidth > containerWidth) { 182 overflow.push(item); 183 } else { 184 visible.push(item); 185 } 186 }); 187 if (overflow.length === 0) return; 188 menu.innerHTML = ''; 189 visible.forEach(function (item) { menu.appendChild(item); }); 190 moreList.innerHTML = ''; 191 overflow.forEach(function (item) { 192 item.classList.add('menu-item-more-child'); 193 moreList.appendChild(item); 194 }); 195 menu.appendChild(moreItem); 196 } 197 recalc(); 198 if ( document.fonts && document.fonts.ready ) { 199 document.fonts.ready.then(function () { 200 recalc(); 201 }); 202 } 203 window.addEventListener('load', recalc); 204 var resizeTimer; 205 window.addEventListener('resize', function () { 206 clearTimeout(resizeTimer); 207 resizeTimer = setTimeout(recalc, 150); 208 }); 209 document.addEventListener('click', function (e) { 210 if (moreItem && !moreItem.contains(e.target)) { 211 moreItem.classList.remove('is-open'); 212 var link = moreItem.querySelector('a'); 213 if (link) link.setAttribute('aria-expanded', 'false'); 214 } 215 }); 216 })(); 217 var backToTop = document.querySelector('.back-to-top'); 218 if (backToTop) { 219 var toggleBackToTop = function () { 220 backToTop.classList.toggle('is-visible', window.scrollY > 400); 221 }; 222 window.addEventListener('scroll', toggleBackToTop, { passive: true }); 223 toggleBackToTop(); 224 backToTop.addEventListener('click', function () { 225 window.scrollTo({ top: 0, behavior: 'smooth' }); 226 }); 227 } 228 var progressFill = document.querySelector('.reading-progress-fill'); 229 var articleEl = document.querySelector('.single-article'); 230 if (progressFill && articleEl) { 231 var updateProgress = function () { 232 var articleTop = articleEl.offsetTop; 233 var articleHeight = articleEl.offsetHeight; 234 var scrolled = window.scrollY - articleTop + window.innerHeight * 0.3; 235 var percent = Math.max(0, Math.min(100, (scrolled / articleHeight) * 100)); 236 progressFill.style.width = percent + '%'; 237 }; 238 window.addEventListener('scroll', updateProgress, { passive: true }); 239 window.addEventListener('resize', updateProgress); 240 updateProgress(); 241 } 242 var copyBtn = document.querySelector('.social-share-copy'); 243 if (copyBtn) { 244 copyBtn.addEventListener('click', function () { 245 var url = copyBtn.getAttribute('data-url'); 246 if (navigator.clipboard) { 247 navigator.clipboard.writeText(url).then(function () { 248 copyBtn.classList.add('is-copied'); 249 setTimeout(function () { copyBtn.classList.remove('is-copied'); }, 1500); 250 }); 251 } 252 }); 253 } 254 var contactForm = document.getElementById('hn-contact-form'); 255 if (contactForm) { 256 contactForm.addEventListener('submit', function (e) { 257 e.preventDefault(); 258 var honeypot = contactForm.querySelector('.hn-contact-honeypot'); 259 if (honeypot && honeypot.checked) return; 260 var resultBox = contactForm.querySelector('.hn-contact-result'); 261 var submitBtn = contactForm.querySelector('.hn-contact-submit'); 262 var submitLabel = contactForm.querySelector('.hn-contact-submit-label'); 263 var originalText = submitLabel ? submitLabel.textContent : ''; 264 if (submitBtn) submitBtn.disabled = true; 265 if (submitLabel) submitLabel.textContent = 'Mengirim...'; 266 var formData = new FormData(contactForm); 267 var payload = {}; 268 formData.forEach(function (value, key) { payload[key] = value; }); 269 fetch('https://splitforms.com/api/submit', { 270 method: 'POST', 271 headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, 272 body: JSON.stringify(payload) 273 }) 274 .then(function (response) { 275 return response.json().then(function (result) { 276 return { ok: response.ok, result: result }; 277 }); 278 }) 279 .then(function (data) { 280 if (!resultBox) return; 281 resultBox.classList.remove('is-success', 'is-error'); 282 if (data.ok && data.result && data.result.success) { 283 resultBox.classList.add('is-success'); 284 resultBox.textContent = 'Terima kasih! Pesan kamu berhasil dikirim.'; 285 contactForm.reset(); 286 } else { 287 resultBox.classList.add('is-error'); 288 resultBox.textContent = 'Maaf, terjadi kesalahan. Silakan coba lagi.'; 289 } 290 }) 291 .catch(function () { 292 if (!resultBox) return; 293 resultBox.classList.remove('is-success'); 294 resultBox.classList.add('is-error'); 295 resultBox.textContent = 'Maaf, terjadi kesalahan koneksi. Silakan coba lagi.'; 296 }) 297 .finally(function () { 298 if (submitBtn) submitBtn.disabled = false;
299 if (submitLabel) submitLabel.textContent = originalText; 300 }); 301 }); 302 } 303})();
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.