| 1 |
(function ($) { |
| 2 |
// console.log('rc.js loaded'); |
| 3 |
$(document).on('click', '.rc-button-allow, .rc-button-skip, .rc-button-disallow', function () { |
| 4 |
let nonce = $(this).data('nonce'), |
| 5 |
rc_name = $(this).data('rc_name'), |
| 6 |
date_name = $(this).data('date_name'), |
| 7 |
allow_name = $(this).data('allow_name'), |
| 8 |
review_url = $(this).data('review_url'); |
| 9 |
|
| 10 |
$.ajax({ |
| 11 |
url: ajaxurl, |
| 12 |
type: 'POST', |
| 13 |
data: { |
| 14 |
action: 'rc_sdk_insights', |
| 15 |
button_val: this.value, |
| 16 |
nonce: nonce, |
| 17 |
rc_name: rc_name, |
| 18 |
date_name: date_name, |
| 19 |
allow_name: allow_name, |
| 20 |
}, |
| 21 |
success: function (response) { |
| 22 |
if (response.status == 'success') { |
| 23 |
if ('yes' == response.action) { |
| 24 |
setTimeout(() => { |
| 25 |
window.open(review_url, '_blank'); |
| 26 |
}, 500); |
| 27 |
} |
| 28 |
setTimeout(() => { |
| 29 |
location.reload(); |
| 30 |
}, 1500); |
| 31 |
} else { |
| 32 |
alert(response.message); |
| 33 |
} |
| 34 |
}, |
| 35 |
}); |
| 36 |
}); |
| 37 |
|
| 38 |
$(document).on('click', '.rc-global-notice .notice-dismiss', function () { |
| 39 |
let rc_name = $(this).closest('.rc-global-notice').find("[name='rc_name']").val(), |
| 40 |
nonce = $(this).closest('.rc-global-notice').find("[name='nonce']").val(); |
| 41 |
|
| 42 |
$.ajax({ |
| 43 |
url: ajaxurl, |
| 44 |
type: 'POST', |
| 45 |
data: { |
| 46 |
action: 'rc_sdk_dismiss_notice', |
| 47 |
nonce: nonce, |
| 48 |
rc_name: rc_name, |
| 49 |
}, |
| 50 |
}); |
| 51 |
}); |
| 52 |
|
| 53 |
// Show only the first RC notice |
| 54 |
var $notices = $('.rc-global-notice'); |
| 55 |
if ($notices.length > 0) { |
| 56 |
$notices.first().show(); |
| 57 |
} |
| 58 |
$(document).on('click', '.rc-global-notice .notice-dismiss', function() { |
| 59 |
var $currentNotice = $(this).closest('.rc-global-notice'); |
| 60 |
var $nextNotice = $currentNotice.nextAll('.rc-global-notice:first'); |
| 61 |
|
| 62 |
if ($nextNotice.length) { |
| 63 |
$nextNotice.show(); |
| 64 |
} |
| 65 |
}); |
| 66 |
$('.rc-global-notice button').on('click', function() { |
| 67 |
var $notice = $(this).closest('.rc-global-notice'); |
| 68 |
var $nextNotice = $notice.nextAll('.rc-global-notice:first'); |
| 69 |
|
| 70 |
$notice.fadeOut(300, function() { |
| 71 |
if ($nextNotice.length) { |
| 72 |
$nextNotice.fadeIn(); |
| 73 |
} |
| 74 |
}); |
| 75 |
}); |
| 76 |
|
| 77 |
})(jQuery); |