Browse Source

new state-saving cookie bar

redesign
Anxhelo Lushka 7 years ago
parent
commit
ec09c34009
  1. 1
      _includes/footer.html
  2. 1
      _includes/head.html
  3. 2
      _layouts/default.html
  4. 53
      js/cookie.js
  5. 9
      js/svg.js

1
_includes/footer.html

@ -29,6 +29,7 @@
<script src="{{ "/bower_components/appear/jquery.appear.js" | prepend: site.baseurl }}"></script> <script src="{{ "/bower_components/appear/jquery.appear.js" | prepend: site.baseurl }}"></script>
<script src="{{ "/js/app.js" | prepend: site.baseurl }}"></script> <script src="{{ "/js/app.js" | prepend: site.baseurl }}"></script>
<script src="{{ "/js/svg.js" | prepend: site.baseurl }}"></script> <script src="{{ "/js/svg.js" | prepend: site.baseurl }}"></script>
<script src="{{ "/js/cookie.js" | prepend: site.baseurl }}"></script>
<!-- Matomo --> <!-- Matomo -->
<script type="text/javascript"> <script type="text/javascript">

1
_includes/head.html

@ -21,6 +21,7 @@
<script src="{{ "/bower_components/modernizr/modernizr.js" | prepend: site.baseurl }}"></script> <script src="{{ "/bower_components/modernizr/modernizr.js" | prepend: site.baseurl }}"></script>
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}"> <link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}"> <link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
</head> </head>

2
_layouts/default.html

@ -10,7 +10,7 @@
{{ content }} {{ content }}
<div id="cookieConsent"> <div id="cookieConsent" style="display: none;">
<div id="closeCookieConsent">x</div> <div id="closeCookieConsent">x</div>
This website is using cookies. <a href="/privacy-policy" target="_blank">More info</a>. <a class="cookieConsentOK">That's Fine</a> This website is using cookies. <a href="/privacy-policy" target="_blank">More info</a>. <a class="cookieConsentOK">That's Fine</a>
</div> </div>

53
js/cookie.js

@ -0,0 +1,53 @@
jQuery(function($) {
checkCookie_eu();
function checkCookie_eu()
{
var consent = getCookie_eu("cookies_consent");
if (consent == null || consent == "" || consent == undefined)
{
// show notification bar
$(document).ready(function(){
setTimeout(function () {
$("#cookieConsent").fadeIn(200);
}, 4000);
});
}
}
function setCookie_eu(c_name,value,exdays)
{
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie = c_name + "=" + c_value+"; path=/";
$('#cookieConsent').hide('slow');
}
function getCookie_eu(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
$("#closeCookieConsent .cookieConsentOK").click(function(){
setCookie_eu("cookies_consent", 1, 30);
});
});

9
js/svg.js

@ -34,12 +34,3 @@ jQuery('img.svg').each(function(){
}, 'xml'); }, 'xml');
}); });
$(document).ready(function(){
setTimeout(function () {
$("#cookieConsent").fadeIn(200);
}, 2500);
$("#closeCookieConsent, .cookieConsentOK").click(function() {
$("#cookieConsent").fadeOut(200);
});
});

Loading…
Cancel
Save