add-payment-method.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. jQuery( function( $ ) {
  2. // woocommerce_params is required to continue, ensure the object exists
  3. if ( typeof woocommerce_params === 'undefined' ) {
  4. return false;
  5. }
  6. $( '#add_payment_method' )
  7. /* Payment option selection */
  8. .on( 'click init_add_payment_method', '.payment_methods input.input-radio', function() {
  9. if ( $( '.payment_methods input.input-radio' ).length > 1 ) {
  10. var target_payment_box = $( 'div.payment_box.' + $( this ).attr( 'ID' ) );
  11. if ( $( this ).is( ':checked' ) && ! target_payment_box.is( ':visible' ) ) {
  12. $( 'div.payment_box' ).filter( ':visible' ).slideUp( 250 );
  13. if ( $( this ).is( ':checked' ) ) {
  14. $( 'div.payment_box.' + $( this ).attr( 'ID' ) ).slideDown( 250 );
  15. }
  16. }
  17. } else {
  18. $( 'div.payment_box' ).show();
  19. }
  20. })
  21. // Trigger initial click
  22. .find( 'input[name=payment_method]:checked' ).click();
  23. $( '#add_payment_method' ).submit( function() {
  24. $( '#add_payment_method' ).block({ message: null, overlayCSS: { background: '#fff', opacity: 0.6 } });
  25. });
  26. $( document.body ).trigger( 'init_add_payment_method' );
  27. });