PluginProbe ʕ •ᴥ•ʔ
CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice) / 3.5.0
CookieYes – Cookie Banner for Cookie Consent (Easy to setup GDPR/CCPA Compliant Cookie Notice) v3.5.0
3.5.1 3.5.0 3.4.2 trunk 1.0.1 1.0.3 1.2 1.2.1 1.2.2 1.3 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 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.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.2.0 3.2.1 3.2.10 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.3.9.1 3.4.0 3.4.1
cookie-law-info / legacy / admin / js / cookie-law-info-admin.js
cookie-law-info / legacy / admin / js Last commit date
cookie-law-info-admin-1.6.7.js 1 month ago cookie-law-info-admin.js 1 month ago cookie-law-info-ckyes.js 1 month ago
cookie-law-info-admin.js
487 lines
1 (function( $ ) {
2 'use strict';
3
4 /**
5 * All of the code for your admin-facing JavaScript source
6 * should reside in this file.
7 *
8 * Note: It has been assumed you will write jQuery code here, so the
9 * $ function reference has been prepared for usage within the scope
10 * of this function.
11 *
12 * This enables you to define handlers, for when the DOM is ready:
13 *
14 * $(function() {
15 *
16 * });
17 *
18 * When the window is loaded:
19 *
20 * $( window ).load(function() {
21 *
22 * });
23 *
24 * ...and/or other possibilities.
25 *
26 * Ideally, it is not considered best practise to attach more than a
27 * single DOM-ready or window-load handler for a particular page.
28 * Although scripts in the WordPress core, Plugins and Themes may be
29 * practising this, we should strive to set a better example in our own work.
30 */
31 $(
32 function() {
33 $( '.my-color-field' ).wpColorPicker();
34
35 var cli_nav_tab = $( '.cookie-law-info-tab-head .nav-tab' );
36 if (cli_nav_tab.length > 0) {
37 cli_nav_tab.click(
38 function(){
39 var cli_tab_hash = $( this ).attr( 'href' );
40 cli_nav_tab.removeClass( 'nav-tab-active' );
41 $( this ).addClass( 'nav-tab-active' );
42 cli_tab_hash = cli_tab_hash.charAt( 0 ) == '#' ? cli_tab_hash.substring( 1 ) : cli_tab_hash;
43 var cli_tab_elm = $( 'div[data-id="' + cli_tab_hash + '"]' );
44 $( '.cookie-law-info-tab-content' ).hide();
45 if (cli_tab_elm.length > 0) {
46 cli_tab_elm.fadeIn();
47 }
48 }
49 );
50 var location_hash = window.location.hash;
51 if (location_hash != "") {
52 var cli_tab_hash = location_hash.charAt( 0 ) == '#' ? location_hash.substring( 1 ) : location_hash;
53 if (cli_tab_hash != "") {
54 $( 'div[data-id="' + cli_tab_hash + '"]' ).show();
55 $( 'a[href="#' + cli_tab_hash + '"]' ).addClass( 'nav-tab-active' );
56 }
57 } else {
58 cli_nav_tab.eq( 0 ).click();
59 }
60 }
61 $( '.cli_sub_tab li' ).click(
62 function(){
63 var trgt = $( this ).attr( 'data-target' );
64 var prnt = $( this ).parent( '.cli_sub_tab' );
65 var ctnr = prnt.siblings( '.cli_sub_tab_container' );
66 prnt.find( 'li a' ).css( {'color':'#0073aa','cursor':'pointer'} );
67 $( this ).find( 'a' ).css( {'color':'#000','cursor':'default','font-weight':'600'} );
68 ctnr.find( '.cli_sub_tab_content' ).hide();
69 ctnr.find( '.cli_sub_tab_content[data-id="' + trgt + '"]' ).fadeIn();
70 }
71 );
72 $( '.cli_sub_tab' ).each(
73 function(){
74 var elm = $( this ).children( 'li' ).eq( 0 );
75 elm.click();
76 }
77 );
78 $( '#cli_settings_form' ).submit(
79 function(e){
80 var submit_action = $( '#cli_update_action' ).val();
81 if (submit_action == 'delete_all_settings') {
82 // return;
83 }
84 e.preventDefault();
85 var data = $( this ).serialize();
86 var url = $( this ).attr( 'action' );
87 var spinner = $( this ).find( '.spinner' );
88 var submit_btn = $( this ).find( 'input[type="submit"]' );
89 spinner.css( {'visibility':'visible'} );
90 submit_btn.css( {'opacity':'.5','cursor':'default'} ).prop( 'disabled',true );
91 $.ajax(
92 {
93 url:url,
94 type:'POST',
95 data:data + '&cli_settings_ajax_update=' + submit_action,
96 success:function(data)
97 {
98 spinner.css( {'visibility':'hidden'} );
99 submit_btn.css( {'opacity':'1','cursor':'pointer'} ).prop( 'disabled',false );
100 if (submit_action == 'delete_all_settings') {
101 cli_notify_msg.success( cli_reset_settings_success_message );
102 setTimeout(
103 function(){
104 if( !!ckyConfigs.redirectUrl ) {
105 window.location.href = ckyConfigs.redirectUrl;
106 }
107 },
108 1000
109 );
110 } else {
111 cli_notify_msg.success( cli_settings_success_message );
112 }
113 cli_bar_active_msg();
114 },
115 error:function ()
116 {
117 spinner.css( {'visibility':'hidden'} );
118 submit_btn.css( {'opacity':'1','cursor':'pointer'} ).prop( 'disabled',false );
119 if (submit_action == 'delete_all_settings') {
120 cli_notify_msg.error( cli_reset_settings_error_message );
121 } else {
122 cli_notify_msg.error( cli_settings_error_message );
123 }
124 }
125 }
126 );
127 }
128 );
129
130 // =====================
131 function cli_scroll_accept_er()
132 {
133 if ($( '[name="cookie_bar_as_field"] option:selected' ).val() == 'popup' && $( '[name="popup_overlay_field"]:checked' ).val() == 'true' && $( '[name="scroll_close_field"]:checked' ).val() == 'true') {
134 $( '.cli_scroll_accept_er' ).show();
135 // $('label[for="scroll_close_field"]').css({'color':'red'});
136 } else {
137 $( '.cli_scroll_accept_er' ).hide();
138 // $('label[for="scroll_close_field"]').css({'color':'#23282d'});
139 }
140 }
141 cli_scroll_accept_er();
142 $( '[name="cookie_bar_as_field"]' ).change(
143 function(){
144 cli_scroll_accept_er();
145 }
146 );
147 $( '[name="popup_overlay_field"], [name="scroll_close_field"]' ).click(
148 function(){
149 cli_scroll_accept_er();
150 }
151 );
152 // =====================
153
154 function cli_bar_active_msg()
155 {
156 $( '.cli_bar_state tr' ).hide();
157 if ($( 'input[type="radio"].cli_bar_on' ).is( ':checked' )) {
158 $( '.cli_bar_state tr.cli_bar_on' ).show();
159 } else {
160 $( '.cli_bar_state tr.cli_bar_off' ).show();
161 }
162 }
163 var cli_form_toggler =
164 {
165 set:function()
166 {
167 $( 'select.cli_form_toggle' ).each(
168 function(){
169 cli_form_toggler.toggle( $( this ) );
170 }
171 );
172 $( 'input[type="radio"].cli_form_toggle' ).each(
173 function(){
174 if ($( this ).is( ':checked' )) {
175 cli_form_toggler.toggle( $( this ) );
176 }
177 }
178 );
179 $( 'select.cli_form_toggle' ).change(
180 function(){
181 cli_form_toggler.toggle( $( this ) );
182 }
183 );
184 $( 'input[type="radio"].cli_form_toggle' ).click(
185 function(){
186 if ($( this ).is( ':checked' )) {
187 cli_form_toggler.toggle( $( this ) );
188 }
189 }
190 );
191 },
192 toggle:function(elm)
193 {
194 var vl = elm.val();
195 var trgt = elm.attr( 'cli_frm_tgl-target' );
196 $( '[cli_frm_tgl-id="' + trgt + '"]' ).hide();
197 var selected_target = $( '[cli_frm_tgl-id="' + trgt + '"]' ).filter(
198 function(){
199 return $( this ).attr( 'cli_frm_tgl-val' ) == vl;
200 }
201 );
202 selected_target.show();
203 selected_target.find( 'th' ).each(
204 function(){
205 var prnt = $( this ).parent( 'tr' );
206 var sub_lvl = 1;
207 if (typeof prnt.attr( 'cli_frm_tgl-lvl' ) !== typeof undefined && prnt.attr( 'cli_frm_tgl-lvl' ) !== false) {
208 sub_lvl = prnt.attr( 'cli_frm_tgl-lvl' );
209 }
210 var lft_margin = sub_lvl * 15;
211 $( this ).find( 'label' ).css( {'margin-left':'0px'} ).stop( true,true ).animate( {'margin-left':lft_margin + 'px'} );
212 }
213 );
214
215 }
216 }
217 $( '#button_2_page_field' ).on(
218 'change',
219 function(){
220 if ($( '.cli_privacy_page_not_exists_er' ).length > 0) {
221 $( '.cli_privacy_page_not_exists_er' ).remove();
222 }
223 }
224 );
225
226 cli_form_toggler.set();
227
228 // =====================
229 // Banner Upgrade Flow – Modal 1 & 2
230 // =====================
231 const $cliOverlay = $( '#cli-modal-overlay' );
232 const $cliModal1 = $( '#cli-modal-1' );
233 const $cliModal2 = $( '#cli-modal-2' );
234
235 function cliPositionModals() {
236 const $content = $( '#wpcontent' );
237 if ( ! $content.length ) { return; }
238 const left = $content.offset().left + $content.outerWidth() / 2;
239 $( '.wt-cli-upgrade-modal' ).css( 'left', left + 'px' );
240 }
241
242 function cliOpenModal( $modal ) {
243 $cliOverlay.addClass( 'is-open' );
244 $modal.addClass( 'is-open' );
245 $( 'body' ).css( 'overflow', 'hidden' );
246 cliPositionModals();
247 }
248
249 $( window ).on( 'resize.cliModal', function () {
250 if ( $cliModal1.hasClass( 'is-open' ) || $cliModal2.hasClass( 'is-open' ) ) {
251 cliPositionModals();
252 }
253 } );
254 function cliCloseAll() {
255 $cliOverlay.removeClass( 'is-open' );
256 $cliModal1.removeClass( 'is-open' );
257 $cliModal2.removeClass( 'is-open' );
258 $( 'body' ).css( 'overflow', '' );
259 }
260
261 $( document ).on( 'click', '[data-cli-open-modal="cli-modal-1"]', function ( e ) {
262 e.preventDefault();
263 cliOpenModal( $cliModal1 );
264 } );
265 $cliOverlay.on( 'click', cliCloseAll );
266 $( document ).on( 'click', '.wt-cli-modal-close-btn', cliCloseAll );
267 $( '#cli-btn-review-changes' ).on( 'click', function () {
268 $cliModal1.removeClass( 'is-open' );
269 cliOpenModal( $cliModal2 );
270 } );
271 $( '#cli-btn-view-features' ).on( 'click', function () {
272 $cliModal2.removeClass( 'is-open' );
273 cliOpenModal( $cliModal1 );
274 } );
275
276 // Accordion in Modal 2
277 $( document ).on( 'click', '.wt-cli-accordion-header', function () {
278 const $item = $( this ).closest( '.wt-cli-accordion-item' );
279 const isOpen = $item.hasClass( 'is-open' );
280 $item.toggleClass( 'is-open' );
281 $( this ).attr( 'aria-expanded', ! isOpen );
282 } );
283 // =====================
284
285 }
286 );
287 $( document ).ready(
288 function () {
289 wtCliAdminFunctions.set();
290 }
291 );
292 })( jQuery );
293
294 var wtCliAdminFunctions = {
295
296 set : function() {
297 this.CLIAccordion();
298 this.checkboxTogglerHandler();
299 this.revisitConsentPositionEvent();
300 this.revisitConsentPosition();
301 this.modalEvents();
302 },
303 CLIAccordion : function() {
304
305 if (jQuery( '.wt-cli-accordion-tab' ).hasClass( 'active' )) {
306 jQuery( '.wt-cli-accordion-tab.active' ).find( '.wt-cli-accordion-content' ).slideDown( 0 );
307 }
308 jQuery( document ).on(
309 'click',
310 '.wt-cli-accordion-tab a',
311 function (e) {
312 e.preventDefault();
313 var $this = jQuery( this );
314 if ($this.next().hasClass( 'active' )) {
315 $this.removeClass( 'active' );
316 $this.next().removeClass( 'active' );
317 $this.closest( '.wt-cli-accordion-tab' ).removeClass( 'active' );
318 $this.next().slideUp( 350 );
319 } else {
320 $this.parent().parent().find( '.wt-cli-accordion-content' ).removeClass( 'active' );
321 $this.parent().parent().find( '.wt-cli-accordion-content' ).slideUp( 350 );
322 $this.parent().parent().find( '.wt-cli-accordion-tab a' ).removeClass( 'active' );
323 $this.parent().parent().find( '.wt-cli-accordion-tab' ).removeClass( 'active' );
324 $this.toggleClass( 'active' );
325 $this.closest( '.wt-cli-accordion-tab' ).toggleClass( 'active' );
326 $this.next().toggleClass( 'active' );
327 $this.next().slideToggle( 350 );
328
329 }
330 }
331 );
332
333 },
334 checkboxTogglerHandler: function(){
335 jQuery( 'input[name="showagain_tab_field"],.wt-cli-input-toggle-checkbox' ).each(
336 function(){
337 wtCliAdminFunctions.checkboxToggler( jQuery( this ) );
338 }
339 );
340 jQuery( document ).on(
341 'click',
342 '.wt-cli-input-toggle-checkbox',
343 function(){
344 wtCliAdminFunctions.checkboxToggler( jQuery( this ) );
345 }
346 );
347 },
348 checkboxToggler: function( element ) {
349
350 var currentElement = element;
351 var toggleTarget = currentElement.attr( 'data-cli-toggle-target' );
352 var targetElement = jQuery( '[data-cli-toggle-id=' + toggleTarget + ']' );
353 if ( currentElement.is( ':checked' ) ) {
354 targetElement.slideDown( 200 );
355 targetElement.addClass( 'wt-cli-toggle-active' );
356 } else {
357 targetElement.slideUp( 100 );
358 targetElement.removeClass( 'wt-cli-toggle-active' );
359
360 }
361 },
362 revisitConsentPositionEvent: function(){
363 jQuery( document ).on(
364 'change',
365 'input[type="radio"][name="notify_position_horizontal_field"],select[name="popup_showagain_position_field"],input[name="cookie_bar_as_field"],select[name="widget_position_field"]',
366 function(){
367 wtCliAdminFunctions.revisitConsentPosition();
368 }
369 );
370 },
371
372 revisitConsentPosition: function(){
373 var barType = jQuery( 'input[type="radio"][name="cookie_bar_as_field"]:checked' ).val();
374 var position = jQuery( 'input[type="radio"][name="notify_position_horizontal_field"]:checked' ).val();
375 var revisitConsentMarginLabel = jQuery( '#wt-cli-revisit-consent-margin-label' );
376 var currentText = jQuery( '#wt-cli-revisit-consent-margin-label' ).val();
377 if ( barType === "popup" ) {
378 position = jQuery( 'select[name="popup_showagain_position_field"] option:selected' ).val();
379 } else if ( barType === "widget") {
380 position = jQuery( 'select[name="widget_position_field"] option:selected' ).val();
381 }
382
383 if ( position === 'bottom-right' || position === 'top-right' || position === 'right' ) {
384 currentText = revisitConsentMarginLabel.attr( 'data-cli-right-text' );
385 } else {
386 currentText = revisitConsentMarginLabel.attr( 'data-cli-left-text' );
387 }
388 if (typeof(currentText) != "undefined" && currentText !== null) {
389 revisitConsentMarginLabel.html( currentText );
390 }
391 },
392
393 modalEvents: function(){
394 jQuery( document ).on(
395 'click',
396 '.wt-cli-modal-js-close',
397 function(){
398 wtCliAdminFunctions.closeModal();
399 }
400 );
401 },
402 showModal: function(id) {
403 this.closeModal();
404 let el = jQuery( '#' + id );
405 el.find( '.wt-cli-inline-notice' ).remove();
406 el.addClass( 'on' );
407 this.addOverlay();
408
409 },
410 createModal: function( heading,content ){
411 this.closeModal();
412 var headingHtml = '';
413 if ( heading !== '') {
414 headingHtml = '<div class="wt-cli-modal-header"><h4>' + heading + '</h4></div>';
415 }
416 let html = '<div class="wt-cli-modal on" id="">';
417 html += '<span class="wt-cli-modal-js-close">×</span>';
418 html += headingHtml;
419 html += '<div class="wt-cli-modal-body">';
420 html += '<p>' + content + '</p>';
421 html += '</div>';
422 html += '</div>';
423 jQuery( 'body' ).append( html );
424 this.addOverlay();
425 },
426 addOverlay: function(){
427 const html = '<div class="wt-cli-modal-js-overlay"></div>';
428 jQuery( 'body' ).append( html );
429 },
430 closeOverlay: function(){
431 jQuery( '.wt-cli-modal-js-overlay' ).remove();
432 },
433 closeModal: function(){
434 jQuery( '.wt-cli-modal' ).removeClass( 'on' );
435 this.closeOverlay();
436 },
437 addInlineMessage:function( message, type='notice', element ) {
438 element.find( '.wt-cli-inline-notice' ).remove();
439 var error_message = '<div role="alert" class="wt-cli-inline-notice wt-cli-inline-notice-' + type + '">' + message + '</div>';
440 jQuery( element ).append( error_message );
441 },
442 loadSpinner( element ){
443 var spinner = jQuery( '<span class="spinner"></span>' );
444 spinner.insertBefore( element );
445 spinner.css( {'visibility' : 'visible'} );
446 },
447 removeSpinner: function( element ){
448 var spinner = element.prev( '.spinner' );
449 spinner.remove();
450 },
451 }
452
453 var cli_notify_msg =
454 {
455 error:function(message)
456 {
457 var er_elm = jQuery( '<div class="notify_msg" style="background:#dd4c27; border:solid 1px #dd431c;">' + message + '</div>' );
458 this.setNotify( er_elm );
459 },
460 success:function(message)
461 {
462 var suss_elm = jQuery( '<div class="notify_msg" style="background:#00B200; border:solid 1px #00B200;">' + message + '</div>' );
463 this.setNotify( suss_elm );
464 },
465 setNotify:function(elm)
466 {
467 jQuery( 'body' ).append( elm );
468 elm.stop( true,true ).animate( {'opacity':1,'top':'50px'},1000 );
469 setTimeout(
470 function(){
471 elm.animate(
472 {'opacity':0,'top':'100px'},
473 1000,
474 function(){
475 elm.remove();
476 }
477 );
478 },
479 3000
480 );
481 }
482 }
483 function cli_store_settings_btn_click(vl)
484 {
485 document.getElementById( 'cli_update_action' ).value = vl;
486 }
487