1(function() { 2 "use strict"; 3 4 /** 5 * Apply .scrolled class to the body as the page is scrolled down 6 */ 7 function toggleScrolled() { 8 const selectBody = document.querySelector('body'); 9 const selectHeader = document.querySelector('#header'); 10 if (!selectHeader.classList.contains('scroll-up-sticky') && !selectHeader.classList.contains('sticky-top') && !selectHeader.classList.contains('fixed-top')) return; 11 window.scrollY > 100 ? selectBody.classList.add('scrolled') : selectBody.classList.remove('scrolled'); 12 } 13 14 document.addEventListener('scroll', toggleScrolled); 15 window.addEventListener('load', toggleScrolled); 16 17 /** 18 * Mobile nav toggle 19 */ 20 const mobileNavToggleBtn = document.querySelector('.mobile-nav-toggle'); 21 22 function mobileNavToogle() { 23 document.querySelector('body').classList.toggle('mobile-nav-active'); 24 mobileNavToggleBtn.classList.toggle('bi-list'); 25 mobileNavToggleBtn.classList.toggle('bi-x'); 26 } 27 if (mobileNavToggleBtn) { 28 mobileNavToggleBtn.addEventListener('click', mobileNavToogle); 29 } 30 31 /** 32 * Hide mobile nav on same-page/hash links 33 */ 34 document.querySelectorAll('#navmenu a').forEach(navmenu => { 35 navmenu.addEventListener('click', () => { 36 if (document.querySelector('.mobile-nav-active')) { 37 mobileNavToogle(); 38 } 39 }); 40 41 }); 42 43 /** 44 * Toggle mobile nav dropdowns 45 */ 46 document.querySelectorAll('.navmenu .toggle-dropdown').forEach(navmenu => { 47 navmenu.addEventListener('click', function(e) { 48 e.preventDefault(); 49 this.parentNode.classList.toggle('active'); 50 this.parentNode.nextElementSibling.classList.toggle('dropdown-active'); 51 e.stopImmediatePropagation(); 52 }); 53 }); 54 55 /** 56 * Preloader 57 */ 58 const preloader = document.querySelector('#preloader'); 59 if (preloader) { 60 window.addEventListener('load', () => { 61 preloader.remove(); 62 }); 63 } 64 65 /** 66 * Animation on scroll function and init 67 */ 68 function aosInit() { 69 AOS.init({ 70 duration: 600, 71 easing: 'ease-in-out', 72 once: true, 73 mirror: false 74 }); 75 } 76 window.addEventListener('load', aosInit); 77 78 /** 79 * Initiate glightbox 80 */ 81 const glightbox = GLightbox({ 82 selector: '.glightbox' 83 }); 84 85 /** 86 * Initiate Pure Counter 87 */ 88 new PureCounter(); 89 90 /** 91 * Frequently Asked Questions Toggle 92 */ 93 document.querySelectorAll('.faq-item h3, .faq-item .faq-toggle').forEach((faqItem) => { 94 faqItem.addEventListener('click', () => { 95 faqItem.parentNode.classList.toggle('faq-active'); 96 }); 97 }); 98 99 /** 100 * Correct scrolling position upon page load for URLs containing hash links. 101 */ 102 window.addEventListener('load', function(e) { 103 if (window.location.hash) { 104 if (document.querySelector(window.location.hash)) { 105 setTimeout(() => { 106 let section = document.querySelector(window.location.hash); 107 let scrollMarginTop = getComputedStyle(section).scrollMarginTop; 108 window.scrollTo({ 109 top: section.offsetTop - parseInt(scrollMarginTop), 110 behavior: 'smooth' 111 }); 112 }, 100); 113 } 114 } 115 }); 116 117 /** 118 * Navmenu Scrollspy 119 */ 120 let navmenulinks = document.querySelectorAll('.navmenu a'); 121 122 function navmenuScrollspy() { 123 navmenulinks.forEach(navmenulink => { 124 if (!navmenulink.hash) return; 125 let section = document.querySelector(navmenulink.hash); 126 if (!section) return; 127 let position = window.scrollY + 200; 128 if (position >= section.offsetTop && position <= (section.offsetTop + section.offsetHeight)) { 129 document.querySelectorAll('.navmenu a.active').forEach(link => link.classList.remove('active')); 130 navmenulink.classList.add('active'); 131 } else { 132 navmenulink.classList.remove('active'); 133 } 134 }) 135 } 136 window.addEventListener('load', navmenuScrollspy); 137 document.addEventListener('scroll', navmenuScrollspy); 138 139})();
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.