PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.4
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / deactivation-feedback / assets / deactivation-feedback.js

deactivation-feedback.js in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.4, at deactivation-feedback/assets/deactivation-feedback.js

147 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function () {
2 'use strict';
3
4 let deactivateUrl = '';
5 let currentPlugin = null;
6 let sending = false;
7
8 const modal = jQuery('#psm-dfr-modal');
9
10 /**
11 * Open feedback modal.
12 *
13 * @param {Object} plugin Plugin configuration.
14 * @param {string} url Deactivate URL.
15 */
16 function openModal(plugin, url) {
17 currentPlugin = plugin;
18 deactivateUrl = url;
19
20 jQuery('#psm-dfr-title').text('Quick Feedback');
21
22 jQuery('#psm-dfr-reasons').empty();
23
24 jQuery('#psm-dfr-note').val('');
25
26 jQuery('#psm-dfr-submit')
27 .prop('disabled', false)
28 .text('Submit & Deactivate');
29
30 jQuery.each(plugin.reasons, function (value, label) {
31 jQuery('#psm-dfr-reasons').append(
32 '<div>' +
33 '<label>' +
34 '<input type="radio" name="psm_dfr_reason" value="' +
35 value +
36 '"> ' +
37 label +
38 '</label>' +
39 '</div>'
40 );
41 });
42
43 jQuery('#psm-dfr-modal').fadeIn(150);
44 }
45
46 /**
47 * Close modal.
48 */
49 function closeModal() {
50 jQuery('#psm-dfr-modal').fadeOut(150);
51
52 jQuery('#psm-dfr-note').val('');
53
54 jQuery('#psm-dfr-reasons').empty();
55
56 sending = false;
57 }
58
59 /**
60 * Attach deactivate links.
61 */
62 jQuery.each(window.PSM_DFR.plugins, function (index, plugin) {
63 jQuery(document).on(
64 'click',
65 'tr[data-plugin="' + plugin.plugin_file + '"] .deactivate a',
66 function (event) {
67 event.preventDefault();
68
69 openModal(plugin, jQuery(this).attr('href'));
70 }
71 );
72 });
73
74 /**
75 * Cancel.
76 */
77 jQuery(document).on('click', '#psm-dfr-cancel', function () {
78 closeModal();
79 });
80
81 /**
82 * Overlay click.
83 */
84 jQuery(document).on('click', '.psm-dfr-overlay', function () {
85 closeModal();
86 });
87
88 /**
89 * Skip feedback.
90 */
91 jQuery(document).on('click', '#psm-dfr-skip', function () {
92 window.location.href = deactivateUrl;
93 });
94
95 /**
96 * Submit feedback.
97 */
98 jQuery(document).on('click', '#psm-dfr-submit', function () {
99 if (sending) {
100 return;
101 }
102
103 const reason =
104 jQuery('input[name="psm_dfr_reason"]:checked').val() || '';
105
106 const note = jQuery('#psm-dfr-note').val();
107
108 if ('' === reason) {
109 window.alert('Please select a reason.');
110
111 return;
112 }
113
114 sending = true;
115
116 jQuery(this).prop('disabled', true);
117
118 jQuery.ajax({
119 url: window.PSM_DFR.ajax_url,
120
121 type: 'POST',
122
123 timeout: 5000,
124
125 data: {
126 action: 'psm_dfr_submit',
127
128 nonce: window.PSM_DFR.nonce,
129
130 plugin_file: currentPlugin.plugin_file,
131
132 reason: reason,
133
134 note: note,
135 },
136
137 success: function () {
138 window.location.href = deactivateUrl;
139 },
140
141 error: function () {
142 window.location.href = deactivateUrl;
143 },
144 });
145 });
146 });
147