PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.5.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.5.0
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 / cookiebot-admin-script.js
cookiebot / assets / js / backend Last commit date
gutenberg 3 years ago account.js 1 year ago consent-mapping.js 1 year ago cookiebot-admin-script.js 1 year ago dashboard.js 1 year ago debug-page.js 1 year ago jquery.tipTip.js 3 years ago multiple-page.js 3 years ago network-settings-page.js 1 year ago prior-consent-settings.js 3 years ago settings-page.js 1 year ago support-page.js 3 years ago
cookiebot-admin-script.js
332 lines
1 /**
2 * Load init function when the page is ready
3 *
4 * @since 4.2.10
5 */
6 jQuery( document ).ready( cbInit );
7
8 function cbInit() {
9 jQuery( document ).on( 'click', 'tr[data-slug="cookiebot"] .cb-deactivate-action', event => deactivateCookiebot( event ) );
10 jQuery( document ).on( 'click', '#cb-review__close', event => closeSurveyPopup( event ) );
11 jQuery( document ).on( 'submit', '#cb-review__form', event => submitSurveyPopup( event ) );
12 jQuery( document ).on( 'change', 'input[name="cookiebot-review-option"]', event => showOptionalConsent( event ) )
13 hideSubmitMessage();
14 selectorListeners();
15 }
16
17 /**
18 * Displays popup form.
19 */
20 function deactivateCookiebot( e ) {
21 e.preventDefault();
22
23 let deactivationLink = e.target.href;
24
25 populatePopup();
26 jQuery( '#cb-review__skip' ).attr( 'href', deactivationLink );
27 jQuery( '#cookiebot-review-popup-container' ).addClass( 'cb-opened cb-filled' );
28 }
29
30 function populatePopup(){
31 if(jQuery( '#cookiebot-review-popup-container' ).hasClass( 'cb-filled' )){
32 return;
33 }
34
35 let popupFormContainer = document.createElement('div');
36 const header = renderPopupHeader();
37 const form = renderPopupForm();
38 popupFormContainer.setAttribute('id','cookiebot-popup');
39 popupFormContainer.appendChild(header);
40 popupFormContainer.appendChild(form);
41
42 jQuery('#cookiebot-review-popup-container').append(popupFormContainer);
43 }
44
45 function renderPopupHeader() {
46 let popupHeader = document.createElement('div');
47 let headerLogoContainer = document.createElement('div');
48 let headerLogo = document.createElement('img');
49 let headerTitle = document.createElement('h2');
50 let headerClose = document.createElement('div');
51 popupHeader.classList.add('cb-review__header');
52 headerLogoContainer.classList.add('cb-review__logo');
53 headerLogo.setAttribute('src', cb_survey.logo);
54 headerLogo.setAttribute('alt', 'Usercentrics Cookiebot');
55 headerTitle.setAttribute('id', 'cb-review__title');
56 headerTitle.innerHTML = cb_survey.popup_header_title;
57 headerClose.setAttribute('id', 'cb-review__close');
58 headerClose.classList.add('dashicons','dashicons-dismiss');
59 popupHeader.appendChild(headerLogoContainer).appendChild(headerLogo);
60 popupHeader.appendChild(headerTitle);
61 popupHeader.appendChild(headerClose);
62 return popupHeader;
63 }
64
65 function renderPopupForm(){
66 let popupForm = document.createElement('form');
67 popupForm.setAttribute('id', 'cb-review__form');
68 popupForm.setAttribute('method', 'POST');
69 let firstMsg = document.createElement('p');
70 firstMsg.innerText = cb_survey.first_msg;
71 const labelContainer = renderFormLabels();
72 const consentLabel = renderConsentLabel();
73 const consentActions = renderPopupActions();
74 popupForm.appendChild(firstMsg);
75 popupForm.appendChild(labelContainer);
76 popupForm.appendChild(consentLabel);
77 popupForm.appendChild(consentActions);
78 return popupForm
79 }
80
81 function renderFormLabels(){
82 let labelsContainer = document.createElement('div');
83 let options = cb_survey.options;
84 options.forEach((option)=>{
85 let labelContainer = document.createElement('div');
86 let labelChild = document.createElement('label');
87 let labelInput = document.createElement('input');
88 labelChild.classList.add('cb-review__form--item');
89 labelInput.setAttribute('type', 'radio');
90 labelInput.setAttribute('name', 'cookiebot-review-option');
91 labelInput.setAttribute('value', option.value);
92 let labelText = document.createElement('span');
93 labelText.innerText = option.text;
94 labelChild.appendChild(labelInput);
95 labelChild.appendChild(labelText);
96 labelContainer.appendChild(labelChild);
97
98 if(option.value === '7'){
99 let extraContainer = document.createElement('div');
100 let extraText = document.createElement('textarea');
101 extraContainer.classList.add('cb-review__form--item__custom');
102 extraText.setAttribute('id','cb-review__other-description');
103 extraText.setAttribute('name','other-description');
104 extraText.setAttribute('placeholder',option.extra);
105 extraText.setAttribute('row','1');
106 labelContainer.appendChild(extraContainer).appendChild(extraText);
107 }
108 labelsContainer.appendChild(labelContainer);
109 })
110 return labelsContainer;
111 }
112
113 function renderConsentLabel(){
114 let labelContainer = document.createElement('div');
115 labelContainer.classList.add('consent-item');
116 let consentLabel = document.createElement('label');
117 consentLabel.classList.add('cb-review__form--item');
118 let consentInput = document.createElement('input');
119 consentInput.setAttribute('id','cb-review__debug-reason');
120 consentInput.setAttribute('type','checkbox');
121 consentInput.setAttribute('name','cookiebot-review-debug');
122 consentInput.setAttribute('value','true');
123 consentInput.setAttribute('data-custom-field','true');
124 let consentDescription = document.createElement('span');
125 let consentOpt = document.createElement('b');
126 consentOpt.innerText = cb_survey.consent.optional;
127 let consentLink = document.createElement('a');
128 consentLink.setAttribute('href', 'mailto:unsubscribe@usercentrics.com');
129 consentLink.innerText = 'unsubscribe@usercentrics.com';
130 consentDescription.appendChild(consentOpt);
131 let firstText = document.createElement('span');
132 firstText.innerText = cb_survey.consent.first;
133 consentDescription.appendChild(firstText);
134 consentDescription.appendChild(document.createElement('br'));
135 let secondText = document.createElement('span');
136 secondText.innerText = cb_survey.consent.second;
137 consentDescription.appendChild(secondText);
138 consentDescription.appendChild(consentLink);
139 consentLabel.appendChild(consentInput);
140 consentLabel.appendChild(consentDescription);
141 labelContainer.appendChild(consentLabel);
142 return labelContainer;
143 }
144
145 function renderPopupActions(){
146 let reviewContainer = document.createElement('div');
147 let reviewAlert = document.createElement('div');
148 reviewAlert.setAttribute('id','cb-review__alert');
149 reviewAlert.innerText = cb_survey.alert;
150 let reviewActionContainer = document.createElement('div');
151 reviewActionContainer.classList.add('cb-review__actions');
152 let skipCta = document.createElement('a');
153 skipCta.setAttribute('id','cb-review__skip');
154 skipCta.setAttribute('href','#');
155 skipCta.innerText = cb_survey.actions.skip;
156 let submitCta = document.createElement('input');
157 submitCta.setAttribute('type', 'submit');
158 submitCta.setAttribute('id', 'cb-review__submit');
159 submitCta.setAttribute('value', cb_survey.actions.submit);
160 let reviewPolicy = document.createElement('p');
161 reviewPolicy.classList.add('cb-review__policy');
162 reviewPolicy.innerText = 'See our ';
163 let policyLink = document.createElement('a');
164 policyLink.setAttribute('href', 'https://www.cookiebot.com/en/privacy-policy/?utm_source=wordpress&utm_medium=referral&utm_campaign=banner');
165 policyLink.setAttribute('target', '_blank');
166 policyLink.setAttribute('rel', 'noopener');
167 policyLink.innerText = 'Privacy Policy';
168 reviewPolicy.appendChild(policyLink);
169 let reviewInput = document.createElement('input');
170 reviewInput.setAttribute('type','hidden');
171 reviewInput.setAttribute('name','cookiebot-review-send');
172 reviewInput.setAttribute('value','Cookiebot_Review_Send');
173 reviewActionContainer.appendChild(skipCta);
174 reviewActionContainer.appendChild(submitCta);
175
176 reviewContainer.appendChild(reviewAlert);
177 reviewContainer.appendChild(reviewActionContainer);
178 reviewContainer.appendChild(reviewPolicy);
179 reviewContainer.appendChild(reviewInput);
180 return reviewContainer;
181 }
182
183 /**
184 * Close popup form.
185 */
186
187 function closeSurveyPopup(e) {
188 const popup = jQuery(e.target).closest('.cookiebot-popup-container');
189 popup.removeClass('cb-opened');
190 jQuery('#cb-review__alert').removeClass('show-alert');
191 document.getElementById('cb-review__form').reset();
192 }
193
194 /**
195 * Shows optional consent.
196 */
197
198 function showOptionalConsent(e) {
199 const option = e.target.value;
200 const optionalConsentBox = jQuery('.consent-item');
201 const optionalConsent = jQuery('#cb-review__debug-reason');
202
203 if(option!=='7'){
204 optionalConsentBox.removeClass('show-consent');
205 if(optionalConsent.checked){
206 optionalConsent.checked = false;
207 }
208 }else{
209 optionalConsentBox.addClass('show-consent');
210 }
211 }
212
213 /**
214 * Popup submit
215 */
216 function submitSurveyPopup(e){
217 e.preventDefault();
218 const deactivateLink = jQuery( '#cb-review__skip' ).attr( 'href' );
219 const button = jQuery('#cb-review__submit', '#cb-review__form');
220 if (button.hasClass('disabled')) {
221 return;
222 }
223 const option = jQuery('input[type="radio"]:checked', '#cb-review__form');
224 if(0 === option.length){
225 jQuery('#cb-review__alert').addClass('show-alert');
226 return;
227 }
228 const otherReason = jQuery('#cb-review__other-description');
229 const debugReason = jQuery('#cb-review__debug-reason');
230 jQuery.ajax({
231 url: cb_ajax.ajax_url,
232 type: 'POST',
233 data: {
234 action: 'cb_submit_survey',
235 reason_id: (0 === option.length) ? null : option.val(),
236 reason_text: (0 === option.length) ? 'none' : option.closest('label').text(),
237 reason_info: (0 !== otherReason.length) ? otherReason.val().trim() : '',
238 reason_debug: (!debugReason) ? null : debugReason.val(),
239 survey_nonce: cb_survey.survey_nonce,
240 survey_check: 'ODUwODA1'
241 },
242 beforeSend: function() {
243 button.addClass('disabled');
244 },
245 complete: function(response) {
246 const code = JSON.parse(response.responseText).code;
247 const msg = JSON.parse(response.responseText).data;
248
249 if(code===400||code===401){
250 jQuery('#cb-review__alert').text(msg).addClass('show-alert');
251 button.removeClass('disabled');
252 }else{
253 window.location.href = deactivateLink;
254 }
255 }
256 });
257 }
258
259 function hideSubmitMessage(){
260 let submitMsg = jQuery('.cb-submit__msg');
261 if(submitMsg){
262 setTimeout(function(){
263 submitMsg.fadeOut();
264 },2000)
265 }
266 }
267
268 function selectorListeners(){
269 openItemList();
270 closeitemList();
271 selectListItem();
272 searchListItem();
273 }
274
275 function openItemList() {
276 jQuery(document).on('click','.cb-settings__selector__container .cb-settings__selector-selector',function(){
277 jQuery('.cb-settings__selector-list-container').addClass('hidden');
278 jQuery(this).siblings('.cb-settings__selector-list-container').removeClass('hidden');
279 });
280 }
281
282 function closeitemList() {
283 jQuery(document).on('click','.cb-settings__selector__container .cb-settings__selector-veil',function(){
284 jQuery(this).parent('.cb-settings__selector-list-container').addClass('hidden');
285 jQuery(this).siblings('.cb-settings__selector-search').val('').trigger('keyup');
286 jQuery(this).siblings('.cb-settings__selector-list').scrollTop(0);
287 });
288 }
289
290 function selectListItem() {
291 jQuery(document).on('click','.cb-settings__selector__container .cb-settings__selector-list-item',function(){
292 const item = jQuery(this);
293 const mainParent = item.closest('.cb-settings__selector__container');
294 const itemList = item.parent('.cb-settings__selector-list');
295 const itemValue = item.data('value');
296 const itemAttr = 'cookiebot-tcf-disallowed['+itemValue+']';
297 const itemName = item.text();
298
299 if(!itemList.data('multiple')){
300 itemList.find('.selected').removeClass('selected');
301 }
302
303 item.addClass('selected');
304 mainParent.find('.cb-settings__selector-selector').text(itemName);
305 mainParent.find('.cb-settings__selector__container-input').val(itemValue).attr('name',itemAttr).trigger('change');
306 mainParent.find('.cb-settings__selector-search').val('').trigger('keyup');
307 itemList.scrollTop(0);
308
309 item.closest('.cb-settings__selector-list-container').addClass('hidden');
310 });
311 }
312
313 function searchListItem() {
314 jQuery(document).on('keyup','.cb-settings__selector-search',function(){
315 const searchName = jQuery(this).val().toLowerCase();
316 const itemList = jQuery(this).siblings('.search-list');
317
318 itemList.children().each(function(){
319 const item = jQuery(this);
320 if(searchName.length>0) {
321 const itemName = item.text().trim().toLowerCase();
322 if(itemName.indexOf(searchName) != -1){
323 item.removeClass('hidden');
324 }else{
325 item.addClass('hidden');
326 }
327 }else{
328 item.removeClass('hidden');
329 }
330 });
331 });
332 }