jQuery(document).ready(function($) { var viewportWidth = window.innerWidth || document.documentElement.clientWidth; var viewportHeight = window.innerHeight || document.documentElement.clientHeight; // setTimeout(function() { // $('.count-up-inview.active').countTo({ // onComplete: ( // $(this).find('.count-up-inview.active').removeClass('active') // // setTimeout(function() { // // module_parent.find('.badge_counter .circle').addClass('animated tada'); // // }, counter_completion) // ) // }); // }, 5000); $('.count-up-inview.active').each(function(){ var module_parent = $(this).parent(); var count_up_item = $(this); new Waypoint.Inview({ element: count_up_item, enter: function(down) { // setTimeout(function() { // $('.count-up-inview.active').countTo({ // onComplete: ( // count_up_item.removeClass('active') // ) // }); // }, 300); setTimeout(function() { // var counter_completion = module_parent.find('.count-up-inview').attr('data-speed'); module_parent.find('.count-up-inview.active').countTo({ onComplete: ( module_parent.find('.count-up-inview.active').removeClass('active') // setTimeout(function() { // module_parent.find('.badge_counter .circle').addClass('animated tada'); // }, counter_completion) ) }); }, 400); } }); }); // remove class from product page hero graphics to animate in $(window).load(function() { $('#hero .hero_graphic_item').each(function(i){ var hero_item = $(this); setTimeout(function() { hero_item.removeClass('not_active'); }, 200*i); setTimeout(function() { hero_item.removeClass('hero_graphic_item'); }, 5000); }); // setTimeout(function() { // $('body, html').addClass('popup-open'); // $('#popup-get_2_back.popup-overlay').addClass('popup-open'); // }, 1000); }); // sort retailer list alphabeticallys var select2_alphabetical_sorter = function(data) { return data.sort(function(a,b){ a = a.text.toLowerCase(); b = b.text.toLowerCase(); if(a > b) { return 1; } else if (a < b) { return -1; } return 0; }); }; // initialize select dropdown search $('.retailer_dropdown').select2({ sorter: select2_alphabetical_sorter, placeholder: "*Enter Store Name", allowClear: true, selectOnClose: false, dropdownCssClass: "select2_retailer_dropdown", maximumSelectionLength: 1, }); // open store locator / maps search on submit $('form.retailer_form input[type="submit"]').click(function (e) { e.preventDefault(); var link_url = $(this).closest('.retailer_form').find('.retailer_dropdown').attr('data-store-url'); var option_value = $(this).closest('.retailer_form').find('.retailer_dropdown').find(':selected').val(); var search_query = option_value.replace('\'', '').replace(' ', '+'); var search_query = 'https://maps.google.com/?q='+search_query+''; window.open(search_query, '_blank'); // if(link_url && link_url.length > 0) { // window.open(link_url, '_blank'); // } else { // alert('This retailer does not have a website'); // } }); // // carousel before after photos // var carousel_before_after = $(".carousel_before_after"); // carousel_before_after.owlCarousel({ // loop:true, // margin:24, // nav:true, // dots:true, // items: 2, // slideBy: 1, // mouseDrag: true, // autoHeight: true, // touchDrag: true, // freeDrag: false, // autoplay:true, // URLhashListener:false, // autoplayTimeout:4500, // smartSpeed: 3000, // autoplayHoverPause: false, // responsiveClass:true, // responsive:{ // 0:{ // items:1, // }, // 520:{ // items:1, // }, // 768:{ // items:2, // } // } // }); // carousel testimonials var carousel_testimonials = $(".carousel_testimonials"); carousel_testimonials.owlCarousel({ loop:true, margin:0, nav:true, dots:true, items: 1, slideBy: 1, mouseDrag: true, autoHeight: false, touchDrag: false, freeDrag: false, autoplay:true, URLhashListener:false, autoplayTimeout:6000, smartSpeed: 700, autoplayHoverPause: false }); // carousel product mobile var carousel_product_mobile = $(".carousel_product_mobile"); carousel_product_mobile.owlCarousel({ loop:true, margin:0, nav:true, dots:true, items: 1, slideBy: 1, mouseDrag: true, autoHeight: false, touchDrag: false, freeDrag: false, autoplay:true, URLhashListener:false, autoplayTimeout:6000, smartSpeed: 700, autoplayHoverPause: false }); // 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); }); // popup overlay trigger on link click $('.popup_link_trigger').click(function(e) { e.preventDefault(); var link_id = $(this).attr('href') var link_id = link_id.replace('#', '') $('body, html').addClass('popup-open'); $('.popup-overlay--video#'+link_id+'').addClass('popup-open'); }); // close popup window $('.popup-overlay .close-button').click(function(e) { e.preventDefault(); var target = $(e.target); $('body, html').removeClass('popup-open'); $('.popup-overlay').removeClass('popup-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); } }); // play video with custom icon $('a.play_video').click(function(e){ e.preventDefault(); if ($(this).closest('.responsive_video_wrapper.hosted_self').length > 0) { $(this).hide(); $(this).closest('.responsive_video_wrapper.hosted_self').find('video').get(0).play(); } }); // hide video play icon on video controls click $('video').click(function() { if ($(this).get(0).paused) { // this.pause(); $(this).closest('.responsive_video_wrapper').find('a.play_video').hide(); // alert('video playing'); } }); // waypoints scroll inview for sticky shop now button $('#hero .sticky_shop_now').each(function(){ var this_item = $(this); if($('body.page_customer').length > 0) { var appear_item_start = $('#hero .section_customer'); } if($('body.page_product').length > 0) { var appear_item_start = $('#hero .section_product'); } // var appear_item_end = $('body.home .module-6'); new Waypoint.Inview({ element: appear_item_start, enter: function(direction) { this_item.addClass('entered') }, exited: function(direction) { if (direction == 'up') { this_item.removeClass('entered') } } }); var footer_item = $('#retailers'); new Waypoint.Inview({ element: footer_item, entered: function(direction) { // if (direction == 'down') { this_item.removeClass('entered') // } }, exited: function(direction) { if (direction == 'up') { this_item.addClass('entered') } } }); var footer_contact = $('#callout_contact'); new Waypoint.Inview({ element: footer_contact, enter: function(direction) { if (direction == 'down') { this_item.removeClass('entered') } }, exited: function(direction) { if (direction == 'up') { this_item.addClass('entered') } } }); }); // waypoints scroll inview for sticky shop now button $('#hero .sticky_shop_now').click(function(){ var this_item = $(this); $('#hero .sticky_shop_now').removeClass('entered'); }); // Devices without touch events $('html.no-touchevents .tile').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); } ); $('html.no-touchevents #product_before_after .photo_column .photo_column_inner').hover(function(e) { e.stopPropagation(); // e.preventDefault(); // $(this).toggleClass('hover'); if ($(this).hasClass('hover')) { $(this).removeClass('hover'); } else { $(this).addClass('hover'); } }); // Devices with touch events $('html.touchevents #product_before_after .photo_column .photo_column_inner').click(function(e) { e.stopPropagation(); // e.preventDefault(); // $(this).toggleClass('hover'); if ($(this).hasClass('hover')) { $(this).removeClass('hover'); } else { $(this).addClass('hover'); } }); $(window).on('load', function(){ var site_header_height = $('#site_header').height(); $('#page_product').css({'padding-top':''+site_header_height+'px'}); }); $(window).on('resize', function(){ var win = $(this); //this = window var site_header_height = $('#site_header').height(); $('#page_product').css({'padding-top':''+site_header_height+'px'}); // if (win.width() <= 767) { // start_product_carousel(); // } else { // stop_product_carousel(); // } }); // 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 \ ').each(function () { $(this).addClass('tracking_shop_link'); }); // 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+'') }); // add detailed title to each logo link $('.logo_column img').each(function(){ var logo_retailer_name = $(this).attr('alt'); $(this).closest('.logo_wrapper').attr('data-detailed-title', 'Shop - '+logo_retailer_name+'') }); // add selected retailer to search button as detailed title $('.retailer_dropdown').on('select2:select', function (e) { var retailer_value = $(this).val(); var retailer_text = $(this).closest('.retailer_form').find('option:selected').text(); $(this).closest('.retailer_form').find('input[type="submit"]').attr('data-detailed-title', 'Shop - '+retailer_text+'') // alert(retailer_text); }); // 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 { // close all other tabs $('.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); } }); // trigger pricespider popup from one single button with ps-widget class and ps-sku attribute (any link/button with ps_popup_link class) $(function () { const ps_popuplinkelements = document.getElementsByClassName("cs_popup_link") for (let index = 0; index < ps_popuplinkelements.length; index++) { const ele = ps_popuplinkelements [index] ele.onclick = (e) => { e.stopImmediatePropagation(); e.preventDefault(); document.getElementsByClassName("cswidget")[0].click() } } }); // $(window).on('resize', function(){ // var win = $(this); //this = window // if (win.width() <= 767) { // } else { // } // }); });