cookienotice addon - fixes from pull request reviews

This commit is contained in:
Peter Liebetrau 2019-01-20 20:35:58 +01:00
parent efda326527
commit 12c4fcfcae
7 changed files with 139 additions and 94 deletions

View file

@ -1,23 +1,2 @@
<style type="text/css">
#cookienotice-box {
display: none;
position: fixed;
z-index: 10000;
bottom: 0px;
left: 0;
width: 100%;
background-color: #101010;
color: #f0f0f0;
padding: 2em 1em;
text-align: center;
}
#cookienotice-ok-button {
border: 1px solid darkgoldenrod;
background-color: gold;
color: #101010;
min-width: 80px;
padding: .5em .1em;
}
</style>
<div id="cookienotice-box"><p>{{$text}}</p><button id="cookienotice-ok-button">{{$oktext}}</button></div>

View file

@ -1,40 +1 @@
<!-- <link rel="stylesheet" type="text/css" href="/addon/cookienotice/css/cookienotice.css" /> -->
<script>
window.addEventListener("load", function () {
var cookiename = 'cncookiesaccepted'
var cookie = getCookie(cookiename);
if (cookie == "") {
document.getElementById('cookienotice-box').style.display = 'block';
document.getElementById('cookienotice-ok-button').onclick = function () {
console.log('clicked');
setCookie(cookiename, 1, 365);
document.getElementById('cookienotice-box').style.display = 'none';
};
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
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 "";
}
});
</script>
<script type="text/javascript" src="/addon/cookienotice/cookienotice.js"></script>

View file

@ -5,9 +5,9 @@
<span class="fakelink" onclick="openClose('settings_cookienotice_expanded'); openClose('settings_cookienotice_inflated');">
<h3>{{$title}}</h3>
</span>
<p>{{$description}}</p>
<p>{{$description}}</p>
{{include file="field_textarea.tpl" field=$text}}
{{include file="field_input.tpl" field=$oktext}}
{{include file="field_input.tpl" field=$oktext}}
<div class="settings-submit-wrapper" >
<input type="submit" id="cookienotice-submit" name="cookienotice-submit" class="settings-submit" value="{{$submit}}" />
</div>