;(function ($) { "use strict"; //===== Slick Slider function mainSlider() { var BasicSlider = $('.home-slider'); BasicSlider.on('init', function (e, slick) { var $firstAnimatingElements = $('.single-slider:first-child').find('[data-animation]'); doAnimations($firstAnimatingElements); }); BasicSlider.on('beforeChange', function (e, slick, currentSlide, nextSlide) { var $animatingElements = $('.single-slider[data-slick-index="' + nextSlide + '"]').find('[data-animation]'); doAnimations($animatingElements); }); BasicSlider.slick({ autoplay: true, autoplaySpeed: 7000, dots: false, fade: true, arrows: true, prevArrow: '', nextArrow: '', pauseOnHover: false, responsive: [ { breakpoint: 767, settings: { dots: true, arrows: false } } ] }); function doAnimations(elements) { var animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; elements.each(function () { var $this = $(this); var $animationDelay = $this.data('delay'); var $animationType = 'animated ' + $this.data('animation'); $this.css({ 'animation-delay': $animationDelay, '-webkit-animation-delay': $animationDelay }); $this.addClass($animationType).one(animationEndEvents, function () { $this.removeClass($animationType); }); }); } } mainSlider(); //===== Mobile Menu var menu_toggle = $('.menu-toggle'); var nav_menu = $('.main-navigation ul.nav-menu'); /*------------------------------------------------ MAIN NAVIGATION ------------------------------------------------*/ menu_toggle.click(function(){ $(this).toggleClass('active'); nav_menu.slideToggle(); }); $('.main-navigation .nav-menu .menu-item-has-children > a').after( $('') ); $('button.dropdown-toggle').click(function() { $(this).toggleClass('active'); $(this).parent().find('.sub-menu').first().slideToggle(); }); /*------------------------------------------------ KEYBOARD NAVIGATION ------------------------------------------------*/ if( $(window).width() < 1024 ) { nav_menu.find("li").last().bind( 'keydown', function(e) { if( e.which === 9 ) { e.preventDefault(); $('#benzin-head').find('.menu-toggle').focus(); } }); } else { nav_menu.find("li").unbind('keydown'); } $(window).resize(function() { if( $(window).width() < 1024 ) { nav_menu.find("li").last().bind( 'keydown', function(e) { if( e.which === 9 ) { e.preventDefault(); $('#benzin-head').find('.menu-toggle').focus(); } }); } else { nav_menu.find("li").unbind('keydown'); } }); menu_toggle.on('keydown', function (e) { var tabKey = e.keyCode === 9; var shiftKey = e.shiftKey; if( menu_toggle.hasClass('active') ) { if ( shiftKey && tabKey ) { e.preventDefault(); nav_menu.slideUp(); menu_toggle.removeClass('active'); }; } }); //===== Back to top // Show or hide the sticky footer button $(window).on('scroll', function (event) { if ($(this).scrollTop() > 600) { $('.back-to-top').fadeIn(200) } else { $('.back-to-top').fadeOut(200) } }); //Animate the scroll to yop $('.back-to-top').on('click', function (event) { event.preventDefault(); $('html, body').animate({ scrollTop: 0, }, 1500); }); // Wow new WOW().init(); // Button hover js $('.main-btn, .main-btn-blue').on('mouseenter', function(e) { var parentOffset = $(this).offset(), relX = e.pageX - parentOffset.left, relY = e.pageY - parentOffset.top; $(this).find('span').css({top:relY, left:relX}) }) .on('mouseout', function(e) { var parentOffset = $(this).offset(), relX = e.pageX - parentOffset.left, relY = e.pageY - parentOffset.top; $(this).find('span').css({top:relY, left:relX}) }); // $('[href=#]').click(function(){return false}); })(jQuery);