forked from tgvashworth/jquery.cookieConsent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.cookieConsent.min.js
7 lines (7 loc) · 3.57 KB
/
jquery.cookieConsent.min.js
1
2
3
4
5
6
7
/*!
* jQuery CookieConsent Plugin
* https://github.com/phuu/cookieConsent
*
* Copyright 2012, Tom Ashworth
* Originally created for The Higgs Design Co - http://higgsdesign.com
*/(function(a){a.cookieConsent=function(b){b||(b={});var c={mode:"default",persistence:"heavy",color:{main:"#29f",bg:"#fff",popover:"rgba(0,0,0,.3)",text:"#444"},font:"12px Tahoma, sans-serif",slideSpeed:"fast",width:"auto",maxWidth:"50%",link:{cookies:"http://en.wikipedia.org/wiki/HTTP_cookie",policy:null}};if(a.cookie("cookieConsent")==="yes"){a("html").addClass("cookie-consent-given");a("#cookie-consent-wrapper").slideDown(c.slideSpeed);return}c.content={heading:["strong",{content:"This site uses "},["a",{href:c.link.cookies,content:"cookies."}]],text:["p",{content:"By using this site you agree to our "+(c.link.policy?"":"cookie policy.")},c.link.policy?["a",{href:c.link.policy,content:"cookie policy."}]:[]]};var d=function i(b){var c,d,e=document.createElement(b[0]);if(b[1]){var f=b[1];for(c in f)f.hasOwnProperty(c)&&(c==="content"?a(e).text(f[c]):c==="css"?a(e).css(f[c]):e.setAttribute(c,f[c]))}if(b.length>2){c=2,d=b.length;for(;c<d;c++)typeof b[c]=="string"?a(e).html(a(e).html()+b[c]):e.appendChild(i(b[c]))}return e};a.extend(!0,c,b);var e=["div",{id:"cookie-consent-wrapper"},["div",{id:"cookie-consent"},["div",{id:"cookie-info-icon",content:"i"}],["p",{},c.content.heading],c.content.text,["a",{id:"cookie-close",href:"#",content:"x"}]]],f="";f+="#cookie-consent-wrapper {display:none;z-index:9999;clear:both;overflow:hidden;position:relative;}";c.mode==="popover"&&(f+="#cookie-consent-wrapper {position:fixed;top:0;left:0;right:0;bottom:0;background: "+c.color.popover+"; padding-top: 5em;}");c.mode==="tab"&&(f+="#cookie-consent-wrapper {position:absolute;top:0;left:0;right:0;*width:100%;}");f+="#cookie-consent {color: "+c.color.text+";background: "+c.color.bg+";width: "+c.width+";max-width: "+c.maxWidth+";margin:0 auto;font: "+c.font+";padding: 0.5em;border: 2px solid "+c.color.main+";position: relative;}";c.mode==="tab"&&(f+="#cookie-consent {border-top: none;}");f+="#cookie-info-icon {font-family: serif; font-size: 1.4em;background: "+c.color.main+";float: left;padding: .25em .75em;border-radius: 50%;color: white;margin-right: .5em;}";f+="#cookie-consent p {margin: 0;overflow: hidden;}";f+="#cookie-consent a, #cookie-consent a:visited {color:"+c.color.main+"}";f+="#cookie-consent a:hover {color:"+c.color.text+"}";f+="#cookie-close {position: absolute;top: 0;right: 0;padding: 0em .5em .25em;text-decoration: none;}";f+="#cookie-close:hover {background: #efefef}";f="<style>"+f+"</style>";var g=a("html"),h=d(e);c.persistence==="light"&&a.cookie("cookieConsent","yes");a(h).on("click","#cookie-close",function(){a.cookie("cookieConsent","yes");a(h).slideUp(c.slideSpeed,function(){h.parentNode.removeChild(h);a("html").addClass("cookie-consent-given")})});a(f).appendTo("head");a(h).prependTo("body")}})(jQuery);(function(a){a.cookie=function(b,c,d){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(c))||c===null||c===undefined)){d=a.extend({},d);if(c===null||c===undefined)d.expires=-1;if(typeof d.expires=="number"){var e=d.expires,f=d.expires=new Date;f.setDate(f.getDate()+e)}c=String(c);return document.cookie=[encodeURIComponent(b),"=",d.raw?c:encodeURIComponent(c),d.expires?"; expires="+d.expires.toUTCString():"",d.path?"; path="+d.path:"",d.domain?"; domain="+d.domain:"",d.secure?"; secure":""].join("")}d=c||{};var g=d.raw?function(a){return a}:decodeURIComponent,h=document.cookie.split("; ");for(var i=0,j;j=h[i]&&h[i].split("=");i++)if(g(j[0])===b)return g(j[1]||"");return null}})(jQuery);