1(function () { 2 'use strict'; 3 4 document.addEventListener('DOMContentLoaded', function () { 5 var pill = document.getElementById('snp-nav-pill'); 6 if (!pill) return; 7 8 var hamburger = document.getElementById('snp-hamburger-btn'); 9 var dropdown = document.getElementById('snp-dropdown'); 10 11 // Some smooth-scroll libraries wrap the page in a transformed element. 12 // A fixed element inside that wrapper scrolls away with the content, so 13 // place the plugin UI directly under <body> before measuring or showing it. 14 if (pill.parentNode !== document.body) { 15 document.body.appendChild(pill); 16 } 17 if (dropdown && dropdown.parentNode !== document.body) { 18 document.body.appendChild(dropdown); 19 } 20 21 var settings = window.snpSettings || { appearThreshold: 10, expandThreshold: 200 }; 22 23 function measureExpandedWidth() { 24 var wasExpanded = pill.classList.contains('snp-expanded'); 25 var prevTransition = pill.style.transition; 26 var prevTransform = pill.style.transform; 27 28 pill.style.transition = 'none'; 29 pill.style.transform = 'none'; 30 31 if (!wasExpanded) pill.classList.add('snp-expanded'); 32 pill.style.width = 'auto'; 33 34 var w = Math.ceil(pill.getBoundingClientRect().width); 35 pill.style.setProperty('--snp-expanded-width', w + 'px'); 36 37 pill.style.width = ''; 38 if (!wasExpanded) pill.classList.remove('snp-expanded'); 39 pill.style.transform = prevTransform; 40 41 // force reflow before restoring transition 42 void pill.offsetWidth; 43 pill.style.transition = prevTransition; 44 } 45 46 function onScroll() { 47 var y = window.scrollY || window.pageYOffset; 48 var visible = y > settings.appearThreshold; 49 var expanded = y > settings.expandThreshold; 50 51 pill.classList.toggle('snp-visible', visible); 52 pill.classList.toggle('snp-expanded', expanded); 53 54 if (!expanded) { 55 if (hamburger) hamburger.classList.remove('snp-open'); 56 if (dropdown) dropdown.classList.remove('snp-open'); 57 if (hamburger) hamburger.setAttribute('aria-expanded', 'false'); 58 } 59 } 60 61 if (hamburger) { 62 hamburger.addEventListener('click', function () { 63 var isOpen = hamburger.classList.toggle('snp-open'); 64 if (dropdown) dropdown.classList.toggle('snp-open', isOpen); 65 hamburger.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); 66 }); 67 } 68 69 document.addEventListener('click', function (e) { 70 if (!dropdown || !dropdown.classList.contains('snp-open')) return; 71 if (dropdown.contains(e.target) || (hamburger && hamburger.contains(e.target))) return; 72 dropdown.classList.remove('snp-open'); 73 if (hamburger) { 74 hamburger.classList.remove('snp-open'); 75 hamburger.setAttribute('aria-expanded', 'false'); 76 } 77 }); 78 79 var resizeTimer; 80 window.addEventListener('resize', function () { 81 clearTimeout(resizeTimer); 82 resizeTimer = setTimeout(measureExpandedWidth, 150); 83 }); 84 85 window.addEventListener('scroll', onScroll, { passive: true }); 86 87 measureExpandedWidth(); 88 onScroll(); 89 }); 90})();
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.