let allPlansTopLink = document.querySelector('#protectionPlansAllTitle'); let allPlans = document.querySelectorAll('.carousel-header a'); let protectionPlansHome = document.querySelector('#protectionPlansHomeTitle'); let carouselLinks = document.querySelectorAll('.item-inner a'); let dropdownLinks = document.querySelectorAll('.dropdown-menu li a'); let utagL2 = utag_data.category_l2; console.log('HELP'); console.log(allPlans); if (allPlansTopLink != null) { allPlansTopLink.addEventListener('click', function() { allPlansTealiumClick(utagL2, allPlansTopLink.innerHTML.split(' ').join('_').toLowerCase()); }); } if (protectionPlansHome != null) { protectionPlansHome.addEventListener('click', function() { protectionPlanTealiumClick(utagL2, protectionPlansHome.innerHTML.split(' ').join('_').toLowerCase()); }); } for (let i = 0; i < allPlans.length; i++) { allPlans[i].addEventListener('click', function() { console.log('click!!!'); allPlansTealiumClick(utagL2, allPlans[i].innerHTML.trim().split(' ').join('_').toLowerCase()); }); } for(let i = 0; i < carouselLinks.length; i++) { carouselLinks[i].addEventListener('click', function() { let name = carouselLinks[i].parentNode.previousElementSibling.innerHTML; let eventLabel = carouselLinks[i].innerHTML.trim().toLowerCase(); carouselContentfulTealiumClick(utagL2, name, eventLabel); }); } for(let i = 0; i < dropdownLinks.length; i++) { dropdownLinks[i].addEventListener('click', function() { let name = dropdownLinks[i].innerHTML; let eventLabel = name.split(' ').join('_').toLowerCase(); dropdownTealiumClick(utagL2, name, eventLabel); }); } function allPlansTealiumClick(utag, eventLabel) { let clickdata = { "category_l1":"MLP", "category_l2":"" + utag, "category_l3":"(not set)", "category_l4":"(not set)", "event":"all_protection_plans_click", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"" + eventLabel, "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function protectionPlanTealiumClick(utag, event_label) { let clickdata = { "category_l1":"MLP", "category_l2":"" + utag, "category_l3":"(not set)", "category_l4":"(not set)", "event":"protection_plans_click", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"" + event_label, "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function carouselContentfulTealiumClick(utag, eventName, eventLabel) { let clickdata = { "category_l1":"MLP", "category_l2":"" + utag, "category_l3":"(not set)", "category_l4":"(not set)", "event": eventName + "_page_click", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"" + eventLabel, "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function dropdownTealiumClick(utag, eventName, eventLabel) { let clickdata = { "category_l1":"MLP", "category_l2":"" + utag, "category_l3":"(not set)", "category_l4":"(not set)", "event": eventName + "_plan_page_click", "event_category":"EngagementType", "event_action":"EngagementType_MLP|||Click", "event_label":"" + eventLabel, "event_value":"1", "pagegroup":"mlp" }; window.utag_data = clickdata; window.utag.link(window.utag_data); } function initCarousels() { if (!$.fn.slick) return; var bannerCarousel = $("#banner-carousel"); var protectionPlansCarousel = $("#all-plans-carousel-generic:not(.kitfhelp-carousel)"); var currentProtectionPlan = $(".protection-plan-name"); if (typeof currentProtectionPlan !== "undefined") { var protectionPlanName = currentProtectionPlan.text().toLowerCase().replace(/ /g, "-"); if (protectionPlanName === 'autonation-vehicle-protection-plan') { $("#autonation-vehicle-care-program").addClass("active"); } $("#" + protectionPlanName).remove(); $(".carousel-indicators li:last-child").remove(); } bannerCarousel.slick({ dots: true, infinite: true, autoplay: true }); bannerCarousel.css("visibility", "visible"); if( protectionPlansCarousel.length > 0 ){ protectionPlansCarousel.slick({ dots: true, infinite: true, autoplay: true, autoplaySpeed: 2000, slidesToShow: 3, slidesToScroll: 1, responsive: [ { breakpoint: 769, settings: { slidesToShow: 2 } }, { breakpoint: 426, settings: { slidesToShow: 1 } } ] }); } } //$(function () { initCarousels(); //});