/* Template Name: Crezo - Multipurpose Template Author: Themesdesign Version: 1.0.0 Updated: April 2021 File Description:Main JS file of the template */ (function ($) { 'use strict'; // Navbat Toggle var scroll = $(window).scrollTop(); $('.navbar-toggle').on('click', function (event) { $(this).toggleClass('open'); $('#navigation').slideToggle(400); }); $('.navigation-menu>li').slice(-2).addClass('last-elements'); $('.menu-arrow,.submenu-arrow').on('click', function (e) { if ($(window).width() < 992) { e.preventDefault(); $(this).parent('li').toggleClass('open').find('.submenu:first').toggleClass('open'); } }); $(".navigation-menu a").each(function () { if (this.href == window.location.href) { $(this).parent().addClass("active"); // add active to li of the current link $(this).parent().parent().parent().addClass("active"); // add active class to an anchor $(this).parent().parent().parent().parent().parent().addClass("active"); // add active class to an anchor } }); // Smooth scroll $('.navbar-nav a, .mouse-down a').on('click', function(event) { var $anchor = $(this); $('html, body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top - 0 }, 1500, 'easeInOutExpo'); event.preventDefault(); }); // Clickable Menu $(".has-submenu a").click(function() { if(window.innerWidth < 992){ if($(this).parent().hasClass('open')){ $(this).siblings('.submenu').removeClass('open'); $(this).parent().removeClass('open'); } else { $(this).siblings('.submenu').addClass('open'); $(this).parent().addClass('open'); } } }); //SCROLLSPY $(".navbar-nav").scrollspy({ offset: 20 }); //sticky header on scroll $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 50) { $(".navbar-sticky").addClass("small"); } else { $(".navbar-sticky").removeClass("small"); } }); $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 50) { $(".sticky").addClass("nav-sticky"); } else { $(".sticky").removeClass("nav-sticky"); } }); $(function () { $('[data-toggle="tooltip"]').tooltip() }) // Loader $(window).on('load', function() { $('#status').fadeOut(); $('#preloader').delay(350).fadeOut('slow'); $('body').delay(350).css({ 'overflow': 'visible' }); }); // BACK TO TOP $(window).scroll(function(){ if ($(this).scrollTop() > 100) { $('.back-to-top').fadeIn(); } else { $('.back-to-top').fadeOut(); } }); $('.back-to-top').click(function(){ $("html, body").animate({ scrollTop: 0 }, 1000); return false; }); //Tooltip $(function () { $('[data-toggle="tooltip"]').tooltip() }); //Popover $(function () { $('[data-toggle="popover"]').popover() }); })(jQuery)