PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.12
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.12
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / admin / assets / js / review-prompt.js

review-prompt.js in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.12, at admin/assets/js/review-prompt.js

98 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($, window) {
2 'use strict';
3
4 var data = window.wpfnlReviewPromptData || {};
5 var minChars = parseInt(data.minChars, 10);
6
7 if (isNaN(minChars) || minChars <= 0) {
8 minChars = 50;
9 }
10
11 var errorMessage = data.errorMessage || ('Please share at least ' + minChars + ' characters so we can understand what needs improvement and make things better for you and other users.');
12 var ajaxUrl = data.ajaxUrl || (typeof window.ajaxurl !== 'undefined' ? window.ajaxurl : '');
13
14 $(function () {
15 var selectedFeedbackType = '';
16
17 setTimeout(function () {
18 $('#wpfnl-review-prompt').fadeIn();
19 }, 2000);
20
21 function sendAction(actionType, feedback, feedbackType) {
22 if (!ajaxUrl) {
23 return;
24 }
25
26 $.post(ajaxUrl, {
27 action: 'wpfnl_review_action',
28 wpfnl_action_type: actionType,
29 feedback: feedback || '',
30 feedback_type: feedbackType || '',
31 nonce: data.nonce || ''
32 });
33 }
34
35 $('#wpfnl-review-close').on('click', function () {
36 $('#wpfnl-review-prompt').fadeOut();
37 sendAction('snooze');
38 });
39
40 $('#wpfnl-review-yes').on('click', function () {
41 $('#wpfnl-review-prompt').fadeOut();
42 sendAction('completed');
43 });
44
45 $('#wpfnl-review-okay, #wpfnl-review-no').on('click', function () {
46 $(this).addClass('selected').siblings().removeClass('selected');
47 $('#wpfnl-review-text').text('Sorry to hear that! What could we do better?');
48 $('#wpfnl-feedback-form').fadeIn();
49 selectedFeedbackType = $(this).attr('data-feedback-type') || '';
50 });
51
52 $('#wpfnl-feedback-cancel').on('click', function () {
53 $('#wpfnl-feedback-form').hide();
54 $('#wpfnl-review-options').fadeIn();
55 $('#wpfnl-review-text').text('Is WPFunnels helping you grow your WooCommerce store?');
56 $('#wpfnl-feedback-text').val('');
57 $('#wpfnl-char-count').text('0');
58 $('#wpfnl-char-counter').css('color', '#58151c');
59 $('#wpfnl-feedback-error').remove();
60 $('.wpfnl-review-btn').removeClass('selected');
61 selectedFeedbackType = '';
62 });
63
64 $('#wpfnl-feedback-text').on('input', function () {
65 var len = $(this).val().trim().length;
66 $('#wpfnl-char-count').text(len);
67 $('#wpfnl-feedback-error').hide();
68
69 if (len >= minChars) {
70 $('#wpfnl-char-counter').css('color', '#00a32a');
71 } else {
72 $('#wpfnl-char-counter').css('color', '#d14957');
73 }
74 });
75
76 $('#wpfnl-feedback-submit').on('click', function () {
77 var feedback = $('#wpfnl-feedback-text').val();
78
79 if (feedback.trim().length < minChars) {
80 if ($('#wpfnl-feedback-error').length === 0) {
81 $('#wpfnl-char-counter').after('<div id="wpfnl-feedback-error" style="background-color: #fcf0f1; border-left: 3px solid #d63638; padding: 10px 12px; font-size: 12px; color: #d63638; line-height: 1.4; margin-bottom: 12px; border-radius: 0 3px 3px 0; margin-top: 3px;">' + errorMessage + '</div>');
82 } else {
83 $('#wpfnl-feedback-error').text(errorMessage).show();
84 }
85
86 return;
87 }
88
89 $(this).text('Submitting...').prop('disabled', true);
90 sendAction('feedback', feedback, selectedFeedbackType);
91
92 setTimeout(function () {
93 $('#wpfnl-review-prompt').fadeOut();
94 }, 500);
95 });
96 });
97 })(jQuery, window);
98