review.js
36 lines
| 1 | jQuery(document).ready(function () { |
| 2 | jQuery("#njt-fs-review a").on("click", function () { |
| 3 | const thisElement = this; |
| 4 | const fieldValue = jQuery(thisElement).attr("data"); |
| 5 | const freeLink = "https://wordpress.org/support/plugin/filester/reviews/#new-post"; |
| 6 | let hidePopup = false; |
| 7 | if (fieldValue == "rateNow") { |
| 8 | window.open(freeLink, "_blank"); |
| 9 | } else { |
| 10 | hidePopup = true; |
| 11 | } |
| 12 | |
| 13 | jQuery |
| 14 | .ajax({ |
| 15 | dataType: 'json', |
| 16 | url: wpDataFs.admin_ajax, |
| 17 | type: "post", |
| 18 | data: { |
| 19 | action: "njt_fs_save_review", |
| 20 | field: fieldValue, |
| 21 | nonce: wpDataFs.nonce, |
| 22 | }, |
| 23 | }) |
| 24 | .done(function (result) { |
| 25 | if (hidePopup == true) { |
| 26 | jQuery( "#njt-fs-review .notice-dismiss" ).trigger( "click" ); |
| 27 | } |
| 28 | }) |
| 29 | .fail(function (res) { |
| 30 | if (hidePopup == true) { |
| 31 | console.log(res.responseText); |
| 32 | jQuery( "#njt-fs-review .notice-dismiss" ).trigger( "click" ); |
| 33 | } |
| 34 | }); |
| 35 | }) |
| 36 | }) |