PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.0
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 +7 -95 3.10.153.2.0 View file →
@@ -1,24 +1,13 @@
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) {
11 - window.alert(v.i10n['copied']);
12 -
13 - });
14 - }
15 -
16 8 if($('a.visualizer-action[data-visualizer-type=copy]').length > 0) {
17 - $('a.visualizer-action[data-visualizer-type=copy]').on('click', function(e) {
18 - e.preventDefault();
19 - });
20 - var clipboard = new ClipboardJS('a.visualizer-action[data-visualizer-type=copy]'); // jshint ignore:line
9 + var clipboard = new Clipboard('a.visualizer-action[data-visualizer-type=copy]'); // jshint ignore:line
21 10 clipboard.on('success', function(e) {
22 11 window.alert(v.i10n['copied']);
23 12 });
24 13 }
@@ -27,15 +16,13 @@
27 16 var chart = $(this).attr( 'data-visualizer-chart-id' );
28 17 var container = $(this).attr( 'data-visualizer-container-id' );
29 18 var lock = $('.visualizer-front.visualizer-front-' + chart);
30 19 var mime = $(this).attr( 'data-visualizer-mime' );
20 + console.log(mime);
31 21 lock.lock();
32 22 e.preventDefault();
33 23 $.ajax({
34 24 url : v.rest_url.replace('#id#', chart).replace('#type#', type),
35 - beforeSend: function ( xhr ) {
36 - xhr.setRequestHeader( 'X-WP-Nonce', v.wp_nonce );
37 - },
38 25 success: function(data) {
39 26 if (data && data.data) {
40 27 switch(type){
41 28 case 'csv':
@@ -68,10 +55,9 @@
68 55 $a.remove();
69 56 }
70 57 break;
71 58 case 'print':
72 - case 'image':
73 - $('body').trigger('visualizer:action:specificchart', {action: type, id: container, data: data.data.csv, dataObj: data.data});
59 + $('body').trigger('visualizer:action:specificchart', {action: 'print', id: container, data: data.data.csv});
74 60 break;
75 61 default:
76 62 if(window.visualizer_perform_action) {
77 63 window.visualizer_perform_action(type, chart, data.data);
@@ -94,87 +80,13 @@
94 80 return buf;
95 81 }
96 82
97 83 $(document).ready(function(){
98 -
99 - // for updating the currently displayed chart (preview mode)
100 - window.vizUpdateChartPreview = function(){
101 - var event = new CustomEvent('visualizer:render:currentchart:update', {detail: {visualizer: visualizer}});
102 - document.body.dispatchEvent(event);
103 - };
104 -
105 - initChartDisplay();
84 + $('body').trigger('visualizer:render:chart:start', visualizer);
106 85 initActionsButtons(visualizer);
107 86 registerDefaultActions();
108 87 });
109 88
110 - function initChartDisplay() {
111 - if(visualizer.is_front == true){ // jshint ignore:line
112 - displayChartsOnFrontEnd();
113 - } else {
114 - showChart();
115 - }
116 - }
117 -
118 - /**
119 - * If an `id` is provided, that particular chart will load.
120 - */
121 - function showChart(id) {
122 - // clone the visualizer object so that the original object is not affected.
123 - var viz = Object.assign(visualizer, window.visualizer || {});
124 - if(id){
125 - viz.id = id;
126 - }
127 - $('body').trigger('visualizer:render:chart:start', viz);
128 - }
129 -
130 - function displayChartsOnFrontEnd() {
131 -
132 - $('div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty').each(function(index, element){
133 -
134 - // Do not render charts that are intentionally hidden.
135 - var style = window.getComputedStyle(element);
136 - if (style.display === 'none' || style.visibility === 'hidden') {
137 - return;
138 - }
139 -
140 - var id = $(element).addClass('viz-facade-loaded').attr('id');
141 - setTimeout(function(){
142 - // Add a short delay between each chart to avoid overloading the browser event loop.
143 - showChart(id);
144 - }, ( index + 1 ) * 100);
145 - });
146 -
147 - // interate through all charts that are to be lazy-loaded and observe each one.
148 - $('div.visualizer-front.visualizer-lazy').each(function(index, element){
149 - var id = $(element).attr('id');
150 - var limit = $(element).attr('data-lazy-limit');
151 - if(!limit){
152 - limit = 300;
153 - }
154 - var target = document.querySelector('#' + id);
155 -
156 - // configure the intersection observer instance
157 - var intersectionObserverOptions = {
158 - root: null,
159 - rootMargin: limit + 'px',
160 - threshold: 0
161 - };
162 -
163 - var observer = new IntersectionObserver(function(entries) {
164 - entries.forEach(function(entry) {
165 - if (entry.isIntersecting) {
166 - observer.unobserve(target);
167 - showChart($(entry.target).attr('id'));
168 - }
169 - });
170 - }, intersectionObserverOptions);
171 -
172 - // start observing.
173 - observer.observe(target);
174 - });
175 - }
176 -
177 89 function registerDefaultActions(){
178 90 $('body').off('visualizer:action:specificchart:defaultprint').on('visualizer:action:specificchart:defaultprint', function(event, v){
179 91 var iframe = $('<iframe>').attr("name", "print-visualization").attr("id", "print-visualization").css("position", "absolute");
180 92 iframe.appendTo($('body'));
@@ -237,5 +149,5 @@
237 149 });
238 150
239 151 return $(this);
240 152 };
241 -})(jQuery);
153 +})(jQuery);