(function ($) { "use strict"; // Enable Bootstrap tooltips via data-attributes globally $('[data-toggle="tooltip"]').tooltip(); // Enable Bootstrap popovers via data-attributes globally $('[data-toggle="popover"]').popover(); $(".popover-dismiss").popover({ trigger: "focus" }); // Activate Feather icons feather.replace(); // Activate Bootstrap scrollspy for the sticky nav component $("body").scrollspy({ target: "#stickyNav", offset: 82 }); // Scrolls to an offset anchor when a sticky nav link is clicked $('.nav-sticky a.nav-link[href*="#"]:not([href="#"])').click(function () { if ( location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname ) { var target = $(this.hash); target = target.length ? target : $("[name=" + this.hash.slice(1) + "]"); if (target.length) { $("html, body").animate({ scrollTop: target.offset().top - 81 }, 200 ); return false; } } }); // Collapse Navbar // Add styling fallback for when a transparent background .navbar-marketing is scrolled var navbarCollapse = function () { if ($(".navbar-marketing.bg-transparent.fixed-top").length === 0) { return; } if ($(".navbar-marketing.bg-transparent.fixed-top").offset().top > 0) { $(".navbar-marketing").addClass("navbar-scrolled"); } else { $(".navbar-marketing").removeClass("navbar-scrolled"); } }; // Collapse now if page is not at top navbarCollapse(); // Collapse the navbar when page is scrolled $(window).scroll(navbarCollapse); var headerFixed = function () { var nav = $('.header.bg-color'); if (nav.size() !== 0) { $(window).on('load', function () { var header = $('.header.bg-color'); var offsetTop = $('.header.bg-color').offset().top; var headerHeight = $('.header.bg-color').height(); var buffer = $('
', { height: headerHeight }).insertAfter(header); buffer.hide(); $(window).on('load scroll', function () { if ($(window).scrollTop() > offsetTop) { $('.header.bg-color').addClass('fixed-header'); buffer.show(); } else { $('.header.bg-color').removeClass('fixed-header'); buffer.hide(); } }) }); } }; var responsiveMenu = function () { var menuType = 'desktop'; $(window).on('load resize', function () { var currMenuType = 'desktop'; if (matchMedia('only screen and (max-width: 991px)').matches) { currMenuType = 'mobile'; } if (currMenuType !== menuType) { menuType = currMenuType; if (currMenuType === 'mobile') { var $mobileMenu = $('#mainnav').attr('id', 'mainnav-mobi').hide(); var hasChildMenu = $('#mainnav-mobi').find('li:has(ul)'); $('#header .container').after($mobileMenu); hasChildMenu.children('ul').hide(); hasChildMenu.children('a').after(''); $('.btn-menu').removeClass('active'); } else { var $desktopMenu = $('#mainnav-mobi').attr('id', 'mainnav').removeAttr('style'); $desktopMenu.find('.submenu').removeAttr('style'); $('#header').find('.nav-wrap').append($desktopMenu); $('.btn-submenu').remove(); } } }); $('.btn-menu').on('click', function () { $('#mainnav-mobi').slideToggle(300); $(this).toggleClass('active'); }); $(document).on('click', '#mainnav-mobi li .btn-submenu', function (e) { $(this).toggleClass('active').next('ul').slideToggle(300); e.stopImmediatePropagation() }); }; var removePreloader = function () { $(window).on("load", function () { $(".loader").fadeOut(); $("#loading-overlay").delay(500).fadeOut('slow', function () { $(this).remove(); }); }); }; // Dom Ready $(function () { headerFixed(); responsiveMenu(); removePreloader(); }); })(jQuery);