PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.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 3.10.4 All 148 releases
← All changes | js/render-facade.js +25 -20 3.10.13.4.8 View file →
@@ -1,16 +1,15 @@
1 1 /* global console */
2 2 /* global visualizer */
3 3 /* global jQuery */
4 -var vizClipboard1=null;
4 +
5 5 (function($, visualizer){
6 6
7 7 function initActionsButtons(v) {
8 - if($('a.visualizer-chart-shortcode').length > 0 && vizClipboard1 === null) {
9 - vizClipboard1 = new ClipboardJS('a.visualizer-chart-shortcode'); // jshint ignore:line
10 - vizClipboard1.on('success', function(e) {
8 + if($('a.visualizer-chart-shortcode').length > 0) {
9 + var clipboard1 = new ClipboardJS('a.visualizer-chart-shortcode'); // jshint ignore:line
10 + clipboard1.on('success', function(e) {
11 11 window.alert(v.i10n['copied']);
12 -
13 12 });
14 13 }
15 14
16 15 if($('a.visualizer-action[data-visualizer-type=copy]').length > 0) {
@@ -101,20 +100,30 @@
101 100 var event = new CustomEvent('visualizer:render:currentchart:update', {detail: {visualizer: visualizer}});
102 101 document.body.dispatchEvent(event);
103 102 };
104 103
104 + // facade loads N times in the library and front end (where N = the number of different chart libraries supported)
105 + // so all charts are also loaded N times
106 + // this will ensure that no matter how many times facade is loaded, it initializes all charts only once.
107 + // fixed as part of the issue to add annotations.
108 + if(localStorage.getItem( 'viz-facade-loaded' ) === '1'){
109 + // prevent library from hanging.
110 + setTimeout( function(){
111 + localStorage.removeItem( 'viz-facade-loaded' );
112 + }, 2000);
113 + return;
114 + }
115 + localStorage.setItem( 'viz-facade-loaded', '1');
116 + // remove the flag so that repeated loading of the library does not cause problems.
117 + setTimeout( function(){
118 + localStorage.removeItem( 'viz-facade-loaded' );
119 + }, 2000);
120 +
105 121 initChartDisplay();
106 122 initActionsButtons(visualizer);
107 123 registerDefaultActions();
108 124 });
109 125
110 - // Refresh charts if chart not generated.
111 - function refreshEachCharts() {
112 - setTimeout( function() {
113 - displayChartsOnFrontEnd();
114 - }, 100 );
115 - }
116 -
117 126 function initChartDisplay() {
118 127 if(visualizer.is_front == true){ // jshint ignore:line
119 128 displayChartsOnFrontEnd();
120 129 }else{
@@ -126,9 +135,9 @@
126 135 * If an `id` is provided, that particular chart will load.
127 136 */
128 137 function showChart(id) {
129 138 // clone the visualizer object so that the original object is not affected.
130 - var viz = Object.assign(visualizer, window.visualizer || {});
139 + var viz = Object.assign({}, visualizer);
131 140 if(id){
132 141 viz.id = id;
133 142 }
134 143 $('body').trigger('visualizer:render:chart:start', viz);
@@ -135,15 +144,11 @@
135 144 }
136 145
137 146 function displayChartsOnFrontEnd() {
138 147 // display all charts that are NOT to be lazy-loaded.
139 - $( 'div.viz-facade-loaded:not(.visualizer-lazy):not(.visualizer-cw-error):empty' ).removeClass( 'viz-facade-loaded' );
140 - $('div.visualizer-front:not(.visualizer-lazy):not(.viz-facade-loaded)').each(function(index, element){
141 - if ( $(element).is(':visible') ) {
142 - var id = $(element).addClass('viz-facade-loaded').attr('id');
143 - showChart(id);
144 - }
145 - refreshEachCharts();
148 + $('div.visualizer-front:not(.visualizer-lazy)').each(function(index, element){
149 + var id = $(element).attr('id');
150 + showChart(id);
146 151 });
147 152
148 153 // interate through all charts that are to be lazy-loaded and observe each one.
149 154 $('div.visualizer-front.visualizer-lazy').each(function(index, element){