PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.3.9
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.3.9
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / assets / js / backend / settings-page.js
cookiebot / assets / js / backend Last commit date
gutenberg 3 years ago consent-mapping.js 2 years ago cookiebot-admin-script.js 2 years ago debug-page.js 3 years ago jquery.tipTip.js 3 years ago multiple-page.js 3 years ago network-settings-page.js 3 years ago prior-consent-settings.js 3 years ago settings-page.js 2 years ago support-page.js 3 years ago
settings-page.js
238 lines
1 /**
2 * Load init function when the page is ready
3 *
4 * @since 1.8.0
5 */
6 jQuery( document ).ready( init );
7
8 function init() {
9 language_toggle();
10 advanced_settings_toggle();
11 cookie_blocking_mode();
12 activeSettingsTab();
13 closeSubmitMsg();
14 submitEnable();
15 googleConsentModeOptions();
16 tcfOptions();
17 onAddRestriction();
18 showRestrictionPurposes();
19 onVendorSelection();
20 removeRestriction();
21 }
22
23 function language_toggle() {
24 jQuery( '#show_add_language_guide' ).on( 'click', function ( e ) {
25 e.preventDefault()
26 jQuery( '#add_language_guide' ).slideDown()
27 jQuery( this ).hide()
28 } )
29 jQuery( '#hide_add_language_guide' ).on( 'click', function ( e ) {
30 e.preventDefault()
31 jQuery( '#add_language_guide' ).slideUp()
32 jQuery( '#show_add_language_guide' ).show()
33 } )
34
35 jQuery( '#cookiebot-language' ).on( 'change', function () {
36 if ( this.value === '' ) {
37 jQuery( '#info_lang_autodetect' ).show()
38 jQuery( '#info_lang_specified' ).hide()
39 } else {
40 jQuery( '#info_lang_autodetect' ).hide()
41 jQuery( '#info_lang_specified' ).show()
42 }
43 } )
44 }
45
46 function advanced_settings_toggle() {
47 jQuery( '.cookiebot_fieldset_header' ).on( 'click', function ( e ) {
48 e.preventDefault()
49 jQuery( this ).next().slideToggle()
50 jQuery( this ).toggleClass( 'active' )
51 } )
52 }
53
54 function cookie_blocking_mode() {
55 let cookieBlockingMode = cookiebot_settings.cookieBlockingMode;
56
57 jQuery( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function () {
58 if ( this.value === 'auto' && cookieBlockingMode !== this.value ) {
59 jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
60 jQuery( '#declaration-tag, #cookie-popup, #gcm-cookie-categories, #gtm-cookie-categories').addClass('disabled__item');
61 jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
62 jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', true );
63 jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', true );
64 }
65 if ( this.value === 'manual' && cookieBlockingMode !== this.value ) {
66 jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 );
67 jQuery( '#declaration-tag, #cookie-popup, #gcm-cookie-categories, #gtm-cookie-categories').removeClass('disabled__item');
68 jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false );
69 jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', false );
70 jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', false );
71 }
72 cookieBlockingMode = this.value;
73 } )
74 if ( cookieBlockingMode === 'auto' ) {
75 jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 );
76 jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true );
77 jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', true );
78 jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', true );
79 }
80 }
81
82 function activeSettingsTab() {
83 jQuery('.cb-settings__tabs__item').on('click', function(){
84 let currentTab = jQuery('.cb-settings__tabs__item.active-item').data('tab');
85 let tab = jQuery(this).data('tab');
86 let tabSelector = '#'+tab;
87 jQuery('.cb-settings__tabs__item.active-item, .cb-settings__tabs__content--item.active-item').removeClass('active-item');
88 jQuery(this).addClass('active-item');
89 jQuery(tabSelector).addClass('active-item');
90
91 window.history.replaceState(null, null, '?page=cookiebot_settings&tab='+tab );
92 let referrer = jQuery('input[name="_wp_http_referer"]');
93 let referrerVal = referrer.val();
94 if(referrerVal.indexOf('tab=')!==-1) {
95 referrerVal = referrerVal.replace(currentTab,tab);
96 }else{
97 referrerVal += '&tab=' + tab;
98 }
99 referrer.val(referrerVal);
100 });
101 }
102
103 function closeSubmitMsg() {
104 jQuery('.cb-submit__msg').on('click',function(){
105 jQuery(this).addClass('hidden');
106 });
107 }
108
109 function submitEnable() {
110 const initialValues = jQuery('form').serialize();
111 const events = {
112 change: 'input:not([type=text]), select',
113 input: 'input[type="text"], textarea'
114 };
115
116 Object.entries(events).forEach(entry => {
117 const [eventName, elements] = entry;
118 jQuery(document).on(eventName,elements,{initialValues: initialValues},function(event){
119 checkValues(event.data.initialValues)
120 });
121 });
122 }
123
124 function checkValues(initialValues){
125 let submitBtn = jQuery('p.submit #submit');
126 let newValues = jQuery('form').serialize();
127 if(newValues !== initialValues) {
128 submitBtn.addClass('enabled');
129 }else{
130 submitBtn.removeClass('enabled');
131 }
132 }
133
134 function googleConsentModeOptions() {
135 jQuery('input#gcm').on('change', function () {
136 const parent = jQuery(this).parents('#consent-mode');
137 parent.find('.cb-settings__config__item:has(input#gcm-url-pasthrough)').toggle();
138 parent.find('.cb-settings__config__item:has(ul#cb-settings__gcm__cookie-types)').toggle();
139 const passthroughInput = jQuery('input#gcm-url-pasthrough');
140 const passthroughLabel = passthroughInput.parents('label.switch-checkbox')[0];
141 if (!passthroughLabel || !passthroughLabel.childNodes.length)
142 return;
143 passthroughLabel.childNodes[passthroughLabel.childNodes.length - 1].textContent = 'URL passthrough' + ' ' +
144 (passthroughInput.is(':checked') ? 'enabled' : 'disabled');
145 });
146 jQuery('input#gcm, input#gcm-url-pasthrough').on('change', function () {
147 const input = jQuery(this);
148 const label = input.parents('label.switch-checkbox')[0];
149 if (!label || !label.childNodes.length)
150 return;
151 label.childNodes[label.childNodes.length - 1].textContent = (
152 (input.attr('id') === 'gcm' ? 'Google Consent Mode' : 'URL passthrough') + ' ' +
153 (input.is(':checked') ? 'enabled' : 'disabled')
154 );
155 });
156 }
157
158 function tcfOptions() {
159 jQuery('input#cookiebot-iab').on('change', function () {
160 const parent = jQuery(this).parents('#iab');
161 parent.find('.cb-settings__config__item:has(input.tcf-option)').toggle();
162 });
163 }
164
165 function onAddRestriction() {
166 jQuery('.restriction-vendor-add').on('click', function () {
167 const allCurrentVendors = jQuery( '.cb-settings__vendor__restrictions' ).length;
168 const baseElement = jQuery( '.cb-settings__vendor__restrictions:last' );
169 let newElement = baseElement.clone();
170 newElement.find('.vendor-selector').attr('name','');
171 newElement.find('option').removeAttr('selected');
172 newElement.find('.purpose-item').each(function(index){
173 const itemId = 'cookiebot-vendorx'+( allCurrentVendors + 1 )+'-purposes'+(index+1);
174 jQuery(this).attr('name','');
175 jQuery(this).attr('id',itemId);
176 jQuery(this).removeAttr('checked');
177 jQuery(this).parent().attr('for',itemId);
178 });
179
180 newElement.insertAfter(baseElement);
181 });
182 }
183
184 function showRestrictionPurposes() {
185 jQuery(document).on('click','.vendor-purposes-show', function () {
186 const parent = jQuery(this).parents('.cb-settings__vendor__restrictions');
187 parent.find('.vendor-purposes-restrictions').toggle();
188 });
189 }
190
191 function onVendorSelection() {
192 jQuery(document).on('change', '.cb-settings__selector__container-input', function () {
193 const vendorId = jQuery(this).val();
194 const parent = jQuery(this).parents('.cb-settings__vendor__restrictions');
195 const vendorPurposes = parent.find('.vendor-purposes-restrictions .purpose-item');
196 const fieldName = 'cookiebot-tcf-disallowed[$s]';
197 const purposeFieldName = '[purposes][]';
198
199 jQuery(this).attr('name', fieldName.replace('$s', vendorId));
200 vendorPurposes.each(function(index){
201 const purposeAttribute = fieldName.replace('$s', vendorId) + purposeFieldName;
202 const itemId = 'cookiebot-vendor' + vendorId + '-purposes' + (index+1);
203 jQuery(this).attr('name', purposeAttribute);
204 jQuery(this).attr('id', itemId);
205 jQuery(this).parent().attr('for',itemId);
206 });
207 });
208 }
209
210 function removeRestriction(){
211 const initialValues = jQuery('form').serialize();
212 let submitBtn = jQuery('p.submit #submit');
213 jQuery(document).on('click','.cb-settings__vendor__restrictions .remove__restriction', function(){
214 const restriction = jQuery(this).closest( '.cb-settings__vendor__restrictions' );
215 const allRestrictions = jQuery( '.cb-settings__vendor__restrictions' );
216 if(allRestrictions.length === 1){
217 const selector = restriction.find('.cb-settings__selector-selector');
218 console.log(selector.data('placeholder'));
219 selector.text(selector.data('placeholder'));
220 restriction.find('.cb-settings__selector__container-input').val('');
221 restriction.find('.cb-settings__selector__container-input').attr('name','');
222 restriction.find('.cb-settings__selector-list-item.selected').removeClass('selected');
223 const vendorPurposes = restriction.find('.purpose-item');
224 vendorPurposes.each(function(){
225 jQuery(this).prop( 'checked', false );
226 jQuery(this).attr( 'name', '' );
227 });
228 }else{
229 restriction.remove();
230 }
231 let newValues = jQuery('form').serialize();
232 if(newValues !== initialValues) {
233 submitBtn.addClass('enabled');
234 }else{
235 submitBtn.removeClass('enabled');
236 }
237 });
238 }