Files
torebki-fabiola.pl/wp-content/plugins/platnosci-online-blue-media/assets/js/front.js.old
2026-03-05 13:07:40 +01:00

1 line
3.5 KiB
JavaScript

function addCurrentClass(e){const t=e.closest("#payment");e=t.querySelectorAll(".bm-payment-channel-item > input[type='radio']");const a=t.querySelector(".bm-group-expandable-wrapper"),o=t.querySelector("#bm-gateway-bank-group");e&&e.forEach(e=>{e.checked&&(e.closest(".bm-payment-channel-item").classList.toggle("selected"),isChild(e,t.querySelector("div.bm-group-expandable-wrapper"))||(a.classList.remove("active"),o.checked&&(o.checked=!o.checked))),t.querySelectorAll(".bm-payment-channel-item > input[type='radio']").forEach(e=>{!1===e.checked&&e.closest(".bm-payment-channel-item").classList.remove("selected")})})}function blueMediaRadioShow(){jQuery(".payment_box.payment_method_bluemedia .payment_box.payment_method_bacs").css("display","block")}function blueMediaRadioHide(){jQuery(".payment_box.payment_method_bluemedia .payment_box.payment_method_bacs").css("display","none")}function blueMediaRadioTest(){jQuery("#payment_method_bluemedia").is(":checked")&&blueMediaRadioShow()}function isChild(e,t){for(;null!=e&&"BODY"!=e.tagName.toUpperCase();){if(e==t)return!0;e=e.parentNode}return!1}jQuery(document).ready(function(){function t(){dataLayer.push(arguments)}var e;void 0!==window.blueMedia&&"undefined"!=typeof blue_media_ga4_tasks&&void 0!==blueMedia.ga4TrackingId&&(window.dataLayer=window.dataLayer||[],t("js",new Date),t("config",blueMedia.ga4TrackingId),e=JSON.parse(blue_media_ga4_tasks)[0].events,console.log(e),e.forEach(e=>{t("event",e.name,{items:e.params.items})}))}),document.addEventListener("click",function(e){e=(e=e||window.event).target||e.srcElement;document.querySelector(".bm-group-expandable-wrapper");e.hasAttribute("id")&&"bm-gateway-bank-group"==e.getAttribute("id")&&e.checked&&(document.querySelectorAll(".bm-group-expandable-wrapper").forEach(e=>{e.classList.add("active")}),document.querySelectorAll(".bm-payment-channel-item > input[type='radio']").forEach(e=>{e.checked&&(e.closest(".bm-payment-channel-item").classList.remove("selected"),e.checked=!e.checked)}))});const $button=jQuery("#place_order"),$paymentMethod=jQuery('#payment > ul.wc_payment_methods > li.wc_payment_method > input[type="radio"]'),isPaymentChecked=e=>{let t=!1;return jQuery(e).each(function(){if(jQuery(this).prop("checked"))return!(t=!0)}),t},updateButtonState=()=>{var e,t=isPaymentChecked($paymentMethod),a=jQuery("#payment_method_bluemedia").prop("checked");t&&a?(t=jQuery('#payment > ul.wc_payment_methods > li.wc_payment_method > .payment_method_bluemedia > .payment_box ul#shipping_method > div > li > ul > li > input[type="radio"]'),a=isPaymentChecked(t),t=jQuery("#bm-gateway-bank-group").prop("checked"),e=jQuery('#payment > ul.wc_payment_methods > li.wc_payment_method.payment_method_bluemedia > .payment_method_bluemedia .payment_method_bacs > .bm-payment-channels-wrapper ul.woocommerce-shipping-methods > .bm-group-expandable .bm-group-expandable-wrapper > li > input[type="radio"]'),e=isPaymentChecked(e),a&&t?e?(console.log("Aktywuj przycisk"),jQuery("#place_order").prop("disabled",!1)):(console.log("Dezaktywuj przycisk"),jQuery("#place_order").prop("disabled",!0)):a?(console.log("Aktywuj przycisk"),jQuery("#place_order").prop("disabled",!1)):(console.log("Dezaktywuj przycisk"),jQuery("#place_order").prop("disabled",!0))):(console.log("Aktywuj przycisk"),jQuery("#place_order").prop("disabled",!1))};jQuery(window).on("load",function(){setTimeout(function(){console.log("Cała strona została załadowana po czasie"),updateButtonState()},5e3)}),jQuery(document).on("change",'#payment > ul.wc_payment_methods > li input[type="radio"]',updateButtonState);