woocommerce/assets/js/frontend/add-payment-method.js

36 lines
1.1 KiB
JavaScript
Raw Normal View History

jQuery( function( $ ) {
// woocommerce_params is required to continue, ensure the object exists
2015-07-10 05:13:30 +00:00
if ( typeof woocommerce_params === 'undefined' ) {
return false;
2015-07-10 05:13:30 +00:00
}
$( '#add_payment_method' )
/* Payment option selection */
.on( 'click init_add_payment_method', '.payment_methods input.input-radio', function() {
if ( $( '.payment_methods input.input-radio' ).length > 1 ) {
var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) );
if ( $( this ).is( ':checked' ) && ! target_payment_box.is( ':visible' ) ) {
$( 'div.payment_box' ).filter( ':visible' ).slideUp( 250 );
if ( $( this ).is( ':checked' ) ) {
$( 'div.payment_box.' + $( this ).attr( 'ID' ) ).slideDown( 250 );
}
}
} else {
$( 'div.payment_box' ).show();
}
})
// Trigger initial click
2021-01-07 22:00:55 +00:00
.find( 'input[name=payment_method]:checked' ).trigger( 'click' );
$( '#add_payment_method' ).on( 'submit', function() {
2014-11-13 18:28:15 +00:00
$( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } });
});
2015-04-13 15:37:22 +00:00
$( document.body ).trigger( 'init_add_payment_method' );
});