Subversion Repositories Sites.tela-botanica.org

Compare Revisions

Ignore whitespace Rev 1124 → Rev 1125

/trunk/bandeau_cnil.js
New file
0,0 → 1,79
function ajouterStyle() {
var urlCss = "http://resources.tela-botanica.org/tb/reseau/bandeau_cnil.css";
// http://stackoverflow.com/questions/574944/how-to-load-up-css-files-using-javascript
link = document.createElement("link");
link.href = urlCss;
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
document.getElementsByTagName( "head" )[0].appendChild(link);
}
 
function ajouterBandeau() {
var divCookie =
'<div class="bandeau" id="bandeau_cookie_cnil">'+
'<div class="bandeau_cookie_cnil_titre"> Utilisation des cookies </div>'+
'<hr />'+
'<div class="avertissement_cookie"> '+
'Le site de Tela Botanica utilise des cookies. En poursuivant votre navigation sur le site, vous acceptez l\'utilisation de ces cookies qui permettent notamment de se souvenir de vos pr&eacute;f&eacute;rences. <br />'+
'<a class="en_savoir_plus" target="_blank" href="http://www.tela-botanica.org/page:licence"> En savoir plus</a>'+
'<a class="button" id="accepterCookie" onclick="javascript:accepterCookie()" href="#" > OK </a>'+
'</div>'+
'</div>';
document.body.innerHTML += divCookie;
}
 
function accepterCookie() {
var element = document.getElementById("bandeau_cookie_cnil");
element.parentNode.removeChild(element);
createCookie("cnil", 1, 365);
return false;
}
 
function initialiserBandeauCnil() {
ajouterStyle();
ajouterBandeau();
}
 
/**
* Fonctions tirées de stackoverflow
*/
// http://stackoverflow.com/questions/4825683/how-do-i-create-and-read-a-value-from-cookie
function createCookie(name, value, days) {
var expires;
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toGMTString();
}
else {
expires = "";
}
document.cookie = name + "=" + value + expires + "; path=/";
}
 
function getCookie(c_name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if (c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if (c_end == -1) {
c_end = document.cookie.length;
}
return unescape(document.cookie.substring(c_start, c_end));
}
}
return "";
}
//http://stackoverflow.com/questions/799981/document-ready-equivalent-without-jquery#answer-18775368
document.onreadystatechange = function () {
// tant pis pour les vieux navigateurs qui ne supportent pas document.readyState
if (document.readyState == "complete") {
var cookieCnil = getCookie("cnil");
if(cookieCnil == null || cookieCnil != 1) {
initialiserBandeauCnil();
}
}
}
/trunk/bandeau_cnil.css
New file
0,0 → 1,54
.bandeau {
background-color: #e16039;
border: 1px solid #c2c0ad;
border-radius: 10px;
font-family: helvetica;
opacity: 0.8;
padding: 5px;
position: fixed;
right: 30px;
top: 256px;
width: 350px;
z-index: 99999;
}
 
.avertissement_cookie {
font-size: 12px;
margin: auto;
text-align: center;
width: 100%;
}
 
.button {
border-radius: 5px;
border: 1px solid #5c5a50;
color: #000000;
display: inline-block;
margin-left: 20px;
margin-top: 3px;
padding: 2px 8px;
text-decoration: none;
}
 
.button:hover {
background-color: #5c5950;
color: #FFFFFF;
text-decoration: none;
border-bottom : none;
}
 
.bandeau_cookie_cnil_titre {
font-size: 12px;
text-align: center;
text-transform: uppercase;
}
 
.en_savoir_plus {
color: #000000;
border-bottom: 1px dotted #5c5a50;
}
 
a.en_savoir_plus:hover {
color: #FFFFFF;
border-bottom: 1px dotted #5c5a50;
}