| 1 |
;(function($) { |
| 2 |
$(document).on('change', '.better-payment .payment-form-layout-3 .payment-method-checkbox input', function() { |
| 3 |
if(this.checked) { |
| 4 |
$('.better-payment .payment-form-layout-3 .payment-method-checkbox').removeClass('active'); |
| 5 |
$(this).parent().addClass("active"); |
| 6 |
|
| 7 |
$('.better-payment .payment-form-layout-3 .payment-method-checkbox input').removeAttr('checked', ); |
| 8 |
$(this).attr('checked', true); |
| 9 |
|
| 10 |
let paypalBtnClassName = 'better-payment-paypal-bt'; |
| 11 |
let stripeBtnClassName = 'better-payment-stripe-bt'; |
| 12 |
let targetButtonClassName = $(this).hasClass('layout-payment-method-paypal') ? paypalBtnClassName : stripeBtnClassName; |
| 13 |
|
| 14 |
$('.better-payment .' + paypalBtnClassName + ', .better-payment .' + stripeBtnClassName).addClass('is-hidden'); |
| 15 |
$('.better-payment .' + targetButtonClassName).removeClass('is-hidden'); |
| 16 |
} |
| 17 |
}); |
| 18 |
|
| 19 |
$(document).on('change', '.better-payment .payment-form-layout-1 .payment-method-checkbox input, .better-payment .payment-form-layout-2 .payment-method-checkbox input', function(e) { |
| 20 |
if(this.checked) { |
| 21 |
let paypalBtnClassName = 'better-payment-paypal-bt'; |
| 22 |
let stripeBtnClassName = 'better-payment-stripe-bt'; |
| 23 |
let targetButtonClassName = $(this).hasClass('layout-payment-method-paypal') ? paypalBtnClassName : stripeBtnClassName; |
| 24 |
|
| 25 |
$('.better-payment .' + paypalBtnClassName + ', .better-payment .' + stripeBtnClassName).addClass('is-hidden'); |
| 26 |
$('.better-payment .' + targetButtonClassName).removeClass('is-hidden'); |
| 27 |
} |
| 28 |
}); |
| 29 |
|
| 30 |
$(document).on("click", ".better-payment .bp-modal-button", function (e) { |
| 31 |
e.preventDefault(); |
| 32 |
let $this = $(this); |
| 33 |
let modalWrap = $this.attr("data-targetwrap"); |
| 34 |
|
| 35 |
let modalSelector = "." + modalWrap + " .modal"; |
| 36 |
$(modalSelector).addClass("is-active"); |
| 37 |
}); |
| 38 |
|
| 39 |
$(document).on( |
| 40 |
"click", |
| 41 |
".better-payment .modal-background, .better-payment .modal-close, .better-payment .delete, .better-payment .bp-modal .cancel-button", |
| 42 |
function (e) { |
| 43 |
e.preventDefault(); |
| 44 |
let $this = $(this); |
| 45 |
let modalSelector = $this.closest(".bp-modal .modal"); |
| 46 |
|
| 47 |
$(modalSelector).removeClass("is-active"); |
| 48 |
} |
| 49 |
); |
| 50 |
})(jQuery); |