PluginProbe
Survey Maker by AYS / 5.2.3.9
Survey Maker by AYS v5.2.3.9
5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 5.2.0.9 5.2.1.0 All 152 releases
survey-maker / admin / js / admin.js

admin.js in Survey Maker by AYS 5.2.3.9, at admin/js/admin.js

132 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 'use strict';
3 $.fn.serializeFormJSON = function () {
4 var o = {},
5 a = this.serializeArray();
6 $.each(a, function () {
7 if (o[this.name]) {
8 if (!o[this.name].push) {
9 o[this.name] = [o[this.name]];
10 }
11 o[this.name].push(this.value || '');
12 } else {
13 o[this.name] = this.value || '';
14 }
15 });
16 return o;
17 };
18
19 window.temporary_deactivation_flag = false;
20
21
22 $(document).on('click', '[data-slug="survey-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="javascript:void(0);" class="ays-survey-temporary-deactivation">Temporary deactivation</a>',
26 type: 'question',
27 showCloseButton: true,
28 showCancelButton: 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-survey-upgrade-button",
37 cancelButtonClass: "ays-survey-cancel-button",
38 customClass: "ays-survey-deactivate-popup",
39 }).then(function(result) {
40
41 if( result.dismiss && result.dismiss == 'close' ){
42 return false;
43 }
44
45 var wp_nonce = $(document).find('#ays_survey_ajax_deactivate_plugin_nonce').val();
46 var feedback_container = $(document).find('.ays-survey-dialog-widget');
47 var upgrade_plugin = false;
48 if (result.value) upgrade_plugin = true;
49 var data = {
50 action: 'deactivate_plugin_option_sm',
51 upgrade_plugin: upgrade_plugin,
52 _ajax_nonce: wp_nonce,
53 };
54 $.ajax({
55 url: SurveyMakerAdmin.ajaxUrl,
56 method: 'post',
57 dataType: 'json',
58 data: data,
59 beforeSend: function( xhr ) {
60 if(window.temporary_deactivation_flag === false && feedback_container.length > 0){
61 if(!feedback_container.hasClass('ays-survey-dialog-widget-show')){
62 feedback_container.css('display', 'flex');
63 feedback_container.addClass('ays-survey-dialog-widget-show');
64 }
65 }
66 },
67
68 success:function () {
69 if(window.temporary_deactivation_flag === false && feedback_container.length > 0){
70 if(!feedback_container.hasClass('ays-survey-dialog-widget-show')){
71 feedback_container.css('display', 'flex');
72 }
73 }
74 else{
75 window.location = $(document).find('[data-slug="survey-maker"]').find('.deactivate').find('a').attr('href');
76 }
77 }
78 });
79 });
80 return false;
81 });
82
83 $(document).on('click', '.ays-survey-temporary-deactivation', function (e) {
84 e.preventDefault();
85 window.temporary_deactivation_flag = true;
86 $(document).find('.ays-survey-upgrade-button').trigger('click');
87
88 });
89
90 $(document).on('click', '.ays-survey-dialog-button', function (e) {
91 e.preventDefault();
92
93 var _this = $(this);
94 var parent = _this.parents('.ays-survey-dialog-widget');
95 var form = parent.find('form');
96
97 var data = form.serializeFormJSON();
98
99 var type = _this.attr('data-type');
100 data.type = type;
101 data._ajax_nonce = data.ays_survey_deactivate_feedback_nonce;
102
103 $.ajax({
104 url: SurveyMakerAdmin.ajaxUrl,
105 method: 'post',
106 dataType: 'json',
107 data: data,
108 success:function () {
109 parent.css('display', 'none');
110 window.location = $(document).find('[data-slug="survey-maker"]').find('.deactivate').find('a').attr('href');
111 },
112 error: function(){
113 parent.css('display', 'none');
114 window.location = $(document).find('[data-slug="survey-maker"]').find('.deactivate').find('a').attr('href');
115 }
116 });
117 });
118
119 // Close Feedback popup clicking outside
120 $(document).find('.ays-survey-dialog-widget').on('click', function(e){
121 var modalBox = $(e.target).attr('class');
122 var feedback_container = $(document).find('.ays-survey-dialog-widget');
123 if (typeof modalBox != 'undefined' && modalBox != "" && modalBox.indexOf('ays-survey-dialog-widget-show') != -1) {
124 if(feedback_container.hasClass('ays-survey-dialog-widget-show')){
125 feedback_container.removeClass('ays-survey-dialog-widget-show');
126 }
127 feedback_container.css('display', 'none');
128 window.temporary_deactivation_flag = false;
129 }
130 });
131
132 })(jQuery);