PageSourceSearch

https://techychennai.com/wp-content/themes/techychennai-child/assets/bident-nav.js?ver=3.9.2

js techychennai.com collected 2026-10-02 02:13:12 UTC 4,543 bytes, 122 lines download raw bytes

1/* Bident nav behaviour: collapse on scroll, and a timed auto-hide —
2   stays visible for N seconds after you stop scrolling, then tucks away.
3   Reveals again on any scroll or when hovering the top edge. */
4(function () {
5  var nav = document.getElementById('tcnav');
6  if (!nav) return;
7
8  // Escape any transformed/positioned wrapper (Blocksy's container uses a
9  // transform for its off-canvas panel, which would trap position:fixed).
10  if (nav.parentNode !== document.body) {
11    document.body.insertBefore(nav, document.body.firstChild);
12  }
13
14  // Height + spacer: reserve = top gap (14) + pill height + adjustable gap below.
15  var pillH = parseInt(nav.getAttribute('data-height'), 10) || 76;
16  var gapB  = parseInt(nav.getAttribute('data-gap'), 10);
17  if (isNaN(gapB)) gapB = 16;
18  var reserve = 14 + pillH + gapB;
19  document.body.style.setProperty('--tcnav-h', reserve + 'px');
20
21  // Physical spacer in normal flow — guarantees a gap the theme can't collapse.
22  if (nav.getAttribute('data-sticky') === '1' && !document.getElementById('tcnav-spacer')) {
23    var sp = document.createElement('div');
24    sp.id = 'tcnav-spacer';
25    sp.style.height = reserve + 'px';
26    sp.style.flex = 'none';
27    nav.insertAdjacentElement('afterend', sp);
28  }
29
30  // Icon-only search: click the lens to expand the field.
31  if (nav.getAttribute('data-search') === 'icon') {
32    var sform = nav.querySelector('.tcnav-search');
33    if (sform) {
34      var lens = sform.querySelector('.tcnav-lens');
35      var sinput = sform.querySelector('.tcnav-sinput');
36      (lens || sform).addEventListener('click', function (e) {
37        if (!sform.classList.contains('tc-open')) {
38          e.preventDefault();
39          sform.classList.add('tc-open');
40          if (sinput) sinput.focus();
41        }
42      });
43      document.addEventListener('click', function (e) {
44        if (!sform.contains(e.target)) sform.classList.remove('tc-open');
45      });
46    }
47  }
48
49  var sticky    = nav.getAttribute('data-sticky') === '1';
50  var reveal    = nav.getAttribute('data-reveal') || 'delay'; // always | delay | scrollup
51  var threshold = parseInt(nav.getAttribute('data-threshold'), 10) || 64;
52  var delayMs   = (parseFloat(nav.getAttribute('data-hidedelay')) || 0) * 1000;
53
54  // Hamburger (mobile)
55  var burger = nav.querySelector('.tcnav-burger');
56  var mobile = nav.querySelector('.tcnav-mobile');
57  if (burger && mobile) {
58    burger.addEventListener('click', function () {
59      var open = burger.getAttribute('aria-expanded') === 'true';
60      burger.setAttribute('aria-expanded', String(!open));
61      mobile.hidden = open;
62    });
63    document.addEventListener('click', function (e) {
64      if (!nav.contains(e.target) && burger.getAttribute('aria-expanded') === 'true') {
65        burger.setAttribute('aria-expanded', 'false'); mobile.hidden = true;
66      }
67    });
68  }
69
70  var hideTimer = null, lastY = 0, ticking = false;
71  function y() { return window.pageYOffset || document.documentElement.scrollTop || 0; }
72
73  function scheduleHide() {
74    clearTimeout(hideTimer);
75    if (sticky && reveal === 'delay' && delayMs > 0) {
76      hideTimer = setTimeout(function () {
77        if (y() > threshold) nav.classList.add('tc-hidden');
78      }, delayMs);
79    }
80  }
81
82  function show() {
83    nav.classList.remove('tc-hidden');
84    scheduleHide();
85  }
86
87  function update() {
88    ticking = false;
89    if (!sticky) { nav.classList.remove('tc-on', 'tc-hidden'); lastY = y(); return; }
90
91    var cur = y();
92    // collapsed (corner-pods) styling past the threshold
93    if (cur > threshold) nav.classList.add('tc-on');
94    else { nav.classList.remove('tc-on', 'tc-hidden'); lastY = cur; return; }
95
96    if (reveal === 'always') {
97      nav.classList.remove('tc-hidden');
98    } else if (reveal === 'delay') {
99      show(); // visible on activity, hides after the delay
100    } else if (reveal === 'scrollup') {
101      // hidden while scrolling down; appears on scroll-up
102      if (cur > lastY + 4) nav.classList.add('tc-hidden');
103      else if (cur < lastY - 4) nav.classList.remove('tc-hidden');
104    }
105    lastY = cur;
106  }
107
108  function onScroll() {
109    if (!ticking) { window.requestAnimationFrame(update); ticking = true; }
110  }
111  window.addEventListener('scroll', onScroll, { passive: true });
112
113  // Nudge the top edge to bring the nav back.
114  window.addEventListener('mousemove', function (e) {
115    if (e.clientY <= 16 && reveal !== 'always') {
116      nav.classList.remove('tc-hidden');
117      if (reveal === 'delay') scheduleHide();
118    }
119  }, { passive: true });
120
121  update();
122})();

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.