Ubuntu
jQuery(document).ready(function ($) {
var ccName;
var ccCatsOpenedByUser = false;
var ccCookieWallShownBefore = false;
$('.cmplz-color-picker').wpColorPicker({
change:
function (event, ui) {
var container_id = $(event.target).data('hidden-input');
if (container_id === 'cmplz_text_color'){
ccCheckboxes = '';
}
$('#' + container_id).val(ui.color.toString());
cmplz_apply_style();
cmplz_cookie_warning();
}
}
);
var ccConsentType = $('select[name=cmplz_type]').val();
var settingConsentType = ccConsentType;
if (ccConsentType === 'optinstats') settingConsentType = 'optin';
$(document).on('change', 'select[name=cmplz_type]', function () {
ccConsentType = $('select[name=cmplz_type]').val();
settingConsentType = ccConsentType;
if (ccConsentType === 'optinstats') settingConsentType = 'optin';
cmplz_cookie_warning();
});
$(document).on('keyup', 'input[name=cmplz_header]', function () {
$(".cc-header").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_dismiss]', function () {
if (settingConsentType !== 'optout') {
$(".cc-dismiss").html($(this).val());
}
});
$(document).on('keyup', 'input[name=cmplz_accept]', function () {
$(".cc-allow").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_accept_optinstats]', function () {
$(".cc-allow").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_accept_informational]', function () {
$(".cc-allow").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_revoke]', function () {
$(".cc-revoke").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_readmore_privacy]', function () {
$(".cc-link.privacy-policy").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_view_preferences]', function () {
$(".cc-show-settings").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_accept_all]', function () {
$(".cc-accept-all").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_save_preferences]', function () {
$(".cc-save-settings").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_category_functional]', function () {
$(".cmplz_functional").closest('.cmplz-categories-wrap').find(".cc-category").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_category_stats]', function () {
//keep up to date with other tabs
$('input[name=cmplz_category_stats]').val($(this).val());
$(".cmplz_stats").closest('.cmplz-categories-wrap').find(".cc-category").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_category_prefs]', function () {
//keep up to date with other tabs
$('input[name=cmplz_category_prefs]').val($(this).val());
$(".cmplz_prefs").closest('.cmplz-categories-wrap').find(".cc-category").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_category_all]', function () {
//keep up to date with other tabs
$('input[name=cmplz_category_all]').val($(this).val());
$(".cmplz_marketing").closest('.cmplz-categories-wrap').find(".cc-category").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_readmore_optin]', function () {
$(".cc-link.cookie-policy").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_readmore_impressum]', function () {
$(".cc-link.impressum").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_readmore_optinstats]', function () {
$(".cc-link.cookie-policy").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_banner_width]', function () {
cmplz_apply_style();
});
$(document).on('change', 'input[name=cmplz_banner_width]', function () {
cmplz_apply_style();
});
$(document).on('keyup', 'input[name=cmplz_readmore_optout]', function () {
$(".cc-link.cookie-policy").html($(this).val());
});
$(document).on('keyup', 'input[name=cmplz_readmore_optout_dnsmpi]', function () {
$(".cc-link.cookie-policy").html($(this).val());
});
$(document).on('keyup', 'textarea[name=cmplz_tagmanager_categories]', function () {
var ccCheckboxBase = ''+$(".cmplz_functional").closest(".cmplz-categories-wrap").html()+'
';
var ccTagManagerCategories = $('textarea[name=cmplz_tagmanager_categories]').val();
var ccCategoryAll = $('input[name=cmplz_category_all]').val();
var ccCategoryFunctional = $('input[name=cmplz_category_functional]').val();
ccCheckboxes = ccCheckboxBase.replace('disabled', 'disabled checked');
var ccCheckboxBase = ccCheckboxBase.replace('disabled', 'data-1');
var tmCatsKV = ccTagManagerCategories.split(",");
tmCatsKV.forEach(function(category, i) {
if (category.length > 0)
{
var tmp = ccCheckboxBase.replace(/cmplz_functional/g, 'cmplz_' + i);
tmp = tmp.replace(ccCategoryFunctional, category);
ccCheckboxes += tmp;
}
});
tmp = ccCheckboxBase.replace(/cmplz_functional/g, 'cmplz_marketing');
ccCheckboxes += tmp.replace(ccCategoryFunctional, ccCategoryAll);
cmplz_cookie_warning_render();
});
setTimeout(function () {
if (typeof tinymce !== 'undefined' ) {
for (var i = 0; i < tinymce.editors.length; i++) {
tinymce.editors[i].on('NodeChange keyup', function (ed, e) {
var content;
var link = $(".cc-message").find('a').html();
var editor_id = 'cmplz_message_' + settingConsentType;
var textarea_id = 'cmplz_message';
if (typeof editor_id == 'undefined') editor_id = wpActiveEditor;
if (typeof textarea_id == 'undefined') textarea_id = editor_id;
if (jQuery('#wp-' + editor_id + '-wrap').hasClass('tmce-active') && tinyMCE.get(editor_id)) {
content = tinyMCE.get(editor_id).getContent();
} else {
content = jQuery('#' + textarea_id).val();
}
content = content.replace(/<[\/]{0,1}(p)[^><]*>/ig, "");
$(".cc-message").html(content + '' + link + '');
// Update HTML view textarea (that is the one used to send the data to server).
});
}
}
}, 1500);
$(document).on('change', 'select[name=cmplz_static]', function () {
cmplz_cookie_warning();
});
$(document).on('change', 'select[name=cmplz_position]', function () {
cmplz_apply_style();
cmplz_cookie_warning();
});
$(document).on('change', 'select[name=cmplz_theme]', function () {
cmplz_cookie_warning();
});
$(document).on('change', 'select[name=cmplz_color_scheme]', function () {
var selected_scheme = $('select[name=cmplz_color_scheme]').val();
var colors = color_schemes[selected_scheme];
for (var key in colors) {
if (colors.hasOwnProperty(key)) {
var field = $('input[name=cmplz_'+key+']');
field.val(colors[key]);
field.closest('.cmplz-field').find('.wp-color-result').css({"background-color": colors[key]});
//also try select
var select = $('select[name=cmplz_'+key+']');
select.val(colors[key]);
}
}
cmplz_apply_style();
cmplz_cookie_warning();
});
$(document).on('change', 'select[name=cmplz_checkbox_style]', function () {
ccCheckboxes = '';
cmplz_cookie_warning();
});
$(document).on('keyup', '#cmplz_custom_csseditor', function () {
cmplz_apply_style();
});
$(document).on('change', 'input[name=cmplz_use_custom_cookie_css]', function () {
cmplz_apply_style();
});
$(document).on('change', 'input[name=cmplz_hide_preview]', function () {
cmplz_cookie_warning();
});
$(document).on('change', 'input[name=cmplz_use_box_shadow]', function () {
cmplz_cookie_warning();
});
//cmplz_apply_style();
function cmplz_apply_style(){
$("#cmplz-cookie-inline-css").remove();
var checked = $('input[name=cmplz_use_custom_cookie_css]').is(':checked');
var ccSliderBackgroundColor = $('input[name="cmplz_colorpalette_toggles[background]"]').val();
var ccSliderBulletColor = $('input[name="cmplz_colorpalette_toggles[bullet]"]').val();
var ccSliderBackgroundColorInactive = $('input[name="cmplz_colorpalette_toggles[inactive]"]').val();
var ccAcceptAllTextColor = $('input[name="cmplz_colorpalette_button_accept[text]"]').val();
var ccAcceptAllBackgroundcolor = $('input[name="cmplz_colorpalette_button_accept[background]"]').val();
var ccAcceptAllHovercolor = getHoverColour(ccAcceptAllBackgroundcolor);
var ccAcceptAllBorderColor = $('input[name="cmplz_colorpalette_button_accept[border]"]').val();
var ccFunctionalTextColor = $('input[name="cmplz_colorpalette_button_deny[text]"]').val();
var ccFuntionalBackgroundcolor = $('input[name="cmplz_colorpalette_button_deny[background]"]').val();
var ccFuntionalHovercolor = getHoverColour(ccFuntionalBackgroundcolor);
var ccFuntionalBorderColor = $('input[name="cmplz_colorpalette_button_deny[border]"]').val();
var ccSettingsTextColor = $('input[name="cmplz_colorpalette_button_settings[text]"]').val();
var ccSettingsBackgroundcolor = $('input[name="cmplz_colorpalette_button_settings[background]"]').val();
var ccSettingsHovercolor = getHoverColour(ccSettingsBackgroundcolor);
var ccSettingsBorderColor = $('input[name="cmplz_colorpalette_button_settings[border]"]').val();
var ccBannerWidth = $('input[name=cmplz_banner_width]').val();
var css = '';
//we use importants here, not because it's needed in the front-end, but because it's needed for the dynamic changes in the wysiwyg editor
css += '.cc-compliance .cc-btn.cc-accept-all{color:' + ccAcceptAllTextColor + '!important;background-color:' + ccAcceptAllBackgroundcolor + ';border-color:' + ccAcceptAllBorderColor + '!important}';
css += '.cc-compliance .cc-btn.cc-accept-all:hover{background-color:' + ccAcceptAllHovercolor + '!important}';
css += '.cc-compliance .cc-btn.cc-allow{color:' + ccAcceptAllTextColor + '!important;background-color:' + ccAcceptAllBackgroundcolor + ';border-color:' + ccAcceptAllBorderColor + '!important}';
css += '.cc-compliance .cc-btn.cc-allow:hover{background-color:' + ccAcceptAllHovercolor + '!important}';
css += '.cc-compliance .cc-btn.cc-dismiss{color:' + ccFunctionalTextColor + '!important;background-color:' + ccFuntionalBackgroundcolor + '!important;border-color:' + ccFuntionalBorderColor + '!important}';
css += '.cc-compliance .cc-btn.cc-dismiss:hover{background-color:' + ccFuntionalHovercolor + '!important}';
css += '.cc-compliance .cc-btn.cc-show-settings{color:' + ccSettingsTextColor + '!important;background-color:' + ccSettingsBackgroundcolor + '!important;border-color:' + ccSettingsBorderColor + '!important}';
css += '.cc-compliance .cc-btn.cc-show-settings:hover{background-color:' + ccSettingsHovercolor + '!important}';
css += '.cc-compliance .cc-btn.cc-save-settings{color:' + ccSettingsTextColor + '!important;background-color:' + ccSettingsBackgroundcolor + '!important;border-color:' + ccSettingsBorderColor + '!important}';
css += '.cc-compliance .cc-btn.cc-save-settings:hover{background-color:' + ccSettingsHovercolor + '!important}';
css += ".cmplz-slider-checkbox input:checked + .cmplz-slider {background-color: "+ccSliderBackgroundColor+"!important}";
css += '.cmplz-slider-checkbox .cmplz-slider {background-color: '+ccSliderBackgroundColorInactive+'!important;}';
css += ".cmplz-slider-checkbox input:focus + .cmplz-slider {}";
css += ".cmplz-slider-checkbox .cmplz-slider:before {background-color: "+ccSliderBulletColor+"!important;}.cmplz-slider-checkbox .cmplz-slider-na:before {color:"+ccSliderBulletColor+"!important;}";
if ( ccBannerWidth !== 468 ) {
css += "#cc-window.cc-floating {max-width:" + ccBannerWidth + "px;}";
}
if (checked){
css +=$('textarea[name="cmplz_custom_css"]').val();
}
$('