/*----------------------------------------------------------------------------------- /* /* Init JS /* -----------------------------------------------------------------------------------*/ jQuery(document).ready(function() { $WIN = $(window); /* Preloader * -------------------------------------------------- */ var Preloader = function() { $WIN.on('load', function() { // will first fade out the loading animation $("#loader").fadeOut("slow", function() { // will fade out the whole DIV that covers the website. $("#preloader").delay(300).fadeOut("slow"); }); }); }; /*----------------------------------------------------*/ /* Adjust Primary Navigation Background Opacity ------------------------------------------------------*/ $(window).on('scroll', function() { var h = $('header').height(); var y = $(window).scrollTop(); var header = $('#main-header'); if ((y > h + 0 ) && ($(window).outerWidth() > 1280 ) ) { header.addClass('opaque'); } else { if (y < h + 0) { header.removeClass('opaque'); } else { header.addClass('opaque'); } } }); /*----------------------------------------------------*/ /* Flexslider /*----------------------------------------------------*/ $('#intro-slider').flexslider({ animation: 'fade', slideshowSpeed: 4000, animationSpeed: 600, pauseOnHover: true, pauseInvisible: true, controlNav: true, directionNav: true, touch: true, }); /* superfish * -------------------------------------------------- */ var SuperFish = function() { $('ul.sf-menu').superfish({ animation: { height: 'show' }, // slide-down effect without fade-in animationOut: { height: 'hide' }, // slide-up effect without fade-in cssArrows: false, // disable css arrows delay: 600 // .6 second delay on mouseout }); }; /* Mobile Menu ------------------------------------------------------ */ var MobileNav = function() { var toggleButton = $('.menu-toggle'), nav = $('.main-navigation'); toggleButton.on('click', function(event) { event.preventDefault(); toggleButton.toggleClass('is-clicked'); nav.slideToggle(); }); if (toggleButton.is(':visible')) nav.addClass('mobile'); $WIN.resize(function() { if (toggleButton.is(':visible')) nav.addClass('mobile'); else nav.removeClass('mobile'); }); $('#main-nav-wrap li').on("click", function() { if (nav.hasClass('mobile')) { toggleButton.toggleClass('is-clicked'); nav.fadeOut(); } }); // $('#main-nav-wrap > ul.mobile >li.has-children').append('