PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 6.3.3
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v6.3.3
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 5.6.6 5.6.7 All 152 releases
poll-maker / admin / js / admin.js

admin.js in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 6.3.3, at admin/js/admin.js

149 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 'use strict';
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
22 $(document).on('click', '[data-slug="poll-maker"] .deactivate a', function () {
23 swal({
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>",
25 footer: '<a href="" class="ays-poll-temporary-deactivation">Temporary deactivation</a>',
26 type: 'question',
27 showCancelButton: true,
28 showCloseButton: true,
29 allowOutsideClick: false,
30 allowEscapeKey: false,
31 allowEnterKey: false,
32 confirmButtonColor: '#3085d6',
33 cancelButtonColor: '#d33',
34 confirmButtonText: 'Upgrade',
35 cancelButtonText: 'Deactivate',
36 confirmButtonClass: "ays-poll-upgrade-button",
37 cancelButtonClass: "ays-poll-cancel-button",
38 customClass: ".ays-poll-deactivate-popup",
39 }).then((result) => {
40 let upgrade_plugin = false;
41 if (result.value) upgrade_plugin = true;
42
43 if( result.dismiss && result.dismiss == 'close' ){
44 return false;
45 }
46
47 var wp_nonce = $(document).find('#ays_poll_maker_ajax_deactivate_plugin_nonce').val();
48 var feedback_container = $(document).find('.ays-poll-dialog-widget');
49
50 let data = {
51 action: 'apm_deactivate_plugin_option_pm',
52 upgrade_plugin,
53 _ajax_nonce: wp_nonce,
54 };
55 $.ajax({
56 url: apm_admin_ajax_obj.ajaxUrl,
57 method: "post",
58 dataType: 'json',
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 },
68 success() {
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 });
84 }
85 });
86 });
87 return false;
88 });
89
90 $(document).on('click', '.ays-poll-temporary-deactivation', function (e) {
91 e.preventDefault();
92
93 window.temporary_deactivation_flag = true;
94 $(document).find('.ays-poll-upgrade-button').trigger('click');
95
96 });
97
98 $('.ays-poll-upgrade-plugin-btn').hover(
99 function() {
100 $(this).css('color', '#3B8D3F');
101 },
102 function() {
103 $(this).css('color', '#01A32A');
104 }
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 });
148
149 })(jQuery);