$(document).ready(function() { // Header Scroll $(window).on('scroll', function() { var $wHeight = $(window).height(); var scroll = $(window).scrollTop(); if (scroll >= $wHeight) { $('#header').addClass('fixed'); } else { $('#header').removeClass('fixed'); } }); // Flexslider $('.flexslider').flexslider({ animation: "fade", directionNav: false, }); // Page Scroll var sections = $('section') nav = $('nav[role="navigation"]'); $(window).on('scroll', function () { var cur_pos = $(this).scrollTop(); sections.each(function() { var top = $(this).offset().top - 276 bottom = top + $(this).outerHeight(); if (cur_pos >= top && cur_pos <= bottom) { nav.find('a').removeClass('active'); nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active'); } }); }); $('a[href*=#]:not([href=#myCarousel],.nav-toggle,.submit)').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top },1000); return false; } } }); // Mobile Navigation $('.nav-toggle').on('click', function() { $(this).toggleClass('close-nav'); nav.toggleClass('open'); return false; }); nav.find('a').on('click', function() { $('.nav-toggle').toggleClass('close-nav'); nav.toggleClass('open'); }); var $item = $('.carousel .item'); var $wHeight = $(window).height(); $item.height($wHeight); $item.addClass('full-screen'); $('.carousel img').each(function() { var $src = $(this).attr('src'); var $color = $(this).attr('data-color'); $(this).parent().css({ 'background-image' : 'url(' + $src + ')', 'background-color' : $color }); $(this).remove(); }); $(window).on('resize', function (){ $wHeight = $(window).height(); $item.height($wHeight); }); /* ================================================== Contact Form ================================================== */ $("#contact-submit").on('click',function() { $contact_form = $('#contact-form'); var fields = $contact_form.serialize(); $.ajax({ type: "POST", url: "wp-content/themes/auro/inc/contact.php", data: fields, dataType: 'json', success: function(response) { if(response.status){ $('#contact-form input').val(''); $('#contact-form textarea').val(''); } $('#response').empty().html(response.html); } }); return false; }); });