-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.eu-cookie-consent.min.js
7 lines (7 loc) · 2.03 KB
/
jquery.eu-cookie-consent.min.js
1
2
3
4
5
6
7
/**
* jQuery EU Cookie Consent v0.9
* https://github.com/dcorb/eu-cookie-consent
* (c) 2016 David Corbacho
* @license MIT
*/
!function(n,t){"use strict";var i=function(e,t,i){return n("<a />",{href:e,text:t,"class":i})[0].outerHTML},o=function(e,i){return e.replace(/\{\{([^}]+)\}\}/g,function(e,o){var c=i[n.trim(o)];return c===t?e:c})};n.EUCookie=function(c){var r,s,a,f=n(document),u=!0,l={message:"This website uses cookies. By using this website we assume you are ok with this.",acceptBtn:"OK",links:[],theme:"dark",expiryDays:365,hideOnScroll:!0,hideOnAnyClick:!0,scrollDelay:3e3,debug:!1,beforeShowFn:function(){return!0},afterShowFn:n.noop};n.extend(l,c);var d={init:function(){if(!s){s=new Date,"undefined"==typeof jQuery.fn.on&&(n.fn.on=jQuery.fn.bind,n.fn.off=jQuery.fn.unbind);var t,i,o=s;try{(a=window.localStorage).setItem(o,o),i=a.getItem(o)!=o,a.removeItem(o),i&&(a=!1)}catch(t){t=e}d.valid()&&l.beforeShowFn(l,a,t)&&(d.show(),f.on("click.EUc",".EUc__btn",d.accept),l.hideOnScroll&&setTimeout(function(){f.on("scroll.EUc",d.accept)},l.scrollDelay),l.hideOnAnyClick&&f.on("click.EUc",d.accept),n(window).on("storage",function(e){"EUcookie"===e.originalEvent.key&&d.accept()}))}},show:function(){var e={link_1:t,link_2:t};n.each(e,function(n){"undefined"!=typeof l.links[n]&&(e[n]=i(l.links.index,l.links[n+"_text"],"EUc__"+n))});var c=i("#",l.acceptBtn,"EUc__btn"),s=c+'<div class="EUc__message">'+o(l.message,e)+"</div>";r=n('<div class="EUc initialEffect '+l.theme+'">'+s+"</div>"),r.appendTo("body"),n.proxy(l.afterShowFn,r)()},valid:function(){var e=!1;if(a){var n=JSON.parse(a.getItem("EUcookie"));e=!n||n&&!!n.stamp&&s.getTime()<n.stamp}return e},accept:function(){u&&(u=!1,f.off("click.EUc scroll.EUc"),d.hide(),d.persist())},hide:function(){r.length&&(r.removeClass("initialEffect"),setTimeout(function(){r.addClass("hideBar")},0),setTimeout(function(){r.remove()},1e3))},persist:function(){a&&!l.debug&&a.setItem("EUcookie",JSON.stringify({stamp:s.toUTCString()}))},destroy:function(){r.remove(),a.removeItem("EUcookie")}};return d}}(jQuery,void 0);