//(function ($) { // jQuery(document).ready(function () { document.addEventListener('DOMContentLoaded',function(event){ // p912419 // cookie advanced settings jQuery(document).on('click', '#popup_accept_button', function (event) { event.preventDefault(); var $selectedGoogleFonts = jQuery("select[name='google-fonts'] option:selected").text(); if ($selectedGoogleFonts === 'Yes') { var $googleFonts = jQuery(document).find('link[data-href]'); jQuery.each($googleFonts, function () { jQuery(this).attr('href', jQuery(this).attr('data-href')).removeAttr('data-href'); }); } }); // check if notice is active and make body higher so that popup dont is in front of bottom links jQuery(window).scroll(function() { if (jQuery('#cookie-notice').is(":visible") == false) return; var height = parseInt(jQuery('#cookie-notice').css('height')) - 10; if(jQuery(window).scrollTop() + jQuery(window).height() > jQuery(document).height() - (height+20)) { jQuery(document.body).css('padding-bottom', height+'px'); } else { jQuery(document.body).css('padding-bottom', 'inherit'); } }); }); //})(jQuery); //(function ($) { 'use strict'; var scrollBar = null; /** * Language switcher click (expand/collapse) */ function preparePopupLangSwitcher() { var $active = jQuery('.sp-dsgvo-lang-active'), $dropdown = jQuery('.sp-dsgvo-lang-dropdown'), $switcher = jQuery('.sp-dsgvo-popup-language-switcher'); $active.on('click tap touchstart', function () { $dropdown.toggleClass('active'); }); jQuery(document).on('click tap touchstart ', function (e) { if (!$switcher.is(e.target) && $switcher.has(e.target).length === 0) { $dropdown.removeClass('active'); } }); } /** * Adds Simplebar js scrollbar */ function prepareScrolling() { var $content = jQuery('#sp-dsgvo-privacy-content-category-content'); if ($content.length > 0) { scrollBar = new SimpleBar(jQuery('#sp-dsgvo-privacy-content-category-content')[0], { autoHide: false }); } var $moreInformation = jQuery('.sp-dsgvo-popup-more-information-content'); if ($moreInformation.length > 0) { scrollBar = new SimpleBar(jQuery('.sp-dsgvo-popup-more-information-content ')[0], { autoHide: false }); } } /** * Adds click event to terms links */ function prepareTermsLinks() { var $links = jQuery('.dsgvo-terms-toggle'); $links.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); var $this = jQuery(this), $content = jQuery('#terms_content_' + $this.attr('data-id')); $content.addClass('active'); scrollBar.recalculate(); jQuery(window).resize(); }); } function preparePopupShowLinks() { var $links = jQuery('.sp-dsgvo-show-privacy-popup'); $links.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); showPopup(); }); // links of privacy policy $links = jQuery('.lwb-ppsp'); $links.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); showPopup(); }); } function preparePopupOverlay() { jQuery('.sp-dsgvo-popup-overlay').on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); closePopup(); }); } function preparePopupActionButtons() { // x button var closeBtns = jQuery('.sp-dsgvo-popup-close'); closeBtns.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); closePopup(); }); // dismiss all button var dismissAllBtns = jQuery('.sp-dsgvo-privacy-btn-accept-nothing'); dismissAllBtns.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); handlePopupButtonAction('dismissAll'); closePopup(); }); // accept selected button var acceptSelectedBtns = jQuery('.sp-dsgvo-privacy-btn-accept-selection'); acceptSelectedBtns.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); handlePopupButtonAction('acceptSelected'); closePopup(); }); // accept all button var acceptAllBtns = jQuery('.sp-dsgvo-privacy-btn-accept-all'); acceptAllBtns.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); handlePopupButtonAction('acceptAll'); closePopup(); }); } function preparePopupSwitches() { // uncheck all jQuery('.sp-dsgvo-switch-integration').not(":disabled").prop('checked', false); jQuery('.sp-dsgvo-switch-integration').change(function () { checkForIntegrationModificationsAndSetColorToButtons(); }); var enabledIntegrations = getEnabledIntegrationsFromCookie(); enabledIntegrations.forEach(function(integration) { // check if the script container exists. if not create it to add script afterwards jQuery('#sp-dsgvo-switch-integration-'+integration).prop('checked', true); }); } function checkForIntegrationModificationsAndSetColorToButtons() { var array1 = getEnabledIntegrationsFromCookie(); var array2 = jQuery('.sp-dsgvo-switch-integration:checked').map(function(){ return jQuery(this).data('slug'); }).get(); var equal = array1.length === array2.length && array1.every(function(value, index) { return value === array2[index]}); if (equal == false) { jQuery('.sp-dsgvo-privacy-btn-accept-selection').addClass('green'); jQuery('.sp-dsgvo-privacy-btn-accept-selection').removeClass('grey'); } else { jQuery('.sp-dsgvo-privacy-btn-accept-selection').removeClass('green'); jQuery('.sp-dsgvo-privacy-btn-accept-selection').addClass('grey'); } } function closePopup() { var $overlay = jQuery('.sp-dsgvo-popup-overlay'); if ($overlay.length > 0) { $overlay.fadeOut(); $overlay.addClass('sp-dsgvo-overlay-hidden'); if (spDsgvoGeneralConfig.showNoticeOnClose == 1 && getAndValidateCookie() == false) { showNotice(); } } } function showPopup() { var $overlay = jQuery('.sp-dsgvo-popup-overlay'); if ($overlay.length > 0) { closeNotice(); $overlay.fadeIn(); $overlay.removeClass('sp-dsgvo-overlay-hidden'); } } function showNotice() { var cnDomNode = jQuery('#cookie-notice'); if (spDsgvoGeneralConfig.hideEffect === 'fade') { cnDomNode.fadeIn(300); } else if (spDsgvoGeneralConfig.hideEffect === 'slide') { cnDomNode.slideDown(300); } else { cnDomNode.css('display', 'flex'); } jQuery('body').addClass('cookies-not-accepted'); } function closeNotice() { var cnDomNode = jQuery('#cookie-notice'); if (cnDomNode.is(":visible") == false) return; if (spDsgvoGeneralConfig.hideEffect === 'fade') { cnDomNode.fadeOut(300, function () { jQuery('#cookie-notice').hide(); jQuery('#cookie-notice-blocker').hide(); jQuery('body').removeClass('cookies-not-accepted'); }); } else if (spDsgvoGeneralConfig.hideEffect === 'slide') { cnDomNode.slideUp(300, function () { jQuery('#cookie-notice').hide(); jQuery('#cookie-notice-blocker').hide(); jQuery('body').removeClass('cookies-not-accepted'); }); } else { jQuery('#cookie-notice').hide(); jQuery('#cookie-notice-blocker').hide(); jQuery('body').removeClass('cookies-not-accepted'); } } function checkCookieAndShowPopupOrNoticeIfNeeded() { if (spDsgvoIntegrationConfig == null) return; if (spDsgvoIntegrationConfig.length == 0 && spDsgvoGeneralConfig.forceCookieInfo == 0) return; if (spDsgvoGeneralConfig.currentPageId == spDsgvoGeneralConfig.privacyPolicyPageId || spDsgvoGeneralConfig.currentPageId == spDsgvoGeneralConfig.imprintPageId) { // dont show popup or notice at imprint or policy page return; } if (getAndValidateCookie() == false) { if (spDsgvoGeneralConfig.initialDisplayType == 'cookie_notice') { showNotice(); } else if (spDsgvoGeneralConfig.initialDisplayType == 'policy_popup') { showPopup(); } } } function showMoreInformationPopup(title, slug, locale) { jQuery('#sp-dsgvo-popup-more-information-title').html(title); jQuery('#sp-dsgvo-popup-more-information-progress').show(); jQuery('.sp-dsgvo-privacy-popup-title-general').hide(); jQuery('#sp-dsgvo-privacy-content-category-content').hide(); jQuery('#sp-dsgvo-privacy-footer').hide(); jQuery('.sp-dsgvo-header-description-text').hide(); jQuery('#sp-dsgvo-more-information-switch-cb').attr('data-slug', slug); jQuery('#sp-dsgvo-more-information-switch-cb').prop('checked', jQuery('#sp-dsgvo-switch-integration-' + slug).prop('checked')); jQuery('#sp-dsgvo-more-information-switch-cb').prop('disabled', jQuery('#sp-dsgvo-switch-integration-' + slug).prop('disabled')); jQuery('.sp-dsgvo-privacy-popup-title-details').show(); jQuery('#sp-dsgvo-popup-more-information').show(); var integrationObject = getIntegrationConfigBySlug(slug); jQuery.get(spDsgvoGeneralConfig.ajaxUrl, {//$.get(spDsgvoGeneralConfig.ajaxUrl, { action: 'legal-web-text-action', slug: slug, textId: 'popup', locale: locale, includeGtagManager: integrationObject.withGtm }, function (data) { jQuery('#sp-dsgvo-popup-more-information-title').html(title); jQuery('#sp-dsgvo-popup-more-information-content').html(data); jQuery('#sp-dsgvo-popup-more-information-progress').hide(); jQuery('.sp-dsgvo-privacy-popup-title-details').show(); jQuery('#sp-dsgvo-popup-more-information').show(); }).fail(function() { hideMoreInformationPopup(); }) } function hideMoreInformationPopup() { jQuery('#sp-dsgvo-popup-more-information').hide(); jQuery('.sp-dsgvo-privacy-popup-title-details').hide(); jQuery('#sp-dsgvo-popup-more-information-progress').hide(); jQuery('#sp-dsgvo-popup-more-information-content').html(''); jQuery('#sp-dsgvo-more-information-switch-cb').attr('data-slug', ''); jQuery('#sp-dsgvo-more-information-switch-cb').prop('checked', false); jQuery('.sp-dsgvo-privacy-popup-title-general').show(); jQuery('.sp-dsgvo-header-description-text').show(); jQuery('#sp-dsgvo-privacy-content-category-content').show(); jQuery('#sp-dsgvo-privacy-footer').show(); } function prepareMoreInformationPopup() { var $links = jQuery('.sp-dsgvo-more-information-link'); $links.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); var $this = jQuery(this); var title = $this.attr('data-title'); var slug = $this.attr('data-slug'); showMoreInformationPopup(title, slug, spDsgvoGeneralConfig.locale); }); var closeBtns = jQuery('.sp-dsgvo-popup-more-information-close'); closeBtns.on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); hideMoreInformationPopup(); }); // set the handler for the more information cb that the outside sb also gets set jQuery('#sp-dsgvo-more-information-switch-cb').change(function () { var $this = $(this); var slug = $this.attr('data-slug'); if (slug == '') return; if (jQuery(this).prop('disabled')) return; jQuery('#sp-dsgvo-switch-integration-' + slug).prop('checked', $this.prop('checked')); checkForIntegrationModificationsAndSetColorToButtons(); }); } function preparePopupGroupSwitches() { jQuery('input[name="sp-dsgvo-switch-category"]').change(function () { var $this = jQuery(this); var slug = $this.attr('data-slug') // get all sp-dsgvo-switch-integration with slug and set same check value jQuery('input[data-category="' + slug + '"]').each(function () { if (jQuery(this).prop('disabled')) return; var category = jQuery(this).attr('data-category') jQuery(this).prop('checked', jQuery('#sp-dsgvo-switch-category-' + category).prop('checked')); }); checkForIntegrationModificationsAndSetColorToButtons(); }); } function prepareNotice() { // sometimes wp admin bar sets a margin top. if its greater 0 set it to the notice position //var bodyMt = $('body,html').css('margin-top'); //$('.cn-bottom').css('bottom', bodyMt); jQuery('#cn-btn-settings').on('click tap touchstart', function (event) { event.preventDefault(); event.stopPropagation(); closeNotice(); showPopup(); }); } function handlePopupButtonAction(action) { if (action == null || action == '') return; var allntegrationSlugs = spDsgvoGeneralConfig.allIntegrationSlugs; var selectedSwitches = jQuery('.sp-dsgvo-switch-integration:checkbox:checked'); var checkedIntegrationSlugs = []; switch (action) { case 'acceptAll': checkedIntegrationSlugs = allntegrationSlugs; break; case 'acceptSelected': jQuery(".sp-dsgvo-switch-integration:checkbox:checked").each(function () { checkedIntegrationSlugs.push(jQuery(this).data("slug")); }); break; case 'dismissAll': checkedIntegrationSlugs = []; // reset them break; } var enabledIntegrationsBeforeClosing = getEnabledIntegrationsFromCookie(); // add gtag manager if used by integration var gtmNeeded = false; checkedIntegrationSlugs.forEach(function(integration) { var integrationObject = getIntegrationConfigBySlug(integration); if (integrationObject == null) return; if (integrationObject.withGtm == '1') { gtmNeeded = true; return; } }); if (gtmNeeded) checkedIntegrationSlugs.push('google-tagmanager'); refreshCookie(checkedIntegrationSlugs); enableIntegrationsAccordingToCookie(); removeCookiesOfDisabledIntegrations(enabledIntegrationsBeforeClosing); } function refreshCookie(checkedIntegrationSlugs) { var cookieData = {}; cookieData.version = spDsgvoGeneralConfig.cookieVersion; cookieData.lifeTime = spDsgvoGeneralConfig.cookieLifeTime; cookieData.integrations = checkedIntegrationSlugs;// cookieData.lastChangeOn = new Date().getTime(); var flatData = encodeURIComponent(JSON.stringify(cookieData)); var d = new Date(); d.setTime(d.getTime() + parseInt(spDsgvoGeneralConfig.cookieLifeTime) * 1000); var expires = "expires=" + d.toUTCString(); document.cookie = spDsgvoGeneralConfig.cookieName + "=" + flatData + ";" + expires + ";path=/"; } function isGtagMangerIsActive() { return window.google_tag_manager != null; } function enableIntegrationsAccordingToCookie() { var enabledIntegrations = getEnabledIntegrationsFromCookie(); // first check if one needs gtag manager and enable it if needed var gtmNeeded = false; enabledIntegrations.forEach(function(integration) { var integrationObject = getIntegrationConfigBySlug(integration); if (integrationObject == null) return; if (integrationObject.withGtm == '1') { gtmNeeded = true; return; } }); if (gtmNeeded && isGtagMangerIsActive() == false) { var integrationObject = getIntegrationConfigBySlug('google-tagmanager'); if (integrationObject == null) return; try { jQuery('head').append(atob(integrationObject.jsCode)); } catch (e) { console.log('could not activate ' + integrationObject.slug); } } enabledIntegrations.forEach(function(integration) { if (integration == 'google-tagmanager') return; var integrationObject = getIntegrationConfigBySlug(integration); if (integrationObject == null) return; if (integrationObject.insertLocation == 'head') { // check if head contains the script, if not, add it var pos = jQuery("head").html().indexOf('sp-dsgvo-script-container-' + integrationObject.slug); var lastPos = jQuery("head").html().lastIndexOf('sp-dsgvo-script-container-' + integrationObject.slug); if (pos == lastPos) { try { jQuery('head').append(atob(integrationObject.jsCode)); } catch (e) { console.log('could not activate ' + integration); } } } else { // check if the script container exists. if not create it to add script afterwards var scriptContainer = jQuery('.sp-dsgvo-script-container-' + integration); var found = scriptContainer.length; if (found == false) { scriptContainer = jQuery('
', { // id: 'sp-dsgvo-script-container-' + integration, "class": 'sp-dsgvo-script-container sp-dsgvo-script-container-' + integration, }).appendTo(integrationObject.insertLocation); found = true; } // if found and empty add js code to the container var isEmpty = jQuery.trim(scriptContainer.html()) == ''; if (found && isEmpty) { try { scriptContainer.append(atob(integrationObject.jsCode)); } catch (e) { console.log('could not activate ' + integration); } } } }); } function removeCookiesOfDisabledIntegrations(enabledIntegrationsBeforeClosing) { var reloadNeeded = 0; var enabledIntegrations = getEnabledIntegrationsFromCookie(); // it nothing was enabled and all gets dismissed its not needed to to anything // could happen on first visit when dismiss all if (enabledIntegrations.length == 0 && enabledIntegrationsBeforeClosing.length == 0) return; // if nothing is enabled, remove all if (enabledIntegrations == null || enabledIntegrations == '' || enabledIntegrations == '' || Array.isArray(enabledIntegrations) == false) { jQuery('.sp-dsgvo-script-container').each(function () { jQuery(this).empty(); }); spDsgvoIntegrationConfig.forEach(function(integrationConfig) { // remove cookies of the integration var cookiesToDeleteString = integrationConfig.cookieNames; if (cookiesToDeleteString != null || cookiesToDeleteString != '') { var cookieNames = cookiesToDeleteString.split(';'); if (cookieNames != null && cookieNames.length > 0) { cookieNames.forEach(function(cookieName) { deleteCookieByName(cookieName); }); } } }); // safe mode because scripts still could run in browser location.reload(); return; } spDsgvoIntegrationConfig.forEach(function(integrationConfig) { if(enabledIntegrations.includes(integrationConfig.slug) == false) { // check if it was enabled before if (enabledIntegrationsBeforeClosing.includes(integrationConfig.slug)) reloadNeeded++; /* currently not needed because we remove it in reload because otherwise the script cant be removed from js vm //remove script of the integration var scriptContainer = $('#sp-dsgvo-script-container-'+integrationConfig.slug); var found = scriptContainer.length; if (found == false) { // if not found also check in head var children = $('head').find('div#sp-dsgvo-script-container-' + integrationConfig.slug); if (children.length > 0) { scriptContainer = children[0]; found = true; } } if (found) { scriptContainer.empty(); scriptContainer.each(function () { $(this).empty(); }); } */ // remove cookies of the integration var cookiesToDeleteString = integrationConfig.cookieNames; if (cookiesToDeleteString != null || cookiesToDeleteString != '') { var cookieNames = cookiesToDeleteString.split(';'); if (cookieNames != null && cookieNames.length > 0) { cookieNames.forEach(function(cookieName) { deleteCookieByName(cookieName); }); } } } }); if (reloadNeeded > 0) { // safe mode because scripts still could run in browser location.reload(); } } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function validateCookieData(cookie) { if (cookie == null || cookie == '') return false; var cookieData = {}; try { cookieData = JSON.parse(decodeURIComponent(cookie)); } catch (e) { return false; } if (cookieData.version < spDsgvoGeneralConfig.cookieVersion) { return false; } return true; } function getAndValidateCookie() { var cookie = getCookie(spDsgvoGeneralConfig.cookieName); return validateCookieData(cookie); } function getEnabledIntegrationsFromCookie() { var enabledIntegrations = [] var cookie = getCookie(spDsgvoGeneralConfig.cookieName); if (cookie != '') { try { var objectData = JSON.parse(decodeURIComponent(cookie)); enabledIntegrations = objectData.integrations; } catch (e) { enabledIntegrations = []; } } return enabledIntegrations; } function deleteCookieByName(pattern) { if (pattern == '') return; var matcher = new RegExp("^"+pattern, "g"); if ((matcher).test(document.cookie) == false) return; // Get an array of all cookie names (the regex matches what we don't want) var cookieNames = document.cookie.split(/=[^;]*(?:;\s*|$)/); // Remove any that match the pattern for (var i = 0; i < cookieNames.length; i++) { if (matcher.test(cookieNames[i])) { document.cookie = cookieNames[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT;'; // path=' + path; } } } function getIntegrationConfigBySlug(slug) { var integrationObject = spDsgvoIntegrationConfig.find(obj => { return obj.slug === slug }) return integrationObject; } // jQuery(document).ready(function () { document.addEventListener('DOMContentLoaded',function(event){ // alert('test'); enableIntegrationsAccordingToCookie(); preparePopupLangSwitcher(); prepareMoreInformationPopup(); prepareTermsLinks(); preparePopupActionButtons(); preparePopupGroupSwitches(); preparePopupSwitches(); prepareScrolling(); prepareNotice(); preparePopupShowLinks(); //preparePopupOverlay(); checkCookieAndShowPopupOrNoticeIfNeeded(); }); //})(jQuery);