gutenberg
4 years ago
debug-page.js
4 years ago
jquery.tipTip.js
4 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
3 years ago
support-page.js
3 years ago
settings-page.js
114 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 | } |
| 16 | |
| 17 | function language_toggle() { |
| 18 | jQuery( '#show_add_language_guide' ).on( 'click', function ( e ) { |
| 19 | e.preventDefault() |
| 20 | jQuery( '#add_language_guide' ).slideDown() |
| 21 | jQuery( this ).hide() |
| 22 | } ) |
| 23 | jQuery( '#hide_add_language_guide' ).on( 'click', function ( e ) { |
| 24 | e.preventDefault() |
| 25 | jQuery( '#add_language_guide' ).slideUp() |
| 26 | jQuery( '#show_add_language_guide' ).show() |
| 27 | } ) |
| 28 | |
| 29 | jQuery( '#cookiebot-language' ).on( 'change', function () { |
| 30 | if ( this.value === '' ) { |
| 31 | jQuery( '#info_lang_autodetect' ).show() |
| 32 | jQuery( '#info_lang_specified' ).hide() |
| 33 | } else { |
| 34 | jQuery( '#info_lang_autodetect' ).hide() |
| 35 | jQuery( '#info_lang_specified' ).show() |
| 36 | } |
| 37 | } ) |
| 38 | } |
| 39 | |
| 40 | function advanced_settings_toggle() { |
| 41 | jQuery( '.cookiebot_fieldset_header' ).on( 'click', function ( e ) { |
| 42 | e.preventDefault() |
| 43 | jQuery( this ).next().slideToggle() |
| 44 | jQuery( this ).toggleClass( 'active' ) |
| 45 | } ) |
| 46 | } |
| 47 | |
| 48 | function resetConsentMapping() { |
| 49 | if ( confirm( 'Are you sure you want to reset to default consent mapping?' ) ) { |
| 50 | jQuery( '.consent_mapping_table input[type=checkbox]' ).each( function () { |
| 51 | if ( !this.disabled ) { |
| 52 | this.checked = ( jQuery( this ).data( 'default-value' ) === '1' ) |
| 53 | } |
| 54 | } ) |
| 55 | } |
| 56 | return false |
| 57 | } |
| 58 | |
| 59 | function cookie_blocking_mode() { |
| 60 | var cookieBlockingMode = cookiebot_settings.cookieBlockingMode; |
| 61 | |
| 62 | jQuery( 'input[type=radio][name=cookiebot-cookie-blocking-mode]' ).on( 'change', function () { |
| 63 | if ( this.value === 'auto' && cookieBlockingMode !== this.value ) { |
| 64 | jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ); |
| 65 | jQuery( '#declaration-tag, #cookie-popup').addClass('disabled__item'); |
| 66 | jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ) |
| 67 | } |
| 68 | if ( this.value === 'manual' && cookieBlockingMode !== this.value ) { |
| 69 | jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 1 ); |
| 70 | jQuery( '#declaration-tag, #cookie-popup').removeClass('disabled__item'); |
| 71 | jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', false ) |
| 72 | } |
| 73 | cookieBlockingMode = this.value |
| 74 | } ) |
| 75 | if ( cookieBlockingMode === 'auto' ) { |
| 76 | jQuery( '#cookiebot-setting-async, #cookiebot-setting-hide-popup' ).css( 'opacity', 0.4 ) |
| 77 | jQuery( 'input[type=radio][name=cookiebot-script-tag-uc-attribute], input[name=cookiebot-nooutput]' ).prop( 'disabled', true ) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | function activeSettingsTab() { |
| 82 | jQuery('.cb-settings__tabs__item').on('click', function(){ |
| 83 | let currentTab = jQuery('.cb-settings__tabs__item.active-item').data('tab'); |
| 84 | let tab = jQuery(this).data('tab'); |
| 85 | let tabSelector = '#'+tab; |
| 86 | jQuery('.cb-settings__tabs__item.active-item, .cb-settings__tabs__content--item.active-item').removeClass('active-item'); |
| 87 | jQuery(this).addClass('active-item'); |
| 88 | jQuery(tabSelector).addClass('active-item'); |
| 89 | |
| 90 | window.history.replaceState(null, null, '?page=cookiebot_settings&tab='+tab ); |
| 91 | let referrer = jQuery('input[name="_wp_http_referer"]'); |
| 92 | let referrerVal = referrer.val(); |
| 93 | if(referrerVal.indexOf('tab=')!==-1) { |
| 94 | referrerVal = referrerVal.replace(currentTab,tab); |
| 95 | }else{ |
| 96 | referrerVal += '&tab=' + tab; |
| 97 | } |
| 98 | referrer.val(referrerVal); |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | function closeSubmitMsg() { |
| 103 | jQuery('.cb-submit__msg').on('click',function(){ |
| 104 | jQuery(this).addClass('hidden'); |
| 105 | }); |
| 106 | } |
| 107 | |
| 108 | function submitEnable() { |
| 109 | jQuery(':input').change( |
| 110 | function(){ |
| 111 | jQuery('p.submit #submit').addClass('enabled'); |
| 112 | } |
| 113 | ); |
| 114 | } |