PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
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/library.js +151 -14 3.0.53.11.10 View file →
@@ -1,5 +1,7 @@
1 1 /* global visualizer */
2 +/* global alert */
3 +
2 4 (function (wpmv) {
3 5 var vm, vmv;
4 6
5 7 vm = visualizer.media = {};
@@ -20,14 +22,27 @@
20 22 self.createIframeStates();
21 23 },
22 24
23 25 open: function () {
24 - wpmv.MediaFrame.prototype.open.apply(this, arguments);
26 + try{
27 + wpmv.MediaFrame.prototype.open.apply(this, arguments);
28 + }catch(error){
29 + alert(visualizer.i10n.conflict);
30 + }
25 31 this.$el.addClass('hide-menu');
26 32 }
27 33 });
28 34 })(wp.media.view);
29 35
36 +function createPopupProBlocker( $ , e ) {
37 + if ( ! visualizer.is_pro_user && e.target.classList.contains('viz-is-pro-chart') ) {
38 + $("#overlay-visualizer").css("display", "block");
39 + $(".vizualizer-renew-notice-popup").css("display", "block");
40 + return true;
41 + }
42 + return false;
43 +}
44 +
30 45 (function ($, vmv, vu) {
31 46 var resizeTimeout;
32 47
33 48 $.fn.adjust = function () {
@@ -35,9 +50,17 @@
35 50 var width = $('#visualizer-library').width(),
36 51 margin = width * 0.02;
37 52
38 53 width *= 0.305;
39 - $(this).width(width - 14).height(width * 0.75).parent().css('margin-right', margin + 'px').css('margin-bottom', margin + 'px');
54 + $(this).prev( '.visualizer-chart-title' ).width(width - 14);
55 + var ChartHeight = width * 0.93;
56 + if ( $( '.visualizer-nochart-canvas' ).length === 0 ) {
57 + ChartHeight = width * 0.78;
58 + if ( $( '#visualizer-sidebar' ).hasClass('one-columns') ) {
59 + ChartHeight = width * 0.92;
60 + }
61 + }
62 + $(this).width(width).height( ChartHeight );
40 63 });
41 64 };
42 65
43 66 $('.visualizer-chart-canvas').adjust();
@@ -42,32 +65,78 @@
42 65
43 66 $('.visualizer-chart-canvas').adjust();
44 67
45 68 $(document).ready(function () {
46 - $('.visualizer-chart, .visualizer-library-pagination').fadeIn(500);
69 + // clears the filters in the library form and submits.
70 + $('#viz-lib-reset').on('click', function(e){
71 + e.preventDefault();
72 + $(this).parent('form')[0].reset();
73 + $(this).parent('form').find('.viz-filter').each(function(index, el){
74 + var tag = $(el).prop('tagName').toLowerCase() + (typeof $(el).attr('type') !== 'undefined' ? $(el).attr('type').toLowerCase() : '');
75 + switch(tag){
76 + case 'select':
77 + $(el).prop('selectedIndex', 0);
78 + break;
79 + case 'inputtext':
80 + $(el).val('');
81 + break;
82 + }
47 83
48 - $('.visualizer-chart-shortcode').click(function (e) {
84 + });
85 + $(this).parent('form').submit();
86 + });
87 +
88 + $('.visualizer-chart-shortcode').click(function (event) {
89 +
90 + if ( createPopupProBlocker( $, event ) ) {
91 + event.preventDefault();
92 + event.stopPropagation();
93 + return;
94 + }
95 +
49 96 var range, selection;
50 97
51 98 if (window.getSelection && document.createRange) {
52 99 selection = window.getSelection();
53 100 range = document.createRange();
54 - range.selectNodeContents(e.target);
101 + range.selectNodeContents(event.target);
55 102 selection.removeAllRanges();
56 103 selection.addRange(range);
57 104 } else if (document.selection && document.body.createTextRange) {
58 105 range = document.body.createTextRange();
59 - range.moveToElementText(e.target);
106 + range.moveToElementText(event.target);
60 107 range.select();
61 108 }
62 109 });
63 110
64 - $('.add-new-h2').click(function () {
111 + $( '.visualizer-languages-list' ).on( 'click', '[data-lang_code]', function() {
112 + if ( $(this).find( 'i' ).hasClass( 'otgs-ico-add' ) ) {
113 + vu.create = vu.create + '&lang=' + $(this).data('lang_code') + '&parent_chart_id=' + $(this).data('chart');
114 + $('.add-new-chart').click();
115 + } else {
116 + vu.edit = vu.edit + '&lang=' + $(this).data('lang_code') + '&chart=' + $(this).data('chart');
117 + $('.visualizer-chart-edit').click();
118 + }
119 + } );
120 +
121 + $('.add-new-chart').click(function () {
65 122 var wnd = window,
66 123 view = new vmv.Chart({action: vu.create});
124 + vu.create = vu.create.replace(/[\?&]lang=[^&]+/, '').replace(/[\?&]parent_chart_id=[^&]+/, '');
67 125
126 + window.parent.addEventListener('message', function(event){
127 + switch(event.data) {
128 + case 'visualizer:mediaframe:close':
129 + view.close();
130 + break;
131 + }
132 + }, false);
133 +
134 + // remove the 'type' while refreshing the library page on creation of a new chart.
135 + // this is to avoid cases where users have filtered for chart type A and end up creating chart type B
136 + // remove 'vaction' as well so that additional actions are removed
68 137 wnd.send_to_editor = function () {
69 - wnd.location.href = vu.base;
138 + wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, '');
70 139 };
71 140 view.open();
72 141
73 142 return false;
@@ -72,14 +141,22 @@
72 141
73 142 return false;
74 143 });
75 144
76 - $('.visualizer-chart-edit').click(function () {
77 - var wnd = window,
78 - view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')});
145 + $('.visualizer-chart-edit').click(function (event) {
79 146
147 + if ( createPopupProBlocker( $, event ) ) {
148 + return;
149 + }
150 +
151 + var wnd = window;
152 + var view = new vmv.Chart( {
153 + action: vu.edit.indexOf('&chart') != -1 ? vu.edit : vu.edit + '&chart=' + $(this).attr('data-chart')
154 + } );
155 + vu.edit = vu.edit.replace(/[\?&]lang=[^&]+/, '');
156 +
80 157 wnd.send_to_editor = function () {
81 - wnd.location.reload();
158 + wnd.location.href = wnd.location.href.replace(/vaction/, '');
82 159 };
83 160
84 161 view.open();
85 162
@@ -84,10 +161,20 @@
84 161 view.open();
85 162
86 163 return false;
87 164 });
165 + $(".visualizer-chart-clone").on("click", function ( event ) {
166 + if ( createPopupProBlocker( $, event ) ) {
167 + event.preventDefault();
168 + }
169 + });
88 170
89 - $(".visualizer-chart-export").on("click", function () {
171 + $(".visualizer-chart-export").on("click", function (event) {
172 +
173 + if ( createPopupProBlocker( $, event ) ) {
174 + return;
175 + }
176 +
90 177 $.ajax({
91 178 url: $(this).attr("data-chart"),
92 179 method: "get",
93 180 success: function (data, textStatus, jqXHR) {
@@ -105,8 +192,28 @@
105 192 }
106 193 });
107 194 return false;
108 195 });
196 +
197 + $(".visualizer-chart-image").on("click", function (event) {
198 + if ( createPopupProBlocker( $, event ) ) {
199 + return;
200 + }
201 + $('body').trigger('visualizer:action:specificchart', {action: 'image', id: $(this).attr("data-chart"), data: null, dataObj: {name: $(this).attr("data-chart-title")}});
202 + return false;
203 + });
204 +
205 + // if vaction=addnew is found as a GET request parameter, show the modal.
206 + if(location.href.indexOf('vaction=addnew') !== -1){
207 + $('.add-new-chart').first().trigger('click');
208 + }
209 +
210 + //if vaction=edit is found as a GET request parameter, show the modal.
211 + if(location.href.indexOf('vaction=edit') !== -1 && location.href.indexOf('chart=') !== -1){
212 + const chartId = location.href.split('chart=')[1].split('&')[0];
213 + $('.visualizer-chart-edit').attr('data-chart', chartId).trigger('click');
214 + }
215 +
109 216 $(window).resize(function () {
110 217 clearTimeout(resizeTimeout);
111 218 resizeTimeout = setTimeout(function () {
112 219 $('.visualizer-chart-canvas').adjust();
@@ -111,6 +218,36 @@
111 218 resizeTimeout = setTimeout(function () {
112 219 $('.visualizer-chart-canvas').adjust();
113 220 }, 100);
114 221 });
222 +
223 + $('.visualizer-error i.error').on('click', function(){
224 + alert( $(this).attr('data-viz-error') );
225 + });
226 + $('.visualizer-chart:not(.visualizer-chart-display), .visualizer-library-pagination').fadeIn(500);
115 227 });
116 -})(jQuery, visualizer.media.view, visualizer.urls);
228 +})(jQuery, visualizer.media.view, visualizer.urls);
229 +
230 +
231 +document.querySelectorAll('.visualizer-chart').forEach(function (chart) {
232 + const translatable = chart.querySelector('.visualizer-languages-list');
233 + if ( ! translatable ) {
234 + return;
235 + }
236 +
237 + const chartId = chart.querySelector('.visualizer-chart-canvas')?.id?.replace('visualizer-', '');
238 +
239 + if ( ! chartId ) {
240 + return;
241 + }
242 +
243 + const translatableActions = translatable.querySelectorAll('[data-lang_code]');
244 + translatableActions.forEach(function (action) {
245 + action.addEventListener('click', function () {
246 + window?.tiTrk?.with('visualizer')?.add({
247 + feature: 'chart-library',
248 + featureComponent: 'chart-language-translations-used',
249 + groupId: chartId,
250 + });
251 + });
252 + });
253 +});