PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.1.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.1.4
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 +6 -239 3.1.32.1.4 View file →
@@ -1,45 +1,10 @@
1 1 /* global prompt */
2 2 /* global visualizer */
3 3 /* global alert */
4 -/* global ajaxurl */
5 -/* global CodeMirror */
6 4
7 5 (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 - });
14 -
15 6 $(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');
19 -
20 - init_permissions();
21 -
22 - if(typeof visualizer !== 'undefined' && visualizer.is_pro) {
23 - init_db_import();
24 - init_filter_import();
25 - }
26 -
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 - }
37 -
38 - if($('span.viz-gvlink').length > 0) {
39 - $('span.viz-gvlink').html($('span.viz-gvlink').html().replace('?', chart_type_in_api_link));
40 - }
41 -
42 7 $('.type-radio').change(function () {
43 8 $('.type-label-selected').removeClass('type-label-selected');
44 9 $(this).parent().addClass('type-label-selected');
45 10 });
@@ -45,11 +10,10 @@
45 10 });
46 11
47 12 $('#vz-chart-settings h2').click(function () {
48 13 $("#vz-chart-source").hide();
49 - $("#vz-chart-permissions").removeClass('open').addClass('bottom-fixed');
50 14 $(this).parent().removeClass('bottom-fixed').addClass('open');
51 - $("#vz-chart-permissions .viz-group-header").hide();
15 +
52 16 return false;
53 17 });
54 18 $('#vz-chart-settings .customize-section-back').click(function () {
55 19 $("#vz-chart-source").show();
@@ -56,15 +20,15 @@
56 20 $(this).parent().parent().removeClass('open').addClass('bottom-fixed');
57 21
58 22 return false;
59 23 });
60 - $('.viz-group-title').click(function () {
24 + $('.group-title').click(function () {
61 25 var parent = $(this).parent();
62 26
63 27 if (parent.hasClass('open')) {
64 28 parent.removeClass('open');
65 29 } else {
66 - parent.parent().find('.viz-group.open').removeClass('open');
30 + parent.parent().find('.group.open').removeClass('open');
67 31 parent.addClass('open');
68 32 }
69 33 });
70 34 $('#view-remote-file').click(function () {
@@ -95,215 +59,18 @@
95 59 $('#thehole').load(function () {
96 60 $('#canvas').unlock();
97 61 });
98 62
99 - $('.viz-section-title').click(function () {
100 - $(this).toggleClass('open').parent().find('.viz-section-items').toggle();
63 + $('.section-title').click(function () {
64 + $(this).toggleClass('open').parent().find('.section-items').toggle();
101 65 });
102 66
103 67 $('.more-info').click(function () {
104 - $(this).parent().find('.viz-section-description:first').toggle();
68 + $(this).parent().find('.section-description:first').toggle();
105 69 return false;
106 70 });
107 71
108 - $('#cancel-button').click(function () {
109 - $('#cancel-form').submit();
110 - });
111 -
112 72 });
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 -
306 73 })(jQuery);
307 74
308 75 (function ($) {
309 76 $.fn.lock = function () {