PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.1.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.1.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
visualizer / js / render-facade.js

render-facade.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.1.2, at js/render-facade.js

125 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global console */
2 /* global visualizer */
3 /* global jQuery */
4
5 (function($, visualizer){
6
7 function initActionsButtons(v) {
8 if($('a.visualizer-action[data-visualizer-type=copy]').length > 0) {
9 var clipboard = new Clipboard('a.visualizer-action[data-visualizer-type=copy]'); // jshint ignore:line
10 clipboard.on('success', function(e) {
11 window.alert(v.i10n['copied']);
12 });
13 }
14 $('a.visualizer-action[data-visualizer-type!=copy]').on('click', function(e) {
15 var type = $(this).attr( 'data-visualizer-type' );
16 var chart = $(this).attr( 'data-visualizer-chart-id' );
17 var lock = $('.visualizer-front.visualizer-front-' + chart);
18 lock.lock();
19 e.preventDefault();
20 $.ajax({
21 url : v.rest_url.replace('#id#', chart).replace('#type#', type),
22 success: function(data) {
23 if (data && data.data) {
24 switch(type){
25 case 'csv':
26 var a = document.createElement("a");
27 document.body.appendChild(a);
28 a.style = "display: none";
29 var blob = new Blob([data.data.csv], {type: $(this).attr( 'data-visualizer-mime' ) }),
30 url = window.URL.createObjectURL(blob);
31 a.href = url;
32 a.download = data.data.name;
33 a.click();
34 setTimeout(function () {
35 window.URL.revokeObjectURL(url);
36 }, 100);
37 break;
38 case 'xls':
39 var $a = $("<a>");
40 $a.attr("href",data.data.csv);
41 $("body").append($a);
42 $a.attr("download",data.data.name);
43 $a[0].click();
44 $a.remove();
45 break;
46 case 'print':
47 var iframe = $('<iframe>').attr("name", "print-visualization").attr("id", "print-visualization").css("position", "absolute");
48 iframe.appendTo($('body'));
49 var iframe_doc = iframe.get(0).contentWindow || iframe.get(0).contentDocument.document || iframe.get(0).contentDocument;
50 iframe_doc.document.open();
51 iframe_doc.document.write(data.data.csv);
52 iframe_doc.document.close();
53 setTimeout(function(){
54 window.frames['print-visualization'].focus();
55 window.frames['print-visualization'].print();
56 iframe.remove();
57 }, 500);
58 break;
59 default:
60 if(window.visualizer_perform_action) {
61 window.visualizer_perform_action(type, chart, data.data);
62 }
63 break;
64 }
65 }
66 lock.unlock();
67 }
68 });
69 });
70 }
71
72 $(document).ready(function(){
73 $('body').trigger('visualizer:render:chart:start', visualizer);
74 initActionsButtons(visualizer);
75 });
76 })(jQuery, visualizer);
77
78 (function ($) {
79 $.fn.lock = function () {
80 $(this).each(function () {
81 var $this = $(this);
82 var position = $this.css('position');
83
84 if (!position) {
85 position = 'static';
86 }
87
88 switch (position) {
89 case 'absolute':
90 case 'relative':
91 break;
92 default:
93 $this.css('position', 'relative');
94 break;
95 }
96 $this.data('position', position);
97
98 var width = $this.width(),
99 height = $this.height();
100
101 var locker = $('<div class="locker"></div>');
102 locker.width(width).height(height);
103
104 var loader = $('<div class="locker-loader"></div>');
105 loader.width(width).height(height);
106
107 locker.append(loader);
108 $this.append(locker);
109 $(window).resize(function () {
110 $this.find('.locker,.locker-loader').width($this.width()).height($this.height());
111 });
112 });
113
114 return $(this);
115 };
116
117 $.fn.unlock = function () {
118 $(this).each(function () {
119 $(this).find('.locker').remove();
120 $(this).css('position', $(this).data('position'));
121 });
122
123 return $(this);
124 };
125 })(jQuery);