paypal-admin.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. jQuery( function( $ ) {
  2. 'use strict';
  3. /**
  4. * Object to handle PayPal admin functions.
  5. */
  6. var wc_paypal_admin = {
  7. isTestMode: function() {
  8. return $( '#woocommerce_paypal_testmode' ).is( ':checked' );
  9. },
  10. /**
  11. * Initialize.
  12. */
  13. init: function() {
  14. $( document.body ).on( 'change', '#woocommerce_paypal_testmode', function() {
  15. var test_api_username = $( '#woocommerce_paypal_sandbox_api_username' ).parents( 'tr' ).eq( 0 ),
  16. test_api_password = $( '#woocommerce_paypal_sandbox_api_password' ).parents( 'tr' ).eq( 0 ),
  17. test_api_signature = $( '#woocommerce_paypal_sandbox_api_signature' ).parents( 'tr' ).eq( 0 ),
  18. live_api_username = $( '#woocommerce_paypal_api_username' ).parents( 'tr' ).eq( 0 ),
  19. live_api_password = $( '#woocommerce_paypal_api_password' ).parents( 'tr' ).eq( 0 ),
  20. live_api_signature = $( '#woocommerce_paypal_api_signature' ).parents( 'tr' ).eq( 0 );
  21. if ( $( this ).is( ':checked' ) ) {
  22. test_api_username.show();
  23. test_api_password.show();
  24. test_api_signature.show();
  25. live_api_username.hide();
  26. live_api_password.hide();
  27. live_api_signature.hide();
  28. } else {
  29. test_api_username.hide();
  30. test_api_password.hide();
  31. test_api_signature.hide();
  32. live_api_username.show();
  33. live_api_password.show();
  34. live_api_signature.show();
  35. }
  36. } );
  37. $( '#woocommerce_paypal_testmode' ).change();
  38. }
  39. };
  40. wc_paypal_admin.init();
  41. });