PluginProbe
Autoptimize / trunk
Autoptimize vtrunk
3.1.16 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 All 108 releases
autoptimize / classes / static / exit-survey / exit-survey.js

exit-survey.js in Autoptimize trunk, at classes/static/exit-survey/exit-survey.js

123 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 $(document).ready(function () {
3 var targetElement = 'tr[data-slug="autoptimize"] span.deactivate a';
4 var redirectUrl = $(targetElement).attr('href');
5 if ($('.ao-feedback-overlay').length === 0) {
6 $('body').prepend('<div class="ao-feedback-overlay"></div>');
7 }
8 $('#ao_uninstall_feedback_popup').appendTo($(targetElement).parent());
9
10 $(targetElement).on('click', function (e) {
11 e.preventDefault();
12 $('#ao_uninstall_feedback_popup ').addClass('active');
13 $('body').addClass('ao-feedback-open');
14 $('.ao-feedback-overlay').on('click', function () {
15 $('#ao_uninstall_feedback_popup ').removeClass('active');
16 $('body').removeClass('ao-feedback-open');
17 });
18 });
19
20 $('#ao_uninstall_feedback_popup .info-disclosure-link').on('click', function (e) {
21 e.preventDefault();
22 $(this).parent().find('.info-disclosure-content').toggleClass('active');
23 });
24
25 $('#ao_uninstall_feedback_popup input[type="radio"]').on('change', function () {
26 var radio = $(this);
27 $('p.last-attempt').hide();
28 if (radio.parent().find('textarea').length > 0 &&
29 radio.parent().find('textarea').val().length === 0) {
30 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').attr('disabled', 'disabled');
31 radio.parent().find('textarea').on('keyup', function (e) {
32 if ($(this).val().length === 0) {
33 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').attr('disabled', 'disabled');
34 } else if ( $('#ao_feedback998')[0].checkValidity() == true ) {
35 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').removeAttr('disabled');
36 }
37 });
38 } else {
39 if ( $('#ao_feedback998')[0].checkValidity() == true ) {
40 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').removeAttr('disabled');
41 }
42 $(this).siblings('p.last-attempt').show();
43 }
44 });
45
46 $('#ao_feedback998').on('keyup', function (e) {
47 email_node = $(this);
48 email_val = email_node.val();
49 if ( email_val.length > 0 && email_node[0].checkValidity() == false ) {
50 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').attr('disabled', 'disabled');
51 } else if ( $( '#ao_uninstall_feedback_popup input[name="ao-deactivate-option"]:checked' ).length > 0 ) {
52 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').removeAttr('disabled');
53 }
54 });
55
56 $('#ao_uninstall_feedback_popup #ao-deactivate-no').on('click', function (e) {
57 e.preventDefault();
58 e.stopPropagation();
59 $(targetElement).unbind('click');
60 $('body').removeClass('ao-feedback-open');
61 $('#ao_uninstall_feedback_popup').remove();
62 if (redirectUrl !== '') {
63 location.href = redirectUrl;
64 }
65 });
66
67 $('#ao_uninstall_feedback_popup #ao-deactivate-cancel').on('click', function (e) {
68 e.preventDefault();
69 e.stopPropagation();
70 $('#ao_uninstall_feedback_popup ').removeClass('active');
71 $('body').removeClass('ao-feedback-open');
72 });
73
74 $('#ao_feedback_email_toggle').on('click', function (e) {
75 $('#ao_feedback998').toggle();
76 });
77
78 $('#ao_uninstall_feedback_popup #ao-deactivate-yes').on('click', function (e) {
79 e.preventDefault();
80 e.stopPropagation();
81 $(targetElement).unbind('click');
82
83 var modal_data = JSON.parse(atob($('#ao_uninstall_feedback_popup').data('modal')))
84
85 var selectedOption = $( '#ao_uninstall_feedback_popup input[name="ao-deactivate-option"]:checked' );
86
87 var reason;
88
89 if( selectedOption.attr("id") === "ao_feedback999" ){
90 reason = 'Other: ' + selectedOption.parent().find('textarea').val().trim()
91 }else{
92 reason = selectedOption.parent().find('label').attr('data-reason').trim()
93 }
94
95 var data = {
96 'url': modal_data.home,
97 'reason': reason,
98 'type': 'WP ' + $('#core_version').text().trim(),
99 'version' : 'AO ' + $('#ao_plugin_version').text().trim(),
100 'email': $('#ao_feedback998').val().trim(),
101 };
102
103 $.ajax({
104 type: 'POST',
105 url: atob( modal_data.dest ),
106 data: data,
107 complete() {
108 $('body').removeClass('ao-feedback-open');
109 $('#ao_uninstall_feedback_popup').remove();
110 if (redirectUrl !== '') {
111 location.href = redirectUrl;
112 }
113 },
114 beforeSend() {
115 $('#ao_uninstall_feedback_popup').addClass('sending-feedback');
116 $('#ao_uninstall_feedback_popup .popup--footer').remove();
117 $('#ao_uninstall_feedback_popup .popup--body').html('<i class="dashicons dashicons-update-alt"></i>');
118 }
119 });
120 });
121 });
122 })(jQuery);
123