cookie-consent.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. {{- if .Site.Params.showCookieConsent }}
  2. <style>
  3. .cookieConsentContainer {
  4. z-index: 999;
  5. width: 350px;
  6. min-height: 20px;
  7. box-sizing: border-box;
  8. padding: 30px 30px 30px 30px;
  9. background: #232323;
  10. overflow: hidden;
  11. position: fixed;
  12. bottom: 30px;
  13. right: 30px;
  14. display: none;
  15. }
  16. .cookieConsentContainer .cookieTitle a {
  17. font-family: OpenSans, arial, "sans-serif";
  18. color: #FFFFFF;
  19. font-size: 22px;
  20. line-height: 20px;
  21. display: block;
  22. }
  23. .cookieConsentContainer .cookieDesc p {
  24. margin: 0;
  25. padding: 0;
  26. font-family: OpenSans, arial, "sans-serif";
  27. color: #FFFFFF;
  28. font-size: 13px;
  29. line-height: 20px;
  30. display: block;
  31. margin-top: 10px;
  32. }
  33. .cookieConsentContainer .cookieDesc a {
  34. font-family: OpenSans, arial, "sans-serif";
  35. color: #FFFFFF;
  36. text-decoration: underline;
  37. }
  38. .cookieConsentContainer .cookieButton a {
  39. display: inline-block;
  40. font-family: OpenSans, arial, "sans-serif";
  41. color: #FFFFFF;
  42. font-size: 14px;
  43. font-weight: bold;
  44. margin-top: 14px;
  45. background: #000000;
  46. box-sizing: border-box;
  47. padding: 15px 24px;
  48. text-align: center;
  49. transition: background 0.3s;
  50. }
  51. .cookieConsentContainer .cookieButton a:hover {
  52. cursor: pointer;
  53. background: #3E9B67;
  54. }
  55. @media (max-width: 980px) {
  56. .cookieConsentContainer {
  57. bottom: 0px !important;
  58. left: 0px !important;
  59. width: 100% !important;
  60. }
  61. }
  62. </style>
  63. <script>
  64. // --- Config --- //
  65. var purecookieTitle = "Cookies."; // Title
  66. var purecookieDesc = "By using this website, you automatically accept that we use cookies."; // Description
  67. var purecookieLink = '<a href="{{ .Site.Params.privacyPolicyPage }}" target="_blank">What for?</a>'; // Cookiepolicy link
  68. var purecookieButton = "Understood"; // Button text
  69. // --- --- //
  70. function pureFadeIn(elem, display){
  71. var el = document.getElementById(elem);
  72. el.style.opacity = 0;
  73. el.style.display = display || "block";
  74. (function fade() {
  75. var val = parseFloat(el.style.opacity);
  76. if (!((val += .02) > 1)) {
  77. el.style.opacity = val;
  78. requestAnimationFrame(fade);
  79. }
  80. })();
  81. };
  82. function pureFadeOut(elem){
  83. var el = document.getElementById(elem);
  84. el.style.opacity = 1;
  85. (function fade() {
  86. if ((el.style.opacity -= .02) < 0) {
  87. el.style.display = "none";
  88. } else {
  89. requestAnimationFrame(fade);
  90. }
  91. })();
  92. };
  93. function setCookie(name,value,days) {
  94. var expires = "";
  95. if (days) {
  96. var date = new Date();
  97. date.setTime(date.getTime() + (days*24*60*60*1000));
  98. expires = "; expires=" + date.toUTCString();
  99. }
  100. document.cookie = name + "=" + (value || "") + expires + "; path=/";
  101. }
  102. function getCookie(name) {
  103. var nameEQ = name + "=";
  104. var ca = document.cookie.split(';');
  105. for(var i=0;i < ca.length;i++) {
  106. var c = ca[i];
  107. while (c.charAt(0)==' ') c = c.substring(1,c.length);
  108. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  109. }
  110. return null;
  111. }
  112. function eraseCookie(name) {
  113. document.cookie = name+'=; Max-Age=-99999999;';
  114. }
  115. function cookieConsent() {
  116. if (!getCookie('purecookieDismiss')) {
  117. document.body.innerHTML += '<div class="cookieConsentContainer" id="cookieConsentContainer"><div class="cookieTitle"><a>' + purecookieTitle + '</a></div><div class="cookieDesc"><p>' + purecookieDesc + ' ' + purecookieLink + '</p></div><div class="cookieButton"><a onClick="purecookieDismiss();">' + purecookieButton + '</a></div></div>';
  118. pureFadeIn("cookieConsentContainer");
  119. }
  120. }
  121. function purecookieDismiss() {
  122. setCookie('purecookieDismiss','1',7);
  123. pureFadeOut("cookieConsentContainer");
  124. }
  125. window.onload = function() { cookieConsent(); };
  126. </script>
  127. {{- end -}}