1/** 2 * News24 Theme - Main JavaScript 3 */ 4 5document.addEventListener('DOMContentLoaded', function() { 6 7 // Mobile Menu Toggle 8 const menuToggle = document.getElementById('menu-toggle'); 9 const mainNav = document.getElementById('main-nav'); 10 11 if (menuToggle && mainNav) { 12 menuToggle.addEventListener('click', function() { 13 mainNav.classList.toggle('active'); 14 15 const spans = this.querySelectorAll('span'); 16 if (mainNav.classList.contains('active')) { 17 spans[0].style.transform = 'rotate(45deg) translate(5px, 5px)'; 18 spans[1].style.opacity = '0'; 19 spans[2].style.transform = 'rotate(-45deg) translate(5px, -5px)'; 20 } else { 21 spans[0].style.transform = 'none'; 22 spans[1].style.opacity = '1'; 23 spans[2].style.transform = 'none'; 24 } 25 }); 26 27 // Close menu when clicking outside 28 document.addEventListener('click', function(e) { 29 if (!menuToggle.contains(e.target) && !mainNav.contains(e.target)) { 30 mainNav.classList.remove('active'); 31 const spans = menuToggle.querySelectorAll('span'); 32 spans[0].style.transform = 'none'; 33 spans[1].style.opacity = '1'; 34 spans[2].style.transform = 'none'; 35 } 36 }); 37 } 38 39 // Lazy load images 40 if ('IntersectionObserver' in window) { 41 const lazyImages = document.querySelectorAll('img[loading="lazy"]'); 42 43 const imageObserver = new IntersectionObserver(function(entries) { 44 entries.forEach(function(entry) { 45 if (entry.isIntersecting) { 46 const img = entry.target; 47 img.classList.add('loaded'); 48 imageObserver.unobserve(img); 49 } 50 }); 51 }); 52 53 lazyImages.forEach(function(img) { 54 imageObserver.observe(img); 55 }); 56 } 57 // Lightbox for article images 58const articleImages = document.querySelectorAll('.n24-article-intro-image img, .n24-article-image img, .n24-article-content img'); 59 60if (articleImages.length > 0) { 61 // Create lightbox element 62 const lightbox = document.createElement('div'); 63 lightbox.className = 'n24-lightbox'; 64 lightbox.innerHTML = '<span class="n24-lightbox-close">×</span><img src="" alt="">'; 65 document.body.appendChild(lightbox); 66 67 const lightboxImg = lightbox.querySelector('img'); 68 const lightboxClose = lightbox.querySelector('.n24-lightbox-close'); 69 70 // Open lightbox on image click 71 articleImages.forEach(function(img) { 72 img.addEventListener('click', function() { 73 lightboxImg.src = this.src; 74 lightboxImg.alt = this.alt; 75 lightbox.classList.add('active'); 76 document.body.style.overflow = 'hidden'; 77 }); 78 }); 79 80 // Close lightbox 81 lightbox.addEventListener('click', function(e) { 82 if (e.target === lightbox || e.target === lightboxClose) { 83 lightbox.classList.remove('active'); 84 document.body.style.overflow = ''; 85 } 86 }); 87 88 // Close on Escape key 89 document.addEventListener('keydown', function(e) { 90 if (e.key === 'Escape' && lightbox.classList.contains('active')) { 91 lightbox.classList.remove('active'); 92 document.body.style.overflow = ''; 93 } 94 }); 95} 96}); 97 98 99/** 100 * Hero Carousel/Slider 101 */ 102var pskCurrentSlide = 0; 103function pskHeroSlide(dir) { 104 var slides = document.querySelectorAll('.hero-carousel .hero-slide'); 105 if (!slides.length) return; 106 slides[pskCurrentSlide].style.display = 'none'; 107 pskCurrentSlide = (pskCurrentSlide + dir + slides.length) % slides.length; 108 slides[pskCurrentSlide].style.display = 'block'; 109} 110 111// Auto-advance carousel every 5s 112(function() { 113 var carousel = document.querySelector('.hero-carousel'); 114 if (carousel) { 115 setInterval(function() { pskHeroSlide(1); }, 5000); 116 } 117})();
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.