PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.6.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.6.6
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 1.6.6, at js/library.js

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