(function($){ $(document).ready( function(){ var $save_message = $("#epanel-ajax-saving"), $save_message_spinner = $save_message.children("img"), $save_message_description = $save_message.children("span"); $("#et_aweber_connection .et_make_connection").on( "click", function( event ) { event.preventDefault(); $.ajax({ type: "POST", url: ajaxurl, data: { action : "et_aweber_submit_authorization_code", et_admin_load_nonce : et_advanced_options.et_admin_load_nonce, et_authorization_code : $("#et_aweber_authorization #et_aweber_authentication_code").val() }, beforeSend: function ( xhr ){ $( '#et_aweber_connection .et_result_error' ).remove(); $save_message.addClass( 'et_loading' ).removeClass( 'success-animation' ); $save_message.fadeIn('fast'); }, success: function( response ){ hide_ajax_popup( response ); if ( response === 'success' ) { $( '#et_aweber_authorization' ).hide(); $( '#et_aweber_remove_connection' ).show(); $save_message.addClass( 'success-animation' ); } else { aweber_show_error_message( response ); } } }); }); $("#et_aweber_connection .et_remove_connection").on( "click", function( event ) { event.preventDefault(); $.ajax({ type: "POST", url: ajaxurl, data: { action : "et_aweber_remove_connection", et_admin_load_nonce : et_advanced_options.et_admin_load_nonce }, beforeSend: function ( xhr ){ $save_message.fadeIn('fast'); }, success: function( response ){ hide_ajax_popup( response ); if ( response === 'success' ) { $( '#et_aweber_remove_connection' ).hide(); $("#et_aweber_authorization #et_aweber_authentication_code").val( '' ); $( '#et_aweber_authorization' ).show(); } else { aweber_show_error_message( response ); } } }); }); function aweber_show_error_message( response ) { var error_html = '
' + et_advanced_options.aweber_failed + '.
'; error_html += '' + response + '
'; error_html += '