Skip to content

Commit

Permalink
Added a "customize cookies" option
Browse files Browse the repository at this point in the history
  • Loading branch information
ToX82 committed Aug 13, 2021
1 parent 6d3f5e0 commit e97d6e8
Show file tree
Hide file tree
Showing 40 changed files with 833 additions and 8 deletions.
44 changes: 44 additions & 0 deletions cookiebar-latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@ function setupCookieBar() {
thirdparty = document.getElementById('cookie-bar-thirdparty');
tracking = document.getElementById('cookie-bar-tracking');

customize = document.getElementById('cookie-bar-customize-block');
buttonCustomize = document.getElementById('cookie-bar-button-customize');
buttonSaveCustomized = document.getElementById('cookiebar-save-customized');
customizeBlock = document.getElementById('cookie-bar-customize-block');
customizeTracking = document.getElementById('cookiebar-tracking-input');
customizeThirdParty = document.getElementById('cookiebar-third-party-input');

scrolling = document.getElementById('cookie-bar-scrolling');
privacyPage = document.getElementById('cookie-bar-privacy-page');
privacyLink = document.getElementById('cookie-bar-privacy-link');
Expand All @@ -257,6 +264,9 @@ function setupCookieBar() {
promptNoConsent.style.display = 'none';
buttonNo.style.display = 'none';
}
if (getURLParameter('showCustomConsent')) {
buttonCustomize.style.display = 'none';
}

if (getURLParameter('blocking')) {
fadeIn(prompt, 500);
Expand All @@ -265,10 +275,18 @@ function setupCookieBar() {

if (getURLParameter('thirdparty')) {
thirdparty.style.display = 'block';
customizeThirdParty.style.display = 'block';
} else {
thirdparty.style.display = 'none';
customizeThirdParty.style.display = 'none';
}

if (getURLParameter('tracking')) {
tracking.style.display = 'block';
customizeTracking.style.display = 'block';
} else {
tracking.style.display = 'none';
customizeTracking.style.display = 'none';
}

if (getURLParameter('hideDetailsBtn')) {
Expand Down Expand Up @@ -297,6 +315,14 @@ function setupCookieBar() {
mainBarPrivacyLink.style.display = 'inline-block';
}

if (getURLParameter('customize')) {
customizeBlock.style.display = 'block';
buttonCustomize.style.display = 'block';
} else {
customizeBlock.style.display = 'none';
buttonCustomize.style.display = 'none';
}

setEventListeners();
fadeIn(cookieBar, 250);
setBodyMargin();
Expand Down Expand Up @@ -510,14 +536,32 @@ function setupCookieBar() {
}
});

buttonSaveCustomized.addEventListener('click', function() {
setCookie('cookiebar', 'CookieCustomized');
setCookie('cookiebar-tracking', document.getElementById('cookiebar-tracking').checked);
setCookie('cookiebar-third-barty', document.getElementById('cookiebar-third-party').checked);
clearBodyMargin();
fadeOut(prompt, 250);
fadeOut(cookieBar, 250);
if (getURLParameter('refreshPage')) {
window.location.reload();
}
});

promptBtn.addEventListener('click', function() {
fadeIn(prompt, 250);
});

promptClose.addEventListener('click', function() {
fadeOut(customize, 0);
fadeOut(prompt, 250);
});

buttonCustomize.addEventListener('click', function() {
fadeIn(customize, 0);
fadeIn(prompt, 250);
});

if (getURLParameter('scrolling')) {
var scrollPos = document.body.getBoundingClientRect().top;
var scrolled = false;
Expand Down
2 changes: 1 addition & 1 deletion cookiebar-latest.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lang/bg.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
<br>Тази страница използва проследяващи "бисквитки". За повече подробности, моля да се запозанаете с политиката за поверителност.<br>
</i>

<i id='cookie-bar-customize-block'>
<br>
Ако предпочитате, можете да изберете кои видове бисквитки смятате за приемливи:<br>
<input type="checkbox" id="cookiebar-technical" checked disabled>
<label for="cookiebar-technical">Технически бисквитки (задължителни)</label><br>

<span id="cookiebar-third-party-input">
<input type="checkbox" id="cookiebar-third-party" value="1">
<label for="cookiebar-third-party">Бисквитки на трети страни</label><br>
</span>

<span id="cookiebar-tracking-input">
<input type="checkbox" id="cookiebar-tracking" value="1">
<label for="cookiebar-tracking">Проследяване на бисквитки</label><br>
</span>

<button id="cookiebar-save-customized">Запазете предпочитанията ми</button>
<br>
</i>

<i id='cookie-bar-privacy-page'>
<br>За да научите повече подробности за използваните на тази страница "бисквитки" или "локално хранилище", моля да прочетете <a rel='nofollow noopener noreferrer' id='cookie-bar-privacy-link' href=''>ПОЛИТИКА ЗА ПОВЕРИТЕЛНОСТ</a>.<br><br></i>

Expand Down Expand Up @@ -45,4 +65,5 @@
</p>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button-no">Забрани бисквитките</a>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button">Разреши бисквитките</a>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button-customize">Özelleştirmek</a>
</div>
21 changes: 21 additions & 0 deletions lang/br.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@
<br>Este site utiliza cookies de rastreamento, veja os detalhes do manifesto de privacidade.<br>
</i>

<i id='cookie-bar-customize-block'>
<br>
Se preferir, você pode selecionar quais tipos de cookies acha aceitáveis:<br>
<input type="checkbox" id="cookiebar-technical" checked disabled>
<label for="cookiebar-technical">Cookies técnicos (obrigatório)</label><br>

<span id="cookiebar-third-party-input">
<input type="checkbox" id="cookiebar-third-party" value="1">
<label for="cookiebar-third-party">Cookies de terceiros</label><br>
</span>

<span id="cookiebar-tracking-input">
<input type="checkbox" id="cookiebar-tracking" value="1">
<label for="cookiebar-tracking">Cookies de rastreamento</label><br>
</span>

<button id="cookiebar-save-customized">Salvar minhas preferências</button>
<br>
</i>

<i id='cookie-bar-privacy-page'>
<br>Para ver mais detalhes sobre como este site utiliza cookies ou localStorage, por favor leia o nosso <a rel='nofollow noopener noreferrer' id='cookie-bar-privacy-link' href=''>MANIFESTO DE PRIVACIDADE</a>.<br><br>
</i>
Expand Down Expand Up @@ -50,4 +70,5 @@
</p>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button-no">Bloquear cookies</a>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button">Permitir cookies</a>
<a rel='nofollow noopener noreferrer' id="cookie-bar-button-customize">Customizar</a>
</div>
Loading

0 comments on commit e97d6e8

Please # to comment.