PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.10.5
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.10.5
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / js / setup-wizard.js

setup-wizard.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.10.5, at js/setup-wizard.js

311 lines 9.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Plugin Name: Visualizer: Tables and Charts for WordPress
3 * Plugin URI: https://themeisle.com/plugins/visualizer-charts-and-graphs/
4 * Author: Themeisle
5 *
6 * @package Visualizer
7 */
8 /* jshint unused:false */
9 jQuery(function ($) {
10 var provideContent = function(id, stepDirection, stepPosition, selStep, callback) {
11 // Import chart data.
12 if ( 1 == id ) {
13 var chartType = $(".vz-radio-btn:checked").val();
14 var percentBarWidth = 100;
15 var loaderDelay;
16 $.ajax( {
17 beforeSend: function() {
18 loaderDelay = setInterval(function () {
19 $('.vz-progress-bar').css({
20 width: percentBarWidth-- + '%'
21 });
22 }, 1000);
23 },
24 type: 'POST',
25 url: visualizerSetupWizardData.ajax.url,
26 dataType: 'json',
27 data: {
28 action: 'visualizer_wizard_step_process',
29 security: visualizerSetupWizardData.ajax.security,
30 chart_type: chartType,
31 step: 'step_2',
32 },
33 success: function (data) {
34 clearInterval( loaderDelay );
35 loaderDelay = setInterval(function () {
36 $('.vz-progress-bar').css({
37 width: percentBarWidth-- + '%'
38 });
39 if ( percentBarWidth <= 0 ) {
40 if ( 1 === data.success ) {
41 var importMessage = jQuery('[data-import_message]');
42 importMessage
43 .html( importMessage.data('import_message') )
44 .addClass('import_message');
45
46 $('#step-2').find('button.disabled').removeClass('disabled');
47 } else if( 2 === data.status && '' !== data.message ) {
48 $('#step-2')
49 .find('.vz-error-notice')
50 .html( '<p>' + data.message + '</p>' )
51 .removeClass('hidden');
52 } else {
53 $('#smartwizard').smartWizard('reset');
54 }
55 $('.vz-progress-bar').css({
56 width: 0
57 });
58 clearInterval( loaderDelay );
59 }
60 }, 100 );
61 },
62 error: function() {
63 $('#step-2').find('.vz-progress-bar').animate({ width: '0' });
64 }
65 } );
66 }
67 callback();
68 }
69 $("#smartwizard").smartWizard({
70 transition: {
71 animation: "fade", // Animation effect on navigation, none|fade|slideHorizontal|slideVertical|slideSwing|css(Animation CSS class also need to specify)
72 speed: "400", // Animation speed. Not used if animation is 'css'
73 },
74 lang: {
75 // Language variables for button
76 next: visualizerSetupWizardData.nextButtonText,
77 previous: visualizerSetupWizardData.backButtonText,
78 },
79 keyboard: {
80 keyNavigation: false, // Enable/Disable keyboard navigation(left and right keys are used if enabled)
81 },
82 anchor: {
83 enableNavigation: false, // Enable/Disable anchor navigation
84 enableNavigationAlways: false, // Activates all anchors clickable always
85 },
86 style: {
87 // CSS Class settings
88 btnCss: "",
89 btnNextCss: "btn-primary next-btn",
90 btnPrevCss: "btn-light",
91 },
92 getContent: provideContent
93 });
94
95 // click to open accordion.
96 $(".vz-accordion .vz-accordion-item .vz-accordion-item__button").on(
97 "click",
98 function () {
99 var current_item = $(this).parents();
100 $(".vz-accordion .vz-accordion-item .vz-accordion-item__content").each(
101 function (i, el) {
102 if ($(el).parent().is(current_item)) {
103 $(el).prev().toggleClass("is-active");
104 $(el).slideToggle();
105 $(this).toggleClass("is-active");
106 } else {
107 $(el).prev().removeClass("is-active");
108 $(el).slideUp();
109 $(this).removeClass("is-active");
110 }
111 }
112 );
113 }
114 );
115
116 // Click to next step.
117 $(document).on(
118 "click",
119 ".btn-primary:not(.next-btn,.vz-create-page,.vz-subscribe)",
120 function (e) {
121 var stepNumber = $(this).data("step_number");
122 switch (stepNumber) {
123 case 1:
124 if ($(".vz-radio-btn").is(":checked")) {
125 $('#smartwizard').smartWizard('next');
126 }
127 break;
128 case 3:
129 var urlParams = new URLSearchParams(window.location.search);
130 urlParams.set('preview_chart', Date.now());
131 window.location.hash = "#step-3";
132 window.location.search = urlParams;
133 break;
134 case 4:
135 $('#step-4').find('.spinner').addClass('is-active');
136 $('#step-4').find('.vz-error-notice').addClass('hidden');
137
138 $.post(
139 visualizerSetupWizardData.ajax.url,
140 {
141 action: 'visualizer_wizard_step_process',
142 security: visualizerSetupWizardData.ajax.security,
143 slug: 'optimole-wp',
144 step: 'step_4',
145 },
146 function (response) {
147 if (1 === response.status) {
148 $('#smartwizard').smartWizard('next');
149 } else if ( 'undefined' !== typeof response.message ) {
150 $('#step-4')
151 .find('.vz-error-notice')
152 .html("<p>" + response.message + "</p>");
153 $('#step-4').find('.vz-error-notice').removeClass('hidden');
154 }
155 $('#step-4').find('.spinner').removeClass('is-active');
156 }
157 ).fail(function () {
158 $('#step-4').find('.spinner').removeClass('is-active');
159 });
160 e.preventDefault();
161 break;
162 default:
163 e.preventDefault();
164 break;
165 }
166 }
167 );
168
169 // Create draft page.
170 $(document).on("click", ".vz-create-page", function (e) {
171 var _this = $(this);
172 _this.next(".spinner").addClass("is-active");
173 $.post(
174 visualizerSetupWizardData.ajax.url,
175 {
176 action: "visualizer_wizard_step_process",
177 security: visualizerSetupWizardData.ajax.security,
178 step: "create_draft_page",
179 basic_shortcode: $("#basic_shortcode").val(),
180 add_basic_shortcode: $("#insert_shortcode").is(":checked"),
181 },
182 function (res) {
183 if (res.status > 0) {
184 $("#smartwizard").smartWizard("next");
185 }
186 _this.next(".spinner").removeClass("is-active");
187 }
188 ).fail(function () {
189 _this.next(".spinner").removeClass("is-active");
190 });
191 e.preventDefault();
192 });
193
194 // Enable performance feature.
195 $("#step-4").on("change", "input:checkbox", function () {
196 if ($(this).is(":checked")) {
197 $(".skip-improvement").hide();
198 $(".vz-wizard-install-plugin").show();
199 } else {
200 $(".skip-improvement").show();
201 $(".vz-wizard-install-plugin").hide();
202 }
203 });
204
205 // Step: 4 Skip and subscribe process.
206 $(document).on( 'click', '.vz-subscribe', function (e) {
207 var withSubscribe = $(this).data("vz_subscribe");
208 var postData = {
209 action: "visualizer_wizard_step_process",
210 security: visualizerSetupWizardData.ajax.security,
211 step: "step_subscribe",
212 };
213 var emailElement = $("#vz_subscribe_email");
214 // Remove error message.
215 emailElement.next(".vz-field-error").remove();
216
217 if (withSubscribe) {
218 var subscribeEmail = emailElement.val();
219 var EmailTest = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
220 var errorMessage = "";
221
222 if ("" === subscribeEmail) {
223 errorMessage = visualizerSetupWizardData.errorMessages.requiredEmail;
224 } else if (!EmailTest.test(subscribeEmail)) {
225 errorMessage = visualizerSetupWizardData.errorMessages.invalidEmail;
226 }
227 if ("" !== errorMessage) {
228 $('<span class="vz-field-error">' + errorMessage + "</span>").insertAfter(emailElement);
229 return false;
230 }
231
232 postData.email = subscribeEmail;
233 postData.with_subscribe = withSubscribe;
234 }
235 var currentStep = $( '.vz-wizard-wrap .tab-pane:last-child' );
236 currentStep.find(".spinner").addClass("is-active");
237
238 $.post(visualizerSetupWizardData.ajax.url, postData, function (res) {
239 $('.redirect-popup').find('h3.popup-title').html(res.message);
240 $('.redirect-popup').show();
241 if (1 === res.status) {
242 setTimeout(function () {
243 window.location.href = res.redirect_to;
244 }, 5000);
245 } else {
246 $('.redirect-popup').hide();
247 }
248 currentStep.find('.spinner').removeClass('is-active');
249 }).fail(function () {
250 $('.redirect-popup').hide();
251 currentStep.find('.spinner').removeClass('is-active');
252 });
253 e.preventDefault();
254 });
255
256 // Click to copy.
257 var clipboard = new ClipboardJS(".vz-copy-code-btn");
258 clipboard.on("success", function (e) {
259 var inputElement = $(e.trigger).prev("input:text");
260 });
261
262 // Remove disabled class from get started button.
263 $("#step-1").on("change", "input:radio", function () {
264 $("#step-1").find('[data-step_number="1"]').removeClass("disabled");
265 });
266
267 // Change button text.
268 $(document).on("change", "#insert_shortcode", function () {
269 if ($(this).is(":checked")) {
270 $(".vz-create-page").html(
271 visualizerSetupWizardData.draftPageButtonText.firstButtonText +
272 ' <span class="dashicons dashicons-arrow-right-alt"></span>'
273 );
274 } else {
275 $(".vz-create-page").html(
276 visualizerSetupWizardData.draftPageButtonText.secondButtonText +
277 ' <span class="dashicons dashicons-arrow-right-alt"></span>'
278 );
279 }
280 });
281
282 $('.vz-chart-list > ul').slick({
283 dots: false,
284 infinite: false,
285 speed: 400,
286 slidesToShow: 1,
287 centerMode: false,
288 variableWidth: true
289 })
290 .on( 'afterChange', function(event, slick, currentSlide) {
291 // Disable next buttion.
292 if( currentSlide === 4 ) {
293 $('.slick-next').attr('disabled', true).css('pointer-events', 'none');
294 } else {
295 $('.slick-next').removeAttr('disabled').css('pointer-events', 'all');
296 }
297 // Disable prev buttion.
298 if( currentSlide === 0 ) {
299 $('.slick-prev').attr('disabled', true).css('pointer-events', 'none');
300 } else {
301 $('.slick-prev').removeAttr('disabled').css('pointer-events', 'all');
302 }
303 } );
304
305 $(window).bind('pageshow', function() {
306 if ( jQuery('.vz-chart-option input').is(':checked') ) {
307 $('#step-1').find('button.disabled').removeClass('disabled');
308 }
309 });
310 });
311