jQuery(function ($) { "use strict"; // Handle preloader const loader = document.querySelector(".preloader"); if (loader) { // Check if page is already loaded if (document.readyState === 'complete') { loader.style.display = "none"; } else { // Handle loading on mobile and desktop window.addEventListener('load', function() { loader.style.opacity = "0"; loader.style.transition = "opacity 0.3s ease-out"; setTimeout(() => { loader.style.display = "none"; }, 300); }); // Fallback - hide loader after maximum wait time (3 seconds) setTimeout(() => { if (loader.style.display !== "none") { loader.style.display = "none"; } }, 3000); } } // Handle header scroll behavior function handleHeaderScroll() { const scroll = $(window).scrollTop(); const header = $(".header"); if (scroll < 100) { header.removeClass("animated fadeInDown menu-fixed"); } else { header.addClass("animated fadeInDown menu-fixed"); } } // Handle scroll to top visibility function handleScrollToTop() { if ($(this).scrollTop() > 200) { $(".scroll-to-top").fadeIn(200); } else { $(".scroll-to-top").fadeOut(200); } } $(".elementor").parents(".sec-mar").removeClass("sec-mar"); // Initialize all sliders function initSliders() { // Winner slider $('.winner-slider').not('.slick-initialized').slick({ speed: 700, arrows: true, dots: false, nextArrow: '', prevArrow: '', }); // Testimonial slider $('.testimonial-slider').not('.slick-initialized').slick({ autoplay: true, speed: 700, arrows: false, vertical: true, verticalSwiping: true, }); // Contest slider $('.contest-slider').not('.slick-initialized').slick({ slidesToShow: 3, slidesToScroll: 1, infinite: false, speed: 700, arrows: true, dots: false, nextArrow: '', prevArrow: '', responsive: [{ breakpoint: 1200, settings: { slidesToShow: 2 } }, { breakpoint: 768, settings: { slidesToShow: 1 } }] }); // Initialize other sliders... // (keeping other slider initializations but they follow the same pattern) } // Initialize countdown timers function initCountdowns() { const clock = $('.clock'); const clock2 = $('.clock2'); if (clock.length) { clock.countdown(clock.attr('data-clock'), function(event) { $(this).html(event.strftime('' + '
%D

days

' + '
%H

hours

' + '
%M

minutes

' + '
%S

seconds

')); }); } if (clock2.length) { clock2.countdown(clock2.attr('data-clock'), function(event) { $(this).html(event.strftime('' + '
%D

d

' + '
%H

h

' + '
%M

m

' + '
%S

s

')); }); } } // Document ready handlers $(function() { // Initialize nice select if ($.fn.niceSelect) { $('select').niceSelect(); } // Initialize tooltips if ($.fn.tooltip) { $('[data-toggle="tooltip"]').tooltip(); } // Mobile menu handling $(".navbar-collapse>ul>li>a, .navbar-collapse ul.sub-menu>li>a").on("click", function() { const element = $(this).parent("li"); if (element.hasClass("open")) { element.removeClass("open"); element.find("li").removeClass("open"); } else { element.addClass("open"); element.siblings("li").removeClass("open"); element.siblings("li").find("li").removeClass("open"); } }); // Initialize lightcase if ($.fn.lightcase) { $('a[data-rel^=lightcase]').lightcase(); } // Background image handling $('.bg_img').css('background-image', function() { return 'url(' + $(this).data('background') + ')'; }); // Initialize sliders initSliders(); // Initialize countdowns initCountdowns(); // Scroll handlers $(window).on("scroll", handleHeaderScroll); $(window).on("scroll", handleScrollToTop); // Initial header check handleHeaderScroll(); // Scroll to top click handler $(".scroll-to-top").on("click", function(event) { event.preventDefault(); $("html, body").animate({ scrollTop: 0 }, 300); }); // Theme switcher $('.theme-switcher__icon').on('click', function() { $('.theme-switcher').toggleClass('active'); }); }); });