/*----------------------------------------------------------------------------------- /* /* Init JS /* -----------------------------------------------------------------------------------*/ jQuery(document).ready(function() { $WIN = $(window); /*----------------------------------------------------*/ /* 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 speed: 'fast', // fast normal slow speedOut: 'fast', // fast normal slow }); }; /* 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 a').on("click", function() { if (nav.hasClass('mobile')) { toggleButton.toggleClass('is-clicked'); nav.fadeOut(); } }); $('#main-nav-wrap > ul.mobile >li.has-children').append('
'); $('li.has-children .accordion-toggle').click(function() { $(this).parent().find('> ul').slideToggle(200); $(this).toggleClass('toggle-background'); }); }; /*-----------------------------------------------------------------------------------*/ /* NICESCROLL /*-----------------------------------------------------------------------------------*/ jQuery("body").niceScroll({ cursorcolor: "#f2da00", cursorborder: "0px", cursorwidth: "8px", zindex: "9999" }); /* Smooth Scrolling * ------------------------------------------------------ */ var SmoothScroll = function() { $('.smoothscroll').on('click', function(e) { var target = this.hash, $target = $(target); e.preventDefault(); e.stopPropagation(); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, cfg.scrollDuration, 'swing').promise().done(function() { window.location.hash = target; }); }); }; /* Back to Top * ------------------------------------------------------ */ // declare variable var scrollTop = $(".scrollTop"); $(window).scroll(function() { // declare variable var topPos = $(this).scrollTop(); // if user scrolls down - show scroll to top button if (topPos > 100) { $(scrollTop).css("opacity", "1"); } else { $(scrollTop).css("opacity", "0"); } }); // scroll END //Click event to scroll to top $(scrollTop).click(function() { $('html, body').animate({ scrollTop: 0 }, 300); return false; }); // click() scroll top EMD /* Animations * ------------------------------------------------------ */ // Function which adds the 'animated' class to any '.animatable' in view var doAnimations = function() { // Calc current offset and get all animatables var offset = $(window).scrollTop() + $(window).height(), $animatables = $('.animatable'); // Unbind scroll handler if we have no animatables if ($animatables.size() == 0) { $(window).off('scroll', doAnimations); } // Check all animatables and animate them if necessary $animatables.each(function(i) { var $animatable = $(this); if (($animatable.offset().top + $animatable.height() - 100) < offset) { $animatable.removeClass('animatable').addClass('animated'); } }); }; // Hook doAnimations on scroll, and trigger a scroll $(window).on('scroll', doAnimations); $(window).trigger('scroll'); /* Initialize * ------------------------------------------------------ */ (function ssInit() { SuperFish(); MobileNav(); SmoothScroll(); })(); });