jQuery(document).ready(function ($) { // faq section question / answer accordion toggle $('.questions_wrapper ul li .question').click(function (e) { e.preventDefault(); // $(this).closest('ul').find('li .answer').toggle(); $(this).closest('li').find('> .answer').slideToggle(300); $(this).closest('li').toggleClass('open'); }); // scroll to anchor link on click $('a.link_scrollto[href^="#"]').click(function (e) { e.preventDefault(); var link_anchor = $(this).attr('href'); // scroll to anchor link if section ID is visible and exists if ($('' + link_anchor + ':visible').length > 0) { $('html, body').animate({ scrollTop: $('' + link_anchor + '').offset().top + 0 }, 300); } // scroll to anchor link tab wrapper if hidden else { var current_tab = $('' + link_anchor + '').closest('.tab_wrapper'); // close all other tabs $('.tab_wrapper').removeClass('open'); $('.tab_wrapper .tab_content').slideUp(300); current_tab.addClass('open'); current_tab.find('.tab_content').slideDown(300); setTimeout(function () { $('html, body').animate({ scrollTop: current_tab.offset().top - 10 }, 300); }, 300); } }); $(window).on('resize', function () { // add detailed title to each logo link $('.tab_headline h3').each(function () { var headline_copy = $(this).text(); $(this).closest('.tab_headline').attr('data-detailed-title', 'Tab - ' + headline_copy + '') }); // mobile accordion tabs $('.tab_wrapper .tab_headline').click(function (e) { e.preventDefault(); var current_tab = $(this).closest('.tab_wrapper'); if ($(this).closest('.tab_wrapper').hasClass('open')) { $(this).closest('.tab_wrapper').removeClass('open'); $(this).closest('.tab_wrapper').find('.tab_content').slideUp(300); } else { $('.tab_wrapper').removeClass('open'); $('.tab_wrapper .tab_content').slideUp(300); $(this).closest('.tab_wrapper').addClass('open'); $(this).closest('.tab_wrapper').find('.tab_content').slideDown(300); setTimeout(function () { $('html, body').animate({ scrollTop: current_tab.offset().top - 10 }, 300); }, 300); } }); // add classes to all shop links for tracking $('\ a.logo_wrapper, \ #site_header .col_buttons .btn, \ .sticky_shop_now, \ .retailer_form input[type="submit"], \ .link_scrollto, \ .tab_headline, \ .cta_wrapper .btn, \ .btn_wrapper .btn, \ .logo_column .logo_wrapper, \ .product_wrapper a.btn \ ').each(function () { $(this).addClass('tracking_shop_link'); }); }) });