; (function($) { "use strict"; //Mobile Menu $("#primary-menu").slicknav({ allowParentLinks: true, prependTo: '#mobile', label: 'Menu', }); var sf = $('#primary-menu').superfish({ delay: 500, // one second delay on mouseout animation: { opacity: 'show', height: 'show' }, // fade-in and slide-down animation speed: 'fast', // faster animation speed }); // Header Search if ($(".search-open").length) { $(".search-open").on("click", function(e) { e.preventDefault(); $(".header-search-popup").toggleClass("active"); }); } // Sticky Menu Premium $(window).on('scroll', function() { var scroll = $(window).scrollTop(); if (scroll < 100) { $("#sticky-header").removeClass("sticky-bar"); } else { $("#sticky-header").addClass("sticky-bar"); } }); // Theme Preloader $(window).on("load", function() { if ($(".preloader-area").length) { $(".preloader-area").fadeOut(); } }); // Post Slider if( $(".post-slider-box").length ){ function GrowupMainSlider() { var GrowupSlider = $('.post-slider-box'); GrowupSlider.on('init', function (e, slick) { var $firstAnimatingElements = $('.post-slide-item:first-child').find('[data-animation]'); doAnimations($firstAnimatingElements); }); GrowupSlider.on('beforeChange', function (e, slick, currentSlide, nextSlide) { var $animatingElements = $('.post-slide-item[data-slick-index="' + nextSlide + '"]').find('[data-animation]'); doAnimations($animatingElements); }); GrowupSlider.slick({ autoplay: true, autoplaySpeed: 8000, dots: false, fade: true, arrows: true, prevArrow: '', nextArrow: '', }); function doAnimations(elements) { var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; elements.each(function () { var $this = $(this); var $animationDelay = $this.data('delay'); var $animationType = 'animated ' + $this.data('animation'); $this.css({ 'animation-delay': $animationDelay, '-webkit-animation-delay': $animationDelay }); $this.addClass($animationType).one(animationEndEvents, function () { $this.removeClass($animationType); }); }); } } GrowupMainSlider(); } // Bottom to top $(window).on('scroll', function() { if ($(this).scrollTop() > 300) { $('#back-top').fadeIn(); } else { $('#back-top').fadeOut(); } }); $('#back-top').on('click', function() { $("html, body").animate({ scrollTop: 0 }, 1000); return false; }); // PopUp Video if( $(".mfp-iframe").length ){ $('.mfp-iframe').magnificPopup({ type: 'iframe', mainClass: 'mfp-fade', removalDelay: 160, preloader: false, fixedContentPos: false }); } // Post Gallerly if ($('.post-gallery').length) { $('.post-gallery').slick({ dots: false, infinite: true, speed: 700, cssEase: 'linear', autoplay: true, autoplaySpeed: 2000, arrows: true, prevArrow: '', nextArrow: '', }); } // Theme Dark And Light Mode Options document.addEventListener('DOMContentLoaded', function() { const darkSwitch = document.querySelector('#darkswitch'); const htmlElement = document.querySelector('html'); function setThemeMode(mode) { htmlElement.setAttribute('data-theme-mode', mode); localStorage.setItem('themeMode', mode); } function loadThemeMode() { const storedTheme = localStorage.getItem('themeMode'); const defaultTheme = 'light'; if (storedTheme) { setThemeMode(storedTheme); if (darkSwitch) { darkSwitch.checked = storedTheme === 'dark'; } } else { setThemeMode(defaultTheme); if (darkSwitch) { darkSwitch.checked = defaultTheme === 'dark'; } } } if (darkSwitch) { darkSwitch.addEventListener('click', function () { if (darkSwitch.checked) { setThemeMode('dark'); } else { setThemeMode('light'); } }); } loadThemeMode(); }); }(jQuery))