/*----------------------------------------------------------------------------------- /* /* Init JS /* -----------------------------------------------------------------------------------*/ jQuery(document).ready(function() { $WIN = $(window); /*----------------------------------------------------*/ /* Flexslider /*----------------------------------------------------*/ $('#about-slider').flexslider({ animation: 'fade', controlNav: true, directionNav: false, touch: true, }); /*----------------------------------------------------*/ /* 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() > 1024)) { header.addClass('opaque'); } else { if (y < h + 0) { header.removeClass('opaque'); } else { header.addClass('opaque'); } } }); /* 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', }); }; /* 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'); }); }; /* 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 /* Initialize * ------------------------------------------------------ */ (function ssInit() { SuperFish(); MobileNav(); SmoothScroll(); })(); });