jQuery(document).ready(function($) { var viewportWidth = window.innerWidth || document.documentElement.clientWidth; var viewportHeight = window.innerHeight || document.documentElement.clientHeight; $('.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() { module_parent.find('.count-up-inview.active').countTo({ onComplete: ( module_parent.find('.count-up-inview.active').removeClass('active') ) }); }, 400); } }); }); // 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); }); // 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 channel sight 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() } } }); });