PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.1
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 +203 -11 3.0.73.11.1 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,77 @@
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() {
37 +
38 + var link = document.createElement('link');
39 + link.rel = 'stylesheet';
40 + link.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css';
41 + document.head.appendChild(link);
42 +
43 + var overlay = document.createElement('div');
44 + overlay.classList.add('vizualizer-renew-notice-overlay');
45 + overlay.id = 'overlay-visualizer';
46 + document.body.appendChild(overlay);
47 +
48 + var popup = document.createElement('div');
49 + popup.classList.add('vizualizer-renew-notice-popup');
50 +
51 + var closeIcon = document.createElement('i');
52 + closeIcon.classList.add('fas', 'fa-times', 'vizualizer-renew-notice-close-icon');
53 + closeIcon.addEventListener('click', function() {
54 + document.body.removeChild(overlay);
55 + popup.style.display = 'none';
56 + });
57 + popup.appendChild(closeIcon);
58 +
59 + var heading = document.createElement('h1');
60 + heading.textContent = 'Alert!';
61 + heading.classList.add('vizualizer-renew-notice-heading');
62 + popup.appendChild(heading);
63 +
64 + var message = document.createElement('p');
65 + message.textContent = 'In order to edit premium charts, benefit from updates and support for Visualizer Premium plugin, please renew your license code or activate it.';
66 + message.classList.add('vizualizer-renew-notice-message');
67 + popup.appendChild(message);
68 +
69 + var buttonsContainer = document.createElement('div');
70 + buttonsContainer.classList.add('vizualizer-renew-notice-buttons-container');
71 +
72 + var link1 = document.createElement('a');
73 + link1.href = 'https://store.themeisle.com/';
74 + link1.target = '_blank';
75 + var button1 = document.createElement('button');
76 + button1.innerHTML = '<span class="fas fa-shopping-cart"></span> Renew License';
77 + button1.classList.add('vizualizer-renew-notice-button', 'vizualizer-renew-notice-renew-button');
78 + link1.appendChild(button1);
79 + buttonsContainer.appendChild(link1);
80 +
81 + var link2 = document.createElement('a');
82 + link2.href = '/wp-admin/options-general.php#visualizer_pro_license';
83 + var button2 = document.createElement('button');
84 + button2.innerHTML = '<span class="fas fa-key"></span> Activate License';
85 + button2.classList.add('vizualizer-renew-notice-button', 'vizualizer-renew-notice-activate-button');
86 + link2.appendChild(button2);
87 + buttonsContainer.appendChild(link2);
88 +
89 + popup.appendChild(buttonsContainer);
90 +
91 + document.body.appendChild(popup);
92 +
93 +}
94 +
30 95 (function ($, vmv, vu) {
31 96 var resizeTimeout;
32 97
33 98 $.fn.adjust = function () {
@@ -35,9 +100,17 @@
35 100 var width = $('#visualizer-library').width(),
36 101 margin = width * 0.02;
37 102
38 103 width *= 0.305;
39 - $(this).width(width - 14).height(width * 0.75).parent().css('margin-right', margin + 'px').css('margin-bottom', margin + 'px');
104 + $(this).prev( '.visualizer-chart-title' ).width(width - 14);
105 + var ChartHeight = width * 0.93;
106 + if ( $( '.visualizer-nochart-canvas' ).length === 0 ) {
107 + ChartHeight = width * 0.78;
108 + if ( $( '#visualizer-sidebar' ).hasClass('one-columns') ) {
109 + ChartHeight = width * 0.92;
110 + }
111 + }
112 + $(this).width(width).height( ChartHeight );
40 113 });
41 114 };
42 115
43 116 $('.visualizer-chart-canvas').adjust();
@@ -42,11 +115,36 @@
42 115
43 116 $('.visualizer-chart-canvas').adjust();
44 117
45 118 $(document).ready(function () {
46 - $('.visualizer-chart, .visualizer-library-pagination').fadeIn(500);
119 + // clears the filters in the library form and submits.
120 + $('#viz-lib-reset').on('click', function(e){
121 + e.preventDefault();
122 + $(this).parent('form')[0].reset();
123 + $(this).parent('form').find('.viz-filter').each(function(index, el){
124 + var tag = $(el).prop('tagName').toLowerCase() + (typeof $(el).attr('type') !== 'undefined' ? $(el).attr('type').toLowerCase() : '');
125 + switch(tag){
126 + case 'select':
127 + $(el).prop('selectedIndex', 0);
128 + break;
129 + case 'inputtext':
130 + $(el).val('');
131 + break;
132 + }
47 133
134 + });
135 + $(this).parent('form').submit();
136 + });
137 +
48 138 $('.visualizer-chart-shortcode').click(function (e) {
139 +
140 + if ( ! visualizer.is_pro_user && e.target.classList.contains('viz-is-pro-chart') ) {
141 + createPopupProBlocker();
142 + e.preventDefault();
143 + e.stopPropagation();
144 + return;
145 + }
146 +
49 147 var range, selection;
50 148
51 149 if (window.getSelection && document.createRange) {
52 150 selection = window.getSelection();
@@ -60,14 +158,36 @@
60 158 range.select();
61 159 }
62 160 });
63 161
64 - $('.add-new-h2').click(function () {
162 + $( '.visualizer-languages-list' ).on( 'click', '[data-lang_code]', function() {
163 + if ( $(this).find( 'i' ).hasClass( 'otgs-ico-add' ) ) {
164 + vu.create = vu.create + '&lang=' + $(this).data('lang_code') + '&parent_chart_id=' + $(this).data('chart');
165 + $('.add-new-chart').click();
166 + } else {
167 + vu.edit = vu.edit + '&lang=' + $(this).data('lang_code') + '&chart=' + $(this).data('chart');
168 + $('.visualizer-chart-edit').click();
169 + }
170 + } );
171 +
172 + $('.add-new-chart').click(function () {
65 173 var wnd = window,
66 174 view = new vmv.Chart({action: vu.create});
175 + vu.create = vu.create.replace(/[\?&]lang=[^&]+/, '').replace(/[\?&]parent_chart_id=[^&]+/, '');
67 176
177 + window.parent.addEventListener('message', function(event){
178 + switch(event.data) {
179 + case 'visualizer:mediaframe:close':
180 + view.close();
181 + break;
182 + }
183 + }, false);
184 +
185 + // remove the 'type' while refreshing the library page on creation of a new chart.
186 + // this is to avoid cases where users have filtered for chart type A and end up creating chart type B
187 + // remove 'vaction' as well so that additional actions are removed
68 188 wnd.send_to_editor = function () {
69 - wnd.location.href = vu.base;
189 + wnd.location.href = vu.base.replace(/type=[a-zA-Z]*/, '').replace(/vaction/, '');
70 190 };
71 191 view.open();
72 192
73 193 return false;
@@ -72,14 +192,23 @@
72 192
73 193 return false;
74 194 });
75 195
76 - $('.visualizer-chart-edit').click(function () {
77 - var wnd = window,
78 - view = new vmv.Chart({action: vu.edit + '&chart=' + $(this).attr('data-chart')});
196 + $('.visualizer-chart-edit').click(function (event) {
79 197
198 + if ( ! visualizer.is_pro_user && event.target.classList.contains('viz-is-pro-chart') ) {
199 + createPopupProBlocker();
200 + return;
201 + }
202 +
203 + var wnd = window;
204 + var view = new vmv.Chart( {
205 + action: vu.edit.indexOf('&chart') != -1 ? vu.edit : vu.edit + '&chart=' + $(this).attr('data-chart')
206 + } );
207 + vu.edit = vu.edit.replace(/[\?&]lang=[^&]+/, '');
208 +
80 209 wnd.send_to_editor = function () {
81 - wnd.location.reload();
210 + wnd.location.href = wnd.location.href.replace(/vaction/, '');
82 211 };
83 212
84 213 view.open();
85 214
@@ -84,10 +213,22 @@
84 213 view.open();
85 214
86 215 return false;
87 216 });
217 + $(".visualizer-chart-clone").on("click", function ( event ) {
218 + if ( ! visualizer.is_pro_user && event.target.classList.contains('viz-is-pro-chart') ) {
219 + createPopupProBlocker();
220 + event.preventDefault();
221 + }
222 + });
88 223
89 - $(".visualizer-chart-export").on("click", function () {
224 + $(".visualizer-chart-export").on("click", function (event) {
225 +
226 + if ( ! visualizer.is_pro_user && event.target.classList.contains('viz-is-pro-chart') ) {
227 + createPopupProBlocker();
228 + return;
229 + }
230 +
90 231 $.ajax({
91 232 url: $(this).attr("data-chart"),
92 233 method: "get",
93 234 success: function (data, textStatus, jqXHR) {
@@ -105,8 +246,29 @@
105 246 }
106 247 });
107 248 return false;
108 249 });
250 +
251 + $(".visualizer-chart-image").on("click", function (event) {
252 + if ( ! visualizer.is_pro_user && event.target.classList.contains('viz-is-pro-chart') ) {
253 + createPopupProBlocker();
254 + return;
255 + }
256 + $('body').trigger('visualizer:action:specificchart', {action: 'image', id: $(this).attr("data-chart"), data: null, dataObj: {name: $(this).attr("data-chart-title")}});
257 + return false;
258 + });
259 +
260 + // if vaction=addnew is found as a GET request parameter, show the modal.
261 + if(location.href.indexOf('vaction=addnew') !== -1){
262 + $('.add-new-chart').first().trigger('click');
263 + }
264 +
265 + //if vaction=edit is found as a GET request parameter, show the modal.
266 + if(location.href.indexOf('vaction=edit') !== -1 && location.href.indexOf('chart=') !== -1){
267 + const chartId = location.href.split('chart=')[1].split('&')[0];
268 + $('.visualizer-chart-edit').attr('data-chart', chartId).trigger('click');
269 + }
270 +
109 271 $(window).resize(function () {
110 272 clearTimeout(resizeTimeout);
111 273 resizeTimeout = setTimeout(function () {
112 274 $('.visualizer-chart-canvas').adjust();
@@ -111,6 +273,36 @@
111 273 resizeTimeout = setTimeout(function () {
112 274 $('.visualizer-chart-canvas').adjust();
113 275 }, 100);
114 276 });
277 +
278 + $('.visualizer-error i.error').on('click', function(){
279 + alert( $(this).attr('data-viz-error') );
280 + });
281 + $('.visualizer-chart:not(.visualizer-chart-display), .visualizer-library-pagination').fadeIn(500);
115 282 });
116 -})(jQuery, visualizer.media.view, visualizer.urls);
283 +})(jQuery, visualizer.media.view, visualizer.urls);
284 +
285 +
286 +document.querySelectorAll('.visualizer-chart').forEach(function (chart) {
287 + const translatable = chart.querySelector('.visualizer-languages-list');
288 + if ( ! translatable ) {
289 + return;
290 + }
291 +
292 + const chartId = chart.querySelector('.visualizer-chart-canvas')?.id?.replace('visualizer-', '');
293 +
294 + if ( ! chartId ) {
295 + return;
296 + }
297 +
298 + const translatableActions = translatable.querySelectorAll('[data-lang_code]');
299 + translatableActions.forEach(function (action) {
300 + action.addEventListener('click', function () {
301 + window?.tiTrk?.with('visualizer')?.add({
302 + feature: 'chart-library',
303 + featureComponent: 'chart-language-translations-used',
304 + groupId: chartId,
305 + });
306 + });
307 + });
308 +});