jQuery(document).ready(function($){ /* affix the navbar after scroll below header */ $('#nav').affix({ offset: { top: $('#carousel-example-generic').height()-$('#nav').height() } }); /* highlight the top nav as scrolling occurs */ $('body').scrollspy({ target: '#nav' }) // swipe function $(".carousel-inner").swiperight(function() { $(this).parent().carousel('prev'); }); $(".carousel-inner").swipeleft(function() { $(this).parent().carousel('next'); }); // multi item $('.carousel[data-type="multi"] .item').each(function(){ var next = $(this).next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); for (var i=0;i<1;i++) { next=next.next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); } }); $('.counter').counterUp({ delay: 10, time: 1000 }); // browser window scroll (in pixels) after which the "back to top" link is shown var offset = 300, //browser window scroll (in pixels) after which the "back to top" link opacity is reduced offset_opacity = 1200, //duration of the top scrolling animation (in ms) scroll_top_duration = 700, //grab the "back to top" link $back_to_top = $('.rrf-top'); //hide or show the "back to top" link $(window).scroll(function(){ ( $(this).scrollTop() > offset ) ? $back_to_top.addClass('rrf-is-visible') : $back_to_top.removeClass('rrf-is-visible cd-fade-out'); if( $(this).scrollTop() > offset_opacity ) { $back_to_top.addClass('rrf-fade-out'); } }); //smooth scroll to top $back_to_top.on('click', function(event){ event.preventDefault(); $('body,html').animate({ scrollTop: 0 , }, scroll_top_duration ); }); var toggles = document.querySelectorAll(".c-hamburger"); for (var i = toggles.length - 1; i >= 0; i--) { var toggle = toggles[i]; toggleHandler(toggle); }; function toggleHandler(toggle) { toggle.addEventListener( "click", function(e) { e.preventDefault(); (this.classList.contains("is-active") === true) ? this.classList.remove("is-active") : this.classList.add("is-active"); }); } });