PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.5.1
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.5.1
6.5.1 6.5.0 6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 All 154 releases
← All changes | admin/js/admin.js +85 -1 5.6.2 → 6.5.1 View file →
@@ -1,7 +1,25 @@
1 1 (function($) {
2 2 'use strict';
3 3
4 + $.fn.serializeFormJSON = function () {
5 + var o = {},
6 + a = this.serializeArray();
7 + $.each(a, function () {
8 + if (o[this.name]) {
9 + if (!o[this.name].push) {
10 + o[this.name] = [o[this.name]];
11 + }
12 + o[this.name].push(this.value || '');
13 + } else {
14 + o[this.name] = this.value || '';
15 + }
16 + });
17 + return o;
18 + };
19 +
20 + window.temporary_deactivation_flag = false;
21 +
4 22 $(document).on('click', '[data-slug="poll-maker"] .deactivate a', function () {
5 23 swal({
6 24 html: "<h2>Do you want to upgrade to Pro version or permanently delete the plugin?</h2><ul><li>Upgrade: Your data will be saved for upgrade.</li><li>Deactivate: Your data will be deleted completely.</li></ul>",
7 25 footer: '<a href="" class="ays-poll-temporary-deactivation">Temporary deactivation</a>',
@@ -26,8 +44,9 @@
26 44 return false;
27 45 }
28 46
29 47 var wp_nonce = $(document).find('#ays_poll_maker_ajax_deactivate_plugin_nonce').val();
48 + var feedback_container = $(document).find('.ays-poll-dialog-widget');
30 49
31 50 let data = {
32 51 action: 'apm_deactivate_plugin_option_pm',
33 52 upgrade_plugin,
@@ -37,10 +56,32 @@
37 56 url: apm_admin_ajax_obj.ajaxUrl,
38 57 method: "post",
39 58 dataType: 'json',
40 59 data,
60 + beforeSend: function( xhr ) {
61 + if(window.temporary_deactivation_flag === false && feedback_container.length > 0){
62 + if(!feedback_container.hasClass('ays-poll-dialog-widget-show')){
63 + feedback_container.css('display', 'flex');
64 + feedback_container.addClass('ays-poll-dialog-widget-show');
65 + }
66 + }
67 + },
41 68 success() {
42 - location.replace($('[data-slug="poll-maker"] .deactivate a').attr('href'))
69 + if(window.temporary_deactivation_flag === false && feedback_container.length > 0){
70 + if(!feedback_container.hasClass('ays-poll-dialog-widget-show')){
71 + feedback_container.css('display', 'flex');
72 + }
73 + } else {
74 + window.location = $(document).find('[data-slug="poll-maker"]').find('.deactivate').find('a').attr('href');
75 + }
76 + },
77 + error: function(){
78 + swal.fire({
79 + type: 'info',
80 + html: "<h2>"+ apm_admin_ajax_obj.errorMsg +"</h2><p>"+ apm_admin_ajax_obj.somethingWentWrong +"</p>"
81 + }).then( function(res) {
82 + window.location = $(document).find('[data-slug="poll-maker"]').find('.deactivate').find('a').attr('href');
83 + });
43 84 }
44 85 });
45 86 });
46 87 return false;
@@ -48,8 +89,9 @@
48 89
49 90 $(document).on('click', '.ays-poll-temporary-deactivation', function (e) {
50 91 e.preventDefault();
51 92
93 + window.temporary_deactivation_flag = true;
52 94 $(document).find('.ays-poll-upgrade-button').trigger('click');
53 95
54 96 });
55 97
@@ -60,6 +102,48 @@
60 102 function() {
61 103 $(this).css('color', '#01A32A');
62 104 }
63 105 );
106 +
107 + $(document).on('click', '.ays-poll-dialog-button', function (e) {
108 + e.preventDefault();
109 +
110 + var _this = $(this);
111 + var parent = _this.parents('.ays-poll-dialog-widget');
112 + var form = parent.find('form');
113 +
114 + var data = form.serializeFormJSON();
115 +
116 + var type = _this.attr('data-type');
117 + data.type = type;
118 + data._ajax_nonce = data.ays_poll_deactivate_feedback_nonce;
119 +
120 + $.ajax({
121 + url: apm_admin_ajax_obj.ajaxUrl,
122 + method: 'post',
123 + dataType: 'json',
124 + data: data,
125 + success:function () {
126 + parent.css('display', 'none');
127 + window.location = $(document).find('[data-slug="poll-maker"]').find('.deactivate').find('a').attr('href');
128 + },
129 + error: function(){
130 + parent.css('display', 'none');
131 + window.location = $(document).find('[data-slug="poll-maker"]').find('.deactivate').find('a').attr('href');
132 + }
133 + });
134 + });
135 +
136 + // Close Feedback popup clicking outside
137 + $(document).find('.ays-poll-dialog-widget').on('click', function(e){
138 + var modalBox = $(e.target).attr('class');
139 + var feedback_container = $(document).find('.ays-poll-dialog-widget');
140 + if (typeof modalBox != 'undefined' && modalBox != "" && modalBox.indexOf('ays-poll-dialog-widget-show') != -1) {
141 + if(feedback_container.hasClass('ays-poll-dialog-widget-show')){
142 + feedback_container.removeClass('ays-poll-dialog-widget-show');
143 + }
144 + feedback_container.css('display', 'none');
145 + window.temporary_deactivation_flag = false;
146 + }
147 + });
64 148
65 149 })(jQuery);