$ = jQuery; jQuery(document).ready(function( $ ) { "use strict"; /* ** Main Navigation ===== */ // Navigation Hover $('#top-menu, #main-menu').find('li').on('mouseenter', function() { $(this).children('.sub-menu').stop().fadeIn( 200 ); }).on('mouseleave', function() { $(this).children('.sub-menu').stop().fadeOut( 200 ); }); // Mobile Menu $('.mobile-menu-btn').on( 'click', function() { $('.mobile-menu-container').slideToggle(); }); // Responsive Menu $( '#mobile-menu .menu-item-has-children' ).prepend( '
' ); $( '#mobile-menu .sub-menu' ).before( ' ' ); // Responsive sub-menu btn $('.sub-menu-btn').click(function(){ $(this).closest('li').children('.sub-menu').slideToggle(); $(this).closest('li').children('.sub-menu-btn-icon').children('i').toggleClass( 'fa-rotate-270' ); }); // Search Form $('.main-nav-icons').after($('.main-nav-search #searchform').remove()); var mainNavSearch = $('#main-nav #searchform'); mainNavSearch.find('#s').attr( 'placeholder', mainNavSearch.find('#s').data('placeholder') ); $('.main-nav-search').click(function() { if ( mainNavSearch.css('display') === 'none' ) { mainNavSearch.show(); $('.main-nav-search i:last-of-type').show(); $('.main-nav-search i:first-of-type').hide(); $('.dark-mode-switcher').css('visibility', 'hidden'); } else { mainNavSearch.hide(); $('.main-nav-search i:last-of-type').hide(); $('.main-nav-search i:first-of-type').show(); $('.dark-mode-switcher').css('visibility', 'visible'); } }); /* ** Featured Slider ===== */ var RTL = false; if( $('html').attr('dir') == 'rtl' ) { RTL = true; } $('#featured-slider').slick({ prevArrow: '', nextArrow: '', dotsClass: 'slider-dots', adaptiveHeight: true, rtl: RTL, speed: 750, customPaging: function(slider, i) { return ''; } }); /* ** Single Navigation ===== */ var singleNav = $('.single-navigation'), headerHeight = $('#page-header').outerHeight(); $(window).scroll(function() { if ( $(this).scrollTop() > headerHeight ) { singleNav.fadeIn(); } else { singleNav.fadeOut(); } }); /* ** Sidebars ===== */ // Sidebar Alt Scroll $('.sidebar-alt').perfectScrollbar({ suppressScrollX : true, includePadding : true, wheelSpeed: 3.5 }); // Sidebar Alt $('.main-nav-sidebar').on('click', function () { $('.sidebar-alt').css( 'left','0' ); $('.sidebar-alt-close').fadeIn( 500 ); }); // Sidebar Alt Close function asheAltSidebarClose() { var leftPosition = parseInt( $( ".sidebar-alt" ).outerWidth(), 10 ) + 30; $('.sidebar-alt').css( 'left','-'+ leftPosition +'px' ); $('.sidebar-alt-close').fadeOut( 500 ); } $('.sidebar-alt-close, .sidebar-alt-close-btn').on('click', function () { asheAltSidebarClose(); }); /* ** Scroll Top Button ===== */ $('.scrolltop').on( 'click', function() { $('html, body').animate( { scrollTop : 0 }, 800 ); return false; }); $( window ).on( 'scroll', function() { if ($(this).scrollTop() >= 800 ) { $('.scrolltop').fadeIn(350); } else { $('.scrolltop').fadeOut(350); } }); /* ** Dark Mode */ var darkModeSwitcher = $('.dark-mode-switcher'); if ( darkModeSwitcher.length === 1 ) { var boxedBackground = ''; if ( $('body').hasClass('ashe-boxed-style') ) { boxedBackground = '.featured-slider-area #featured-slider,#featured-links,.category-description,.author-description,.comments-area,article.post,article.blog-post,.single .related-posts,.page-content article.page,.sidebar-left .ashe-widget,.sidebar-right .ashe-widget,.page-footer-inner,.blog-pagination,main#main{background:#333!important}'; } var darkModeCSS = ''; darkModeSwitcher.on( 'click', function() { var body = $( 'body' ); if ( body.hasClass( 'ashe-dark-mode' ) ) { body.removeClass( 'ashe-dark-mode' ); localStorage.setItem( 'asheDarkMode', 'off' ); // Remove darkModeSwitcher.find('i').removeAttr('class').addClass('fa-regular fa-moon'); $('style#ashe_dark_mode').remove(); } else { body.addClass( 'ashe-dark-mode' ); localStorage.setItem( 'asheDarkMode', 'on' ); // Apply darkModeSwitcher.find('i').removeAttr('class').addClass('fa-regular fa-sun'); $('head').append( darkModeCSS ); } }); // Apply on Load if ( 'on' === localStorage.getItem('asheDarkMode') ) { $( 'body' ).addClass( 'ashe-dark-mode' ); darkModeSwitcher.find('i').removeAttr('class').addClass('fa-regular fa-sun'); $('head').append( darkModeCSS ); } } else { if ( 'on' === localStorage.getItem('asheDarkMode') ) { localStorage.setItem( 'asheDarkMode', 'off' ); } } /* ** Window Resize ===== */ $( window ).on( 'resize', function() { if ( $('.mobile-menu-btn').css('display') === 'none' ) { $( '.mobile-menu-container' ).css({ 'display' : 'none' }); } asheStickySidebar(); asheAltSidebarClose(); }); /* ** Run Functions ===== */ // FitVids $('.slider-item, .post-media').fitVids(); }); // end dom ready /* ** Window Load ===== */ jQuery( window ).on( 'load', function() { asheStickySidebar(); ashePreloader(); }); /* ** Global Functions ===== */ // Preloader function ashePreloader() { if ( $('.ashe-preloader-wrap').length ) { setTimeout(function(){ $('.ashe-preloader-wrap > div').fadeOut( 600 ); $('.ashe-preloader-wrap').fadeOut( 1500 ); }, 300); if ( $('body').hasClass('elementor-editor-active') ) { setTimeout(function(){ $('.ashe-preloader-wrap > div').fadeOut( 600 ); $('.ashe-preloader-wrap').fadeOut( 1500 ); }, 300); } } } // Sticky Sidebar function asheStickySidebar() { if ( $( '.main-content' ).data('sidebar-sticky') === 1 ) { var SidebarOffset = 0; if ( $("#main-nav").attr( 'data-fixed' ) === '1' ) { SidebarOffset = 40; } $('.sidebar-left,.sidebar-right').stick_in_parent({ parent: ".main-content", offset_top: SidebarOffset, spacer: '.sidebar-left-wrap,.sidebar-right-wrap' }); if ( $('.mobile-menu-btn').css('display') !== 'none' ) { $('.sidebar-left,.sidebar-right').trigger("sticky_kit:detach"); } } }