3333 } ) ;
3434} ) ( wp . media . view ) ;
3535
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-
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 ;
9343}
9444
9545( function ( $ , vmv , vu ) {
@@ -135,12 +85,11 @@ function createPopupProBlocker() {
13585 $ ( this ) . parent ( 'form' ) . submit ( ) ;
13686 } ) ;
13787
138- $ ( '.visualizer-chart-shortcode' ) . click ( function ( e ) {
88+ $ ( '.visualizer-chart-shortcode' ) . click ( function ( event ) {
13989
140- if ( ! visualizer . is_pro_user && e . target . classList . contains ( 'viz-is-pro-chart' ) ) {
141- createPopupProBlocker ( ) ;
142- e . preventDefault ( ) ;
143- e . stopPropagation ( ) ;
90+ if ( createPopupProBlocker ( $ , event ) ) {
91+ event . preventDefault ( ) ;
92+ event . stopPropagation ( ) ;
14493 return ;
14594 }
14695
@@ -149,12 +98,12 @@ function createPopupProBlocker() {
14998 if ( window . getSelection && document . createRange ) {
15099 selection = window . getSelection ( ) ;
151100 range = document . createRange ( ) ;
152- range . selectNodeContents ( e . target ) ;
101+ range . selectNodeContents ( event . target ) ;
153102 selection . removeAllRanges ( ) ;
154103 selection . addRange ( range ) ;
155104 } else if ( document . selection && document . body . createTextRange ) {
156105 range = document . body . createTextRange ( ) ;
157- range . moveToElementText ( e . target ) ;
106+ range . moveToElementText ( event . target ) ;
158107 range . select ( ) ;
159108 }
160109 } ) ;
@@ -195,8 +144,7 @@ function createPopupProBlocker() {
195144
196145 $ ( '.visualizer-chart-edit' ) . click ( function ( event ) {
197146
198- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
199- createPopupProBlocker ( ) ;
147+ if ( createPopupProBlocker ( $ , event ) ) {
200148 return ;
201149 }
202150
@@ -215,16 +163,14 @@ function createPopupProBlocker() {
215163 return false ;
216164 } ) ;
217165 $ ( ".visualizer-chart-clone" ) . on ( "click" , function ( event ) {
218- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
219- createPopupProBlocker ( ) ;
166+ if ( createPopupProBlocker ( $ , event ) ) {
220167 event . preventDefault ( ) ;
221168 }
222169 } ) ;
223170
224171 $ ( ".visualizer-chart-export" ) . on ( "click" , function ( event ) {
225172
226- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
227- createPopupProBlocker ( ) ;
173+ if ( createPopupProBlocker ( $ , event ) ) {
228174 return ;
229175 }
230176
@@ -249,8 +195,7 @@ function createPopupProBlocker() {
249195 } ) ;
250196
251197 $ ( ".visualizer-chart-image" ) . on ( "click" , function ( event ) {
252- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
253- createPopupProBlocker ( ) ;
198+ if ( createPopupProBlocker ( $ , event ) ) {
254199 return ;
255200 }
256201 $ ( 'body' ) . trigger ( 'visualizer:action:specificchart' , { action : 'image' , id : $ ( this ) . attr ( "data-chart" ) , data : null , dataObj : { name : $ ( this ) . attr ( "data-chart-title" ) } } ) ;
0 commit comments