var $ = jQuery.noConflict(); $(document).ready(function () { //commonly accesed DOM elements var main = $('.on-canvas'); var mobileNav = $('.mobile-navigation'); var offCanvasClick = $('.off-canvas-click'); var header = $('header'); //page width determines offsets or whether a function should run or not //for example parallax() only works on desktop sizes and up var pageWidth = $(window).width(); //Smooth scroll function (currently not in use due to foundation's media query conflicts) $('body').on('click', '.scroller', function () { var offset = function () { if (pageWidth < 1024) { //mobile header size return 70; } else { //desktop header size return 208; } }; $('html, body').animate({ scrollTop: $($.attr(this, 'href')).offset().top - offset() }, 800, 'easeOutQuart'); }); $('.js-menu-toggle').on('click', function (e) { e.preventDefault(); if (main.hasClass('menu-is-open')) { toggleMenu(); } else { toggleMenu(); } }); //Menu toggle function function toggleMenu() { if (!main.hasClass('menu-is-open')) { $('.js-menu-toggle .title').html('Close'); } else { $('.js-menu-toggle .title').html('Menu'); } //trigger classes for displaying mobile nav main.toggleClass('menu-is-open'); mobileNav.toggleClass('menu-is-open'); //offCanvasClick.toggleClass('active'); } //open (or close) submenu items in the lateral menu. Close all the other open submenu items. //@Events: menu:clicked $('.mobile-navigation .has-sub > a, .sidebar .has-sub > a').on('click', function (e) { if (!$(this).parents('header').length && !$(this).parents('footer').length) { e.preventDefault(); } if ($(this).hasClass('submenu-open')) { $(this).removeClass('submenu-open').next('ul').slideUp(400).end().trigger("menu:clicked", [$(this)]); } else { $(this).addClass('submenu-open').next('ul').slideDown(400).end().trigger("menu:clicked", [$(this)]); $(this).parent('.has-sub').siblings('.has-sub').children('a').removeClass('submenu-open').next('ul').slideUp(400); } }); //Bind to event created the menu system $(document).on("menu:clicked", function (event, el) { //if sidebar is clicked if (el.parents('.sidebar').length) { } //if mobile nav is clicked else { } }); function parallax() { var scrolled = $(window).scrollTop(); //custom parallax animations //$('.feat > .row, .feat > .row-outer .row').css('bottom',-(scrolled*0.4)+'px'); //$('.feat > .row, .feat > .row-outer .row').css('opacity',( 1 - scrolled * 0.62 / 100)); /*$('.feat > .row-outer').css('opacity',( 1 - scrolled * 0.22 / 100));*/ $('.main-slider .row-outer').css('opacity', (1 - scrolled * 0.32 / 100)); } function headerAnimate() { var scrollTop = $(window).scrollTop(); //remove .js-animate from the header HTML in order to prevent header animation if (header.hasClass('js-animate')) { //scroll > n, where n is an arbitrary value, can be different per site if (scrollTop > 120) { header.addClass('scrolled'); } else { header.removeClass('scrolled'); } } } headerAnimate(); //functions to run on scroll $(window).scroll(function () { //only run parallax if on desktop screen //(mobile parallax interferes with content consumption) if (pageWidth > 1024) { parallax(); headerAnimate(); } }); $('.s3accordion > .s3panel > a').on('click', function (e) { e.preventDefault(); if (!$(this).parent().hasClass('js-opened')) { $('.js-opened').find('div').slideUp(); $('.js-opened').removeClass('js-opened'); $(this).next().slideDown(); $(this).parent().addClass('js-opened'); } else { $(this).next().slideUp(); $(this).parent().removeClass('js-opened'); } }); // Scroller - function to scroll down to hashes and consider sticky header/nav if (window.location.hash) { var hash = window.location.hash.substring(1); //Puts hash in variable, and removes the # character console.log(hash); var div = "#" + hash; var offset = function () { if (pageWidth < 800) { return 80; } else if (pageWidth < 1024) { //mobile header size return 80; } else { //desktop header size return 200; } }; jQuery('html, body').animate({ scrollTop: jQuery(div).offset().top - offset() }, 1000, 'easeOutQuart'); } //form update $('.s3-form').on('valid', function () { $(this).find('.submit').text('Sending...').addClass("is-disabled"); }); // gallery dropdown click if (pageWidth < 1024) { $('body.gallery .gallery-dropdown').on('click', function () { $(this).find('.selector').toggleClass('active'); }); } // Adds class="here" to active link var pathArray = location.href.split('/'); var protocol = pathArray[0]; var host = pathArray[2]; var url = protocol + '//' + host; $('.links a').each(function () { if (window.location.href == url + $(this).attr('href')) { $(this).addClass('here'); //also adds submenu-open to links with dropdowns $(this).parents(".has-sub").addClass("sub-open"); $(this).parents(".has-sub").find("> a").addClass("submenu-open"); } }); function here() { // adds class here to menu to be active var pathArray = location.href.split('/'); var protocol = pathArray[0]; var host = pathArray[2]; var url = protocol + '//' + host; $('body.hamburgerMenu .main-links a,body.hamburgerMenu .sub-links a').each(function () { if (window.location.href == url + $(this).attr('href')) { // clicks current category parent link so children are open var category = $(this).parents('ul').attr('data-val'); $('.fixed-nav .main-links li.has-sub.' + category + '> a').click(); // adds here to current child link $(this).addClass('here'); } }); } here(); // WP Fixed Nav if ($('#wpadminbar').length) { $('#wpadminbar').appendTo('body'); } // popup video $('.popup-video').magnificPopup({ type: 'iframe' }); ///////////////////////////////// // hamburger menu js //////////////////////////////// // active hamburger menu icon $('body.hamburgerMenu .icon-holder .icon').on('click', function () { $(this).toggleClass('active'); // toggle fixed menu $('.fixed-nav').slideToggle(350); $('header').toggleClass('open-menu'); setTimeout(function () { // return menu to default if close/re-open $('.fixed-nav ul li.has-sub > a').removeClass('here'); $('.fixed-nav .sub-links ul').removeClass('active'); $('.fixed-nav .sub-links').removeClass('mobile-opened'); $('header').removeClass('child-open'); // run active state for menu after clearing here(); }, 200); }); // fixed menu $('body.hamburgerMenu .fixed-nav ul li.has-sub a').on('click', function () { var val = $(this).attr('data-val'); var theme = $(this).attr('data-theme'); // active state $('.fixed-nav .main-links ul li.has-sub a').removeClass('here'); $(this).addClass('here'); // show sub links if there is any $('.fixed-nav .sub-links ul').removeClass('active'); $('.fixed-nav .sub-links ul.' + val).addClass('active'); // close gallery sublinks $('.fixed-nav .sub-links ul.gallery a.has-links').removeClass('opened'); $('.fixed-nav .sub-links ul.gallery li ul').removeClass('opened').hide(); // toggle mobile class to slide nav $('.fixed-nav .sub-links').addClass('mobile-opened'); $('header').addClass('child-open'); }); // add back functionality for mobile menu $('body.hamburgerMenu .fixed-nav ul li.back a').on('click', function () { $('.fixed-nav ul li.has-sub > a').removeClass('here'); $('.fixed-nav .sub-links').removeClass('mobile-opened'); $('header').removeClass('child-open'); $('.fixed-nav .sub-links ul').removeClass('active'); $('.fixed-nav .sub-links ul.gallery li ul').removeClass('opened').hide(); $('.fixed-nav .sub-links ul.gallery a.has-links').removeClass('opened'); }); // open index pages $('body.hamburgerMenu .index-link').on('click', function () { var val = $(this).attr('data-val'); $('.icon-holder .icon').click(); setTimeout(function () { $('.fixed-nav .main-links .has-sub.' + val + '> a').click(); }, 400); }); // run accordion function tablet-down only var ww = $(window).width(); var wh = $(window).height(); if (ww < 1024 || wh < 800) { accordion(); } // run sticky faq list if desktop only if (ww > 1024 && wh > 800) { stickyFAQ(); } // faq accordions function accordion() { $('.faq-style .question').on('click', function () { $(this).toggleClass('opened').find('.answer').slideToggle(250); }); } // run function when scrolling $(window).scroll(function () { if (ww > 1024 && wh > 800) { stickyFAQ(); } }); // build faq side list $('.faq-style .questions .question').each(function () { var title = $(this).find('h3').text(); $('.faq-style .sticky-side .list').append('
' + title + '
'); }); // fixed faq questions function stickyFAQ() { if ($('.faq-style').length != '') { var sb = $('.faq-style .sticky-side'); var content = $('.faq-style .content'); var offset = content.offset().top - 180; var scrollTop = $(window).scrollTop(); // prevent from staying sticky at bottom var sbHeight = sb.height(); var sbInnerHeight = sb.innerHeight(); var qHeight = $('.faq-style .content').innerHeight(); var bottom = $('.faq-style .content').offset().top + qHeight - sbInnerHeight - 180; if (scrollTop > offset) { // within faq content sb.removeClass('bottom').addClass('sticky'); // scrolling past faq content if (scrollTop > bottom) { sb.removeClass('sticky').addClass('bottom'); } } else { // scrolling above faq content sb.removeClass('sticky bottom'); } } } // jump to faq logic $('.faq-style .sticky-side p').on('click', function () { // active state for links $('.faq-style .sticky-side p').removeClass('active'); $(this).addClass('active'); // scroll to section var val = $(this).index(); $('html, body').animate({ scrollTop: $('.faq-style .questions .question').eq(val).offset().top - 163 }, 500); return false; }); // Sticky Form $(".sticky-form-header").on("click", function (e) { e.preventDefault(); var el = $(this); var parent = el.parent(); if (parent.hasClass("is-active")) { el.text("Schedule a consultation"); parent.removeClass("is-active"); } else { el.text("Close"); parent.addClass("is-active"); } }); // set sticky form closed on mobile if (pageWidth < 800) { if ($(".sticky-form-wrap").hasClass("is-active")) { $(".sticky-form-wrap").removeClass("is-active"); $(".sticky-form-header").text("Schedule a consultation"); } } $('.testimonialsCarousel').owlCarousel({ loop: true, nav: true, dots: true, margin: 130, center: true, autoplay: true, responsive: { 0: { items: 1 }, 1000: { items: 2.5 } } }); if (window.location.pathname == '/') { console.log('home'); function mouseout() { var gradBox = this.querySelector('.gradBox'); var media = this.querySelector('.media'); gradBox.style.top = '-30px'; gradBox.style.left = '-30px'; media.style.top = '0px'; media.style.left = '0px'; } function shadow(e) { console.log(this); var gradBox = this.querySelector('.gradBox'); var media = this.querySelector('.media'); var walk = 20; var offsetWidth = this.offsetWidth; var offsetHeight = this.offsetHeight; var offset = this.getBoundingClientRect(); var x = offset.x; var y = offset.y; if (this !== e.target) { x = e.x; y = e.y; } var xWalk = Math.round((x / offsetWidth * walk) - 50); var yWalk = Math.round((y / offsetHeight * walk) - (walk / 1.2)); var xWalkMedia = Math.round(-(x / offsetWidth * walk) - 10); var yWalkMedia = Math.round((y / offsetWidth * walk) + (walk / 1.6)); gradBox.style.left = xWalk + 'px'; gradBox.style.top = yWalk + 'px'; media.style.left = xWalkMedia + 'px'; media.style.top = '-' + yWalkMedia + 'px'; } var homeOne = document.querySelector('.half-image.homeOne'); var homeTwo = document.querySelector('.half-image.homeTwo'); var homeThree = document.querySelector('.half-image.homeThree'); var homeFour = document.querySelector('.half-image.homeFour'); homeOne.addEventListener('mousemove', shadow); homeOne.addEventListener('mouseout', mouseout); homeTwo.addEventListener('mousemove', shadow); homeTwo.addEventListener('mouseout', mouseout) homeThree.addEventListener('mousemove', shadow); homeThree.addEventListener('mouseout', mouseout) homeFour.addEventListener('mousemove', shadow); homeFour.addEventListener('mouseout', mouseout); } else { console.log(window.location.pathname); } $('.homeBeauty .middle li').on('click', function () { var val = $(this).attr('data-val'); $('.homeBeauty .middle li').removeClass('active'); $(this).addClass('active'); // show classes $('.homeBeauty .content .text').removeClass('active'); $('.homeBeauty .content .text.' + val).addClass('active'); }); $(".btn-pop-out").on('click', function (e) { e.preventDefault(); $(".pop-out-special").toggleClass("visible"); $(".special-banner").toggleClass('hide'); $("body").toggleClass("pop-out-overflow"); }); });