PluginProbe
Media Cloud Sync / 1.2.2
Media Cloud Sync v1.2.2
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / assets / js / deactivate.js

deactivate.js in Media Cloud Sync 1.2.2, at assets/js/deactivate.js

129 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Deactivation Form
2 jQuery(document).ready(function () {
3 jQuery(document).on("click", function (e) {
4 var popup = document.getElementById("dw-wpmcs-survey-form");
5 var overlay = document.getElementById("dw-wpmcs-survey-form-wrap");
6 var openButton = document.getElementById("deactivate-media-cloud-sync");
7
8 if (e.target.id == "dw-wpmcs-survey-form-wrap") {
9 dwWpmcsClosePopup();
10 }
11 if (e.target === openButton) {
12 e.preventDefault();
13 popup.style.display = "block";
14 overlay.style.display = "block";
15 }
16 if (e.target.id == "dw-wpmcs-skip") {
17 e.preventDefault();
18 var urlRedirect = document
19 .querySelector("a#deactivate-media-cloud-sync")
20 .getAttribute("href");
21 window.location = urlRedirect;
22 }
23 if (e.target.id == "dw-wpmcs-cancel") {
24 e.preventDefault();
25 dwWpmcsClosePopup();
26 }
27 });
28
29 function dwWpmcsClosePopup() {
30 var popup = document.getElementById("dw-wpmcs-survey-form");
31 var overlay = document.getElementById("dw-wpmcs-survey-form-wrap");
32 popup.style.display = "none";
33 overlay.style.display = "none";
34 jQuery("#dw-wpmcs-survey-form form")[0].reset();
35 jQuery("#dw-wpmcs-survey-form form .dw-wpmcs-comments").hide();
36 jQuery("#dw-wpmcs-error").html("");
37 }
38
39 jQuery("#dw-wpmcs-survey-form form").on("submit", function (e) {
40 e.preventDefault();
41 var valid = dwWpmcsValidate();
42 if (valid) {
43 var urlRedirect = document
44 .querySelector("a#deactivate-media-cloud-sync")
45 .getAttribute("href");
46 var form = jQuery(this);
47 var formArray = form.serializeArray();
48 var jsonData = {};
49 formArray.forEach(function (item) {
50 jsonData[item.name] = item.value;
51 });
52 var actionUrl =
53 "https://feedbacks.dudlewebs.com/api/submit-feedback.php";
54 jQuery.ajax({
55 type: "post",
56 url: actionUrl,
57 data: jsonData,
58 dataType: "json",
59 beforeSend: function () {
60 jQuery("#dw-wpmcs-deactivate").prop("disabled", "disabled");
61 },
62 success: function (data) {
63 window.location = urlRedirect;
64 },
65 error: function (jqXHR, textStatus, errorThrown) {
66 window.location = urlRedirect;
67 },
68 });
69 }
70 });
71
72 jQuery("#dw-wpmcs-survey-form .dw-wpmcs-comments textarea").on(
73 "keyup",
74 function () {
75 dwWpmcsValidate();
76 }
77 );
78
79 jQuery("#dw-wpmcs-survey-form form input[type='radio']").on(
80 "change",
81 function () {
82 dwWpmcsValidate();
83 let val = jQuery(this).val();
84 if (
85 val == "I found a bug" ||
86 val == "Plugin suddenly stopped working" ||
87 val == "Plugin broke my site" ||
88 val == "Other" ||
89 val == "Plugin doesn't meet my requirement"
90 ) {
91 jQuery("#dw-wpmcs-survey-form form .dw-wpmcs-comments").show();
92 } else {
93 jQuery("#dw-wpmcs-survey-form form .dw-wpmcs-comments").hide();
94 }
95 }
96 );
97
98 function dwWpmcsValidate() {
99 var error = "";
100 var reason = jQuery(
101 "#dw-wpmcs-survey-form form input[name='reason']:checked"
102 ).val();
103 if (!reason) {
104 error += "Please select your reason for deactivation";
105 }
106 if (
107 error === "" &&
108 (reason == "I found a bug" ||
109 reason == "Plugin suddenly stopped working" ||
110 reason == "Plugin broke my site" ||
111 reason == "Other" ||
112 reason == "Plugin doesn't meet my requirement")
113 ) {
114 var comments = jQuery(
115 "#dw-wpmcs-survey-form .dw-wpmcs-comments textarea"
116 ).val();
117 if (comments.length <= 0) {
118 error += "Please specify";
119 }
120 }
121 if (error !== "") {
122 jQuery("#dw-wpmcs-error").html(error);
123 return false;
124 }
125 jQuery("#dw-wpmcs-error").html("");
126 return true;
127 }
128 });
129