PageSourceSearch

https://www.jurnal.id/wp-content/cache/min/1/wp-content/themes/jur…/js/topbar-observer.js?ver=1787738298

js jurnal.id collected 2026-09-24 09:29:13 UTC 7,140 bytes, 36 lines download raw bytes

1(function(){'use strict';function runWhenIdle(fn,timeout){const idleTimeout=typeof timeout==='number'?timeout:1200;if('requestIdleCallback' in window){window.requestIdleCallback(fn,{timeout:idleTimeout});return}
2window.setTimeout(fn,1)}
3function onReady(fn){if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',fn,{once:!0});return}
4fn()}
5function debounce(fn,wait){let timeoutId=0;return function(){window.clearTimeout(timeoutId);timeoutId=window.setTimeout(fn,wait)}}
6function bindMediaChange(mediaQueryList,handler){if(!mediaQueryList)return;if(typeof mediaQueryList.addEventListener==='function'){mediaQueryList.addEventListener('change',handler);return}
7if(typeof mediaQueryList.addListener==='function'){mediaQueryList.addListener(handler)}}
8function logoOnMobile(){var container=document.querySelector('.topbar__logos-flip');if(!container)return;var logos=Array.from(container.querySelectorAll('.logo-item'));if(logos.length<=1)return;var mobileMedia=window.matchMedia('(max-width: 991px)');var reducedMotion=window.matchMedia('(prefers-reduced-motion: reduce)');var animDuration=300;var delay=5000;var current=0;var rotateTimer=0;var transitionTimer=0;function clearRotateTimer(){if(!rotateTimer)return;window.clearTimeout(rotateTimer);rotateTimer=0}
9function clearTransitionTimer(){if(!transitionTimer)return;window.clearTimeout(transitionTimer);transitionTimer=0}
10function shouldRotate(){return mobileMedia.matches&&!reducedMotion.matches&&!document.hidden}
11function resetLogos(){clearRotateTimer();clearTransitionTimer();current=0;logos.forEach(function(logo,idx){logo.classList.remove('active','is-entering','is-leaving');if(idx===0){logo.classList.add('active')}});scheduleNext()}
12function scheduleNext(){clearRotateTimer();if(!shouldRotate())return;rotateTimer=window.setTimeout(rotate,delay)}
13function rotate(){if(!shouldRotate())return;var next=(current+1)%logos.length;var currentLogo=logos[current];var nextLogo=logos[next];nextLogo.classList.remove('active','is-leaving');nextLogo.classList.add('is-entering');currentLogo.classList.remove('is-entering');window.requestAnimationFrame(function(){currentLogo.classList.remove('active');currentLogo.classList.add('is-leaving');nextLogo.classList.remove('is-entering');nextLogo.classList.add('active');transitionTimer=window.setTimeout(function(){currentLogo.classList.remove('is-leaving');current=next;transitionTimer=0;scheduleNext()},animDuration)})}
14resetLogos();document.addEventListener('visibilitychange',function(){if(document.hidden){clearRotateTimer();return}
15scheduleNext()});bindMediaChange(mobileMedia,resetLogos);bindMediaChange(reducedMotion,resetLogos)}
16function initTopbarObserver(bufferPx=150,deadPx=24,dwellMs=140){const header=document.querySelector('.header-inline')||document.querySelector('[class^="header-inline"]')||document.querySelector('header');const topbar=(header&&header.querySelector('.topbar'))||document.getElementById('header-topbar')||document.querySelector('.topbar');if(!topbar)return;topbar.classList.add('topbar--pending');const ZONES_SEL=['section[class*="masthead"]','section[class*="hero"]','div[class*="masthead"]','div[class*="hero"]','main[class*="masthead"]','main[class*="hero"]','article[class*="masthead"]','article[class*="hero"]','header[class*="masthead"]','header[class*="hero"]','div[class*="highlight-area"]','header[class*="blog__header"]','div[class*="search__hero"]','section[class*="ebook-highlight"]','div[class*="ins-ebook-single-s1"]','section[class*="tb-trigger"]','div[class*="tb-trigger"]'].join(', ');const getHeaderH=()=>(header?(header.offsetHeight||0):0);let zones=[];let ranges=[];let ticking=!1;let headerHeight=getHeaderH();let resizeObserver=null;let hasCommittedInitialState=!1;function matchesZone(el){return!!(el&&el.matches&&el.matches(ZONES_SEL))}
17function hasRelevantZone(node){if(!node||node.nodeType!==1)return!1;if(matchesZone(node))return!0;return!!(node.querySelector&&node.querySelector(ZONES_SEL))}
18const scheduleRebuild=debounce(()=>{rebuildAndEval()},120);let committedHidden=null;let candidateHidden=null;let candidateSince=0;function queryZones(){zones=Array.from(document.querySelectorAll(ZONES_SEL)).filter(el=>el.getClientRects().length>0)}
19function computeRanges(){headerHeight=getHeaderH();ranges=zones.map(z=>{const rect=z.getBoundingClientRect();const top=rect.top+window.scrollY;return{top,bottom:top+rect.height}})}
20function inBuffered(line,buf){for(const r of ranges){if(line>=(r.top-buf)&&line<=(r.bottom+buf))return!0}
21return!1}
22function decideHidden(line){const bufHide=bufferPx+deadPx;const bufShow=Math.max(0,bufferPx-deadPx);if(committedHidden===!0){return!inBuffered(line,bufShow)}else{return!inBuffered(line,bufHide)}}
23function applyHidden(hidden){if(committedHidden===hidden)return;committedHidden=hidden;topbar.classList.toggle('hide',hidden);if(!hasCommittedInitialState){hasCommittedInitialState=!0;topbar.classList.remove('topbar--pending')}}
24function reevaluate(forceCommit){ticking=!1;if(ranges.length===0){applyHidden(!0);return}
25const line=Math.round(window.scrollY+headerHeight);const wantHidden=decideHidden(line);if(forceCommit===!0||committedHidden===null){candidateHidden=wantHidden;candidateSince=performance.now();applyHidden(wantHidden);return}
26const now=performance.now();if(candidateHidden!==wantHidden){candidateHidden=wantHidden;candidateSince=now;return}
27if((now-candidateSince)>=dwellMs){applyHidden(candidateHidden)}}
28function onScroll(){if(!ticking){ticking=!0;requestAnimationFrame(reevaluate)}}
29function rebuildAndEval(){topbar.classList.add('is-resizing');queryZones();computeRanges();if('ResizeObserver' in window){if(resizeObserver){resizeObserver.disconnect()}
30resizeObserver=new ResizeObserver(scheduleRebuild);if(header)resizeObserver.observe(header);zones.forEach(zone=>resizeObserver.observe(zone))}
31requestAnimationFrame(()=>{candidateHidden=null;candidateSince=performance.now();reevaluate(!0);requestAnimationFrame(()=>topbar.classList.remove('is-resizing'))})}
32rebuildAndEval();window.addEventListener('scroll',onScroll,{passive:!0});const onResize=scheduleRebuild;window.addEventListener('resize',onResize,{passive:!0});if(window.visualViewport){window.visualViewport.addEventListener('resize',onResize,{passive:!0})}
33const mo=new MutationObserver((mutations)=>{for(let i=0;i<mutations.length;i++){const mutation=mutations[i];if(!mutation)continue;if(mutation.type==='childList'){for(let j=0;j<mutation.addedNodes.length;j++){if(hasRelevantZone(mutation.addedNodes[j])){scheduleRebuild();return}}
34for(let j=0;j<mutation.removedNodes.length;j++){if(hasRelevantZone(mutation.removedNodes[j])){scheduleRebuild();return}}}}});mo.observe(document.documentElement,{childList:!0,subtree:!0});function disconnectZoneObserver(){mo.disconnect()}
35if(document.readyState==='complete'){reevaluate(!0);window.setTimeout(disconnectZoneObserver,3000)}else{window.addEventListener('load',()=>{scheduleRebuild();reevaluate(!0);window.setTimeout(disconnectZoneObserver,3000)},{once:!0})}}
36onReady(function(){runWhenIdle(logoOnMobile,1200);window.requestAnimationFrame(function(){initTopbarObserver(150,24,140)})})})()

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.