forked from carlwoodhouse/jquery.cookieBar
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.cookieBar.min.js
1 lines (1 loc) · 1.5 KB
/
jquery.cookieBar.min.js
1
(function(e){e.cookie=function(o,i,n){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(i))||null===i||void 0===i)){if(n=e.extend({},n),null!==i&&void 0!==i||(n.expires=-1),"number"==typeof n.expires){var t=n.expires,r=n.expires=new Date;r.setDate(r.getDate()+t)}return i=String(i),document.cookie=[encodeURIComponent(o),"=",n.raw?i:encodeURIComponent(i),n.expires?"; expires="+n.expires.toUTCString():"",n.path?"; path="+n.path:"",n.domain?"; domain="+n.domain:"",n.secure?"; secure":""].join("")}n=i||{};for(var c,s=n.raw?function(e){return e}:decodeURIComponent,a=document.cookie.split("; "),u=0;c=a[u]&&a[u].split("=");u++)if(s(c[0])===o)return s(c[1]||"");return null},e.fn.cookieBar=function(o){var i=e.extend({closeButton:"none",hideOnClose:!0,secure:!1,path:"/",domain:""},o);return this.each(function(){var o=e(this);o.hide(),"none"==i.closeButton&&(o.append('<a class="cookiebar-close">Continue</a>'),e.extend(i,{closeButton:".cookiebar-close"})),"hide"!=e.cookie("cookiebar")&&o.show(),o.find(i.closeButton).click(function(){return i.hideOnClose&&o.hide(),e.cookie("cookiebar","hide",{path:i.path,secure:i.secure,domain:i.domain,expires:30}),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);