-
Notifications
You must be signed in to change notification settings - Fork 38
/
jquery.cookieBar.min.js
1 lines (1 loc) · 1.51 KB
/
jquery.cookieBar.min.js
1
(function(e){e.cookie=function(o,n,i){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(n))||null==n)){if(i=e.extend({},i),null==n&&(i.expires=-1),"number"==typeof i.expires){var t=i.expires,r=i.expires=new Date;r.setDate(r.getDate()+t)}return n=String(n),document.cookie=[encodeURIComponent(o),"=",i.raw?n:encodeURIComponent(n),i.expires?"; expires="+i.expires.toUTCString():"",i.path?"; path="+i.path:"",i.domain?"; domain="+i.domain:"",i.secure?"; secure":""].join("")}i=n||{};for(var s,a=i.raw?function(e){return e}:decodeURIComponent,c=document.cookie.split("; "),u=0;s=c[u]&&c[u].split("=");u++)if(a(s[0])===o)return a(s[1]||"");return null},e.fn.cookieBar=function(o){var n=e.extend({closeButton:"none",hideOnClose:!0,secure:!1,path:"/",domain:"",name:"cookiebar",expiresDays:365},o);return this.each(function(){var o=e(this);o.hide(),"none"==n.closeButton&&(o.append('<a class="cookiebar-close">Continue</a>'),e.extend(n,{closeButton:".cookiebar-close"})),"hide"!=e.cookie(n.name)&&o.show(),o.find(n.closeButton).click(function(){return n.hideOnClose&&o.hide(),e.cookie(n.name,"hide",{path:n.path,secure:n.secure,domain:n.domain,expires:n.expiresDays}),o.trigger("cookieBar-close"),!1})})},e.cookieBar=function(o){e("body").prepend('<div class="ui-widget"><div style="display: none;" class="cookie-message ui-widget-header blue"><p>By using this website you allow us to place cookies on your computer. They are harmless and never personally identify you.</p></div></div>'),e(".cookie-message").cookieBar(o)}})(jQuery);