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.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
visualizer / js / library.js

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

116 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global visualizer */
2 (function (wpmv) {
3 var vm, vmv;
4
5 vm = visualizer.media = {};
6 vmv = vm.view = {};
7
8 vmv.Chart = wpmv.MediaFrame.extend({
9 initialize: function () {
10 var self = this;
11
12 _.defaults(self.options, {
13 action: '',
14 state: 'iframe:visualizer'
15 });
16
17 wpmv.MediaFrame.prototype.initialize.apply(self, arguments);
18
19 wpmv.settings.tabUrl = self.options.action;
20 self.createIframeStates();
21 },
22
23 open: function () {
24 wpmv.MediaFrame.prototype.open.apply(this, arguments);
25 this.$el.addClass('hide-menu');
26 }
27 });
28 })(wp.media.view);
29
30 (function ($, vmv, vu) {
31 var resizeTimeout;
32
33 $.fn.adjust = function () {
34 return $(this).each(function () {
35 var width = $('#visualizer-library').width(),
36 margin = width * 0.02;
37
38 width *= 0.305;
39 $(this).width(width - 14).height(width * 0.75).parent().css('margin-right', margin + 'px').css('margin-bottom', margin + 'px');
40 });
41 };
42
43 $('.visualizer-chart-canvas').adjust();
44
45 $(document).ready(function () {
46 $('.visualizer-chart, .visualizer-library-pagination').fadeIn(500);
47
48 $('.visualizer-chart-shortcode').click(function (e) {
49 var range, selection;
50
51 if (window.getSelection && document.createRange) {
52 selection = window.getSelection();
53 range = document.createRange();
54 range.selectNodeContents(e.target);
55 selection.removeAllRanges();
56 selection.addRange(range);
57 } else if (document.selection && document.body.createTextRange) {
58 range = document.body.createTextRange();
59 range.moveToElementText(e.target);
60 range.select();
61 }
62 });
63
64 $('.add-new-h2').click(function () {
65 var wnd = window,
66 view = new vmv.Chart({action: vu.create});
67
68 wnd.send_to_editor = function () {
69 wnd.location.href = vu.base;
70 };
71 view.open();
72
73 return false;
74 });
75
76 $('.visualizer-chart-edit').click(function () {
77 var wnd = window,
78 view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')});
79
80 wnd.send_to_editor = function () {
81 wnd.location.reload();
82 };
83
84 view.open();
85
86 return false;
87 });
88
89 $(".visualizer-chart-export").on("click", function () {
90 $.ajax({
91 url: $(this).attr("data-chart"),
92 method: "get",
93 success: function (data, textStatus, jqXHR) {
94 var a = document.createElement("a");
95 document.body.appendChild(a);
96 a.style = "display: none";
97 var blob = new Blob([data.data.csv], {type: "application/csv"}),
98 url = window.URL.createObjectURL(blob);
99 a.href = url;
100 a.download = data.data.name;
101 a.click();
102 setTimeout(function () {
103 window.URL.revokeObjectURL(url);
104 }, 100);
105 }
106 });
107 return false;
108 });
109 $(window).resize(function () {
110 clearTimeout(resizeTimeout);
111 resizeTimeout = setTimeout(function () {
112 $('.visualizer-chart-canvas').adjust();
113 }, 100);
114 });
115 });
116 })(jQuery, visualizer.media.view, visualizer.urls);