33
33
} ) ;
34
34
} ) ( wp . media . view ) ;
35
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
-
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 ;
93
43
}
94
44
95
45
( function ( $ , vmv , vu ) {
@@ -135,12 +85,11 @@ function createPopupProBlocker() {
135
85
$ ( this ) . parent ( 'form' ) . submit ( ) ;
136
86
} ) ;
137
87
138
- $ ( '.visualizer-chart-shortcode' ) . click ( function ( e ) {
88
+ $ ( '.visualizer-chart-shortcode' ) . click ( function ( event ) {
139
89
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 ( ) ;
144
93
return ;
145
94
}
146
95
@@ -149,12 +98,12 @@ function createPopupProBlocker() {
149
98
if ( window . getSelection && document . createRange ) {
150
99
selection = window . getSelection ( ) ;
151
100
range = document . createRange ( ) ;
152
- range . selectNodeContents ( e . target ) ;
101
+ range . selectNodeContents ( event . target ) ;
153
102
selection . removeAllRanges ( ) ;
154
103
selection . addRange ( range ) ;
155
104
} else if ( document . selection && document . body . createTextRange ) {
156
105
range = document . body . createTextRange ( ) ;
157
- range . moveToElementText ( e . target ) ;
106
+ range . moveToElementText ( event . target ) ;
158
107
range . select ( ) ;
159
108
}
160
109
} ) ;
@@ -195,8 +144,7 @@ function createPopupProBlocker() {
195
144
196
145
$ ( '.visualizer-chart-edit' ) . click ( function ( event ) {
197
146
198
- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
199
- createPopupProBlocker ( ) ;
147
+ if ( createPopupProBlocker ( $ , event ) ) {
200
148
return ;
201
149
}
202
150
@@ -215,16 +163,14 @@ function createPopupProBlocker() {
215
163
return false ;
216
164
} ) ;
217
165
$ ( ".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 ) ) {
220
167
event . preventDefault ( ) ;
221
168
}
222
169
} ) ;
223
170
224
171
$ ( ".visualizer-chart-export" ) . on ( "click" , function ( event ) {
225
172
226
- if ( ! visualizer . is_pro_user && event . target . classList . contains ( 'viz-is-pro-chart' ) ) {
227
- createPopupProBlocker ( ) ;
173
+ if ( createPopupProBlocker ( $ , event ) ) {
228
174
return ;
229
175
}
230
176
@@ -249,8 +195,7 @@ function createPopupProBlocker() {
249
195
} ) ;
250
196
251
197
$ ( ".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 ) ) {
254
199
return ;
255
200
}
256
201
$ ( 'body' ) . trigger ( 'visualizer:action:specificchart' , { action : 'image' , id : $ ( this ) . attr ( "data-chart" ) , data : null , dataObj : { name : $ ( this ) . attr ( "data-chart-title" ) } } ) ;
0 commit comments