| @@ -1,15 +1,15 @@ | ||
| 1 | 1 | ( function() { |
| 2 | 2 | function setupStripeConnectListener() { |
| 3 | - onclickPreventDefault( '#frm_disconnect_stripe', handleStripeDisconnectClick ); | |
| 4 | - onclickPreventDefault( '#frm_reauth_stripe', handleStripeReauthClick ); | |
| 5 | - onclickPreventDefault( '#frm_connect_with_oauth', handleConnectWithOauth ); | |
| 3 | + onclickPreventDefault( '.frm_disconnect_stripe', handleStripeDisconnectClick ); | |
| 4 | + onclickPreventDefault( '.frm_reauth_stripe', handleStripeReauthClick ); | |
| 5 | + onclickPreventDefault( '.frm_connect_with_oauth', handleConnectWithOauth ); | |
| 6 | 6 | renderStripeConnectSettingsButton(); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | function renderStripeConnectSettingsButton() { |
| 10 | 10 | const container = document.getElementById( 'frm_strp_settings_container' ); |
| 11 | - if ( null !== container ) { | |
| 11 | + if ( container ) { | |
| 12 | 12 | postAjax( |
| 13 | 13 | { |
| 14 | 14 | action: 'frm_strp_connect_get_settings_button' |
| 15 | 15 | }, |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | function handleStripeReauthClick( trigger ) { |
| 47 | 47 | strpSettingsAjaxRequest( |
| 48 | 48 | 'frm_stripe_connect_reauth', |
| 49 | 49 | function( data ) { |
| 50 | - if ( 'undefined' !== typeof data.connect_url ) { | |
| 50 | + if ( data.connect_url !== undefined ) { | |
| 51 | 51 | window.location = data.connect_url; |
| 52 | 52 | } else { |
| 53 | 53 | renderStripeConnectSettingsButton(); |
| 54 | 54 | } |
| @@ -61,9 +61,9 @@ | ||
| 61 | 61 | trigger.classList.add( 'frm_loading_button' ); |
| 62 | 62 | strpSettingsAjaxRequest( |
| 63 | 63 | 'frm_stripe_connect_oauth', |
| 64 | 64 | function( data ) { |
| 65 | - if ( 'undefined' !== typeof data.redirect_url ) { | |
| 65 | + if ( data.redirect_url !== undefined ) { | |
| 66 | 66 | window.location = data.redirect_url; |
| 67 | 67 | } else { |
| 68 | 68 | renderStripeConnectSettingsButton(); |
| 69 | 69 | } |
| @@ -73,10 +73,10 @@ | ||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | function strpSettingsAjaxRequest( action, success, testMode ) { |
| 76 | 76 | const data = { |
| 77 | - action: action, | |
| 78 | - testMode: testMode, | |
| 77 | + action, | |
| 78 | + testMode, | |
| 79 | 79 | nonce: frmGlobal.nonce |
| 80 | 80 | }; |
| 81 | 81 | postAjax( data, success ); |
| 82 | 82 | } |
| @@ -84,9 +84,9 @@ | ||
| 84 | 84 | function postAjax( data, success ) { |
| 85 | 85 | const xmlHttp = new XMLHttpRequest(); |
| 86 | 86 | const params = typeof data === 'string' ? data : Object.keys( data ).map( |
| 87 | 87 | function( k ) { |
| 88 | - return encodeURIComponent( k ) + '=' + encodeURIComponent( data[ k ] ); | |
| 88 | + return `${ encodeURIComponent( k ) }=${ encodeURIComponent( data[ k ] ) }`; | |
| 89 | 89 | } |
| 90 | 90 | ).join( '&' ); |
| 91 | 91 | |
| 92 | 92 | xmlHttp.open( 'post', ajaxurl, true ); |
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | response = xmlHttp.responseText; |
| 97 | 97 | if ( response !== '' ) { |
| 98 | 98 | response = JSON.parse( response ); |
| 99 | 99 | if ( response.success ) { |
| 100 | - if ( 'undefined' === typeof response.data ) { | |
| 100 | + if ( response.data === undefined ) { | |
| 101 | 101 | response.data = {}; |
| 102 | 102 | } |
| 103 | 103 | success( response.data ); |
| 104 | 104 | } |