//shop name var $ = window_jQuery; var ctaData = {}; ctaData.shop = shopCtaButton; ctaData.action = "getCtaGroupButton"; ctaData.current_page = __st.p; ctaData.window_width = $(window).outerWidth(); ctaData.window_height = $(window).outerHeight(); ctaData.cart_count = $("#CartCount span:first-child").text(); ctaData.pathname = window.location.pathname; ctaData.quote_list = localStorage.getItem(shopCtaButton + "_productIdAddQuoteList") !== null ? JSON.parse(localStorage.getItem(shopCtaButton + "_productIdAddQuoteList")) .length : 0; ctaData.current_domain = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search; $("body").append("
"); processCreateCtaButton(); async function processCreateCtaButton() { $.ajax({ dataType: "json", url: "/cart.js", }).done(function (res) { ctaData.item_count = res.item_count; getDataHtml(ctaData); }); } function getDataHtml(data) { $.get(rootLinkCta + "/cta-group-button.php", data, function (result) { if (typeof result == "string") { result = JSON.parse(result); console.log(result); } console.log(result.msg); $(".otGroupButton").append(result.html); }); } $(document).ready(function () { let debounce = false; $(document).on("click", ".ot-btn-item.back_to_top", function (e) { e.preventDefault(); if (debounce) return; debounce = true; setTimeout(() => { debounce = false; }, 2500); $("html, body").animate({ scrollTop: 0 }, "slow"); }); $(document).on("click", ".ot-btn-item.only_icon.zendesk", function (e) { e.preventDefault(); if ($(this).data("show") == 1) { $(".ot-btn-item.only_icon.zendesk").data("show", 0); $(".ot-btn-item.only_icon.zendesk").attr("data-show", 0); $zopim.livechat.window.hide(); } else { $(".ot-btn-item.only_icon.zendesk").data("show", 1); $(".ot-btn-item.only_icon.zendesk").attr("data-show", 1); $zopim.livechat.window.show(); } }); $(document).on("click", ".ot-btn-item.maps", function (e) { let btnId = $(this).attr("btn-id"); $(".modal-btn-id-" + btnId).css("visibility", "visible"); }); $(document).on("click", ".modal-close", function (e) { e.preventDefault(); let btnId = $(this).attr("btn-id"); $(".modal-btn-id-" + btnId).css("visibility", "hidden"); }); $(document).on("keyup", function (e) { if (e.key === "Escape") { $("#open-modal").css("visibility", "hidden"); } }); $(document).on("click", ".ot-btn-item.whatsapp-live-chat", function (e) { e.preventDefault(); let btnId = $(this).attr("btn-id"); $(".ot-whatsapp-box.btn-id-" + btnId).toggleClass("chatbox-opened"); $(this).find(".whatsapp-bubble").addClass("hide"); }); $(document).on("click", ".close-ot-chctbox", function (e) { e.preventDefault(); let btnId = $(this).attr("btn-id"); $(".ot-whatsapp-box.btn-id-" + btnId).removeClass("chatbox-opened"); }); $(document).scroll(function () { var y = $(this).scrollTop(); $(".cta_group_preview.check-scroll").each(function () { let dataScroll = parseInt($(this).data("scroll")); if (y > dataScroll) { $(this).fadeIn(); } else { $(this).fadeOut(); } }); }); $(document).on("click", ".ot-btn-item", function () { let $ = window_jQuery; let buttonName = $(this).data("type"), groupId = $(this).parents(".cta_group_preview ").attr("group-id"), buttonId = $(this).attr("btn-id"), gaCheck = $(this).data("ga"), faCheck = $(this).data("fa"); $.ajax({ url: `${rootLinkCta}/cta-group-button.php`, data: { shop: shopCtaButton, type: buttonName, buttonId: buttonId, groupId: groupId, action: "countClick", }, dataType: "JSON", type: "GET", }).done(function (resultSettings) {}); if (gaCheck === "enable") { ga("send", { hitType: "event", eventCategory: shopCtaButton, eventAction: "Click", eventLabel: "Omega_CTA_Buttons_" + buttonName, }); } if (faCheck === "enable") { fbq("trackCustom", "Omega_CTA_Buttons_" + buttonName); } }); });