1(function () { 2 function onReady(fn) { 3 if (document.readyState !== 'loading') { 4 fn(); 5 } else { 6 document.addEventListener('DOMContentLoaded', fn); 7 } 8 } 9 10 function easeOutQuart(t) { 11 return 1 - Math.pow(1 - t, 4); 12 } 13 14 function smoothScrollTo(targetY, duration) { 15 var startY = window.scrollY || window.pageYOffset || 0; 16 var diff = targetY - startY; 17 if (duration <= 0 || Math.abs(diff) < 1) { 18 window.scrollTo(0, targetY); 19 return; 20 } 21 var startTime = null; 22 function step(now) { 23 if (startTime === null) { 24 startTime = now; 25 } 26 var t = Math.min(1, (now - startTime) / duration); 27 window.scrollTo(0, startY + diff * easeOutQuart(t)); 28 if (t < 1) { 29 window.requestAnimationFrame(step); 30 } 31 } 32 window.requestAnimationFrame(step); 33 } 34 35 function initLoading() { 36 var loader = document.getElementById('js-loader'); 37 var MIN_MS = 200; 38 var FADE_MS = 500; 39 var OVERLAP_MS = 300; 40 var startTime = (window.performance && performance.now) ? performance.now() : Date.now(); 41 42 function dispatchLoaded() { 43 document.dispatchEvent(new CustomEvent('monogatari:loaded')); 44 } 45 46 function reveal() { 47 if (!loader) { 48 dispatchLoaded(); 49 return; 50 } 51 var now = (window.performance && performance.now) ? performance.now() : Date.now(); 52 var wait = Math.max(0, MIN_MS - (now - startTime)); 53 window.setTimeout(function () { 54 loader.classList.add('is-hidden'); 55 window.setTimeout(dispatchLoaded, Math.max(0, FADE_MS - OVERLAP_MS)); 56 window.setTimeout(function () { 57 loader.classList.add('is-done'); 58 }, FADE_MS); 59 }, wait); 60 } 61 62 if (document.readyState === 'complete') { 63 reveal(); 64 } else { 65 window.addEventListener('load', reveal); 66 } 67 } 68 69 function closeMenu() { 70 var menu = document.querySelector('.js-menu'); 71 var nav = document.getElementById('js-navWrap'); 72 if (menu) { 73 menu.classList.remove('is-active'); 74 } 75 if (nav) { 76 nav.classList.remove('is-active'); 77 } 78 } 79 80 initLoading(); 81 82 onReady(function () { 83 var anchors = document.querySelectorAll('.js-anchor'); 84 Array.prototype.forEach.call(anchors, function (anchor) { 85 anchor.addEventListener('click', function (event) { 86 event.preventDefault(); 87 var href = anchor.getAttribute('href'); 88 var target; 89 if (!href || href === '#') { 90 target = document.documentElement; 91 } else { 92 target = document.querySelector(href); 93 } 94 if (!target) { 95 return; 96 } 97 var position = target.getBoundingClientRect().top + (window.scrollY || window.pageYOffset || 0); 98 smoothScrollTo(position, 1000); 99 closeMenu(); 100 }); 101 }); 102 103 var menuBtn = document.querySelector('.js-menu'); 104 if (menuBtn) { 105 menuBtn.addEventListener('click', function () { 106 menuBtn.classList.toggle('is-active'); 107 var nav = document.getElementById('js-navWrap'); 108 if (!nav) { 109 return; 110 } 111 if (menuBtn.classList.contains('is-active')) { 112 nav.classList.add('is-active'); 113 } else { 114 nav.classList.remove('is-active'); 115 } 116 }); 117 } 118 }); 119})();
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.