| @@ -32,8 +32,17 @@ | ||
| 32 | 32 | } |
| 33 | 33 | }); |
| 34 | 34 | })(wp.media.view); |
| 35 | 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 | + | |
| 36 | 45 | (function ($, vmv, vu) { |
| 37 | 46 | var resizeTimeout; |
| 38 | 47 | |
| 39 | 48 | $.fn.adjust = function () { |
| @@ -75,20 +84,27 @@ | ||
| 75 | 84 | }); |
| 76 | 85 | $(this).parent('form').submit(); |
| 77 | 86 | }); |
| 78 | 87 | |
| 79 | - $('.visualizer-chart-shortcode').click(function (e) { | |
| 88 | + $('.visualizer-chart-shortcode').click(function (event) { | |
| 89 | + | |
| 90 | + if ( createPopupProBlocker( $, event ) ) { | |
| 91 | + event.preventDefault(); | |
| 92 | + event.stopPropagation(); | |
| 93 | + return; | |
| 94 | + } | |
| 95 | + | |
| 80 | 96 | var range, selection; |
| 81 | 97 | |
| 82 | 98 | if (window.getSelection && document.createRange) { |
| 83 | 99 | selection = window.getSelection(); |
| 84 | 100 | range = document.createRange(); |
| 85 | - range.selectNodeContents(e.target); | |
| 101 | + range.selectNodeContents(event.target); | |
| 86 | 102 | selection.removeAllRanges(); |
| 87 | 103 | selection.addRange(range); |
| 88 | 104 | } else if (document.selection && document.body.createTextRange) { |
| 89 | 105 | range = document.body.createTextRange(); |
| 90 | - range.moveToElementText(e.target); | |
| 106 | + range.moveToElementText(event.target); | |
| 91 | 107 | range.select(); |
| 92 | 108 | } |
| 93 | 109 | }); |
| 94 | 110 | |
| @@ -125,9 +141,14 @@ | ||
| 125 | 141 | |
| 126 | 142 | return false; |
| 127 | 143 | }); |
| 128 | 144 | |
| 129 | - $('.visualizer-chart-edit').click(function () { | |
| 145 | + $('.visualizer-chart-edit').click(function (event) { | |
| 146 | + | |
| 147 | + if ( createPopupProBlocker( $, event ) ) { | |
| 148 | + return; | |
| 149 | + } | |
| 150 | + | |
| 130 | 151 | var wnd = window; |
| 131 | 152 | var view = new vmv.Chart( { |
| 132 | 153 | action: vu.edit.indexOf('&chart') != -1 ? vu.edit : vu.edit + '&chart=' + $(this).attr('data-chart') |
| 133 | 154 | } ); |
| @@ -140,10 +161,20 @@ | ||
| 140 | 161 | view.open(); |
| 141 | 162 | |
| 142 | 163 | return false; |
| 143 | 164 | }); |
| 165 | + $(".visualizer-chart-clone").on("click", function ( event ) { | |
| 166 | + if ( createPopupProBlocker( $, event ) ) { | |
| 167 | + event.preventDefault(); | |
| 168 | + } | |
| 169 | + }); | |
| 144 | 170 | |
| 145 | - $(".visualizer-chart-export").on("click", function () { | |
| 171 | + $(".visualizer-chart-export").on("click", function (event) { | |
| 172 | + | |
| 173 | + if ( createPopupProBlocker( $, event ) ) { | |
| 174 | + return; | |
| 175 | + } | |
| 176 | + | |
| 146 | 177 | $.ajax({ |
| 147 | 178 | url: $(this).attr("data-chart"), |
| 148 | 179 | method: "get", |
| 149 | 180 | success: function (data, textStatus, jqXHR) { |
| @@ -162,9 +193,12 @@ | ||
| 162 | 193 | }); |
| 163 | 194 | return false; |
| 164 | 195 | }); |
| 165 | 196 | |
| 166 | - $(".visualizer-chart-image").on("click", function () { | |
| 197 | + $(".visualizer-chart-image").on("click", function (event) { | |
| 198 | + if ( createPopupProBlocker( $, event ) ) { | |
| 199 | + return; | |
| 200 | + } | |
| 167 | 201 | $('body').trigger('visualizer:action:specificchart', {action: 'image', id: $(this).attr("data-chart"), data: null, dataObj: {name: $(this).attr("data-chart-title")}}); |
| 168 | 202 | return false; |
| 169 | 203 | }); |
| 170 | 204 | |
| @@ -172,8 +206,14 @@ | ||
| 172 | 206 | if(location.href.indexOf('vaction=addnew') !== -1){ |
| 173 | 207 | $('.add-new-chart').first().trigger('click'); |
| 174 | 208 | } |
| 175 | 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 | + | |
| 176 | 216 | $(window).resize(function () { |
| 177 | 217 | clearTimeout(resizeTimeout); |
| 178 | 218 | resizeTimeout = setTimeout(function () { |
| 179 | 219 | $('.visualizer-chart-canvas').adjust(); |
| @@ -184,5 +224,30 @@ | ||
| 184 | 224 | alert( $(this).attr('data-viz-error') ); |
| 185 | 225 | }); |
| 186 | 226 | $('.visualizer-chart:not(.visualizer-chart-display), .visualizer-library-pagination').fadeIn(500); |
| 187 | 227 | }); |
| 188 | -})(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 | +}); | |