gutenberg
3 years ago
account-static.js
10 months ago
account.js
10 months ago
amplitude.js
1 year ago
consent-mapping.js
1 year ago
cookiebot-admin-script.js
1 year ago
dashboard.js
1 year ago
jquery.tipTip.js
3 years ago
multiple-page.js
3 years ago
network-settings-page.js
10 months ago
prior-consent-settings.js
3 years ago
settings-page.js
10 months ago
support-page.js
1 year ago
network-settings-page.js
117 lines
| 1 | jQuery( document ).ready( function ( $ ) { |
| 2 | let cookieBlockingMode = cookiebotNetworkSettings.cbm |
| 3 | $( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function () { |
| 4 | if ( this.value === 'auto' && cookieBlockingMode !== this.value ) { |
| 5 | $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ) |
| 6 | $( '#declaration-tag').addClass('disabled__item'); |
| 7 | $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ) |
| 8 | } |
| 9 | if ( this.value === 'manual' && cookieBlockingMode !== this.value ) { |
| 10 | $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 ) |
| 11 | $( '#declaration-tag, #cookie-popup').removeClass('disabled__item'); |
| 12 | $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false ) |
| 13 | } |
| 14 | cookieBlockingMode = this.value |
| 15 | } ) |
| 16 | if ( cookieBlockingMode === 'auto' ) { |
| 17 | $( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ) |
| 18 | $( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ) |
| 19 | } |
| 20 | |
| 21 | jQuery('.cb-submit__msg').on('click',function(){ |
| 22 | jQuery(this).addClass('hidden'); |
| 23 | }); |
| 24 | |
| 25 | const initialValues = jQuery('form').serialize(); |
| 26 | const events = { |
| 27 | change: 'input:not([type=text]), select', |
| 28 | input: 'input[type="text"], textarea' |
| 29 | }; |
| 30 | |
| 31 | Object.entries(events).forEach(entry => { |
| 32 | const [eventName, elements] = entry; |
| 33 | jQuery(document).on(eventName,elements,{initialValues: initialValues},function(event){ |
| 34 | checkValues(event.data.initialValues) |
| 35 | }); |
| 36 | }); |
| 37 | |
| 38 | ruleset_id(); |
| 39 | remove_account(); |
| 40 | } ) |
| 41 | |
| 42 | function check_id_frame(){ |
| 43 | const cbFrameReg = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/; |
| 44 | return cbFrameReg.test(jQuery( '#cookiebot-cbid' ).val()) |
| 45 | } |
| 46 | |
| 47 | function ruleset_id(){ |
| 48 | const cbidField = jQuery( '#cookiebot-cbid' ); |
| 49 | const cbidCheck = jQuery( '.cookiebot-cbid-check' ); |
| 50 | let fieldTimer; |
| 51 | let fieldInterval = 3000; |
| 52 | |
| 53 | cbidField.on('keyup', function () { |
| 54 | clearTimeout(fieldTimer); |
| 55 | cbidField.addClass('check-progress'); |
| 56 | cbidCheck.removeClass('check-pass').addClass('check-progress'); |
| 57 | fieldTimer = setTimeout(show_ruleset_selector, fieldInterval); |
| 58 | }); |
| 59 | |
| 60 | cbidField.on('keydown', function () { |
| 61 | clearTimeout(fieldTimer); |
| 62 | }); |
| 63 | } |
| 64 | function show_ruleset_selector() { |
| 65 | const cbidField = jQuery( '#cookiebot-cbid' ); |
| 66 | const cbidCheck = jQuery( '.cookiebot-cbid-check' ); |
| 67 | const cbidRulesetSelector = jQuery('#cookiebot-ruleset-id-selector'); |
| 68 | const cbidSubmit = jQuery('.cookiebot-cbid-container p.submit #submit'); |
| 69 | |
| 70 | cbidCheck.removeClass('check-progress'); |
| 71 | cbidField.removeClass('check-progress'); |
| 72 | |
| 73 | if(!cbidField.val()){ |
| 74 | cbidCheck.removeClass('check-pass'); |
| 75 | cbidRulesetSelector.addClass('hidden'); |
| 76 | cbidSubmit.addClass('disabled'); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | !check_id_frame() ? cbidRulesetSelector.removeClass('hidden') : cbidRulesetSelector.addClass('hidden'); |
| 81 | |
| 82 | cbidSubmit.removeClass('disabled'); |
| 83 | } |
| 84 | |
| 85 | function remove_account(){ |
| 86 | const removeCta = jQuery('#cookiebot-cbid-reset-dialog'); |
| 87 | const cbidAlert = jQuery('.cb-cbid-alert__msg'); |
| 88 | const confirmCta = jQuery('#cookiebot-cbid-reset'); |
| 89 | const cancelCta = jQuery('#cookiebot-cbid-cancel'); |
| 90 | removeCta.on('click', function(){ |
| 91 | cbidAlert.removeClass('hidden'); |
| 92 | removeCta.addClass('disabled'); |
| 93 | }); |
| 94 | confirmCta.on('click', function(){ |
| 95 | jQuery('#cookiebot-cbid').val('').removeClass('cbid-active'); |
| 96 | |
| 97 | // If the account was disconnected set blocking mode to 'auto' and 'Hide cookie popup' to false. |
| 98 | jQuery('input[type=radio][name=cookiebot-cookie-blocking-mode][value=auto]').prop('checked', true); |
| 99 | jQuery('input[name=cookiebot-nooutput]').prop( 'checked', false ) |
| 100 | |
| 101 | jQuery('.cb-settings__header p.submit #submit').click(); |
| 102 | }); |
| 103 | cancelCta.on('click', function(){ |
| 104 | cbidAlert.addClass('hidden'); |
| 105 | removeCta.removeClass('disabled'); |
| 106 | }); |
| 107 | } |
| 108 | |
| 109 | function checkValues(initialValues){ |
| 110 | let submitBtn = jQuery('p.submit #submit'); |
| 111 | let newValues = jQuery('form').serialize(); |
| 112 | if(newValues !== initialValues) { |
| 113 | submitBtn.addClass('enabled'); |
| 114 | }else{ |
| 115 | submitBtn.removeClass('enabled'); |
| 116 | } |
| 117 | } |