| 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 |
ruleset_id(); |
| 10 |
show_ruleset_selector(); |
| 11 |
remove_account(); |
| 12 |
network_id_override(); |
| 13 |
language_toggle(); |
| 14 |
advanced_settings_toggle(); |
| 15 |
cookie_blocking_mode(); |
| 16 |
activeSettingsTab(); |
| 17 |
initialCheckActiveVendors(); |
| 18 |
closeSubmitMsg(); |
| 19 |
submitEnable(); |
| 20 |
googleConsentModeOptions(); |
| 21 |
tcfOptions(); |
| 22 |
vendorListRequire(); |
| 23 |
selectAllListItem(); |
| 24 |
deselectAllListItem(); |
| 25 |
onAddRestriction(); |
| 26 |
showRestrictionPurposes(); |
| 27 |
onVendorSelection(); |
| 28 |
removeRestriction(); |
| 29 |
generate_shortcode(); |
| 30 |
} |
| 31 |
|
| 32 |
function ruleset_id(){ |
| 33 |
const cbidField = jQuery( '#cookiebot-cbid' ); |
| 34 |
const cbidCheck = jQuery( '.cookiebot-cbid-check' ); |
| 35 |
let fieldTimer; |
| 36 |
let fieldInterval = 3000; |
| 37 |
|
| 38 |
cbidField.on('keyup', function () { |
| 39 |
clearTimeout(fieldTimer); |
| 40 |
cbidField.addClass('check-progress'); |
| 41 |
cbidCheck.removeClass('check-pass').addClass('check-progress'); |
| 42 |
fieldTimer = setTimeout(show_ruleset_selector, fieldInterval); |
| 43 |
}); |
| 44 |
|
| 45 |
cbidField.on('keydown', function () { |
| 46 |
clearTimeout(fieldTimer); |
| 47 |
}); |
| 48 |
} |
| 49 |
|
| 50 |
function show_ruleset_selector() { |
| 51 |
const cbidField = jQuery( '#cookiebot-cbid' ); |
| 52 |
const cbidCheck = jQuery( '.cookiebot-cbid-check' ); |
| 53 |
const cbidRulesetSelector = jQuery('#cookiebot-ruleset-id-selector'); |
| 54 |
const cbidError = jQuery('.cookiebot-cbid-error'); |
| 55 |
|
| 56 |
cbidCheck.removeClass('check-progress'); |
| 57 |
cbidField.removeClass('check-progress'); |
| 58 |
|
| 59 |
if(!cbidField.val()){ |
| 60 |
cbidCheck.removeClass('check-pass'); |
| 61 |
cbidRulesetSelector.addClass('hidden'); |
| 62 |
cbidError.addClass('hidden'); |
| 63 |
jQuery('.cookiebot-cbid-container p.submit #submit').addClass('disabled'); |
| 64 |
return; |
| 65 |
} |
| 66 |
|
| 67 |
// Validate that the field has exactly 9, 14 or 36 characters |
| 68 |
const fieldLength = cbidField.val().length; |
| 69 |
if(fieldLength !== 9 && fieldLength !== 14 && fieldLength !== 36){ |
| 70 |
cbidCheck.removeClass('check-pass'); |
| 71 |
cbidRulesetSelector.addClass('hidden'); |
| 72 |
cbidError.removeClass('hidden'); |
| 73 |
jQuery('.cookiebot-cbid-container p.submit #submit').addClass('disabled'); |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
// Valid input - hide error message |
| 78 |
cbidError.addClass('hidden'); |
| 79 |
|
| 80 |
!check_id_frame() ? cbidRulesetSelector.removeClass('hidden') : cbidRulesetSelector.addClass('hidden'); |
| 81 |
|
| 82 |
jQuery('.cookiebot-cbid-container p.submit #submit').removeClass('disabled'); |
| 83 |
} |
| 84 |
|
| 85 |
function check_id_frame(){ |
| 86 |
const cbFrameReg = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/; |
| 87 |
return cbFrameReg.test(jQuery( '#cookiebot-cbid' ).val()) |
| 88 |
} |
| 89 |
|
| 90 |
function language_toggle() { |
| 91 |
jQuery( '#show_add_language_guide' ).on( 'click', function ( e ) { |
| 92 |
e.preventDefault() |
| 93 |
jQuery( '#add_language_guide' ).slideDown() |
| 94 |
jQuery( this ).hide() |
| 95 |
} ) |
| 96 |
jQuery( '#hide_add_language_guide' ).on( 'click', function ( e ) { |
| 97 |
e.preventDefault() |
| 98 |
jQuery( '#add_language_guide' ).slideUp() |
| 99 |
jQuery( '#show_add_language_guide' ).show() |
| 100 |
} ) |
| 101 |
|
| 102 |
jQuery( '#cookiebot-language' ).on( 'change', function () { |
| 103 |
if ( this.value === '' ) { |
| 104 |
jQuery( '#info_lang_autodetect' ).show() |
| 105 |
jQuery( '#info_lang_specified' ).hide() |
| 106 |
} else { |
| 107 |
jQuery( '#info_lang_autodetect' ).hide() |
| 108 |
jQuery( '#info_lang_specified' ).show() |
| 109 |
} |
| 110 |
} ) |
| 111 |
} |
| 112 |
|
| 113 |
function advanced_settings_toggle() { |
| 114 |
jQuery( '.cookiebot_fieldset_header' ).on( 'click', function ( e ) { |
| 115 |
e.preventDefault() |
| 116 |
jQuery( this ).next().slideToggle() |
| 117 |
jQuery( this ).toggleClass( 'active' ) |
| 118 |
} ) |
| 119 |
} |
| 120 |
|
| 121 |
function cookie_blocking_mode() { |
| 122 |
let cookieBlockingMode = cookiebot_settings.cookieBlockingMode; |
| 123 |
|
| 124 |
jQuery( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function () { |
| 125 |
if ( this.value === 'auto' && cookieBlockingMode !== this.value ) { |
| 126 |
jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ); |
| 127 |
jQuery( '#declaration-tag, #cookie-popup, #gcm-cookie-categories, #gtm-cookie-categories').addClass('disabled__item'); |
| 128 |
if(jQuery( '#gcm-cookie-categories').is(':visible')){ jQuery( '#gcm-cookie-categories').hide() }; |
| 129 |
jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ); |
| 130 |
jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', true ); |
| 131 |
jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', true ); |
| 132 |
} |
| 133 |
if ( this.value === 'manual' && cookieBlockingMode !== this.value ) { |
| 134 |
jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 ); |
| 135 |
jQuery( '#declaration-tag, #cookie-popup, #gcm-cookie-categories, #gtm-cookie-categories').removeClass('disabled__item'); |
| 136 |
if(!jQuery( '#gcm-cookie-categories').is(':visible') && jQuery('input#gcm').is(':checked')){ jQuery( '#gcm-cookie-categories').show() }; |
| 137 |
jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false ); |
| 138 |
jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', false ); |
| 139 |
jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', false ); |
| 140 |
} |
| 141 |
cookieBlockingMode = this.value; |
| 142 |
} ) |
| 143 |
if ( cookieBlockingMode === 'auto' ) { |
| 144 |
jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ); |
| 145 |
jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ); |
| 146 |
jQuery( '#cb-settings__gtm__cookie-types input[type=checkbox]' ).prop( 'disabled', true ); |
| 147 |
jQuery( '#cb-settings__gcm__cookie-types input[type=checkbox]' ).prop( 'disabled', true ); |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
function activeSettingsTab() { |
| 152 |
jQuery('.cb-settings__tabs__item').on('click', function(){ |
| 153 |
let currentTab = jQuery('.cb-settings__tabs__item.active-item').data('tab'); |
| 154 |
let tab = jQuery(this).data('tab'); |
| 155 |
let tabSelector = '#'+tab; |
| 156 |
jQuery('.cb-settings__tabs__item.active-item, .cb-settings__tabs__content--item.active-item').removeClass('active-item'); |
| 157 |
jQuery(this).addClass('active-item'); |
| 158 |
jQuery(tabSelector).addClass('active-item'); |
| 159 |
|
| 160 |
window.history.replaceState(null, null, '?page=cookiebot_settings&tab='+tab ); |
| 161 |
let referrer = jQuery('input[name="_wp_http_referer"]'); |
| 162 |
let referrerVal = referrer.val(); |
| 163 |
if(referrerVal.indexOf('tab=')!==-1) { |
| 164 |
referrerVal = referrerVal.replace(currentTab,tab); |
| 165 |
}else{ |
| 166 |
referrerVal += '&tab=' + tab; |
| 167 |
} |
| 168 |
referrer.val(referrerVal); |
| 169 |
}); |
| 170 |
} |
| 171 |
|
| 172 |
function closeSubmitMsg() { |
| 173 |
jQuery('.cb-submit__msg').on('click',function(){ |
| 174 |
jQuery(this).addClass('hidden'); |
| 175 |
}); |
| 176 |
} |
| 177 |
|
| 178 |
function submitEnable() { |
| 179 |
const initialValues = jQuery(':input[name!=_wp_http_referer]','form').serialize(); |
| 180 |
const events = { |
| 181 |
change: 'input:not([type=text]), select', |
| 182 |
input: 'input[type="text"], textarea' |
| 183 |
}; |
| 184 |
|
| 185 |
Object.entries(events).forEach(entry => { |
| 186 |
const [eventName, elements] = entry; |
| 187 |
jQuery(document).on(eventName,elements,{initialValues: initialValues},function(event){ |
| 188 |
checkValues(event.data.initialValues) |
| 189 |
}); |
| 190 |
}); |
| 191 |
} |
| 192 |
|
| 193 |
function checkValues(initialValues){ |
| 194 |
let submitBtn = jQuery('.cb-settings__header p.submit #submit'); |
| 195 |
let newValues = jQuery(':input[name!=_wp_http_referer]','form').serialize(); |
| 196 |
if(newValues !== initialValues) { |
| 197 |
submitBtn.addClass('enabled'); |
| 198 |
}else{ |
| 199 |
submitBtn.removeClass('enabled'); |
| 200 |
} |
| 201 |
checkActiveVendors(); |
| 202 |
} |
| 203 |
|
| 204 |
function googleConsentModeOptions() { |
| 205 |
jQuery('input#gcm').on('change', function () { |
| 206 |
const parent = jQuery(this).parents('#consent-mode'); |
| 207 |
parent.find('.cb-settings__config__item:has(input#gcm-url-pasthrough)').toggle(); |
| 208 |
const gcmCookiesCategoriesContainer = parent.find('.cb-settings__config__item:has(ul#cb-settings__gcm__cookie-types)'); |
| 209 |
if(!gcmCookiesCategoriesContainer.hasClass('disabled__item')){ |
| 210 |
gcmCookiesCategoriesContainer.is(':visible') ? gcmCookiesCategoriesContainer.hide() : gcmCookiesCategoriesContainer.show(); |
| 211 |
}else{ |
| 212 |
gcmCookiesCategoriesContainer.hide(); |
| 213 |
} |
| 214 |
const passthroughInput = jQuery('input#gcm-url-pasthrough'); |
| 215 |
const passthroughLabel = passthroughInput.parents('label.switch-checkbox')[0]; |
| 216 |
if (!passthroughLabel || !passthroughLabel.childNodes.length) |
| 217 |
return; |
| 218 |
passthroughLabel.childNodes[passthroughLabel.childNodes.length - 1].textContent = 'URL passthrough' + ' ' + |
| 219 |
(passthroughInput.is(':checked') ? 'enabled' : 'disabled'); |
| 220 |
}); |
| 221 |
jQuery('input#gcm, input#gcm-url-pasthrough').on('change', function () { |
| 222 |
const input = jQuery(this); |
| 223 |
const label = input.parents('label.switch-checkbox')[0]; |
| 224 |
if (!label || !label.childNodes.length) |
| 225 |
return; |
| 226 |
label.childNodes[label.childNodes.length - 1].textContent = ( |
| 227 |
(input.attr('id') === 'gcm' ? 'Google Consent Mode' : 'URL passthrough') + ' ' + |
| 228 |
(input.is(':checked') ? 'enabled' : 'disabled') |
| 229 |
); |
| 230 |
}); |
| 231 |
} |
| 232 |
|
| 233 |
function tcfOptions() { |
| 234 |
jQuery('input#cookiebot-iab').on('change', function () { |
| 235 |
const parent = jQuery(this).parents('#iab'); |
| 236 |
parent.find('.cb-settings__config__item:has(input.tcf-option)').toggle(); |
| 237 |
}); |
| 238 |
} |
| 239 |
|
| 240 |
function checkIabActive() { |
| 241 |
return jQuery('input#cookiebot-iab:checked').length; |
| 242 |
} |
| 243 |
|
| 244 |
function initialCheckActiveVendors() { |
| 245 |
if(!checkIabActive()){ |
| 246 |
return; |
| 247 |
} |
| 248 |
|
| 249 |
const allVendorInputChecked = jQuery('input[name^="cookiebot-tcf-vendors"]:checked').length; |
| 250 |
if(!allVendorInputChecked && check_id_frame()) { |
| 251 |
jQuery('.vendor-selected-items-message').removeClass('hidden'); |
| 252 |
jQuery('.cb-vendor-alert__msg').removeClass('hidden'); |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
function checkActiveVendors() { |
| 257 |
if(!checkIabActive()){ |
| 258 |
return; |
| 259 |
} |
| 260 |
|
| 261 |
if(!check_id_frame()) { |
| 262 |
return; |
| 263 |
} |
| 264 |
|
| 265 |
let submitBtn = jQuery('.cb-settings__header p.submit #submit'); |
| 266 |
const allVendorInputChecked = jQuery('input[name^="cookiebot-tcf-vendors"]:checked').length; |
| 267 |
if(!allVendorInputChecked) { |
| 268 |
jQuery('.vendor-selected-items-message').removeClass('hidden'); |
| 269 |
jQuery('.cb-vendor-alert__msg').removeClass('hidden'); |
| 270 |
submitBtn.removeClass('enabled'); |
| 271 |
}else{ |
| 272 |
jQuery('.vendor-selected-items-message').addClass('hidden'); |
| 273 |
jQuery('.cb-vendor-alert__msg').addClass('hidden'); |
| 274 |
if(!submitBtn.hasClass('enabled')) { |
| 275 |
submitBtn.addClass('enabled'); |
| 276 |
} |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
function selectAllListItem(){ |
| 281 |
jQuery(document).on('click','.cb-settings__selector-all',function(){ |
| 282 |
const itemList = jQuery(this).siblings('.search-list'); |
| 283 |
itemList.children().each(function(){ |
| 284 |
jQuery(this).find('input').prop('checked', true); |
| 285 |
}) |
| 286 |
checkActiveVendors(); |
| 287 |
}) |
| 288 |
} |
| 289 |
|
| 290 |
function deselectAllListItem(){ |
| 291 |
jQuery(document).on('click','.cb-settings__selector-none',function(){ |
| 292 |
const itemList = jQuery(this).siblings('.search-list'); |
| 293 |
itemList.children().each(function(){ |
| 294 |
jQuery(this).find('input').prop('checked', false); |
| 295 |
}) |
| 296 |
checkActiveVendors(); |
| 297 |
}) |
| 298 |
} |
| 299 |
|
| 300 |
function vendorListRequire(){ |
| 301 |
jQuery( document ).on('change', 'input[name^="cookiebot-tcf-vendors"]', function () { |
| 302 |
checkActiveVendors(); |
| 303 |
}); |
| 304 |
} |
| 305 |
|
| 306 |
function onAddRestriction() { |
| 307 |
jQuery('.restriction-vendor-add').on('click', function () { |
| 308 |
const allCurrentVendors = jQuery( '.cb-settings__vendor__restrictions' ).length; |
| 309 |
const baseElement = jQuery( '.cb-settings__vendor__restrictions:last' ); |
| 310 |
let newElement = baseElement.clone(); |
| 311 |
newElement.find('.vendor-selector').attr('name',''); |
| 312 |
newElement.find('option').removeAttr('selected'); |
| 313 |
newElement.find('.purpose-item').each(function(index){ |
| 314 |
const itemId = 'cookiebot-vendorx'+( allCurrentVendors + 1 )+'-purposes'+(index+1); |
| 315 |
jQuery(this).attr('name',''); |
| 316 |
jQuery(this).attr('id',itemId); |
| 317 |
jQuery(this).removeAttr('checked'); |
| 318 |
jQuery(this).parent().attr('for',itemId); |
| 319 |
}); |
| 320 |
|
| 321 |
newElement.insertAfter(baseElement); |
| 322 |
}); |
| 323 |
} |
| 324 |
|
| 325 |
function showRestrictionPurposes() { |
| 326 |
jQuery(document).on('click','.vendor-purposes-show', function () { |
| 327 |
const parent = jQuery(this).parents('.cb-settings__vendor__restrictions'); |
| 328 |
parent.find('.vendor-purposes-restrictions').toggle(); |
| 329 |
}); |
| 330 |
} |
| 331 |
|
| 332 |
function onVendorSelection() { |
| 333 |
jQuery(document).on('change', '.cb-settings__selector__container-input', function () { |
| 334 |
const vendorId = jQuery(this).val(); |
| 335 |
const parent = jQuery(this).parents('.cb-settings__vendor__restrictions'); |
| 336 |
const vendorPurposes = parent.find('.vendor-purposes-restrictions .purpose-item'); |
| 337 |
const fieldName = 'cookiebot-tcf-disallowed[$s]'; |
| 338 |
const purposeFieldName = '[purposes][]'; |
| 339 |
|
| 340 |
jQuery(this).attr('name', fieldName.replace('$s', vendorId)); |
| 341 |
vendorPurposes.each(function(index){ |
| 342 |
const purposeAttribute = fieldName.replace('$s', vendorId) + purposeFieldName; |
| 343 |
const itemId = 'cookiebot-vendor' + vendorId + '-purposes' + (index+1); |
| 344 |
jQuery(this).attr('name', purposeAttribute); |
| 345 |
jQuery(this).attr('id', itemId); |
| 346 |
jQuery(this).parent().attr('for',itemId); |
| 347 |
}); |
| 348 |
}); |
| 349 |
} |
| 350 |
|
| 351 |
function removeRestriction(){ |
| 352 |
const initialValues = jQuery(':input[name!=_wp_http_referer]','form').serialize(); |
| 353 |
let submitBtn = jQuery('.cb-settings__header p.submit #submit'); |
| 354 |
jQuery(document).on('click','.cb-settings__vendor__restrictions .remove__restriction', function(){ |
| 355 |
const restriction = jQuery(this).closest( '.cb-settings__vendor__restrictions' ); |
| 356 |
const allRestrictions = jQuery( '.cb-settings__vendor__restrictions' ); |
| 357 |
if(allRestrictions.length === 1){ |
| 358 |
const selector = restriction.find('.cb-settings__selector-selector'); |
| 359 |
selector.text(selector.data('placeholder')); |
| 360 |
restriction.find('.cb-settings__selector__container-input').val(''); |
| 361 |
restriction.find('.cb-settings__selector__container-input').attr('name',''); |
| 362 |
restriction.find('.cb-settings__selector-list-item.selected').removeClass('selected'); |
| 363 |
const vendorPurposes = restriction.find('.purpose-item'); |
| 364 |
vendorPurposes.each(function(){ |
| 365 |
jQuery(this).prop( 'checked', false ); |
| 366 |
jQuery(this).attr( 'name', '' ); |
| 367 |
}); |
| 368 |
}else{ |
| 369 |
restriction.remove(); |
| 370 |
} |
| 371 |
let newValues = jQuery(':input[name!=_wp_http_referer]','form').serialize(); |
| 372 |
if(newValues !== initialValues) { |
| 373 |
submitBtn.addClass('enabled'); |
| 374 |
}else{ |
| 375 |
submitBtn.removeClass('enabled'); |
| 376 |
} |
| 377 |
}); |
| 378 |
} |
| 379 |
|
| 380 |
function generate_shortcode(){ |
| 381 |
jQuery('#cookiebot-embedding').on('change', function(){ |
| 382 |
const typeOptions = jQuery('#cookiebot-embedding-type option'); |
| 383 |
const className = jQuery(this).val(); |
| 384 |
typeOptions.each(function(){ |
| 385 |
if(jQuery(this).hasClass(className)){ |
| 386 |
jQuery(this).removeClass('hide-option'); |
| 387 |
}else{ |
| 388 |
jQuery(this).addClass('hide-option'); |
| 389 |
} |
| 390 |
}); |
| 391 |
jQuery('#cookiebot-embedding-type option:not(.hide-option)').each(function(index){ |
| 392 |
if(index>0) |
| 393 |
return; |
| 394 |
jQuery(this).prop('selected', true); |
| 395 |
}); |
| 396 |
}); |
| 397 |
|
| 398 |
jQuery('#cookiebot-embedding-type').on('change', function(){ |
| 399 |
const typeName = jQuery(this).val(); |
| 400 |
if(typeName==='service-specific'){ |
| 401 |
jQuery( '#cookiebot-embedding-single-service-container' ).removeClass('hide-container'); |
| 402 |
}else{ |
| 403 |
jQuery( '#cookiebot-embedding-single-service-container' ).addClass('hide-container'); |
| 404 |
jQuery( '#cookiebot-embedding-single-service' ).val(''); |
| 405 |
} |
| 406 |
}); |
| 407 |
|
| 408 |
const embedInputs = jQuery('#cookiebot-tcf-toggle, #cookiebot-embedding, #cookiebot-embedding-type, #cookiebot-embedding-single-service'); |
| 409 |
embedInputs.each(function (){ |
| 410 |
jQuery(this).on('change keyup', function(){ |
| 411 |
let shortcode = '[uc_embedding'; |
| 412 |
const className = jQuery('#cookiebot-embedding').val(); |
| 413 |
const toggleEnabled = jQuery('#cookiebot-tcf-toggle'); |
| 414 |
const typeName = jQuery('#cookiebot-embedding-type').val(); |
| 415 |
const serviceName = jQuery('#cookiebot-embedding-single-service').val(); |
| 416 |
|
| 417 |
|
| 418 |
switch (className) { |
| 419 |
case 'tcf' : shortcode += ' class="tcf"'; break; |
| 420 |
default : shortcode += ' class="gdpr"'; |
| 421 |
} |
| 422 |
switch (toggleEnabled.is(':checked')) { |
| 423 |
case true : shortcode += ' show-toggle="true"'; break; |
| 424 |
default : shortcode += ' show-toggle="false"'; |
| 425 |
} |
| 426 |
switch (typeName) { |
| 427 |
case 'category' : shortcode += ' type="category"'; break; |
| 428 |
case 'category-only' : shortcode += ' type="category-only"'; break; |
| 429 |
case 'service-specific' : shortcode += ' type="service-specific"'; break; |
| 430 |
case 'purposes' : shortcode += ' type="purposes"'; break; |
| 431 |
case 'vendors' : shortcode += ' type="vendors"'; break; |
| 432 |
default : shortcode += ' type="all"'; |
| 433 |
} |
| 434 |
if(serviceName.length > 0){ |
| 435 |
shortcode += ' service="' + serviceName + '"'; |
| 436 |
} |
| 437 |
shortcode += ']'; |
| 438 |
jQuery('#embedding-shortcode').attr('value',shortcode); |
| 439 |
}); |
| 440 |
}); |
| 441 |
} |
| 442 |
|
| 443 |
function remove_account(){ |
| 444 |
const removeCta = jQuery('#cookiebot-cbid-reset-dialog'); |
| 445 |
const cbidAlert = jQuery('.cb-cbid-alert__msg'); |
| 446 |
const cbidOverrideAlert = jQuery('.cb-cbid-subsite-alert__msg'); |
| 447 |
const confirmCta = jQuery('#cookiebot-cbid-reset, #cookiebot-subsite-cbid-reset'); |
| 448 |
const cancelCta = jQuery('#cookiebot-cbid-cancel, #cookiebot-subsite-cbid-cancel'); |
| 449 |
removeCta.on('click', function(){ |
| 450 |
if(cbidOverrideAlert.length !== 0){ |
| 451 |
cbidOverrideAlert.removeClass('hidden'); |
| 452 |
}else{ |
| 453 |
cbidAlert.removeClass('hidden'); |
| 454 |
} |
| 455 |
removeCta.addClass('disabled'); |
| 456 |
}); |
| 457 |
confirmCta.on('click', function(){ |
| 458 |
jQuery('#cookiebot-cbid').val('').removeClass('cbid-active'); |
| 459 |
jQuery('#cookiebot-cbid-override').prop('checked',false); |
| 460 |
|
| 461 |
// If the account was disconnected set blocking mode to 'auto' and 'Hide cookie popup' to false. |
| 462 |
jQuery('input[type=radio][name=cookiebot-cookie-blocking-mode][value=auto]').prop('checked', true); |
| 463 |
jQuery('input[name=cookiebot-nooutput]').prop( 'checked', false ) |
| 464 |
|
| 465 |
jQuery('.cb-settings__header p.submit #submit').click(); |
| 466 |
}); |
| 467 |
cancelCta.on('click', function(){ |
| 468 |
cbidAlert.addClass('hidden'); |
| 469 |
cbidOverrideAlert.addClass('hidden'); |
| 470 |
jQuery('#cookiebot-cbid-override').prop('checked',true); |
| 471 |
removeCta.removeClass('disabled'); |
| 472 |
}); |
| 473 |
} |
| 474 |
|
| 475 |
function network_id_override() { |
| 476 |
const overrideCheck = jQuery('#cookiebot-cbid-override'); |
| 477 |
overrideCheck.on('change', function(){ |
| 478 |
jQuery('.cb-settings__header p.submit #submit').addClass('disabled'); |
| 479 |
if(overrideCheck.is(':checked') && overrideCheck.hasClass('cb-no-network')){ |
| 480 |
jQuery('#cookiebot-cbid-network-dialog').addClass('hidden'); |
| 481 |
jQuery('.cookiebot-cbid-container p.submit #submit').addClass('disabled').removeClass('hidden'); |
| 482 |
jQuery('.cookiebot-cbid-container #cookiebot-cbid').removeClass('cbid-active').attr('placeholder', '').val(''); |
| 483 |
} |
| 484 |
if(!overrideCheck.is(':checked')){ |
| 485 |
if(!overrideCheck.hasClass('cb-no-network')){ |
| 486 |
jQuery('.cb-cbid-subsite-alert__msg').removeClass('hidden'); |
| 487 |
}else{ |
| 488 |
jQuery('#cookiebot-cbid-network-dialog').removeClass('hidden'); |
| 489 |
jQuery('.cookiebot-cbid-container p.submit #submit').addClass('hidden'); |
| 490 |
jQuery('.cookiebot-cbid-container #cookiebot-cbid').addClass('cbid-active').val('').attr('placeholder', jQuery('.cookiebot-cbid-container #cookiebot-cbid').attr('data-network')); |
| 491 |
} |
| 492 |
} |
| 493 |
}); |
| 494 |
} |
| 495 |
|
| 496 |
function copyEmbedShortcode() { |
| 497 |
const t = document.getElementById( 'embedding-shortcode' ) |
| 498 |
t.select() |
| 499 |
t.setSelectionRange( 0, 99999 ) |
| 500 |
document.execCommand( 'copy' ) |
| 501 |
} |
| 502 |
|
| 503 |
// Event Listeners |
| 504 |
document.getElementById('banner-close-btn')?.addEventListener('click', async () => { |
| 505 |
const banner = document.getElementById('banner-live-notice') |
| 506 |
if (banner) banner.remove(); |
| 507 |
}); |
| 508 |
|