#HTTP_HEADER{Content-Type: text/javascript; charset=#CHARSET}
/*
* Copyright (C) 2012 PrimeBox (info@primebox.co.uk)
*
* This work is licensed under the Creative Commons
* Attribution 3.0 Unported License. To view a copy
* of this license, visit
* http://creativecommons.org/licenses/by/3.0/.
*
* Documentation available at:
* http://www.primebox.co.uk/projects/cookie-bar/
*
* When using this software you use it at your own risk. We hold
* no responsibility for any damage caused by using this plugin
* or the documentation provided.
*/
[(#CONFIG{cookiebar/message_txt}|?{
[(#SET{message,#CONFIG{cookiebar/message_txt}|typo|texte_script})],
[(#SET{message,<:cookiebar:message_message|texte_script:>})]
})]
[(#CONFIG{cookiebar/accept_txt}|?{
[(#SET{accepttext,#CONFIG{cookiebar/accept_txt}|typo|texte_script})],
[(#SET{accepttext,<:cookiebar:message_accepttext|texte_script:>})]
})]
[(#CONFIG{cookiebar/decline_txt}|?{
[(#SET{declinetext,#CONFIG{cookiebar/decline_txt}|typo|texte_script})],
[(#SET{declinetext,<:cookiebar:message_declinetext|texte_script:>})]
})]
[(#CONFIG{cookiebar/policy_txt}|?{
[(#SET{policytext,#CONFIG{cookiebar/policy_txt}|typo|texte_script})],
[(#SET{policytext,<:cookiebar:message_policytext|texte_script:>})]
})]
(function($){
$.cookieBar = function(options,val){
if(options=='cookies'){
var doReturn = 'cookies';
}else if(options=='set'){
var doReturn = 'set';
}else{
var doReturn = false;
}
var defaults = {
message: '#GET{message}', //Message displayed on bar
acceptButton: #CONFIG{cookiebar/accept_button,true} , //Set to true to show accept/enable button
acceptText: '#GET{accepttext}', //Text on accept/enable button
declineButton: #CONFIG{cookiebar/decline_button,true}, //Set to true to show decline/disable button
declineText: '#GET{declinetext}', //Text on decline/disable button
policyButton: #CONFIG{cookiebar/policy_button,false}, //Set to true to show Privacy Policy button
policyText: '#GET{policytext}', //Text on Privacy Policy button
policyURL: '#CONFIG{cookiebar/policy_url}', //URL of Privacy Policy
autoEnable: true, //Set to true for cookies to be accepted automatically. Banner still shows
acceptOnContinue: false, //Set to true to silently accept cookies when visitor moves to another page
expireDays: 365, //Number of days for cookieBar cookie to be stored for
forceShow: false, //Force cookieBar to show regardless of user cookie preference
effect: '[(#CONFIG{cookiebar/effet,slide})]', //Options: slide, fade, hide
element: 'body', //Element to append/prepend cookieBar to. Remember "." for class or "#" for id.
append: false, //Set to true for cookieBar HTML to be placed at base of website. Actual position may change according to CSS
fixed: [(#CONFIG{cookiebar/position}|match{fixed}|?{true,false})], //Set to true to add the class "fixed" to the cookie bar. Default CSS should fix the position
bottom: [(#CONFIG{cookiebar/position}|=={fixed-bottom}|?{true,false})], //Force CSS when fixed, so bar appears at bottom of website
zindex: '999', //Can be set in CSS, although some may prefer to set here
redirect: String(window.location.href), //Current location
domain: String(window.location.hostname), //Location of privacy policy
referrer: String(document.referrer) //Where visitor has come from
};
var options = $.extend(defaults,options);
//Sets expiration date for cookie
var expireDate = new Date();
expireDate.setTime(expireDate.getTime()+(options.expireDays*24*60*60*1000));
expireDate = expireDate.toGMTString();
var cookieEntry = 'cb-enabled={value}; expires='+expireDate+'; path=/';
//Retrieves current cookie preference
var i,cookieValue='',aCookie,aCookies=document.cookie.split('; ');
for (i=0;i=0 && String(window.location.href).indexOf(options.policyURL)==-1 && doReturn!='cookies' && doReturn!='set' && cookieValue!='accepted' && cookieValue!='declined'){
doReturn = 'set';
val = 'accepted';
}
}
if(doReturn=='cookies'){
//Returns true if cookies are enabled, false otherwise
if(cookieValue=='enabled' || cookieValue=='accepted'){
return true;
}else{
return false;
}
}else if(doReturn=='set' && (val=='accepted' || val=='declined')){
//Sets value of cookie to 'accepted' or 'declined'
document.cookie = cookieEntry.replace('{value}',val);
if(val=='accepted'){
return true;
}else{
return false;
}
}else{
//Sets up enable/accept button if required
var message = options.message.replace('{policy_url}',options.policyURL);
if(options.acceptButton){
var acceptButton = ''+options.acceptText+'';
}else{
var acceptButton = '';
}
//Sets up disable/decline button if required
if(options.declineButton){
var declineButton = ''+options.declineText+'';
}else{
var declineButton = '';
}
//Sets up privacy policy button if required
if(options.policyButton){
var policyButton = ''+options.policyText+'';
}else{
var policyButton = '';
}
//Whether to add "fixed" class to cookie bar
if(options.fixed){
if(options.bottom){
var fixed = ' class="fixed bottom"';
}else{
var fixed = ' class="fixed"';
}
}else{
var fixed = '';
}
if(options.zindex!=''){
var zindex = ' style="z-index:'+options.zindex+';"';
}else{
var zindex = '';
}
//Displays the cookie bar if arguments met
if(options.forceShow || cookieValue=='enabled' || cookieValue==''){
if(options.append){
$(options.element).append('