PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.2
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
← All changes | js/frame.js +60 -92 3.10.33.4.2 View file →
@@ -1,11 +1,9 @@
1 1 /* global prompt */
2 2 /* global visualizer */
3 3 /* global alert */
4 -/* global confirm */
5 4 /* global ajaxurl */
6 5 /* global CodeMirror */
7 -/* global vizHaveSettingsChanged */
8 6
9 7 (function ($) {
10 8 $(window).on('load', function(){
11 9 // scroll to the selected chart type.
@@ -17,27 +15,9 @@
17 15 $(document).ready(function () {
18 16 onReady();
19 17 });
20 18
21 - function initTabs(){
22 - $( "#sidebar" ).lock();
23 - $( "#viz-tabs" ).tabs({
24 - create: function( event, ui ) {
25 - $(this).addClass('done');
26 - $( "#sidebar" ).unlock();
27 - },
28 - beforeActivate: function( event, ui ) {
29 - // if settings have changed in tab #2 and tab #1 is being activated, warn the user.
30 - if(vizHaveSettingsChanged() && ui.newTab.find( 'a' ).attr( 'id' ).includes('viz-tab-basic')){
31 - return confirm(visualizer.l10n.save_settings);
32 - }
33 - }
34 - });
35 - }
36 -
37 19 function onReady() {
38 - initTabs();
39 -
40 20 // open the correct source tab/sub-tab.
41 21 var source = $('#visualizer-chart-id').attr('data-chart-source');
42 22 $('li.viz-group.' + source).addClass('open');
43 23 $('li.viz-group.' + source + ' span.viz-section-title.' + source).addClass('open');
@@ -73,8 +53,22 @@
73 53 $('.type-label-selected').removeClass('type-label-selected');
74 54 $(this).parent().addClass('type-label-selected');
75 55 });
76 56
57 + $('#vz-chart-settings h2').click(function () {
58 + $("#vz-chart-source").hide();
59 + $("#vz-chart-permissions").removeClass('open').addClass('bottom-fixed');
60 + $(this).parent().removeClass('bottom-fixed').addClass('open');
61 + $("#vz-chart-permissions .viz-group-header").hide();
62 + return false;
63 + });
64 + $('#vz-chart-settings .customize-section-back').click(function () {
65 + $("#vz-chart-source").show();
66 + $(this).parent().parent().removeClass('open').addClass('bottom-fixed');
67 +
68 + return false;
69 + });
70 +
77 71 // collapse other open sections of this group
78 72 $(document).on('click', '.viz-group-title', function () {
79 73 var parent = $(this).parent();
80 74
@@ -84,17 +78,15 @@
84 78 parent.parent().find('.viz-group.open').removeClass('open');
85 79 parent.addClass('open');
86 80 }
87 81
88 - /*
89 - * if the user wants to perform an action and click that tab to change the source
90 - * and the chart is no longer showing because that particular LHS screen is showing
91 - * e.g. create parameters, import json, db query box etc.
92 - * we need to make sure we cancel the current process WITHOUT saving
93 - * and then show the chart as it was
94 - * let's close the LHS window and show the chart that is hidden
95 - */
96 - $('body').trigger('visualizer:change:action');
82 + // if the user wanted to perform an action
83 + // and the chart is no longer showing because that particular screen is showing
84 + // e.g. create parameters
85 + // and then the user decided to click on another action
86 + // let's invoke the show chart of the previous action so that the chart shows
87 + // and the user does not get confused
88 + $('input[type="button"][data-current!="chart"].show-chart-toggle').trigger('click');
97 89 });
98 90
99 91 // collapse other open subsections of this section
100 92 $(document).on('click', '.viz-section-title', function () {
@@ -127,11 +119,11 @@
127 119 $(this).parent().submit();
128 120 }
129 121 });
130 122
131 - $( window ).on( 'load', function() {
123 + $('#thehole').load(function () {
132 124 $('#canvas').unlock();
133 - } );
125 + });
134 126
135 127 $(document).on('click', '.viz-section-title', function () {
136 128 $(this).toggleClass('open').parent().find('.viz-section-items').toggle();
137 129 });
@@ -177,8 +169,37 @@
177 169 $('select.viz-select-library').val( $('select.viz-select-library option:not(.disabled)').val() );
178 170 }
179 171
180 172 function init_permissions(){
173 + $('#vz-chart-permissions h2').click(function () {
174 + $("#vz-chart-source").hide();
175 + $("#vz-chart-permissions .viz-group-header").show();
176 + $("#vz-chart-settings").removeClass('open').addClass('bottom-fixed');
177 +
178 + $('#settings-button').click(function(e) {
179 + e.preventDefault();
180 + $('#permissions-form').submit();
181 + $('#settings-form').submit();
182 + });
183 +
184 + $(this).parent().removeClass('bottom-fixed').addClass('open');
185 +
186 + return false;
187 + });
188 + $('#vz-chart-permissions .customize-section-back').click(function () {
189 + $("#vz-chart-source").show();
190 +
191 + $("#vz-chart-permissions .viz-group-header").hide();
192 + $('#settings-button').click(function(e) {
193 + e.preventDefault();
194 + $('#settings-form').submit();
195 + });
196 +
197 + $(this).parent().parent().removeClass('open').addClass('bottom-fixed');
198 +
199 + return false;
200 + });
201 +
181 202 $('.visualizer-permission').chosen({
182 203 width : '50%',
183 204 search_contains : true
184 205 });
@@ -316,18 +337,8 @@
316 337 });
317 338 });
318 339
319 340 $( '#db-chart-button' ).on( 'click', function(){
320 -
321 - $('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
322 - var filter_button = $( '#db-chart-button' );
323 - $( '#visualizer-db-query' ).css("z-index", "-1").hide();
324 - filter_button.val( filter_button.attr( 'data-t-chart' ) );
325 - filter_button.html( filter_button.attr( 'data-t-chart' ) );
326 - filter_button.attr( 'data-current', 'chart' );
327 - $( '#canvas' ).css("z-index", "1").show();
328 - });
329 -
330 341 $('#content').css('width', 'calc(100% - 300px)');
331 342 if( $(this).attr( 'data-current' ) === 'chart'){
332 343 $(this).val( $(this).attr( 'data-t-filter' ) );
333 344 $(this).html( $(this).attr( 'data-t-filter' ) );
@@ -375,32 +386,12 @@
375 386 heightStyle: 'content',
376 387 active: false,
377 388 collapsible: true
378 389 });
379 -
380 - // open the accordions by default if they are indicated with the 'open' class.
381 - $('.visualizer-json-subform .viz-substep.open').each(function(i, e){
382 - $('.visualizer-json-subform').accordion( "option", "active", i );
383 - });
384 390
385 391 // toggle between chart and create/modify parameters
386 - $( '#json-chart-button, #woo-chart-button' ).on( 'click', function(){
387 -
388 - $('body').off('visualizer:change:action').on('visualizer:change:action', function(e){
389 - var filter_button = $( '#json-chart-button, #woo-chart-button' );
390 - $( '#visualizer-json-screen' ).css("z-index", "-1").hide();
391 - filter_button.val( filter_button.attr( 'data-t-chart' ) );
392 - filter_button.html( filter_button.attr( 'data-t-chart' ) );
393 - filter_button.attr( 'data-current', 'chart' );
394 - $( '#canvas' ).css("z-index", "1").show();
395 - $( '#vz-import-woo-report' ).find( 'select, input' ).removeAttr( 'disabled' );
396 - });
397 -
398 - if ( 'json-chart-button' === $( this ).attr( 'id' ) ) {
399 - $( '#vz-import-woo-report' ).find( 'select, input' ).attr( 'disabled', true );
400 - } else {
401 - $( '#vz-import-woo-report' ).find( 'select, input' ).removeAttr( 'disabled' );
402 - }
392 + $( '#json-chart-button' ).on( 'click', function(){
393 + var $bttn = $(this);
403 394 $('#content').css('width', 'calc(100% - 100px)');
404 395 if( $(this).attr( 'data-current' ) === 'chart'){
405 396 // toggle from chart to LHS form
406 397 $(this).val( $(this).attr( 'data-t-filter' ) );
@@ -407,17 +398,8 @@
407 398 $(this).html( $(this).attr( 'data-t-filter' ) );
408 399 $(this).attr( 'data-current', 'filter' );
409 400 $( '.visualizer-editor-lhs' ).hide();
410 401 $( '#visualizer-json-screen' ).css("z-index", "9999").show();
411 - if ( 'woo-chart-button' === $( this ).attr( 'id' ) && '' !== $( '#vz-woo-source:visible' ).val() ) {
412 - $( '#vz-import-json-url' ).val( visualizer.rest_base + $( '#vz-woo-source' ).val() ).attr( 'readonly', true );
413 - } else {
414 - if ( 'undefined' !== $( '#vz-import-json-url' ).attr( 'readonly' ) ) {
415 - $( '#vz-import-json-url' ).val( '' ).removeAttr( 'readonly' ).removeAttr( 'value' );
416 - $('#json-endpoint-form')[0].reset();
417 - $('.visualizer-json-form h3.viz-step:not(.step1)').addClass('ui-state-disabled');
418 - }
419 - }
420 402 $( '#canvas' ).hide();
421 403 }else{
422 404 // toggle from LHS form to chart
423 405 $( '#json-conclude-form' ).trigger('submit');
@@ -424,9 +406,9 @@
424 406 }
425 407 } );
426 408
427 409 $('body').on('visualizer:json:form:submit', function() {
428 - var filter_button = $( '#json-chart-button, #woo-chart-button' );
410 + var filter_button = $( '#json-chart-button' );
429 411 $( '#visualizer-json-screen' ).css("z-index", "-1").hide();
430 412 $('#canvas').lock();
431 413 filter_button.val( filter_button.attr( 'data-t-chart' ) );
432 414 filter_button.html( filter_button.attr( 'data-t-chart' ) );
@@ -431,9 +413,9 @@
431 413 filter_button.val( filter_button.attr( 'data-t-chart' ) );
432 414 filter_button.html( filter_button.attr( 'data-t-chart' ) );
433 415 filter_button.attr( 'data-current', 'chart' );
434 416 end_ajax( $( '#visualizer-json-screen' ) );
435 - $( '#canvas' ).removeClass('visualizer-chart-loaded').css("z-index", "1").show();
417 + $( '#canvas' ).css("z-index", "1").show();
436 418 });
437 419
438 420
439 421 // fetch the roots for the provided endpoint
@@ -526,9 +508,9 @@
526 508 return false;
527 509 }
528 510
529 511 // populate the form elements that are in the other tabs.
530 - $('#json-conclude-form-helper .json-form-element, #json-endpoint-form .json-form-element, #json-root-form .json-form-element, #vz-import-json .json-form-element, #vz-import-woo-report .json-form-element:not(:disabled)').each(function(x, y){
512 + $('#json-conclude-form-helper .json-form-element, #json-endpoint-form .json-form-element, #json-root-form .json-form-element, #vz-import-json .json-form-element').each(function(x, y){
531 513 $('#json-conclude-form').append('<input type="hidden" name="' + y.name + '" value="' + y.value + '">');
532 514 });
533 515
534 516 $('body').trigger('visualizer:json:form:submit');
@@ -534,12 +516,11 @@
534 516 $('body').trigger('visualizer:json:form:submit');
535 517 });
536 518
537 519 // update the schedule
538 - $('#json-chart-save-button, #woo-chart-save-button').on('click', function(e){
520 + $('#json-chart-save-button').on('click', function(e){
539 521 e.preventDefault();
540 522 $('#canvas').lock();
541 - var btnID = jQuery( this ).attr( 'id' );
542 523 $.ajax({
543 524 url : ajaxurl,
544 525 method : 'post',
545 526 data : {
@@ -544,11 +525,10 @@
544 525 method : 'post',
545 526 data : {
546 527 'action' : visualizer.ajax['actions']['json_set_schedule'],
547 528 'security' : visualizer.ajax['nonces']['json_set_schedule'],
548 - 'chart' : $('#vz-json-time, #vz-woo-time').attr('data-chart'),
549 - 'time' : $('#vz-json-time, #vz-woo-time').val(),
550 - 'is_woocommerce_report': 'woo-chart-save-button' === btnID,
529 + 'chart' : $('#vz-json-time').attr('data-chart'),
530 + 'time' : $('#vz-json-time').val()
551 531 },
552 532 success : function(data){
553 533 // do nothing.
554 534 },
@@ -556,20 +536,8 @@
556 536 $('#canvas').unlock();
557 537 }
558 538 });
559 539 });
560 -
561 - // Select WooCommerce report endpoint.
562 - $( '#vz-woo-source' ).on( 'click', function( e ) {
563 - // Trigger change action.
564 - $( 'body' ).trigger( 'visualizer:change:action' );
565 -
566 - if ( '' !== $( this ).val() ) {
567 - $( '#woo-chart-button, #woo-chart-save-button' ).removeAttr( 'disabled' );
568 - } else {
569 - $( '#woo-chart-button, #woo-chart-save-button' ).attr( 'disabled', true );
570 - }
571 - } );
572 540
573 541 }
574 542
575 543 function init_editor_table() {