|
17 | 17 | }
|
18 | 18 | });
|
19 | 19 |
|
| 20 | + $('#mc_notice_button').on('click', function() { |
| 21 | + $('.mc-wc-notice').fadeOut() |
| 22 | + }); |
| 23 | + |
20 | 24 | // re-enable disable select input on audience settings submit
|
21 | 25 | $('#mailchimp_woocommerce_options').on('submit', function() {
|
22 | 26 | $('select[name="mailchimp-woocommerce[mailchimp_list]"]').prop('disabled', false);
|
|
331 | 335 | $('#mailchimp-oauth-error').hide();
|
332 | 336 | $('#mailchimp-oauth-connecting').hide();
|
333 | 337 | $('#mailchimp-oauth-connected').show();
|
334 |
| - |
| 338 | + |
| 339 | + let body = JSON.parse(finishResponse.data.body); |
335 | 340 | // get access_token from finishResponse and fill api-key field value including data_center
|
336 |
| - var accessToken = JSON.parse(finishResponse.data.body).access_token + '-' + JSON.parse(finishResponse.data.body).data_center |
| 341 | + var accessToken = body.access_token + '-' + body.data_center |
337 | 342 | $('#mailchimp-woocommerce-mailchimp-api-key').val(accessToken);
|
338 |
| - |
| 343 | + |
339 | 344 | // always go to next step on success, so change url of wp_http_referer
|
340 | 345 | if ($('input[name=mailchimp_woocommerce_wizard_on]').val() == 1) {
|
341 | 346 | var query = window.location.href.match(/^(.*)\&/);
|
|
374 | 379 | $('#tower_box_switch').change(function (e){
|
375 | 380 | var switch_button = this;
|
376 | 381 | var opt = this.checked ? 1 : 0;
|
| 382 | + var notice = $('.mc-wc-notice'); |
| 383 | + let notice_content = $('#mc_notice_text'); |
| 384 | + var content = $('.mc-wc-tab-content'); |
| 385 | + |
| 386 | + //content.addClass('loading'); |
| 387 | + |
| 388 | + notice_content.text(''); |
| 389 | + notice.removeClass('error success'); |
377 | 390 |
|
378 | 391 | var data = {
|
379 | 392 | action: 'mailchimp_woocommerce_tower_status',
|
|
384 | 397 | $('#tower_box_status_' + opt).show();
|
385 | 398 |
|
386 | 399 | $.post(ajaxurl, data, function(response) {
|
| 400 | + content.removeClass('loading'); |
387 | 401 | if (response.success) {
|
388 |
| - $('#mc-tower-save').html(response.data); |
389 |
| - $('#mc-tower-save').css('color', '#628735').show().fadeOut(3000); |
| 402 | + notice_content.text(response.data); |
| 403 | + notice.addClass('success').fadeIn(); |
390 | 404 | switch_button.checked = opt;
|
391 | 405 | }
|
392 | 406 | else {
|
393 |
| - $('#mc-tower-save').html(response.data.error); |
394 |
| - $('#mc-tower-save').css('color', 'red').show().fadeOut(3000); |
| 407 | + $('<div class="notices-content-wrapper sync-notices"><div class="notice notice-error inline is-dismissible"><p>' + response.data.error +'</p></div></div>').insertAfter('.mc-wc-tab-buttons'); |
395 | 408 | switch_button.checked = 1 - opt;
|
396 | 409 | $('.tower_box_status').hide();
|
397 | 410 | $('#tower_box_status_' + (1 - opt)).show();
|
|
402 | 415 | $('#comm_box_switch').change(function (e){
|
403 | 416 | var switch_button = this;
|
404 | 417 | var opt = this.checked ? 1 : 0;
|
405 |
| - |
| 418 | + var notice = $('.mc-wc-notice'); |
| 419 | + let notice_content = $('#mc_notice_text'); |
| 420 | + var content = $('.mc-wc-tab-content'); |
| 421 | + |
| 422 | + //content.addClass('loading'); |
| 423 | + |
| 424 | + notice_content.text(''); |
| 425 | + notice.removeClass('error success'); |
| 426 | + |
406 | 427 | var data = {
|
407 |
| - action: 'mailchimp_woocommerce_communication_status', |
| 428 | + action: 'mailchimp_woocommerce_communication_status', |
408 | 429 | opt: opt
|
409 | 430 | }
|
410 | 431 |
|
411 | 432 | $('.comm_box_status').hide();
|
412 | 433 | $('#comm_box_status_' + opt).show();
|
413 | 434 |
|
414 | 435 | $.post(ajaxurl, data, function(response) {
|
| 436 | + content.removeClass('loading'); |
415 | 437 | if (response.success) {
|
416 |
| - $('#mc-comm-save').html(response.data); |
417 |
| - $('#mc-comm-save').css('color', '#628735').show().fadeOut(3000); |
| 438 | + notice_content.text(response.data); |
| 439 | + notice |
| 440 | + .addClass('success') |
| 441 | + .fadeIn(); |
418 | 442 | switch_button.checked = opt;
|
419 | 443 | }
|
420 | 444 | else {
|
421 |
| - $('#mc-comm-save').html(response.data.error); |
422 |
| - $('#mc-comm-save').css('color', 'red').show().fadeOut(3000); |
| 445 | + $('<div class="notices-content-wrapper sync-notices"><div class="notice notice-error inline is-dismissible"><p>' + response.data.error +'</p></div></div>').insertAfter('.mc-wc-tab-buttons'); |
423 | 446 | switch_button.checked = 1 - opt;
|
424 | 447 | $('.comm_box_status').hide();
|
425 | 448 | $('#comm_box_status_' + (1 - opt)).show();
|
|
0 commit comments