PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.7.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.7.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
← All changes | js/library.js +76 -147 3.10.131.7.6 View file →
@@ -1,162 +1,106 @@
1 1 /* global visualizer */
2 -/* global alert */
2 +(function(wpmv) {
3 + var vm, vmv;
3 4
4 -(function (wpmv) {
5 - var vm, vmv;
5 + vm = visualizer.media = {};
6 + vmv = vm.view = {};
6 7
7 - vm = visualizer.media = {};
8 - vmv = vm.view = {};
8 + vmv.Chart = wpmv.MediaFrame.extend({
9 + initialize: function() {
10 + var self = this;
9 11
10 - vmv.Chart = wpmv.MediaFrame.extend({
11 - initialize: function () {
12 - var self = this;
12 + _.defaults(self.options, {
13 + action: '',
14 + state: 'iframe:visualizer'
15 + });
13 16
14 - _.defaults(self.options, {
15 - action: '',
16 - state: 'iframe:visualizer'
17 - });
17 + wpmv.MediaFrame.prototype.initialize.apply(self, arguments);
18 18
19 - wpmv.MediaFrame.prototype.initialize.apply(self, arguments);
19 + wpmv.settings.tabUrl = self.options.action;
20 + self.createIframeStates();
21 + },
20 22
21 - wpmv.settings.tabUrl = self.options.action;
22 - self.createIframeStates();
23 - },
24 -
25 - open: function () {
26 - try{
27 - wpmv.MediaFrame.prototype.open.apply(this, arguments);
28 - }catch(error){
29 - alert(visualizer.i10n.conflict);
30 - }
31 - this.$el.addClass('hide-menu');
32 - }
33 - });
23 + open: function() {
24 + wpmv.MediaFrame.prototype.open.apply(this, arguments);
25 + this.$el.addClass('hide-menu');
26 + }
27 + });
34 28 })(wp.media.view);
35 29
36 -(function ($, vmv, vu) {
37 - var resizeTimeout;
30 +(function($, vmv, vu) {
31 + var resizeTimeout;
38 32
39 - $.fn.adjust = function () {
40 - return $(this).each(function () {
41 - var width = $('#visualizer-library').width(),
42 - margin = width * 0.02;
33 + $.fn.adjust = function() {
34 + return $(this).each(function() {
35 + var width = $('#visualizer-library').width(),
36 + margin = width * 0.02;
43 37
44 - width *= 0.305;
45 - $(this).prev( '.visualizer-chart-title' ).width(width - 14);
46 - var ChartHeight = width * 0.93;
47 - if ( $( '.visualizer-nochart-canvas' ).length === 0 ) {
48 - ChartHeight = width * 0.78;
49 - if ( $( '#visualizer-sidebar' ).hasClass('one-columns') ) {
50 - ChartHeight = width * 0.92;
51 - }
52 - }
53 - $(this).width(width).height( ChartHeight );
54 - });
55 - };
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 + };
56 42
57 - $('.visualizer-chart-canvas').adjust();
43 + $('.visualizer-chart-canvas').adjust();
58 44
59 - $(document).ready(function () {
60 - // clears the filters in the library form and submits.
61 - $('#viz-lib-reset').on('click', function(e){
62 - e.preventDefault();
63 - $(this).parent('form')[0].reset();
64 - $(this).parent('form').find('.viz-filter').each(function(index, el){
65 - var tag = $(el).prop('tagName').toLowerCase() + (typeof $(el).attr('type') !== 'undefined' ? $(el).attr('type').toLowerCase() : '');
66 - switch(tag){
67 - case 'select':
68 - $(el).prop('selectedIndex', 0);
69 - break;
70 - case 'inputtext':
71 - $(el).val('');
72 - break;
73 - }
45 + $(document).ready(function() {
46 + $('.visualizer-chart, .visualizer-library-pagination').fadeIn(500);
74 47
75 - });
76 - $(this).parent('form').submit();
77 - });
48 + $('.visualizer-chart-shortcode').click(function(e) {
49 + var range, selection;
78 50
79 - $('.visualizer-chart-shortcode').click(function (e) {
80 - var range, selection;
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 + });
81 63
82 - if (window.getSelection && document.createRange) {
83 - selection = window.getSelection();
84 - range = document.createRange();
85 - range.selectNodeContents(e.target);
86 - selection.removeAllRanges();
87 - selection.addRange(range);
88 - } else if (document.selection && document.body.createTextRange) {
89 - range = document.body.createTextRange();
90 - range.moveToElementText(e.target);
91 - range.select();
92 - }
93 - });
64 + $('.add-new-h2').click(function() {
65 + var wnd = window,
66 + view = new vmv.Chart({action: vu.create});
94 67
95 - $( '.visualizer-languages-list' ).on( 'click', '[data-lang_code]', function() {
96 - if ( $(this).find( 'i' ).hasClass( 'otgs-ico-add' ) ) {
97 - vu.create = vu.create + '&lang=' + $(this).data('lang_code') + '&parent_chart_id=' + $(this).data('chart');
98 - $('.add-new-chart').click();
99 - } else {
100 - vu.edit = vu.edit + '&lang=' + $(this).data('lang_code') + '&chart=' + $(this).data('chart');
101 - $('.visualizer-chart-edit').click();
102 - }
103 - } );
68 + wnd.send_to_editor = function() {
69 + wnd.location.href = vu.base;
70 + };
71 + view.open();
104 72
105 - $('.add-new-chart').click(function () {
106 - var wnd = window,
107 - view = new vmv.Chart({action: vu.create});
108 - vu.create = vu.create.replace(/[\?&]lang=[^&]+/, '').replace(/[\?&]parent_chart_id=[^&]+/, '');
73 + return false;
74 + });
109 75
110 - window.parent.addEventListener('message', function(event){
111 - switch(event.data) {
112 - case 'visualizer:mediaframe:close':
113 - view.close();
114 - break;
115 - }
116 - }, false);
76 + $('.visualizer-chart-edit').click(function() {
77 + var wnd = window,
78 + view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')});
117 79
118 - // remove the 'type' while refreshing the library page on creation of a new chart.
119 - // this is to avoid cases where users have filtered for chart type A and end up creating chart type B
120 - // remove 'vaction' as well so that additional actions are removed
121 - wnd.send_to_editor = function () {
122 - wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, '');
123 - };
124 - view.open();
80 + wnd.send_to_editor = function() {
81 + wnd.location.reload();
82 + };
125 83
126 - return false;
127 - });
84 + view.open();
128 85
129 - $('.visualizer-chart-edit').click(function () {
130 - var wnd = window;
131 - var view = new vmv.Chart( {
132 - action: vu.edit.indexOf('&chart') != -1 ? vu.edit : vu.edit + '&chart=' + $(this).attr('data-chart')
133 - } );
134 - vu.edit = vu.edit.replace(/[\?&]lang=[^&]+/, '');
86 + return false;
87 + });
135 88
136 - wnd.send_to_editor = function () {
137 - wnd.location.href = wnd.location.href.replace(/vaction/, '');
138 - };
139 -
140 - view.open();
141 -
142 - return false;
143 - });
144 -
145 - $(".visualizer-chart-export").on("click", function () {
89 + $(".visualizer-chart-export").on("click", function() {
146 90 $.ajax({
147 91 url: $(this).attr("data-chart"),
148 92 method: "get",
149 - success: function (data, textStatus, jqXHR) {
93 + success: function( data, textStatus, jqXHR ){
150 94 var a = document.createElement("a");
151 95 document.body.appendChild(a);
152 96 a.style = "display: none";
153 97 var blob = new Blob([data.data.csv], {type: "application/csv"}),
154 - url = window.URL.createObjectURL(blob);
98 + url = window.URL.createObjectURL(blob);
155 99 a.href = url;
156 100 a.download = data.data.name;
157 101 a.click();
158 - setTimeout(function () {
102 + setTimeout(function(){
159 103 window.URL.revokeObjectURL(url);
160 104 }, 100);
161 105 }
162 106 });
@@ -162,27 +106,12 @@
162 106 });
163 107 return false;
164 108 });
165 109
166 - $(".visualizer-chart-image").on("click", function () {
167 - $('body').trigger('visualizer:action:specificchart', {action: 'image', id: $(this).attr("data-chart"), data: null, dataObj: {name: $(this).attr("data-chart-title")}});
168 - return false;
169 - });
170 -
171 - // if vaction=addnew is found as a GET request parameter, show the modal.
172 - if(location.href.indexOf('vaction=addnew') !== -1){
173 - $('.add-new-chart').first().trigger('click');
174 - }
175 -
176 - $(window).resize(function () {
177 - clearTimeout(resizeTimeout);
178 - resizeTimeout = setTimeout(function () {
179 - $('.visualizer-chart-canvas').adjust();
180 - }, 100);
181 - });
182 -
183 - $('.visualizer-error i.error').on('click', function(){
184 - alert( $(this).attr('data-viz-error') );
185 - });
186 - $('.visualizer-chart:not(.visualizer-chart-display), .visualizer-library-pagination').fadeIn(500);
187 - });
110 + $(window).resize(function() {
111 + clearTimeout(resizeTimeout);
112 + resizeTimeout = setTimeout(function() {
113 + $('.visualizer-chart-canvas').adjust();
114 + }, 100);
115 + });
116 + });
188 117 })(jQuery, visualizer.media.view, visualizer.urls);