PluginProbe
Chartify – WordPress Chart Plugin / 3.5.2
Chartify – WordPress Chart Plugin v3.5.2
3.8.0 3.7.9 3.7.8 3.7.7 3.7.6 3.7.5 trunk 1.0.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 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.1.4 3.1.5 3.1.6 All 83 releases
chart-builder / admin / js / chart-builder-admin-general.js

chart-builder-admin-general.js in Chartify – WordPress Chart Plugin 3.5.2, at admin/js/chart-builder-admin-general.js

778 lines 30.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 $(document).ready(function () {
5 var sourceType = 'google-charts';
6 var chartType = 'pie_chart';
7
8 $('[data-toggle="popover"]').popover();
9 $('[data-bs-toggle="tooltip"]').tooltip();
10
11 /* == Add new modal configuration == */
12 $(document).on('dblclick', '.ays-chart-layer_box_blocks label.ays-chart-dblclick-layer:not(.ays-chart-type-pro-feature)', function(){
13 $(document).find('.ays-chart-select_button_layer input.ays-chart-layer_button').trigger('click');
14 });
15
16 $(document).on('change', '.ays-chart-choose-source', function(){
17 $(document).find('.ays-chart-select_button_layer input.ays-chart-layer_button').prop('disabled',false).attr("data-type" , $(this).val());
18 });
19
20 $(document).on('change', '.ays-chart-layer_box_source_type_select' ,function(){
21 var type = $(this).find('option:selected').val();
22
23 sourceType = type ?? 'google-charts';
24 $(document).find('.ays-chart-layer_box_blocks').hide();
25 $(document).find('.ays-chart-layer_box_blocks[source-type="' + sourceType + '"]').show();
26
27 if (sourceType === 'chart-js') {
28 $(document).find('.ays-chart-layer_box_link').hide();
29 } else {
30 $(document).find('.ays-chart-layer_box_link').show();
31 }
32 });
33
34 $(document).on('click', '.ays-chart-layer_button' ,function(){
35 chartType = $(document).find('.ays-chart-choose-source:checked').val();
36
37 var currentUrl = new URL(window.location.href);
38
39 currentUrl.searchParams.set('source', sourceType);
40 currentUrl.searchParams.set('type', chartType);
41
42 window.location.href = currentUrl.toString();
43 });
44 /* */
45
46 $(document).find('#ays-title').on('input', function () {
47 $(document).find('.ays_chart_title_in_top').text($(this).val());
48 });
49
50 $(document).find('.form-check-input.select-all').on('click', function() {
51 var checkboxes = $(document).find('.check-current-row');
52 if ($(this).prop('checked') == true && checkboxes.length !== 0) {
53 $(this).parents('thead').next('tbody').find('tr').addClass("ays-chart-tr-selected");
54 checkboxes.prop('checked',true);
55 $(document).find('#ays-chart-bulk-delete').prop('disabled', false);
56 $(document).find('#ays-chart-bulk-delete-bottom').prop('disabled', false);
57 } else {
58 $(this).parents('thead').next('tbody').find('tr').removeClass("ays-chart-tr-selected");
59 checkboxes.prop('checked',false);
60 $(document).find('#ays-chart-bulk-delete').prop('disabled', true);
61 $(document).find('#ays-chart-bulk-delete-bottom').prop('disabled', true);
62 }
63 });
64
65 $(document).find('.check-current-row').on('click', function() {
66 var checkboxesArr = $(document).find('.check-current-row');
67 var selectAllCheckBox = $(document).find('.form-check-input.select-all');
68 var count = 0;
69
70 for (var i = 0; i < checkboxesArr.length; i++) {
71 if (checkboxesArr.eq(i).prop('checked') == true) {
72 count++;
73 }
74 }
75
76 if ((count == 0 && selectAllCheckBox.prop('checked') == true) || (count != 0 && selectAllCheckBox.prop('checked') == true)) {
77 selectAllCheckBox.prop('checked', false);
78 } else if (count == checkboxesArr.length && selectAllCheckBox.prop('checked') == false) {
79 selectAllCheckBox.prop('checked', true);
80 }
81
82 if ( $(this).prop('checked') ) {
83 $(this).parents('tr').addClass("ays-chart-tr-selected");
84 $(document).find('#ays-chart-bulk-delete').prop('disabled', false);
85 $(document).find('#ays-chart-bulk-delete-bottom').prop('disabled', false);
86 } else if ( !$(this).prop('checked') && count > 0) {
87 $(this).parents('tr').removeClass("ays-chart-tr-selected");
88 $(document).find('#ays-chart-bulk-delete').prop('disabled', false);
89 $(document).find('#ays-chart-bulk-delete-bottom').prop('disabled', false);
90 } else {
91 $(this).parents('tr').removeClass("ays-chart-tr-selected");
92 $(document).find('#ays-chart-bulk-delete').prop('disabled', true);
93 $(document).find('#ays-chart-bulk-delete-bottom').prop('disabled', true);
94 }
95 });
96
97 // Bulk delete confirmation
98 $(document).on('click', '#ays-chart-bulk-delete', function(e) {
99 e.preventDefault();
100 var confirm = window.confirm(aysChartBuilderAdmin.confirmDelete);
101 if (confirm) {
102 $(document).find('#ays-chart-bulk-delete-confirm').trigger('click');
103 }
104 });
105 $(document).on('click', '#ays-chart-bulk-delete-bottom', function(e) {
106 e.preventDefault();
107 var confirm = window.confirm(aysChartBuilderAdmin.confirmDelete);
108 if (confirm) {
109 $(document).find('#ays-chart-bulk-delete-confirm-bottom').trigger('click');
110 }
111 });
112
113 // Delete confirmation
114 $(document).on('click', '.ays_chart_delete_confirm', function(e){
115 e.preventDefault();
116 var confirm = window.confirm(aysChartBuilderAdmin.confirmDelete);
117 if (confirm){
118 window.location.replace($(this).attr('href'));
119 }
120 });
121
122 function performSearch() {
123 var _this = $(this);
124 var parent = _this.parents('form');
125
126 var search_input = parent.find('input#ays-chart-search-input');
127 var input_value = search_input.val();
128
129 var field = 's';
130 var flag = false;
131 var url = window.location.href;
132 if (url.indexOf('?' + field + '=') != -1) {
133 flag = true;
134 } else if (url.indexOf('&' + field + '=') != -1) {
135 flag = true;
136 }
137
138 if (flag) {
139 if (typeof input_value != 'undefined' && input_value != "") {
140 url = location.href.replace(/&s=([^&]$|[^&]*)/i, "&s=" + input_value);
141 } else if (input_value == "") {
142 url = location.href.replace(/&s=([^&]$|[^&]*)/i, "");
143 }
144 } else {
145 if (typeof input_value != 'undefined' && input_value != "") {
146 url = location.href + "&s=" + input_value;
147 }
148 }
149
150 location.href = url.replace(/&paged=([^&]$|[^&]*)/i, "&paged=1");
151 }
152
153 $(document).find("input#ays-chart-search-input + button#ays-chart-search").on("click", function (e) {
154 e.preventDefault();
155 performSearch.call(this);
156 });
157
158 $(document).on("keypress", '#ays-chart-search-input', function (e) {
159 if (e.which === 13) {
160 e.preventDefault();
161 performSearch.call(this);
162 }
163 });
164
165 $(document).on("click", "button[id^='ays-chart-filter']", function (e) {
166 e.preventDefault();
167 var _this = $(this);
168 var parent = _this.parents('form');
169
170 var inputSelectors = ['#ays-chart-filter-select', '#ays-chart-filter-author', '#ays-chart-filter-source', '#ays-chart-filter-chart-source', '#ays-chart-filter-date', '#ays-chart-order-by', '#ays-chart-order'];
171 var inputValues = inputSelectors.map(selector => parent.find(selector).val());
172
173 var filterFields = ['filterbytype', 'filterbyauthor', 'filterbysource', 'filterbychartsource', 'filterbydate', 'orderby', 'order'];
174
175 addFiltersUrl(inputValues, filterFields);
176 });
177
178 $(document).on("click", "button[id^='ays-chart-filter-clear']", function (e) {
179 e.preventDefault();
180 clearFiltersUrl();
181 });
182
183 function addFiltersUrl(inputValues, filterFields) {
184 var url = window.location.href;
185 for (var i = 0; i < inputValues.length; i++) {
186 var flag = url.includes('?' + filterFields[i] + '=') || url.includes('&' + filterFields[i] + '=');
187 if (flag) {
188 url = url.replace(new RegExp('&?' + filterFields[i] + '=([^&]*)'), '');
189 }
190 if (inputValues[i]) {
191 url += '&' + filterFields[i] + '=' + inputValues[i];
192 }
193 }
194
195 location.href = url.replace(/&paged=([^&]$|[^&]*)/i, "&paged=1");
196 }
197
198 function clearFiltersUrl() {
199 var url = window.location.href;
200 var filterFields = ['filterbytype', 'filterbyauthor', 'filterbysource', 'filterbychartsource', 'filterbydate', 'orderby', 'order'];
201
202 for (var i = 0; i < filterFields.length; i++) {
203 url = url.replace(new RegExp('&?' + filterFields[i] + '=([^&]*)'), '');
204 }
205
206 location.href = url.replace(/&paged=([^&]$|[^&]*)/i, "&paged=1");
207 }
208
209 $(document).find('#ays-chart-filter-author').select2({
210 placeholder: aysChartBuilderAdmin.selectUser,
211 dropdownAutoWidth: true,
212 minimumInputLength: 1,
213 allowClear: true,
214 language: {
215 searching: function() {
216 return aysChartBuilderAdmin.searching;
217 },
218 inputTooShort: function () {
219 return aysChartBuilderAdmin.pleaseEnterMore;
220 }
221 },
222 ajax: {
223 url: ajaxurl,
224 dataType: 'json',
225 data: function (response) {
226 var checkedUsers = $(document).find('#ays-chart-filter-author').val();
227 return {
228 action: 'ays_chart_admin_ajax',
229 function: window.aysChartBuilderChartSettings.ajax['actions']['author_user_search'],
230 security: window.aysChartBuilderChartSettings.ajax['nonces']['author_user_search'],
231 params: {
232 search: response.term,
233 val: checkedUsers
234 }
235 };
236 }
237 }
238 });
239 $(document).find('#ays-chart-filter-author-bottom').select2({
240 placeholder: aysChartBuilderAdmin.selectUser,
241 dropdownAutoWidth: true,
242 minimumInputLength: 1,
243 allowClear: true,
244 language: {
245 searching: function() {
246 return aysChartBuilderAdmin.searching;
247 },
248 inputTooShort: function () {
249 return aysChartBuilderAdmin.pleaseEnterMore;
250 }
251 },
252 ajax: {
253 url: ajaxurl,
254 dataType: 'json',
255 data: function (response) {
256 var checkedUsers = $(document).find('#ays-chart-filter-author-bottom').val();
257 return {
258 action: 'ays_chart_admin_ajax',
259 function: window.aysChartBuilderChartSettings.ajax['actions']['author_user_search'],
260 security: window.aysChartBuilderChartSettings.ajax['nonces']['author_user_search'],
261 params: {
262 search: response.term,
263 val: checkedUsers
264 }
265 };
266 }
267 }
268 });
269
270 $(document).on('mouseenter', 'td.column-title', function() {
271 // $(this).find('.chart-list-table-actions-row').css('visibility', 'visible');
272 $(this).find('.chart-list-table-actions-row').css('display', 'flex');
273 // $(this).css('padding', '8px 8px');
274 });
275 $(document).on('mouseleave', 'td.column-title', function() {
276 // $(this).find('.chart-list-table-actions-row').css('visibility', 'hidden');
277 $(this).find('.chart-list-table-actions-row').hide();
278 // $(this).css('padding', '23px 8px');
279 });
280
281 $(document).find('.ays-chart-copy-image').on('click', function(){
282 var _this = this;
283 var input = $(_this).parent().find('input.ays-chart-shortcode-input');
284 var length = input.val().length;
285
286 input[0].focus();
287 input[0].setSelectionRange(0, length);
288 document.execCommand('copy');
289 // document.getSelection().removeAllRanges();
290
291 $(_this).attr('data-original-title', aysChartBuilderAdmin.copied);
292 $(_this).attr("data-bs-original-title", aysChartBuilderAdmin.copied);
293 $(_this).attr("title", aysChartBuilderAdmin.copied);
294 $(_this).tooltip('show');
295 });
296
297 $(document).find('.ays-chart-shortcode-input').on('focus', function(){
298 this.setSelectionRange(0, $(this).val().length);
299 });
300
301 $(document).find('.ays-chart-copy-image').on('mouseleave', function(){
302 var _this = this;
303
304 $(_this).attr('data-original-title', aysChartBuilderAdmin.clickForCopy);
305 $(_this).attr("data-bs-original-title", aysChartBuilderAdmin.clickForCopy);
306 $(_this).attr("title", aysChartBuilderAdmin.clickForCopy);
307 });
308
309 $(document).on('click', '.notice-dismiss', function (e) {
310 changeCurrentUrl('status');
311 });
312
313 var toggle_ddmenu = $(document).find('.toggle_ddmenu');
314 toggle_ddmenu.on('click', function () {
315 var ddmenu = $(this).next();
316 var state = ddmenu.attr('data-expanded');
317 switch (state) {
318 case 'true':
319 $(this).find('.ays_fa').css({
320 transform: 'rotate(0deg)'
321 });
322 ddmenu.attr('data-expanded', 'false');
323 break;
324 case 'false':
325 $(this).find('.ays_fa').css({
326 transform: 'rotate(90deg)'
327 });
328 ddmenu.attr('data-expanded', 'true');
329 break;
330 }
331 });
332
333 function changeCurrentUrl(key){
334 var linkModified = location.href.split('?')[1].split('&');
335 for(var i = 0; i < linkModified.length; i++){
336 if(linkModified[i].split("=")[0] == key){
337 linkModified.splice(i, 1);
338 }
339 }
340 linkModified = linkModified.join('&');
341 window.history.replaceState({}, document.title, '?'+linkModified);
342 }
343
344 // Select message vars charts page
345 $(document).find('.ays-chart-message-vars-icon').on('click', function(e){
346 $(this).parents(".ays-chart-message-vars-box").find(".ays-chart-message-vars-data").toggle('fast');
347 });
348
349 $(document).find('.ays-chart-open-charts-list').on('click', function(e){
350 $(this).parents(".ays-chart-subtitle-main-box").find(".ays-chart-charts-data").toggle('fast');
351 });
352
353 $(document).on( "click" , function(e){
354 if($(e.target).closest('.ays-chart-message-vars-box,.ays-chart-subtitle-main-box').length != 0){
355
356 }
357 else{
358 $(document).find(".ays-chart-message-vars-box .ays-chart-message-vars-data,.ays-chart-subtitle-main-box .ays-chart-charts-data").hide('fast');
359 }
360 });
361
362 $(document).find(".ays-chart-go-to-charts").on("click" , function(e){
363 e.preventDefault();
364 var confirmRedirect = window.confirm('Are you sure you want to redirect to another chart? Note that the changes made in this chart will not be saved.');
365 if(confirmRedirect){
366 window.location = $(this).attr("href");
367 }
368 });
369
370 $(document).find('.ays-chart-message-vars-each-data').on('click', function(e){
371 var messageVar = $(this).find(".ays-chart-message-vars-each-var").val();
372 var mainParent = $(this).parents('.ays-chart-box-for-mv');
373 var dataTMCE = mainParent.find('.ays-chart-message-vars-data').attr('data-tmce');
374
375 if ( mainParent.find("#wp-"+dataTMCE+"-wrap").hasClass("tmce-active") ){
376 window.tinyMCE.get(dataTMCE).setContent( window.tinyMCE.get(dataTMCE).getContent() + messageVar + " " );
377 }else{
378 mainParent.find('#'+dataTMCE).append( " " + messageVar + " ");
379 }
380 });
381
382 $(document).on("click", ".ays-chart-cards-block .ays-chart-card__footer button.status-missing", function(e){
383 var $this = $(this);
384 var thisParent = $this.parents(".ays-chart-cards-block");
385
386 $this.prop('disabled', true);
387 $this.addClass('disabled');
388
389 var loader_html = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>';
390
391 $this.html(loader_html);
392
393 var attr_plugin = $this.attr('data-plugin');
394 var wp_nonce = thisParent.find('#ays_chart_ajax_install_plugin_nonce').val();
395
396 var data = {
397 action: 'ays_chart_install_plugin',
398 _ajax_nonce: wp_nonce,
399 plugin: attr_plugin,
400 type: 'plugin'
401 };
402
403 $.ajax({
404 url: aysChartBuilderAdmin.ajaxUrl,
405 method: 'post',
406 dataType: 'json',
407 data: data,
408 success: function (response) {
409 if (response.success) {
410 swal.fire({
411 type: 'success',
412 html: "<h4>"+ response['data']['msg'] +"</h4>"
413 }).then( function(res) {
414 if ( $this.hasClass('status-missing') ) {
415 $this.removeClass('status-missing');
416 }
417 $this.text(aysChartBuilderAdmin.activated);
418 $this.addClass('status-active');
419 });
420 }
421 else {
422 swal.fire({
423 type: 'info',
424 html: "<h4>"+ response['data'][0]['message'] +"</h4>"
425 }).then( function(res) {
426 $this.text(aysChartBuilderAdmin.errorMsg);
427 });
428 }
429 },
430 error: function(){
431 swal.fire({
432 type: 'info',
433 html: "<h2>"+ aysChartBuilderAdmin.loadResource +"</h2><br><h6>"+ aysChartBuilderAdmin.somethingWentWrong +"</h6>"
434 }).then( function(res) {
435 $this.text(aysChartBuilderAdmin.errorMsg);
436 });
437 // $this.prop('disabled', false);
438 // if ( $this.hasClass('disabled') ) {
439 // $this.removeClass('disabled');
440 // }
441 }
442 });
443 });
444
445 $(document).on("click", ".ays-chart-cards-block .ays-chart-card__footer button.status-installed", function(e){
446 var $this = $(this);
447 var thisParent = $this.parents(".ays-chart-cards-block");
448
449 $this.prop('disabled', true);
450 $this.addClass('disabled');
451
452 var loader_html = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i>';
453
454 $this.html(loader_html);
455
456 var attr_plugin = $this.attr('data-plugin');
457 var wp_nonce = thisParent.find('#ays_chart_ajax_install_plugin_nonce').val();
458
459 var data = {
460 action: 'ays_chart_activate_plugin',
461 _ajax_nonce: wp_nonce,
462 plugin: attr_plugin,
463 type: 'plugin'
464 };
465
466 $.ajax({
467 url: aysChartBuilderAdmin.ajaxUrl,
468 method: 'post',
469 dataType: 'json',
470 data: data,
471 success: function (response) {
472 if( response.success ){
473 swal.fire({
474 type: 'success',
475 html: "<h4>"+ response['data'] +"</h4>"
476 }).then( function(res) {
477 if ( $this.hasClass('status-installed') ) {
478 $this.removeClass('status-installed');
479 }
480 $this.text(aysChartBuilderAdmin.activated);
481 $this.addClass('status-active disabled');
482 });
483 } else {
484 swal.fire({
485 type: 'info',
486 html: "<h4>"+ response['data'][0]['message'] +"</h4>"
487 });
488 }
489 },
490 error: function(){
491 swal.fire({
492 type: 'info',
493 html: "<h2>"+ aysChartBuilderAdmin.loadResource +"</h2><br><h6>"+ aysChartBuilderAdmin.somethingWentWrong +"</h6>"
494 }).then( function(res) {
495 $this.text(aysChartBuilderAdmin.errorMsg);
496 });;
497 // $this.prop('disabled', false);
498 // if ( $this.hasClass('disabled') ) {
499 // $this.removeClass('disabled');
500 // }
501 }
502 });
503 });
504
505 $(document).on("click", "#ays-chart-dismiss-buttons-content .ays-button, #ays-chart-dismiss-buttons-content-helloween .ays-button-helloween, #ays-chart-dismiss-buttons-content-black-friday .ays-button-black-friday", function(e){
506 e.preventDefault();
507
508 var $this = $(this);
509 var thisParent = $this.parents("#ays-chart-dismiss-buttons-content");
510 // var thisParent = $this.parents("#ays-chart-dismiss-buttons-content-helloween");
511 // var thisParent = $this.parents("#ays-chart-dismiss-buttons-content-black-friday");
512 var mainParent = $this.parents("div.ays_chart_dicount_info");
513 var closeButton = mainParent.find("button.notice-dismiss");
514
515 var attr_plugin = $this.attr('data-plugin');
516 var wp_nonce = thisParent.find('#chart-builder-sale-banner').val();
517 if(typeof wp_nonce == 'undefined'){
518 wp_nonce = $(document).find('#chart-builder-sale-banner').val();
519 }
520
521 var data = {
522 action: 'ays_chart_dismiss_button',
523 _ajax_nonce: wp_nonce,
524 };
525
526 $.ajax({
527 url: aysChartBuilderAdmin.ajaxUrl,
528 method: 'post',
529 dataType: 'json',
530 data: data,
531 success: function (response) {
532 if( response.status ){
533 closeButton.trigger('click');
534 } else {
535 swal.fire({
536 type: 'info',
537 html: "<h2>"+ aysChartBuilderAdmin.errorMsg +"</h2><br><h6>"+ aysChartBuilderAdmin.somethingWentWrong +"</h6>"
538 }).then(function(res) {
539 closeButton.trigger('click');
540 });
541 }
542 },
543 error: function(){
544 swal.fire({
545 type: 'info',
546 html: "<h2>"+ aysChartBuilderAdmin.errorMsg +"</h2><br><h6>"+ aysChartBuilderAdmin.somethingWentWrong +"</h6>"
547 }).then(function(res) {
548 closeButton.trigger('click');
549 });
550 }
551 });
552 });
553
554 /* */
555
556 // Pro features start
557 $(document).find(".ays-pro-features-v2-upgrade-button").hover(function() {
558 // Code to execute when the mouse enters the element
559 var unlockedImg = "Unlocked_24_24.svg";
560 var imgBox = $(this).find(".ays-pro-features-v2-upgrade-icon");
561 var imgUrl = imgBox.attr("data-img-src");
562 var newString = imgUrl.replace("Locked_24x24.svg", unlockedImg);
563
564 imgBox.css("background-image", 'url(' + newString + ')');
565 imgBox.attr("data-img-src", newString);
566 }, function() {
567
568 var lockedImg = "Locked_24x24.svg";
569 var imgBox = $(this).find(".ays-pro-features-v2-upgrade-icon");
570 var imgUrl = imgBox.attr("data-img-src");
571 var newString = imgUrl.replace("Unlocked_24_24.svg", lockedImg);
572
573 imgBox.css("background-image", 'url(' + newString + ')');
574 imgBox.attr("data-img-src", newString);
575 });
576 // Pro features end
577
578 var checkCountdownIsExists = $(document).find('#ays-chart-countdown-main-container');
579
580 if ( checkCountdownIsExists.length > 0 ) {
581 var second = 1000,
582 minute = second * 60,
583 hour = minute * 60,
584 day = hour * 24;
585
586 var chartCountdownEndTime = aysChartBuilderAdmin.chartBannerDate;
587 // var chartCountdownEndTime = "JAN 15, 2025 23:59:59";
588 var countDown_new = new Date(chartCountdownEndTime).getTime();
589
590 if ( isNaN(countDown_new) || isFinite(countDown_new) == false ) {
591 var AYS_QUIZ_MILLISECONDS = 3 * day;
592 var countdownStartDate = new Date(Date.now() + AYS_QUIZ_MILLISECONDS);
593 var quizCountdownEndTime = countdownStartDate.aysQuizCustomFormat( "#YYYY#-#MM#-#DD# #hhhh#:#mm#:#ss#" );
594 var countDown_new = new Date(quizCountdownEndTime).getTime();
595 }
596
597 aysChartBannerCountdown();
598
599 var y = setInterval(function() {
600
601 var now = new Date().getTime();
602 var distance_new = countDown_new - now;
603
604 aysChartBannerCountdown();
605
606 if (distance_new < 0) {
607 var headline = document.getElementById("ays-chart-countdown-headline"),
608 countdown = document.getElementById("ays-chart-countdown"),
609 content = document.getElementById("ays-chart-countdown-content");
610
611 // headline.innerText = "Sale is over!";
612 countdown.style.display = "none";
613 content.style.display = "block";
614
615 clearInterval(y);
616 }
617 }, 1000);
618 }
619
620 function aysChartBannerCountdown(){
621 var now = new Date().getTime();
622 var distance_new = countDown_new - now;
623
624 var countDownDays = document.getElementById("ays-chart-countdown-days");
625 var countDownHours = document.getElementById("ays-chart-countdown-hours");
626 var countDownMinutes = document.getElementById("ays-chart-countdown-minutes");
627 var countDownSeconds = document.getElementById("ays-chart-countdown-seconds");
628
629 if((countDownDays !== null || countDownHours !== null || countDownMinutes !== null || countDownSeconds !== null) && distance_new > 0){
630
631 var countDownDays_innerText = Math.floor(distance_new / (day));
632 var countDownHours_innerText = Math.floor((distance_new % (day)) / (hour));
633 var countDownMinutes_innerText = Math.floor((distance_new % (hour)) / (minute));
634 var countDownSeconds_innerText = Math.floor((distance_new % (minute)) / second);
635
636 if( isNaN(countDownDays_innerText) || isNaN(countDownHours_innerText) || isNaN(countDownMinutes_innerText) || isNaN(countDownSeconds_innerText) ){
637 var headline = document.getElementById("ays-chart-countdown-headline"),
638 countdown = document.getElementById("ays-chart-countdown"),
639 content = document.getElementById("ays-chart-countdown-content");
640
641 // headline.innerText = "Sale is over!";
642 countdown.style.display = "none";
643 content.style.display = "block";
644
645 clearInterval(y);
646 } else {
647 countDownDays.innerText = countDownDays_innerText;
648 countDownHours.innerText = countDownHours_innerText;
649 countDownMinutes.innerText = countDownMinutes_innerText;
650 countDownSeconds.innerText = countDownSeconds_innerText;
651 }
652 }
653 }
654
655 Date.prototype.aysChartCustomFormat = function( formatString){
656 var YYYY,YY,MMMM,MMM,MM,M,DDDD,DDD,DD,D,hhhh,hhh,hh,h,mm,m,ss,s,ampm,AMPM,dMod,th;
657 YY = ((YYYY=this.getFullYear())+"").slice(-2);
658 MM = (M=this.getMonth()+1)<10?('0'+M):M;
659 MMM = (MMMM=["January","February","March","April","May","June","July","August","September","October","November","December"][M-1]).substring(0,3);
660 DD = (D=this.getDate())<10?('0'+D):D;
661 DDD = (DDDD=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][this.getDay()]).substring(0,3);
662 th=(D>=10&&D<=20)?'th':((dMod=D%10)==1)?'st':(dMod==2)?'nd':(dMod==3)?'rd':'th';
663 formatString = formatString.replace("#YYYY#",YYYY).replace("#YY#",YY).replace("#MMMM#",MMMM).replace("#MMM#",MMM).replace("#MM#",MM).replace("#M#",M).replace("#DDDD#",DDDD).replace("#DDD#",DDD).replace("#DD#",DD).replace("#D#",D).replace("#th#",th);
664 h=(hhh=this.getHours());
665 if (h==0) h=24;
666 if (h>12) h-=12;
667 hh = h<10?('0'+h):h;
668 hhhh = hhh<10?('0'+hhh):hhh;
669 AMPM=(ampm=hhh<12?'am':'pm').toUpperCase();
670 mm=(m=this.getMinutes())<10?('0'+m):m;
671 ss=(s=this.getSeconds())<10?('0'+s):s;
672
673 return formatString.replace("#hhhh#",hhhh).replace("#hhh#",hhh).replace("#hh#",hh).replace("#h#",h).replace("#mm#",mm).replace("#m#",m).replace("#ss#",ss).replace("#s#",s).replace("#ampm#",ampm).replace("#AMPM#",AMPM);
674 // token: description: example:
675 // #YYYY# 4-digit year 1999
676 // #YY# 2-digit year 99
677 // #MMMM# full month name February
678 // #MMM# 3-letter month name Feb
679 // #MM# 2-digit month number 02
680 // #M# month number 2
681 // #DDDD# full weekday name Wednesday
682 // #DDD# 3-letter weekday name Wed
683 // #DD# 2-digit day number 09
684 // #D# day number 9
685 // #th# day ordinal suffix nd
686 // #hhhh# 2-digit 24-based hour 17
687 // #hhh# military/24-based hour 17
688 // #hh# 2-digit hour 05
689 // #h# hour 5
690 // #mm# 2-digit minute 07
691 // #m# minute 7
692 // #ss# 2-digit second 09
693 // #s# second 9
694 // #ampm# "am" or "pm" pm
695 // #AMPM# "AM" or "PM" PM
696 };
697
698 var createdNewChart = getCookie('ays_chart_created_new');
699 if (createdNewChart && createdNewChart > 1) {
700 var url = new URL(window.location.href);
701 var getCustomPostId = getCookie('ays_chart_created_new_'+createdNewChart+'_post_id');
702 var link = "#";
703 if(getCustomPostId){
704 link = getCustomPostId;
705 }
706
707 var parameterValue = url.searchParams.get("action");
708 var htmlDefaultText = '<p style="margin-top:1rem;">For more detailed configuration visit <a href="admin.php?page=chart-builder&action=edit&id=' + createdNewChart + '">edit chart page</a>.</p>';
709
710 var htmlContent = parameterValue && parameterValue == 'edit' ? '' : htmlDefaultText;
711 var previewButtonSvgIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.9999 7.21325C11.8231 7.21325 11.6535 7.28349 11.5285 7.40851C11.4035 7.53354 11.3333 7.70311 11.3333 7.87992V12.6666C11.3333 12.8434 11.263 13.013 11.138 13.138C11.013 13.263 10.8434 13.3333 10.6666 13.3333H3.33325C3.15644 13.3333 2.98687 13.263 2.86185 13.138C2.73682 13.013 2.66659 12.8434 2.66659 12.6666V5.33325C2.66659 5.15644 2.73682 4.98687 2.86185 4.86185C2.98687 4.73682 3.15644 4.66658 3.33325 4.66658H8.11992C8.29673 4.66658 8.4663 4.59635 8.59132 4.47132C8.71635 4.3463 8.78658 4.17673 8.78658 3.99992C8.78658 3.82311 8.71635 3.65354 8.59132 3.52851C8.4663 3.40349 8.29673 3.33325 8.11992 3.33325H3.33325C2.80282 3.33325 2.29411 3.54397 1.91904 3.91904C1.54397 4.29411 1.33325 4.80282 1.33325 5.33325V12.6666C1.33325 13.197 1.54397 13.7057 1.91904 14.0808C2.29411 14.4559 2.80282 14.6666 3.33325 14.6666H10.6666C11.197 14.6666 11.7057 14.4559 12.0808 14.0808C12.4559 13.7057 12.6666 13.197 12.6666 12.6666V7.87992C12.6666 7.70311 12.5963 7.53354 12.4713 7.40851C12.3463 7.28349 12.1767 7.21325 11.9999 7.21325ZM14.6133 1.74659C14.5456 1.58369 14.4162 1.45424 14.2533 1.38659C14.1731 1.35242 14.087 1.33431 13.9999 1.33325H9.99992C9.82311 1.33325 9.65354 1.40349 9.52851 1.52851C9.40349 1.65354 9.33325 1.82311 9.33325 1.99992C9.33325 2.17673 9.40349 2.3463 9.52851 2.47132C9.65354 2.59635 9.82311 2.66659 9.99992 2.66659H12.3933L5.52659 9.52658C5.4641 9.58856 5.4145 9.66229 5.38066 9.74353C5.34681 9.82477 5.32939 9.91191 5.32939 9.99992C5.32939 10.0879 5.34681 10.1751 5.38066 10.2563C5.4145 10.3375 5.4641 10.4113 5.52659 10.4733C5.58856 10.5357 5.66229 10.5853 5.74353 10.6192C5.82477 10.653 5.91191 10.6705 5.99992 10.6705C6.08793 10.6705 6.17506 10.653 6.2563 10.6192C6.33754 10.5853 6.41128 10.5357 6.47325 10.4733L13.3333 3.60659V5.99992C13.3333 6.17673 13.4035 6.3463 13.5285 6.47132C13.6535 6.59635 13.8231 6.66658 13.9999 6.66658C14.1767 6.66658 14.3463 6.59635 14.4713 6.47132C14.5963 6.3463 14.6666 6.17673 14.6666 5.99992V1.99992C14.6655 1.9128 14.6474 1.82673 14.6133 1.74659Z" fill="#007DCB"/></svg>';
712
713 swal({
714 title: '<strong>Great job</strong>',
715 type: 'success',
716 html: '<p>Your chart is Created!<br>Copy the generated shortcode and paste it into any post or page to display the chart.</p><input type="text" id="ays-chart-create-new" onClick="this.setSelectionRange(0, this.value.length)" readonly value="[ays_chart id=\'' + createdNewChart + '\']" />' + htmlContent,
717 confirmButtonText: '<a href="'+ link +'" target="_blank">'+ 'Preview Chart' + ' ' + previewButtonSvgIcon +'</a>',
718 confirmButtonAriaLabel: 'Preview this chart',
719 showCloseButton: true,
720 focusConfirm: false,
721 cancelButtonText: '<i class="ays_fa ays_fa_thumbs_up"></i> Done',
722 cancelButtonAriaLabel: 'Thumbs up, done!',
723 });
724 deleteCookie('ays_chart_created_new');
725 deleteCookie('ays_chart_created_new'+createdNewChart+'_post_id');
726 }
727
728 function getCookie (cname) {
729 let name = cname + "=";
730 let decodedCookie = decodeURIComponent(document.cookie);
731 let ca = decodedCookie.split(';');
732 for(let i = 0; i <ca.length; i++) {
733 let c = ca[i];
734 while (c.charAt(0) == ' ') {
735 c = c.substring(1);
736 }
737 if (c.indexOf(name) == 0) {
738 return c.substring(name.length, c.length);
739 }
740 }
741 return "";
742 }
743
744 function deleteCookie (name) {
745 document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
746 }
747
748 });
749
750 })(jQuery);
751
752 function selectAndCopyElementContents(el) {
753 if (window.getSelection && document.createRange) {
754 var _this = jQuery(document).find('.ays-chart-copy-element-box');
755
756 var text = el.textContent;
757 var textField = document.createElement('textarea');
758
759 textField.innerText = text;
760 document.body.appendChild(textField);
761 textField.select();
762 document.execCommand('copy');
763 textField.remove();
764
765 var selection = window.getSelection();
766 selection.setBaseAndExtent(el,0,el,1);
767
768 _this.attr( "data-original-title", 'Copied!' );
769 _this.attr( "title", 'Copied!' );
770
771 _this.tooltip("show");
772
773 } else if (document.selection && document.body.createTextRange) {
774 var textRange = document.body.createTextRange();
775 textRange.moveToElementText(el);
776 textRange.select();
777 }
778 }