PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 1.6.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v1.6.0
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
← All changes | js/frame.js +75 -305 3.1.31.6.0 View file →
@@ -1,314 +1,68 @@
1 -/* global prompt */
2 -/* global visualizer */
3 -/* global alert */
4 -/* global ajaxurl */
5 -/* global CodeMirror */
1 +(function($) {
2 + $(document).ready(function() {
3 + $('.type-radio').change(function() {
4 + $('.type-label-selected').removeClass('type-label-selected');
5 + $(this).parent().addClass('type-label-selected');
6 + });
6 7
7 -(function ($) {
8 - $(window).on('load', function(){
9 - // scroll to the selected chart type.
10 - if($('label.type-label.type-label-selected').length > 0) {
11 - $('label.type-label.type-label-selected')[0].scrollIntoView();
12 - }
13 - });
8 + $('.group-title').click(function() {
9 + var parent = $(this).parent();
14 10
15 - $(document).ready(function () {
16 - // open the correct source tab.
17 - var source = $('#visualizer-chart-id').attr('data-chart-source');
18 - $('li.viz-group.' + source).addClass('open');
11 + if (parent.hasClass('open')) {
12 + parent.removeClass('open');
13 + } else {
14 + $('.group.open').removeClass('open');
15 + parent.addClass('open');
16 + }
17 + });
19 18
20 - init_permissions();
19 + $('#remote-file').click(function() {
20 + var url = $.trim(prompt(visualizer.l10n.remotecsv_prompt));
21 21
22 - if(typeof visualizer !== 'undefined' && visualizer.is_pro) {
23 - init_db_import();
24 - init_filter_import();
25 - }
22 + if (url != '') {
23 + if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{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u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)) {
24 + if (url.substr(url.length - 8) == '/pubhtml') {
25 + url = url.substring(0, url.length - 8) + '/export?format=csv';
26 + }
26 27
27 - // update the manual configuation link to point to the correct chart type.
28 - var type = $('#visualizer-chart-id').attr('data-chart-type');
29 - var chart_type_in_api_link = type + 'chart';
30 - switch (type) {
31 - case "gauge":
32 - case "table":
33 - case "timeline":
34 - chart_type_in_api_link = type;
35 - break;
36 - }
28 + $('#remote-data').val(url);
29 + $('#csv-file').val('');
30 + $('#canvas').lock();
31 + $('#csv-form').submit();
32 + } else {
33 + alert(visualizer.l10n.invalid_source);
34 + }
35 + }
36 + });
37 37
38 - if($('span.viz-gvlink').length > 0) {
39 - $('span.viz-gvlink').html($('span.viz-gvlink').html().replace('?', chart_type_in_api_link));
40 - }
38 + $('#csv-file').change(function() {
39 + if ($.trim($(this).val()) != '') {
40 + $('#remote-data').val('');
41 + $('#canvas').lock();
42 + $('#csv-form').submit();
43 + }
44 + });
41 45
42 - $('.type-radio').change(function () {
43 - $('.type-label-selected').removeClass('type-label-selected');
44 - $(this).parent().addClass('type-label-selected');
45 - });
46 + $('#thehole').load(function() {
47 + $('#canvas').unlock();
48 + });
46 49
47 - $('#vz-chart-settings h2').click(function () {
48 - $("#vz-chart-source").hide();
49 - $("#vz-chart-permissions").removeClass('open').addClass('bottom-fixed');
50 - $(this).parent().removeClass('bottom-fixed').addClass('open');
51 - $("#vz-chart-permissions .viz-group-header").hide();
52 - return false;
53 - });
54 - $('#vz-chart-settings .customize-section-back').click(function () {
55 - $("#vz-chart-source").show();
56 - $(this).parent().parent().removeClass('open').addClass('bottom-fixed');
50 + $('.section-title').click(function() {
51 + $(this).toggleClass('open').parent().find('.section-items').toggle();
52 + });
57 53
58 - return false;
59 - });
60 - $('.viz-group-title').click(function () {
61 - var parent = $(this).parent();
54 + $('.more-info').click(function() {
55 + $(this).parent().find('.section-description:first').toggle();
56 + return false;
57 + });
62 58
63 - if (parent.hasClass('open')) {
64 - parent.removeClass('open');
65 - } else {
66 - parent.parent().find('.viz-group.open').removeClass('open');
67 - parent.addClass('open');
68 - }
69 - });
70 - $('#view-remote-file').click(function () {
71 - var url = $(this).parent().find('#remote-data').val();
72 -
73 - if (url !== '') {
74 - if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)) {
75 - if (url.substr(url.length - 8) === '/pubhtml') {
76 - url = url.substring(0, url.length - 8) + '/export?format=csv';
77 - }
78 -
79 - $('#canvas').lock();
80 - $(this).parent().submit();
81 - } else {
82 - alert(visualizer.l10n.invalid_source);
83 - }
84 - }
85 - });
86 -
87 - $('#vz-import-file').click(function (e) {
88 - e.preventDefault();
89 - if ($.trim($(this).parent().find("#csv-file").val()) !== '') {
90 - $('#canvas').lock();
91 - $(this).parent().submit();
92 - }
93 - });
94 -
95 - $('#thehole').load(function () {
96 - $('#canvas').unlock();
97 - });
98 -
99 - $('.viz-section-title').click(function () {
100 - $(this).toggleClass('open').parent().find('.viz-section-items').toggle();
101 - });
102 -
103 - $('.more-info').click(function () {
104 - $(this).parent().find('.viz-section-description:first').toggle();
105 - return false;
106 - });
107 -
108 - $('#cancel-button').click(function () {
109 - $('#cancel-form').submit();
110 - });
111 -
112 - });
113 -
114 - function init_permissions(){
115 - $('#vz-chart-permissions h2').click(function () {
116 - $("#vz-chart-source").hide();
117 - $("#vz-chart-permissions .viz-group-header").show();
118 - $("#vz-chart-settings").removeClass('open').addClass('bottom-fixed');
119 -
120 - $('#settings-button').click(function(e) {
121 - e.preventDefault();
122 - $('#permissions-form').submit();
123 - $('#settings-form').submit();
124 - });
125 -
126 - $(this).parent().removeClass('bottom-fixed').addClass('open');
127 -
128 - return false;
129 - });
130 - $('#vz-chart-permissions .customize-section-back').click(function () {
131 - $("#vz-chart-source").show();
132 -
133 - $("#vz-chart-permissions .viz-group-header").hide();
134 - $('#settings-button').click(function(e) {
135 - e.preventDefault();
136 - $('#settings-form').submit();
137 - });
138 -
139 - $(this).parent().parent().removeClass('open').addClass('bottom-fixed');
140 -
141 - return false;
142 - });
143 -
144 - $('.visualizer-permission').chosen({
145 - width : '50%',
146 - search_contains : true
147 - });
148 -
149 - $('.visualizer-permission-type').each(function(x, y){
150 - var type = $(y).attr('data-visualizer-permission-type');
151 - var child = $('.visualizer-permission-' + type + '-specific');
152 - if($(y).val() === 'all'){
153 - child.next('div.chosen-container').hide();
154 - return;
155 - }
156 - });
157 -
158 - $('.visualizer-permission-type').on('change', function(evt, params) {
159 - var type = $(this).attr('data-visualizer-permission-type');
160 - var child = $('.visualizer-permission-' + type + '-specific');
161 - child.empty();
162 - if(params.selected === 'all'){
163 - child.next('div.chosen-container').hide();
164 - return;
165 - } else {
166 - child.next('div.chosen-container').show();
167 - }
168 - child.append('<option value="">' + visualizer.l10n['loading'] + '</option>').trigger('chosen:updated');
169 - $.ajax({
170 - url : visualizer.ajax['url'],
171 - method : 'post',
172 - data : {
173 - 'action' : visualizer.ajax['actions']['permissions'],
174 - 'nonce' : visualizer.ajax['nonces']['permissions'],
175 - 'type' : params.selected
176 - },
177 - success : function(d, textStatus, XMLHttpRequest){
178 - if(d.success) {
179 - child.empty();
180 - $.each(d.data, function(k, v){
181 - child.append('<option value="' + k + '">' + v + '</option>');
182 - });
183 - child.trigger('chosen:updated');
184 - }
185 - }
186 - });
187 - });
188 - }
189 -
190 - // https://codemirror.net/
191 - function init_db_import_component(){
192 - var table_columns = visualizer.db_query.tables;
193 - var code_mirror = wp.CodeMirror || CodeMirror;
194 - var cm = code_mirror.fromTextArea($('.visualizer-db-query').get(0), {
195 - value: $('.visualizer-db-query').val(),
196 - autofocus: true,
197 - mode: 'text/x-mysql',
198 - lineWrapping: true,
199 - dragDrop: false,
200 - matchBrackets: true,
201 - autoCloseBrackets: true,
202 - extraKeys: {"Ctrl-Space": "autocomplete"},
203 - hintOptions: { tables: table_columns }
204 - });
205 -
206 - // force refresh so that the query shows on first time load. Otherwise you have to click on the editor for it to show.
207 - $('body').on('visualizer:db:query:focus', function(event, data){
208 - cm.refresh();
209 - });
210 -
211 - cm.focus();
212 -
213 - // update text area.
214 - cm.on('inputRead', function(x, y){
215 - cm.save();
216 - });
217 -
218 - // backspace and delete do not register so the text box does not get empty if the entire query is deleted
219 - // from the editor. Let's force this.
220 - $('body').on('visualizer:db:query:update', function(event, data){
221 - cm.save();
222 - });
223 - }
224 -
225 - function init_filter_import() {
226 - $( '#db-filter-save-button' ).on( 'click', function(){
227 - $('#vz-filter-wizard').submit();
228 - });
229 - }
230 -
231 - function init_db_import(){
232 - $( '#visualizer-db-query' ).css("z-index", "-1").hide();
233 -
234 - init_db_import_component();
235 -
236 - $('#visualizer-query-fetch').on('click', function(e){
237 -
238 - $('body').trigger('visualizer:db:query:update', {});
239 - if($('.visualizer-db-query').val() === ''){
240 - return;
241 - }
242 -
243 - start_ajax($('#visualizer-db-query'));
244 - $('.db-wizard-results').empty();
245 - $('.db-wizard-error').empty();
246 - $.ajax({
247 - url : ajaxurl,
248 - method : 'post',
249 - data : {
250 - 'action' : visualizer.ajax['actions']['db_get_data'],
251 - 'security' : visualizer.ajax['nonces']['db_get_data'],
252 - 'params' : $('#db-query-form').serialize()
253 - },
254 - success : function(data){
255 - if(data.success){
256 - $('.db-wizard-results').html(data.data.table);
257 - $('#results').DataTable({
258 - "paging": false
259 - });
260 - }else{
261 - $('.db-wizard-error').html(data.data.msg);
262 - }
263 - },
264 - complete: function(){
265 - end_ajax($('#visualizer-db-query'));
266 - }
267 - });
268 - });
269 -
270 - $( '#db-chart-button' ).on( 'click', function(){
271 - $('#content').css('width', 'calc(100% - 300px)');
272 - if( $(this).attr( 'data-current' ) === 'chart'){
273 - $(this).val( $(this).attr( 'data-t-filter' ) );
274 - $(this).html( $(this).attr( 'data-t-filter' ) );
275 - $(this).attr( 'data-current', 'filter' );
276 - $( '.visualizer-editor-lhs' ).hide();
277 - $( '#visualizer-db-query' ).css("z-index", "9999").show();
278 - $('body').trigger('visualizer:db:query:focus', {});
279 - $( '#canvas' ).hide();
280 - }else{
281 - var filter_button = $(this);
282 - $( '#visualizer-db-query' ).css("z-index", "-1").hide();
283 - $('#canvas').lock();
284 - filter_button.val( filter_button.attr( 'data-t-chart' ) );
285 - filter_button.html( filter_button.attr( 'data-t-chart' ) );
286 - filter_button.attr( 'data-current', 'chart' );
287 - $( '#canvas' ).css("z-index", "1").show();
288 - $( '#db-chart-save-button' ).trigger('click');
289 - }
290 - } );
291 -
292 - $( '#db-chart-save-button' ).on( 'click', function(){
293 - $('#viz-db-wizard-params').val($('#db-query-form').serialize());
294 - $('#vz-db-wizard').submit();
295 - });
296 - }
297 -
298 - function start_ajax(element){
299 - element.lock();
300 - }
301 -
302 - function end_ajax(element){
303 - element.unlock();
304 - }
305 -
59 + });
306 60 })(jQuery);
307 61
308 -(function ($) {
309 - $.fn.lock = function () {
310 - $(this).each(function () {
62 +(function($) {
63 + $.fn.lock = function() {
64 + $(this).each(function() {
311 65 var $this = $(this);
312 66 var position = $this.css('position');
313 67
314 68 if (!position) {
@@ -314,9 +68,9 @@
314 68 if (!position) {
315 69 position = 'static';
316 70 }
317 71
318 - switch (position) {
72 + switch(position) {
319 73 case 'absolute':
320 74 case 'relative':
321 75 break;
322 76 default:
@@ -335,21 +89,37 @@
335 89 loader.width(width).height(height);
336 90
337 91 locker.append(loader);
338 92 $this.append(locker);
339 - $(window).resize(function () {
93 + $(window).resize(function() {
340 94 $this.find('.locker,.locker-loader').width($this.width()).height($this.height());
341 95 });
342 96 });
343 97
344 98 return $(this);
345 - };
99 + }
346 100
347 - $.fn.unlock = function () {
348 - $(this).each(function () {
101 + $.fn.unlock = function() {
102 + $(this).each(function() {
349 103 $(this).find('.locker').remove();
350 104 $(this).css('position', $(this).data('position'));
351 105 });
352 106
353 107 return $(this);
354 - };
355 -})(jQuery);
108 + }
109 +})(jQuery);
110 +
111 +//Hide / show settings in sidebar
112 +(function($) {
113 + $(document).ready(function() {
114 +
115 + $('.advanced-settings-btn').click(function(){
116 + $('.second-screen, .return-settings-btn').removeClass("hidden-setting");
117 + $('.initial-screen').addClass("hidden-setting");
118 + });
119 +
120 + $('.return-settings-btn').click(function(){
121 + $('.second-screen, .return-settings-btn').addClass("hidden-setting");
122 + $('.initial-screen').removeClass("hidden-setting");
123 + });
124 + });
125 +})(jQuery);