Skip to content

Commit

Permalink
Release 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ToX82 committed Jun 7, 2015
1 parent 2886abe commit 4630c0a
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion cookiebar-latest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin URL: http://cookie-bar.eu/
@author: Emanuele "ToX" Toscano
@description: Cookie Bar is a free & simple solution to the EU cookie law.
@version: 1.4
@version: 1.4.1
*/

/*
Expand All @@ -21,6 +21,17 @@ var CookieLanguages = [
function setupCookieBar() {
scriptPath = getScriptPath();


/**
* If cookies are disallowed, delete all the cookies at every refresh
* @param null
* @return null
*/
if (getCookie("cookiebar") == "CookieDisallowed") {
removeCookie();
setCookie("cookiebar", "CookieDisallowed");
}

/**
* Load plugin only if needed or the "always" parameter is set (do nothing if cookiebar cookie is set)
* @param null
Expand Down Expand Up @@ -277,6 +288,22 @@ function setupCookieBar() {
}, 300);
}

/**
* Clear the bottom (or top) margin when the user closes the CookieBar
* @param null
* @return null
*/
function clearBodyMargin() {
var height = document.getElementById("cookie-bar").clientHeight;


if (getURLParameter("top")) {
document.getElementsByTagName('body')[0].style.marginTop = -height + "px";
} else {
document.getElementsByTagName('body')[0].style.marginBottom = -height + "px";
}
}

/**
* Get ul parameter to look for
* @param {string} name - param name
Expand All @@ -299,6 +326,7 @@ function setupCookieBar() {
function setEventListeners() {
button.addEventListener('click', function () {
setCookie("cookiebar", "CookieAllowed");
clearBodyMargin();
fadeOut(prompt, 250);
fadeOut(cookieBar, 250);
});
Expand All @@ -308,6 +336,8 @@ function setupCookieBar() {
var confirm = window.confirm(txt);
if (confirm === true) {
removeCookie();
setCookie("cookiebar", "CookieDisallowed");
clearBodyMargin();
fadeOut(prompt, 250);
fadeOut(cookieBar, 250);
}
Expand Down

0 comments on commit 4630c0a

Please sign in to comment.