From ce148f60bab29fdf4834671e1cce9e85967bd814 Mon Sep 17 00:00:00 2001 From: Adam Hutchinson Date: Wed, 7 Sep 2016 17:17:23 +0100 Subject: [PATCH 01/70] Ability to customize locationServices --- build/cookieconsent.min.css | 6 -- build/cookieconsent.min.js | 1 - examples/example-1-themes.html | 2 +- src/cookieconsent.js | 189 ++++++++++++++++++++------------- 4 files changed, 119 insertions(+), 79 deletions(-) delete mode 100644 build/cookieconsent.min.css delete mode 100644 build/cookieconsent.min.js diff --git a/build/cookieconsent.min.css b/build/cookieconsent.min.css deleted file mode 100644 index 2137650b..00000000 --- a/build/cookieconsent.min.css +++ /dev/null @@ -1,6 +0,0 @@ -.cc-window{opacity:1;transition:opacity .5s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)} -.cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} -.cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} -@media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;-ms-grid-row-align:unset;align-items:unset}} -.cc-windowstyle-edgeless.cc-window{padding:0}.cc-floating.cc-windowstyle-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-windowstyle-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-windowstyle-edgeless .cc-message{margin-left:1em}.cc-floating.cc-windowstyle-edgeless .cc-btn+.cc-btn{margin-left:0}.cc-floating.cc-windowstyle-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-windowstyle-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-windowstyle-classic .cc-btn{border-radius:5px}.cc-windowstyle-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-windowstyle-classic .cc-btn{display:inline-block} -.cc-theme-centered-block.cc-window{text-align:center} \ No newline at end of file diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js deleted file mode 100644 index 979115f2..00000000 --- a/build/cookieconsent.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var n=" ";return 1===e.nodeType&&(n+e.className+n).replace(/[\n\t]/g,n).indexOf(n+t+n)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,n){var i=new RegExp("\\b"+t.escapeRegExp(n)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var n=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(n,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,n=t.split("; "+e+"=");return 2!=n.length?void 0:n.pop().split(";").shift()},setCookie:function(e,t,n,i,o){var s=new Date;s.setDate(s.getDate()+(n||365));var a=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];i&&a.push("domain="+i),document.cookie=a.join(";")},deepExtend:function(e,t){for(var n in t){var i=t[n];"object"==typeof i&&null!==i?(e[n]=e[n]||{},this.deepExtend(e[n],i)):e[n]=i}return e},throttle:function(e,t){var n=!1;return function(){n||(e.apply(this,arguments),n=!0,setTimeout(function(){n=!1},t))}},hash:function(e){var t,n,i,o=0;if(0===e.length)return o;for(t=0,i=e.length;t=128?"#000":"#fff"},getLuminance:function(e){if(e=t.validateHex(e),"000000"==e)return"#222";var n,i,o=.2,s="#";for(i=0;i<3;i++)n=parseInt(e.substr(2*i,2),16),n=Math.round(Math.min(Math.max(0,n+n*o),255)).toString(16),s+=("00"+n).substr(n.length);return s},getDirectory:function(){var e,t,n=document.getElementsByTagName("script");for(t=0;t=0;return o&&t(i),o}function r(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",n=["cc-"+t,"cc-type-"+e.type,"cc-windowstyle-"+e.windowstyle];n.push.apply(n,r.call(this));d.call(this,this.options.palette);return this.customStyleSelector&&n.push(this.customStyleSelector),n}function l(){var e={},n=this.options;"false"==n.showlink&&(n.elements.link="",n.elements.messagelink=n.elements.message),Object.keys(n.elements).forEach(function(i){e[i]=t.interpolateString(n.elements[i],function(e){var t=n.content[e];return e&&"string"==typeof t&&t.length?t:""})});var i=n.compliance[n.type];i||(i=n.compliance.info),e.compliance=t.interpolateString(i,function(t){return e[t]});var o=n.layouts[n.layout];return o||(o=n.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function h(e){var n=this.options,i=document.createElement("div"),o=n.container&&1===n.container.nodeType?n.container:document.body;i.innerHTML=e;var s=i.children[0];return s.style.display="none",t.hasClass(s,"cc-window")&&k.call(this)&&t.addClass(s,"cc-invisible"),this.onButtonClick=u.bind(this),s.addEventListener("click",this.onButtonClick),n.autoattach&&(o.firstChild?o.insertBefore(s,o.firstChild):o.appendChild(s)),s}function u(i){var o=i.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+n.join("|")+")\\b")),a=s&&s[1]||!1;a&&(this.setStatus(a),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function d(e){var n=t.hash(JSON.stringify(e)),i="cc-color-override-"+n,o="object"==typeof e&&null!==e;return this.customStyleSelector=o?i:null,o&&p(n,e,"."+i),o}function p(n,i,o){if(e.customStyles[n])return void++e.customStyles[n].references;var s={},a=i.popup,r=i.button,c=i.highlight;a&&(a.text=a.text?a.text:t.getContrast(a.background),a.link=a.link?a.link:a.text,s[o+".cc-window"]=["color: "+a.text,"background-color: "+a.background],s[o+".cc-revoke"]=["color: "+a.text,"background-color: "+a.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+a.link],r&&(r.text=r.text?r.text:t.getContrast(r.background),r.border=r.border?r.border:"transparent",s[o+" .cc-btn"]=["color: "+r.text,"border-color: "+r.border,"background-color: "+r.background],s[o+" .cc-btn:hover"]=["background-color: "+t.getLuminance(r.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+a.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[n]={references:1,element:l.sheet};var h=-1;for(var u in s)l.sheet.insertRule(u+"{"+s[u].join(";")+"}",++h)}function m(n){if("object"==typeof n&&null!==n){var i=t.hash(JSON.stringify(n)),o=e.customStyles[i];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[i]=null}}}function f(e,t){for(var n=0,i=e.length;n=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(n)));var i=this.options.dismissOnScroll;if("number"==typeof i&&i>=0){var o=function(n){window.pageYOffset>Math.floor(i)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=r.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var n=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=h.call(this,n);var i=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var n=!1,o=20,s=window.innerHeight-20;t.hasClass(i,"cc-top")&&e.clientYs&&(n=!0),n?t.hasClass(i,"cc-active")||t.addClass(i,"cc-active"):t.hasClass(i,"cc-active")&&t.removeClass(i,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}function g(e,t){var n=this,i=document.createElement("link"),o=function(e){return function(){t.apply(n,[e].concat(arguments))}};return i.rel="stylesheet",i.type="text/css",i.href=e,i.onload=o(!0),i.onerror=o(!1),document.head.appendChild(i),i}function b(e){if(this.options.pushdown){var t=document.getElementsByTagName("body")[0],n=document.getElementsByClassName("navbar-fixed-top")[0];0!=e?(document.getElementById("wpadminbar")&&(e-=32),k.call(this)&&(t.style.transition="all .4s linear .5s",n&&(n.style.transition="all .4s linear .5s"))):(t.style.transition="none",n&&(n.style.transition="none")),t.style.marginTop=e+"px",n&&(n.style.marginTop=e+"px")}}function k(){return this.options?this.options.transitions&&e.hasTransition:e.hasTransition}var w={cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},enabled:!0,container:null,autoattach:!0,stylesheet:t.getDirectory()+"cookieconsent.min.css",onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},showlink:!0,elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},position:"bottom",type:"info",compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},layout:"basic",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},pushdown:!0,transitions:!0,windowstyle:"block",window:'',revokeBtn:'
Cookie Policy
',revokable:!1,animateRevokable:!0,regionalLaw:!0,countryCode:null,dismissOnScroll:!1,dismissOnTimeout:!1,palette:null,whitelistPage:[],blacklistPage:[],overrideHTML:null};return i.prototype.initialise=function(n){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},w),"object"==typeof n&&null!==n&&t.deepExtend(this.options,n),a.call(this)&&(this.options.enabled=!1),f(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),f(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0),this.options.stylesheet&&(this.waitingForStylesheet=!0,this.requestedTheme=g.call(this,this.options.stylesheet,function(e){this.waitingForStylesheet=!1,this.openAfterStylesheet&&(this.openAfterStylesheet=!1,this.open())}));var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),o=this.options.overrideHTML;return"string"==typeof o&&o.length&&(i=o),this.element=h.call(this,i),e.getCountryOptions(this.options),v.call(this),y.call(this),this},i.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,m(this.options.palette),this.options=null},i.prototype.open=function(e){return this.options.enabled?this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(k.call(this)?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),"top"==this.options.position&&b.call(this,this.element.offsetHeight),this):this},i.prototype.close=function(e){return this.options.enabled?(this.isOpen()&&(k.call(this)?this.fadeOut():this.element.style.display="none",e&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),"top"==this.options.position&&b.call(this,0),this):this},i.prototype.fadeIn=function(){var e=this.element;k.call(this)&&(this.afterTransition&&s.call(this,e),t.hasClass(e,"cc-invisible")&&(e.style.display="",this.openingTimeout=setTimeout(o.bind(this,e),5)))},i.prototype.fadeOut=function(){var e=this.element;k.call(this)&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,e)),t.hasClass(e,"cc-invisible")||(this.afterTransition=s.bind(this,e),e.addEventListener("transitionend",this.afterTransition),t.addClass(e,"cc-invisible")))},i.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!k.call(this)||!t.hasClass(this.element,"cc-invisible"))},i.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},i.prototype.setStatus=function(n){var i=this.options.cookie,o=t.getCookie(i.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(n)>=0?(t.setCookie(i.name,n,i.expiryDays,i.domain,i.path),this.options.onStatusChange(n,s)):this.clearStatus()},i.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},i.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},i}(),e.law=function(){var e=["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK","GB"],t=["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],n=["HR","IT","ES"];return{get:function(i){return{hasLaw:e.indexOf(i)>=0,revokable:t.indexOf(i)>=0,explicitAction:n.indexOf(i)>=0}},applyLaw:function(e,t){var n=this.get(t);return n.hasLaw||(e.enabled=!1),1==e.regionalLaw&&(n.revokable&&(e.revokable=!0),n.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e}}}(),e.locate=function(){function e(){var e=this.currentServiceIndex,n=this.locationServices[e];n&&t(n,o.bind(this))}function t(e,t){var i=this;if(e&&e.url&&e.callback){var o=e.isScript?a:r;o(e.url,function(o){var s=o?o.responseText:"";e.__JSONP_DATA&&(s=e.__JSONP_DATA,delete e.__JSONP_DATA),n.call(i,t,e,s)},e.data,e.headers)}}function n(e,t,n){var o=this,s=t.callback(function(t){s||i.call(o,e,t)},n);s&&i.call(this,e,s)}function i(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)}function o(t,n){var i=this.currentServiceIndex,o=this.locationServices[i];t?(console.log("The service["+i+"] ("+o.url+") responded with the following error",t),this.locationServices[i+1]?(this.currentServiceIndex++,e.call(this)):s.call(this,null,new Error("All services failed"))):s.call(this,n,null)}function s(e,t){this.currentServiceIndex=0,this.onComplete(e,t)}function a(e,t){var n=document.createElement("script");n.type="text/"+(e.type||"javascript"),n.src=e.src||e,n.async=!1,n.onreadystatechange=n.onload=function(){var e=n.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),n=null)},document.body.appendChild(n),n=null}function r(e,t,n,i){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(n?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(i))for(var s=0,a=i.length;s3&&t(o)}),o.send(n)}function c(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}return{currentServiceIndex:0,locationServices:[{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var n=JSON.parse(t);return n.error?c(n):{code:n.country}}},{url:"http://freegeoip.net/json/?callback=cookieconsent.locate.jsonp(1)",isScript:!0,callback:function(e,t){var n=JSON.parse(t);return n.error?c(n):{code:n.country_code}}},{url:"http://js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(c(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}],init:function(t,n){this.onComplete=t,"[object Array]"==Object.prototype.toString.call(n)&&(this.locationServices=this.locationServices.concat(n)),e.call(this)},jsonp:function(e){var t=this.locationServices[e];return function(e){t.__JSONP_DATA=JSON.stringify(e)}}}}(),e.factory=function(t){return popup=new e.Popup(t),popup},e.getCountryOptions=function(t){t.countryCode?e.law.applyLaw(t,t.countryCode):e.locate.init(function(n){e.law.applyLaw(t,n.code)})},e.autoOpen=function(t){var n=e.factory(t),i=n.getStatus();return Object.keys(e.status).indexOf(i)<0&&n.options.enabled&&n.open(),n},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/examples/example-1-themes.html b/examples/example-1-themes.html index 281f005e..134d905e 100644 --- a/examples/example-1-themes.html +++ b/examples/example-1-themes.html @@ -30,7 +30,7 @@

Demo 1 Themes

- + - + + + diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 904d38ac..5351cfa6 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -20,7 +20,7 @@ }, removeClass: function (element, className) { - var regex = new RegExp('\\b' + util.escapeRegExp(className) + '\\b'); + var regex = new RegExp('\\b' + this.escapeRegExp(className) + '\\b'); element.className = element.className.replace(regex, ''); }, @@ -55,17 +55,15 @@ }, // only used for extending the initial options - deepExtend: function(dest, src) { - for (var prop in src) { - var v = src[prop]; - if (typeof v === 'object' && v !== null) { - dest[prop] = dest[prop] || {}; - this.deepExtend(dest[prop], v); + deepExtend: function(target, source) { + for (var prop in source) { + if (prop in target && this.isPlainObject(target[prop]) && this.isPlainObject(source[prop])) { + this.deepExtend(target[prop], source[prop]); } else { - dest[prop] = v; + target[prop] = source[prop]; } } - return dest; + return target; }, // only used for throttling the 'mousemove' event (used for animating the revoke button when `animateRevokable` is true) @@ -104,7 +102,7 @@ // used to get text colors if not set getContrast: function (hex){ - hex = util.validateHex(hex); + hex = this.validateHex(hex); var r = parseInt(hex.substr(0,2),16); var g = parseInt(hex.substr(2,2),16); var b = parseInt(hex.substr(4,2),16); @@ -114,7 +112,7 @@ // used to change color on highlight getLuminance: function(hex) { - hex = util.validateHex(hex); + hex = this.validateHex(hex); if (hex=='000000') return '#222'; //for black buttons var lum = 0.2; var rgb = "#", c, i; @@ -143,9 +141,9 @@ }, isPlainObject: function(obj) { - return typeof obj === 'object' && obj !== null; - } - + // The code "typeof obj === 'object' && obj !== null" allows Array objects + return typeof obj === 'object' && obj !== null && obj.constructor == Object; + }, }; // valid cookie values @@ -341,6 +339,8 @@ // Be sure to use the classes `cc-btn` and `cc-allow`, `cc-deny` or `cc-dismiss`. They enable the app to register click // handlers. You can use other pre-existing classes too. See `src/styles` folder. overrideHTML: null, + + autoOpen: true, }; function CookiePopup () { @@ -378,9 +378,8 @@ this.options.enabled = true; } - - // load stylesheet - if (this.options.stylesheet) { + // load stylesheet + /*if (this.options.stylesheet) { this.waitingForStylesheet = true; this.requestedTheme = loadStyles.call(this, this.options.stylesheet, function (success) { this.waitingForStylesheet = false; @@ -389,7 +388,7 @@ this.open(); } }); - } + }*/ // the full markup either contains the wrapper or it does not (for multiple instances) var cookiePopup = this.options.window @@ -409,7 +408,9 @@ applyRevokeButton.call(this); - return this; + if (this.options.autoOpen) { + this.autoOpen(); + } }; CookiePopup.prototype.destroy = function () { @@ -538,7 +539,7 @@ if (!util.hasClass(el, 'cc-invisible')) { this.afterTransition = afterFadeOut.bind(this, el); - el.addEventListener('transitionend', this.afterTransition); + el.addEventListener(cc.transitionEnd, this.afterTransition); util.addClass(el, 'cc-invisible'); } @@ -550,7 +551,15 @@ CookiePopup.prototype.toggleRevokeButton = function (show) { if (this.revokeBtn) this.revokeBtn.style.display = show ? '' : 'none'; - }; + }; + + CookiePopup.prototype.hasConsented = function (options) { + return Object.keys(cc.status).indexOf(this.getStatus()) >= 0; + }; + + CookiePopup.prototype.autoOpen = function (options) { + !this.hasConsented() && this.open(); + }; CookiePopup.prototype.setStatus = function (status) { var c = this.options.cookie; @@ -588,7 +597,7 @@ // is not called (lack of support), the open/close mechanism will still work. function afterFadeOut (el) { el.style.display = 'none'; // after close and before open, the display should be none - el.removeEventListener('transitionend', this.afterTransition); + el.removeEventListener(cc.transitionEnd, this.afterTransition); this.afterTransition = null; } @@ -976,59 +985,10 @@ return CookiePopup }()); - cc.law = (function () { - - var hasLaw = ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'GB', 'UK', 'GB']; - var revokable = ['HR', 'CY', 'DK', 'EE', 'FR', 'DE', 'LV', 'LT', 'NL', 'PT', 'ES']; - var explicitAction = ['HR', 'IT', 'ES']; - - return { - - get: function (countryCode) { - return { - hasLaw: hasLaw.indexOf(countryCode) >= 0, - revokable: revokable.indexOf(countryCode) >= 0, - explicitAction: explicitAction.indexOf(countryCode) >= 0, - }; - }, - - applyLaw: function (options, countryCode) { - var country = this.get(countryCode); - - if (!country.hasLaw) { - // The country has no cookie law - options.enabled = false; - } - - if(options.regionalLaw == true) { - if (country.revokable) { - // we must provide an option to revoke consent at a later time - options.revokable = true; - } - - if (country.explicitAction) { - // user must explicitly click the consent button - options.dismissOnScroll = false; - options.dismissOnTimeout = false; - } - - } - return options; - } - }; - }()); - - cc.Locate = (function () { + cc.Location = (function () { var defaultOptions = { - locationServices: [ - 'freegeoip', - function(cb) { - cb('I failed lol'); - }, - {name: 'ipinfo', PUBLIC_KEY: 1}, - 'freegeoip', 'maxmind' - ] + services: ['freegeoip', 'ipinfo', 'maxmind'] }; // An object containing all the location services we have already set up. @@ -1092,29 +1052,27 @@ } } } - } + }; - function Location(options, onComplete) { + function Location(options) { // Set up options util.deepExtend(this.options = {}, defaultOptions); + if (util.isPlainObject(options)) { util.deepExtend(this.options, options); } - this.onComplete = onComplete; this.currentServiceIndex = 0; // the index (in options) of the service we're currently using - - this.runServices(); } Location.prototype.getServiceByIdx = function(idx) { // This can either be the name of a default locationService, or a function. - var serviceOption = this.options.locationServices[idx]; + var serviceOption = this.options.services[idx]; // User can provide their own servives as functions. if (typeof serviceOption === 'function') return serviceOption; - // If it's a string, use one of the locationServices. + // If it's a string, use one of the location services. if (typeof serviceOption === 'string') return locationServices[serviceOption](); // If it's an object, assume {name: 'ipinfo', ...otherOptions} @@ -1122,25 +1080,31 @@ if (util.isPlainObject(serviceOption)) { return locationServices[serviceOption.name](serviceOption); } - } + }; Location.prototype.getCurrentService = function() { var idx = this.currentServiceIndex; return this.getServiceByIdx(idx); - } + }; // This runs the service located at index `currentServiceIndex`. // If the service fails, `runNextServiceOnError` will continue trying each service until all fail, or one completes successfully - Location.prototype.runServices = function() { + Location.prototype.locate = function () { + var self = this; var service = this.getCurrentService(); if (!service) { return; } - // runs service[idx] and triggers the callback on complete - this.runService(service, this.runNextServiceOnError.bind(this)); - } + return new Promise(function (resolve, reject) { + self.resolvePromise = resolve; + self.rejectPromise = reject; + + // runs service[idx] and triggers the callback on complete + self.runService(service, self.runNextServiceOnError.bind(self)); + }); + }; // Potentially adds a callback to a url for jsonp. Location.prototype.setupUrl = function (service) { @@ -1153,7 +1117,7 @@ return tempName; } }); - } + }; // requires a `service` object that defines at least a `url` and `callback` Location.prototype.runService = function(service, complete) { @@ -1191,7 +1155,7 @@ }, service.data, service.headers); // `service.data` and `service.headers` are optional (they only count if `!service.isScript` anyway) - } + }; // The service request has run (and possibly has a `responseText`) [no `responseText` if `isScript`] // We need to run it's callback which determines if its successful or not @@ -1212,7 +1176,7 @@ if (result) { this.onServiceResult.call(this, complete, result); } - } + }; // This is called with the `result` from `service.callback` regardless of how it provided that result (sync or async). // `result` will be whatever is returned from `service.callback`. A service callback should provide an object with data @@ -1223,7 +1187,7 @@ } else { complete.call(this, null, result); } - } + }; // if `err` is set, the next service handler is called // if `err` is null, the `onComplete` handler is called with `data` @@ -1238,21 +1202,30 @@ if (this.options.locationServices[idx + 1]) { // an error occurred, try the next service this.currentServiceIndex++; - this.runServices.call(this); + + var self = this; + var service = this.getCurrentService(); + + if (!service) { + self.rejectPromise(new Error('Ran out of services to try')); + return; + } + + self.runService(service, self.runNextServiceOnError.bind(self)); } else { this.completeService.call(this, null, new Error('All services failed')); } } else { this.completeService.call(this, data, null); } - } + }; // calls the `onComplete` callback after resetting the `currentServiceIndex` Location.prototype.completeService = function (data, error) { this.currentServiceIndex = 0; - this.onComplete && this.onComplete(data, error); - } + this.resolveProimise && this.resolvePromise(data, error); + }; function getScript (url, callback) { var s = document.createElement('script'); @@ -1307,32 +1280,100 @@ return Location; }()); - cc.factory = function (options) { - options = cc.getCountryOptions(options); - return new cc.Popup(options); - }; + cc.Law = (function () { - // Mutates options based on country requirements. - cc.getCountryOptions = function (options) { - if(options.countryCode) { - cc.law.applyLaw(options, options.countryCode); - return; - } + var defaultOptions = { + hasLaw: ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'GB', 'UK'], + revokable: ['HR', 'CY', 'DK', 'EE', 'FR', 'DE', 'LV', 'LT', 'NL', 'PT', 'ES', 'GB'], + explicitAction: ['HR', 'IT', 'ES'], + }; + + function Law (options) { + this.initialise.apply(this, arguments); + } + + Law.prototype.initialise = function (options) { + // set options back to default options + util.deepExtend(this.options = {}, defaultOptions); + + // merge in user options + if (util.isPlainObject(options)) { + util.deepExtend(this.options, options); + } + }; + + Law.prototype.get = function (countryCode) { + var opts = this.options; + return { + hasLaw: opts.hasLaw.indexOf(countryCode) >= 0, + revokable: opts.revokable.indexOf(countryCode) >= 0, + explicitAction: opts.explicitAction.indexOf(countryCode) >= 0, + }; + }; + + Law.prototype.applyLaw = function (options, countryCode) { + var country = this.get(countryCode); - new cc.Locate(options, function (result) { - cc.law.applyLaw(options, result.code); + if (!country.hasLaw) { + // The country has no cookie law + options.enabled = false; + } + + if(options.regionalLaw == true) { + if (country.revokable) { + // We must provide an option to revoke consent at a later time + options.revokable = true; + } + + if (country.explicitAction) { + // The user must explicitly click the consent button + options.dismissOnScroll = false; + options.dismissOnTimeout = false; + } + } + return options; + }; + + return Law; + }()); + + cc.initialise = function (options) { + var law = new cc.Law(options.law); + return new Promise(function (resolve, reject) { + cc.getCountryCode( + options, + function (result) { + + // don't need the law or location options anymore + delete options.law; + delete options.location; + + if (result.code) { + options = law.applyLaw(options, result.code); + } + + resolve(new cc.Popup(options)); + }, + function (err) { + reject(err); + } + ); }); }; - // only open if the user hasnt answered - cc.autoOpen = function (options) { - var popup = cc.factory(options); - - var status = popup.getStatus(); - if (Object.keys(cc.status).indexOf(status) < 0 && popup.options.enabled) { - popup.open(); + cc.getCountryCode = function (options, cb) { + if (options.law && options.law.countryCode) { + cb({code: options.law.countryCode}); + return; + } + if (options.location) { + var locator = new cc.Location(options.location); + locator.locate(function (serviceResult) { + cb(serviceResult || {}); + }); + return; } - return popup; + cb({}); }; // export utils (no point in hiding them, so we may as well expose them) From a42a29236455e26a9c1ce8fc962aa4f5766096b8 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 9 Sep 2016 16:23:06 +0100 Subject: [PATCH 07/70] the 'initialise' function now returns a promise --- src/cookieconsent.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 5351cfa6..62af1b8d 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -1202,29 +1202,20 @@ if (this.options.locationServices[idx + 1]) { // an error occurred, try the next service this.currentServiceIndex++; - - var self = this; - var service = this.getCurrentService(); - - if (!service) { - self.rejectPromise(new Error('Ran out of services to try')); - return; - } - - self.runService(service, self.runNextServiceOnError.bind(self)); + this.runService(this.getCurrentService(), this.runNextServiceOnError.bind(this)); } else { - this.completeService.call(this, null, new Error('All services failed')); + this.completeService.call(this, this.rejectPromise, new Error('All services failed')); } } else { - this.completeService.call(this, data, null); + this.completeService.call(this, this.resolvePromise, data); } }; // calls the `onComplete` callback after resetting the `currentServiceIndex` - Location.prototype.completeService = function (data, error) { + Location.prototype.completeService = function (fn, data) { this.currentServiceIndex = 0; - this.resolveProimise && this.resolvePromise(data, error); + fn && fn(data); }; function getScript (url, callback) { @@ -1284,7 +1275,7 @@ var defaultOptions = { hasLaw: ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'GB', 'UK'], - revokable: ['HR', 'CY', 'DK', 'EE', 'FR', 'DE', 'LV', 'LT', 'NL', 'PT', 'ES', 'GB'], + revokable: ['HR', 'CY', 'DK', 'EE', 'FR', 'DE', 'LV', 'LT', 'NL', 'PT', 'ES'], explicitAction: ['HR', 'IT', 'ES'], }; From 113296f5f5e914c9904183cb1489a595c3e38cdd Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 9 Sep 2016 16:57:04 +0100 Subject: [PATCH 08/70] fixed example pages --- build/cookieconsent.min.js | 2 +- examples/example-1-themes.html | 1 + examples/example-2-custom-theme.html | 1 + examples/example-3-informational.html | 1 + examples/example-4-opt-out.html | 1 + examples/example-5-opt-in.html | 1 + examples/example-6-location.html | 27 ++++++++++++++++---------- examples/example-7-javascript-api.html | 11 +++++++++-- examples/script.js | 17 +++++++++------- 9 files changed, 42 insertions(+), 20 deletions(-) diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js index 24cdbd0a..d51e985c 100644 --- a/build/cookieconsent.min.js +++ b/build/cookieconsent.min.js @@ -1 +1 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i];return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},getLuminance:function(e){if(e=this.validateHex(e),"000000"==e)return"#222";var t,i,n=.2,o="#";for(i=0;i<3;i++)t=parseInt(e.substr(2*i,2),16),t=Math.round(Math.min(Math.max(0,t+t*n),255)).toString(16),o+=("00"+t).substr(t.length);return o},getDirectory:function(){var e,t,i=document.getElementsByTagName("script");for(t=0;t=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-windowstyle-"+e.windowstyle];i.push.apply(i,a.call(this));d.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;"false"==i.showlink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(e){var i=this.options,n=document.createElement("div"),o=i.container&&1===i.container.nodeType?i.container:document.body;n.innerHTML=e;var s=n.children[0];return s.style.display="none",t.hasClass(s,"cc-window")&&y.call(this)&&t.addClass(s,"cc-invisible"),this.onButtonClick=h.bind(this),s.addEventListener("click",this.onButtonClick),i.autoattach&&(o.firstChild?o.insertBefore(s,o.firstChild):o.appendChild(s)),s}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function d(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&p(i,e,"."+n),o}function p(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+t.getLuminance(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function v(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function b(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}function g(e){if(this.options.pushdown){var t=document.getElementsByTagName("body")[0],i=document.getElementsByClassName("navbar-fixed-top")[0];0!=e?(document.getElementById("wpadminbar")&&(e-=32),y.call(this)&&(t.style.transition="all .4s linear .5s",i&&(i.style.transition="all .4s linear .5s"))):(t.style.transition="none",i&&(i.style.transition="none")),t.style.marginTop=e+"px",i&&(i.style.marginTop=e+"px")}}function y(){return this.options?this.options.transitions&&e.hasTransition:e.hasTransition}var k={cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},enabled:!0,container:null,autoattach:!0,stylesheet:t.getDirectory()+"cookieconsent.min.css",onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},showlink:!0,elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},position:"bottom",type:"info",compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},layout:"basic",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},pushdown:!0,transitions:!0,windowstyle:"block",window:'',revokeBtn:'
Cookie Policy
',revokable:!1,animateRevokable:!0,regionalLaw:!0,countryCode:null,dismissOnScroll:!1,dismissOnTimeout:!1,palette:null,whitelistPage:[],blacklistPage:[],overrideHTML:null,autoOpen:!0};return n.prototype.initialise=function(e){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},k),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),v(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),v(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;"string"==typeof n&&n.length&&(i=n),this.element=u.call(this,i),m.call(this),b.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,f(this.options.palette),this.options=null},n.prototype.open=function(e){return this.options.enabled?this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(y.call(this)?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),"top"==this.options.position&&g.call(this,this.element.offsetHeight),this):this},n.prototype.close=function(e){return this.options.enabled?(this.isOpen()&&(y.call(this)?this.fadeOut():this.element.style.display="none",e&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),"top"==this.options.position&&g.call(this,0),this):this},n.prototype.fadeIn=function(){var e=this.element;y.call(this)&&(this.afterTransition&&s.call(this,e),t.hasClass(e,"cc-invisible")&&(e.style.display="",this.openingTimeout=setTimeout(o.bind(this,e),5)))},n.prototype.fadeOut=function(){var i=this.element;y.call(this)&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!y.call(this)||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(){var e=this,t=this.getCurrentService();if(t)return new Promise(function(i,n){e.resolvePromise=i,e.rejectPromise=n,e.runService(t,e.runNextServiceOnError.bind(e))})},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;if(e)if(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]){this.currentServiceIndex++;var o=this,i=this.getCurrentService();if(!i)return void o.rejectPromise(new Error("Ran out of services to try"));o.runService(i,o.runNextServiceOnError.bind(o))}else this.completeService.call(this,null,new Error("All services failed"));else this.completeService.call(this,t,null)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,this.resolveProimise&&this.resolvePromise(e,t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES","GB"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),1==e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t){var i=new e.Law(t.law);return new Promise(function(n,o){e.getCountryCode(t,function(o){delete t.law,delete t.location,o.code&&(t=i.applyLaw(t,o.code)),n(new e.Popup(t))},function(e){o(e)})})},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file +!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i];return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},getLuminance:function(e){if(e=this.validateHex(e),"000000"==e)return"#222";var t,i,n=.2,o="#";for(i=0;i<3;i++)t=parseInt(e.substr(2*i,2),16),t=Math.round(Math.min(Math.max(0,t+t*n),255)).toString(16),o+=("00"+t).substr(t.length);return o},getDirectory:function(){var e,t,i=document.getElementsByTagName("script");for(t=0;t=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-windowstyle-"+e.windowstyle];i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;"false"==i.showlink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(e){var i=this.options,n=document.createElement("div"),o=i.container&&1===i.container.nodeType?i.container:document.body;n.innerHTML=e;var s=n.children[0];return s.style.display="none",t.hasClass(s,"cc-window")&&y.call(this)&&t.addClass(s,"cc-invisible"),this.onButtonClick=h.bind(this),s.addEventListener("click",this.onButtonClick),i.autoattach&&(o.firstChild?o.insertBefore(s,o.firstChild):o.appendChild(s)),s}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+t.getLuminance(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function v(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function b(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}function g(e){if(this.options.pushdown){var t=document.getElementsByTagName("body")[0],i=document.getElementsByClassName("navbar-fixed-top")[0];0!=e?(document.getElementById("wpadminbar")&&(e-=32),y.call(this)&&(t.style.transition="all .4s linear .5s",i&&(i.style.transition="all .4s linear .5s"))):(t.style.transition="none",i&&(i.style.transition="none")),t.style.marginTop=e+"px",i&&(i.style.marginTop=e+"px")}}function y(){return this.options?this.options.transitions&&e.hasTransition:e.hasTransition}var k={cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},enabled:!0,container:null,autoattach:!0,stylesheet:t.getDirectory()+"cookieconsent.min.css",onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},showlink:!0,elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},position:"bottom",type:"info",compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},layout:"basic",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},pushdown:!0,transitions:!0,windowstyle:"block",window:'',revokeBtn:'
Cookie Policy
',revokable:!1,animateRevokable:!0,regionalLaw:!0,countryCode:null,dismissOnScroll:!1,dismissOnTimeout:!1,palette:null,whitelistPage:[],blacklistPage:[],overrideHTML:null,autoOpen:!0};return n.prototype.initialise=function(e){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},k),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),v(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),v(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;"string"==typeof n&&n.length&&(i=n),this.element=u.call(this,i),m.call(this),b.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,f(this.options.palette),this.options=null},n.prototype.open=function(e){return this.options.enabled?this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(y.call(this)?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),"top"==this.options.position&&g.call(this,this.element.offsetHeight),this):this},n.prototype.close=function(e){return this.options.enabled?(this.isOpen()&&(y.call(this)?this.fadeOut():this.element.style.display="none",e&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),"top"==this.options.position&&g.call(this,0),this):this},n.prototype.fadeIn=function(){var e=this.element;y.call(this)&&(this.afterTransition&&s.call(this,e),t.hasClass(e,"cc-invisible")&&(e.style.display="",this.openingTimeout=setTimeout(o.bind(this,e),5)))},n.prototype.fadeOut=function(){var i=this.element;y.call(this)&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!y.call(this)||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(){var e=this,t=this.getCurrentService();if(t)return new Promise(function(i,n){e.resolvePromise=i,e.rejectPromise=n,e.runService(t,e.runNextServiceOnError.bind(e))})},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.rejectPromise,new Error("All services failed"))):this.completeService.call(this,this.resolvePromise,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),1==e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t){var i=new e.Law(t.law);return new Promise(function(n,o){e.getCountryCode(t,function(o){delete t.law,delete t.location,o.code&&(t=i.applyLaw(t,o.code)),n(new e.Popup(t))},function(e){o(e)})})},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/examples/example-1-themes.html b/examples/example-1-themes.html index 281f005e..50623a10 100644 --- a/examples/example-1-themes.html +++ b/examples/example-1-themes.html @@ -8,6 +8,7 @@ Demo 1 - Themes + diff --git a/examples/example-2-custom-theme.html b/examples/example-2-custom-theme.html index 99ae9aa8..5406558e 100644 --- a/examples/example-2-custom-theme.html +++ b/examples/example-2-custom-theme.html @@ -8,6 +8,7 @@ Demo 2 - Custom CSS + diff --git a/examples/example-3-informational.html b/examples/example-3-informational.html index 8a993655..4bd52b71 100644 --- a/examples/example-3-informational.html +++ b/examples/example-3-informational.html @@ -8,6 +8,7 @@ Demo 3 - Informational + diff --git a/examples/example-4-opt-out.html b/examples/example-4-opt-out.html index 2001c1d8..09fe8511 100644 --- a/examples/example-4-opt-out.html +++ b/examples/example-4-opt-out.html @@ -8,6 +8,7 @@ Demo 4 - Opt-out + diff --git a/examples/example-5-opt-in.html b/examples/example-5-opt-in.html index 2c0e4f2f..4d056e48 100644 --- a/examples/example-5-opt-in.html +++ b/examples/example-5-opt-in.html @@ -8,6 +8,7 @@ Demo 5 - Opt-in + diff --git a/examples/example-6-location.html b/examples/example-6-location.html index da35830d..eb515740 100644 --- a/examples/example-6-location.html +++ b/examples/example-6-location.html @@ -8,6 +8,7 @@ Demo 6 - Location + -
From 32298b628b9ae8f72ac722e24434f27256c93d1c Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Wed, 14 Sep 2016 17:20:23 +0100 Subject: [PATCH 24/70] remove promisey looking code --- src/cookieconsent.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index aa8bf131..3ed1ae94 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -990,7 +990,7 @@ // This runs the service located at index `currentServiceIndex`. // If the service fails, `runNextServiceOnError` will continue trying each service until all fail, or one completes successfully - Location.prototype.locate = function (resolve, reject) { + Location.prototype.locate = function (complete, error) { var self = this; var service = this.getCurrentService(); @@ -998,8 +998,8 @@ return; } - self.resolvePromise = resolve; - self.rejectPromise = reject; + self.callbackComplete = complete; + self.callbackError = error; self.runService(service, self.runNextServiceOnError.bind(self)); }; @@ -1102,10 +1102,10 @@ this.currentServiceIndex++; this.runService(this.getCurrentService(), this.runNextServiceOnError.bind(this)); } else { - this.completeService.call(this, this.rejectPromise, new Error('All services failed')); + this.completeService.call(this, this.callbackError, new Error('All services failed')); } } else { - this.completeService.call(this, this.resolvePromise, data); + this.completeService.call(this, this.callbackComplete, data); } }; @@ -1228,7 +1228,7 @@ // This function initialises the app by combining the use of the Popup, Locator and Law modules // You can string together these three modules yourself however you want, by writing a new function. - cc.initialise = function (options, resolve, reject) { + cc.initialise = function (options, complete, error) { var law = new cc.Law(options.law); cc.getCountryCode(options, function (result) { // don't need the law or location options anymore @@ -1239,8 +1239,8 @@ options = law.applyLaw(options, result.code); } - resolve(new cc.Popup(options)); - }, reject); + complete(new cc.Popup(options)); + }, error); }; // This function tries to find your current location. It either grabs it from a hardcoded option in From b55b72443ec5b986b07ca7e39182fcccaa9310a8 Mon Sep 17 00:00:00 2001 From: Piiu Date: Wed, 14 Sep 2016 17:27:51 +0100 Subject: [PATCH 25/70] new function for getting luminance --- src/cookieconsent.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index cbf5c740..10c447e7 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -114,16 +114,13 @@ // used to change color on highlight getLuminance: function(hex) { - hex = util.validateHex(hex); - if (hex=='000000') return '#222'; //for black buttons - var lum = 0.2; - var rgb = "#", c, i; - for (i = 0; i < 3; i++) { - c = parseInt(hex.substr(i*2,2), 16); - c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); - rgb += ("00"+c).substr(c.length); - } - return rgb; + var num = parseInt(this.validateHex(hex),16), + amt = 38, + R = (num >> 16) + amt, + B = (num >> 8 & 0x00FF) + amt, + G = (num & 0x0000FF) + amt; + var newColour = (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1); + return '#'+newColour; }, // getting the directory of JavaScript file @@ -796,9 +793,11 @@ 'border-color: '+button.border, 'background-color: '+button.background ]; - colorStyles[prefix + ' .cc-btn:hover'] = [ - 'background-color: ' + util.getLuminance(button.background) - ]; + + if(button.background != 'transparent') + colorStyles[prefix + ' .cc-btn:hover'] = [ + 'background-color: ' + util.getLuminance(button.background) + ]; if (highlight) { //assumes highlight.background is set From 9133bf87d1b86a8f62563ddd34a67a3720589b98 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 11:42:11 +0100 Subject: [PATCH 26/70] 'normalise' implies that the arguments are changed --- src/cookieconsent.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 3ed1ae94..c5ff7e50 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -92,9 +92,11 @@ return hash; }, - validateHex: function(hex) { - hex = hex.substr(1); - if (hex.length < 6) { + normaliseHex: function(hex) { + if (hex[0] == '#') { + hex = hex.substr(1); + } + if (hex.length == 3) { hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]; } return hex; @@ -102,7 +104,7 @@ // used to get text colors if not set getContrast: function (hex){ - hex = this.validateHex(hex); + hex = this.normaliseHex(hex); var r = parseInt(hex.substr(0,2),16); var g = parseInt(hex.substr(2,2),16); var b = parseInt(hex.substr(4,2),16); @@ -112,7 +114,7 @@ // used to change color on highlight getLuminance: function(hex) { - hex = this.validateHex(hex); + hex = this.normaliseHex(hex); if (hex=='000000') return '#222'; //for black buttons var lum = 0.2; var rgb = "#", c, i; From b82041b7f2569b8c489dc390b97a13a56a537a7b Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 12:00:22 +0100 Subject: [PATCH 27/70] made getLuminance more like a util function --- src/cookieconsent.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index c5ff7e50..4a6c8ce4 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -113,11 +113,9 @@ }, // used to change color on highlight - getLuminance: function(hex) { - hex = this.normaliseHex(hex); - if (hex=='000000') return '#222'; //for black buttons - var lum = 0.2; + alterLuminance: function(hex, lum) { var rgb = "#", c, i; + hex = this.normaliseHex(hex); for (i = 0; i < 3; i++) { c = parseInt(hex.substr(i*2,2), 16); c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); @@ -753,7 +751,7 @@ 'background-color: '+button.background ]; colorStyles[prefix + ' .cc-btn:hover'] = [ - 'background-color: ' + util.getLuminance(button.background) + 'background-color: ' + getHoverColour(button.background) ]; if (highlight) { @@ -788,6 +786,15 @@ } } + function getHoverColour(hex) { + hex = util.normaliseHex(hex); + // for black buttons + if (hex == '000000') { + return '#222'; + } + return util.alterLuminance(hex, 0.2); + } + function removeCustomStyle (palette) { if (util.isPlainObject(palette)) { var hash = util.hash(JSON.stringify(palette)); From c0b1c09f1bbec173f65ec31bf3e7716aaa4bdcf2 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 12:09:02 +0100 Subject: [PATCH 28/70] we already had a mechanism for theming that wasn't being used, so I changed the name of the variable --- src/cookieconsent.js | 9 ++-- src/styles/themes/classic.css | 23 +++++++++ src/styles/themes/edgeless.css | 24 ++++++++++ .../themes/example-centered-floating.css | 4 -- src/styles/windowstyles.css | 48 ------------------- 5 files changed, 52 insertions(+), 56 deletions(-) create mode 100644 src/styles/themes/classic.css create mode 100644 src/styles/themes/edgeless.css delete mode 100644 src/styles/themes/example-centered-floating.css delete mode 100644 src/styles/windowstyles.css diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 4a6c8ce4..1872efa6 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -260,11 +260,12 @@ // -block (default, no extra classes) // -edgeless // -classic - // use your own style name and use .cc-style-STYLENAME class in CSS to edit . + // use your own style name and use `.cc-theme-STYLENAME` class in CSS to edit . // Note: style "wire" is used for the configurator, but has no CSS styles of it's own, only palette is used. - windowstyle: 'block', + theme: 'block', - // if you want custom colours, pass them in here. this object should look like this + // if you want custom colours, pass them in here. this object should look like this. + // ideally, any custom colours/themes should be created in a separate style sheet, as this is more efficient. // { // popup: {background: '#000000', text: '#fff', link: '#fff'}, // button: {background: 'transparent', border: '#f8e71c', text: '#f8e71c'}, @@ -586,7 +587,7 @@ var classes = [ 'cc-' + positionStyle, // floating or banner 'cc-type-' + opts.type, // add the compliance type - 'cc-windowstyle-' + opts.windowstyle, // add the windwowstyle class + 'cc-theme-' + opts.theme, // add the windwowstyle class ]; classes.push.apply(classes, getPositionClasses.call(this)); diff --git a/src/styles/themes/classic.css b/src/styles/themes/classic.css new file mode 100644 index 00000000..cf3b51a4 --- /dev/null +++ b/src/styles/themes/classic.css @@ -0,0 +1,23 @@ +/* Classic */ + +.cc-floating.cc-theme-classic { + padding: 1.2em; + border-radius: 5px; +} + +.cc-floating.cc-type-info.cc-theme-classic .cc-compliance { + text-align: center; + display: inline; + flex: none; +} + +.cc-theme-classic .cc-btn { + border-radius: 5px; +} +.cc-theme-classic .cc-btn:last-child { + min-width: 140px; +} + +.cc-floating.cc-type-info.cc-theme-classic .cc-btn { + display: inline-block; +} diff --git a/src/styles/themes/edgeless.css b/src/styles/themes/edgeless.css new file mode 100644 index 00000000..e575afa8 --- /dev/null +++ b/src/styles/themes/edgeless.css @@ -0,0 +1,24 @@ +/* Edgeless */ + +.cc-theme-edgeless.cc-window { + padding: 0; +} + +.cc-floating.cc-theme-edgeless .cc-message { + margin: 2em; + margin-bottom: 1.5em; +} + +.cc-banner.cc-theme-edgeless .cc-btn { + margin: 0; + padding: .8em 1.8em; + height: 100%; +} + +.cc-banner.cc-theme-edgeless .cc-message { + margin-left: 1em; +} + +.cc-floating.cc-theme-edgeless .cc-btn +.cc-btn { + margin-left: 0; +} diff --git a/src/styles/themes/example-centered-floating.css b/src/styles/themes/example-centered-floating.css deleted file mode 100644 index a2b2bdd1..00000000 --- a/src/styles/themes/example-centered-floating.css +++ /dev/null @@ -1,4 +0,0 @@ - -.cc-theme-centered-block.cc-window { - text-align: center -} diff --git a/src/styles/windowstyles.css b/src/styles/windowstyles.css deleted file mode 100644 index 1ce4d8fb..00000000 --- a/src/styles/windowstyles.css +++ /dev/null @@ -1,48 +0,0 @@ -/* Edgeless */ - -.cc-windowstyle-edgeless.cc-window { - padding: 0; -} - -.cc-floating.cc-windowstyle-edgeless .cc-message { - margin: 2em; - margin-bottom: 1.5em; -} - -.cc-banner.cc-windowstyle-edgeless .cc-btn { - margin: 0; - padding: .8em 1.8em; - height: 100%; -} - -.cc-banner.cc-windowstyle-edgeless .cc-message { - margin-left: 1em; -} - -.cc-floating.cc-windowstyle-edgeless .cc-btn +.cc-btn { - margin-left: 0; -} - -/* Classic */ - -.cc-floating.cc-windowstyle-classic { - padding: 1.2em; - border-radius: 5px; -} - -.cc-floating.cc-type-info.cc-windowstyle-classic .cc-compliance { - text-align: center; - display: inline; - flex: none; -} - -.cc-windowstyle-classic .cc-btn { - border-radius: 5px; -} -.cc-windowstyle-classic .cc-btn:last-child { - min-width: 140px; -} - -.cc-floating.cc-type-info.cc-windowstyle-classic .cc-btn { - display: inline-block; -} From b5ff96ff7d6c0d117e0d69f1f0ed14975a4b2df0 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 12:35:42 +0100 Subject: [PATCH 29/70] modified example configuration --- examples/example-1-themes.html | 4 ++-- gulpfile.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/example-1-themes.html b/examples/example-1-themes.html index 50623a10..1cc69879 100644 --- a/examples/example-1-themes.html +++ b/examples/example-1-themes.html @@ -73,7 +73,7 @@

Demo 1 Themes

'Nuclear': { type: 'info', position: 'bottom-right', - windowstyle: "edgeless", + theme: "edgeless", palette: palettes.nuclear, content: { "dismiss": "I accept certain doom" @@ -86,7 +86,7 @@

Demo 1 Themes

}, 'Neon': { type: 'info', - windowstyle: "classic", + theme: "classic", position: 'bottom-left', palette: palettes.neon, }, diff --git a/gulpfile.js b/gulpfile.js index 229cc696..1af4fe31 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,6 @@ var cssBuildFiles = [ './src/styles/base.css', './src/styles/layout.css', './src/styles/media.css', - './src/styles/windowstyles.css', // all theme files './src/styles/themes/*.css', From 94e8c38764e87765be0b2fab3b22e9846245cd49 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 13:41:23 +0100 Subject: [PATCH 30/70] added onInitialise function, rather than calling onStatusChange for two different types of callback --- build/cookieconsent.min.css | 4 ++-- build/cookieconsent.min.js | 2 +- src/cookieconsent.js | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build/cookieconsent.min.css b/build/cookieconsent.min.css index 2137650b..ed5b17da 100644 --- a/build/cookieconsent.min.css +++ b/build/cookieconsent.min.css @@ -2,5 +2,5 @@ .cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} .cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} @media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;-ms-grid-row-align:unset;align-items:unset}} -.cc-windowstyle-edgeless.cc-window{padding:0}.cc-floating.cc-windowstyle-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-windowstyle-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-windowstyle-edgeless .cc-message{margin-left:1em}.cc-floating.cc-windowstyle-edgeless .cc-btn+.cc-btn{margin-left:0}.cc-floating.cc-windowstyle-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-windowstyle-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-windowstyle-classic .cc-btn{border-radius:5px}.cc-windowstyle-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-windowstyle-classic .cc-btn{display:inline-block} -.cc-theme-centered-block.cc-window{text-align:center} \ No newline at end of file +.cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block} +.cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0} \ No newline at end of file diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js index 2daa62ec..a3bf7577 100644 --- a/build/cookieconsent.min.js +++ b/build/cookieconsent.min.js @@ -1 +1 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i];return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},getLuminance:function(e){if(e=this.validateHex(e),"000000"==e)return"#222";var t,i,n=.2,o="#";for(i=0;i<3;i++)t=parseInt(e.substr(2*i,2),16),t=Math.round(Math.min(Math.max(0,t+t*n),255)).toString(16),o+=("00"+t).substr(t.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.hasTransition=function(){for(var e=document.documentElement.style,t=["t","OT","msT","MozT","KhtmlT","WebkitT"],i=0,n=t.length;i=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-windowstyle-"+e.windowstyle];i.push.apply(i,a.call(this));d.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=h.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function d(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&p(i,e,"."+n),o}function p(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+t.getLuminance(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function f(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function b(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",windowstyle:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),f(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),f(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;"string"==typeof n&&n.length&&(i=n),this.element=u.call(this,i),m.call(this),b.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,v(this.options.palette),this.options=null},n.prototype.open=function(t){return this.options.enabled?(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),this):this},n.prototype.close=function(t){return this.options.enabled?(this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),this):this},n.prototype.fadeIn=function(){var i=this.element;e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible")&&(i.style.display="",this.openingTimeout=setTimeout(o.bind(this,i),5)))},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.resolvePromise=e,i.rejectPromise=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.rejectPromise,new Error("All services failed"))):this.completeService.call(this,this.resolvePromise,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file +!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i];return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;n++)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.hasTransition=function(){for(var e=document.documentElement.style,t=["t","OT","msT","MozT","KhtmlT","WebkitT"],i=0,n=t.length;i=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-theme-"+e.theme];i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=h.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+v(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function g(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var k={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},k),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;"string"==typeof n&&n.length&&(i=n),this.element=u.call(this,i),b.call(this),g.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(t){return this.options.enabled?(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),this):this},n.prototype.close=function(t){return this.options.enabled?(this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),this):this},n.prototype.fadeIn=function(){var i=this.element;e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible")&&(i.style.display="",this.openingTimeout=setTimeout(o.bind(this,i),5)))},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 1872efa6..3063670d 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -184,7 +184,8 @@ // these callback hooks are called at certain points in the program execution onPopupOpen: function() {}, onPopupClose: function() {}, - onStatusChange: function(status) {}, + onInitialise: function(status) {}, + onStatusChange: function(status, chosenBefore) {}, onRevokeChoice: function() {}, // each item defines the inner text for the element that it references @@ -547,7 +548,7 @@ // this function calls the `onComplete` hook and returns true (if needed) and returns false otherwise function checkCallbackHooks () { - var complete = this.options.onStatusChange; + var complete = this.options.onInitialise; if (!window.navigator.cookieEnabled) { complete(cc.status.deny); From df26a450b7501934ff1c290ff21707fcda5b990e Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 13:54:33 +0100 Subject: [PATCH 31/70] added back dynamic loading as a useful way to defer loading --- src/cookieconsent.js | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 3063670d..c4e08b5b 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -132,6 +132,24 @@ // The code "typeof obj === 'object' && obj !== null" allows Array objects return typeof obj === 'object' && obj !== null && obj.constructor == Object; }, + + loadStylesheet: function (stylesheet, complete) { + var link = document.createElement("link"); + var createCallback = function (success) { + return function () { + complete.apply(null, [success].concat(arguments)); + }; + }; + link.rel = "stylesheet"; + link.type = "text/css"; + link.href = stylesheet; + link.onload = createCallback(true); + link.onerror = createCallback(false); + + document.head.appendChild(link); + + return link; + }, }; // valid cookie values @@ -320,6 +338,12 @@ // Be sure to use the classes `cc-btn` and `cc-allow`, `cc-deny` or `cc-dismiss`. They enable the app to register click // handlers. You can use other pre-existing classes too. See `src/styles` folder. overrideHTML: null, + + // It is recommended that you include your stylesheet as a tag in the of your document. + // However, some people will want to defer the loading of the plugin until later. In such cases, this + // can be used to dynamically load the stylesheet. To do this, enter the filepath of the stylesheet, exactly + // as it would appear in the tags `href` attribute. + stylesheet: null, }; function CookiePopup () { @@ -331,6 +355,10 @@ this.destroy(); // already rendered } + this.waitingForStylesheet = false; // set to true if we have made a request for a stylesheet, and it has not returned + this.openAfterStylesheet = false; // set to true if we tried to `open` to popup whilst `waitingForStylesheet` + this.requestedTheme = null; // this is the tag containing the coookie popup style, we save it so we can delete it later + // set options back to default options util.deepExtend(this.options = {}, defaultOptions); @@ -353,6 +381,20 @@ this.options.enabled = true; } + if (this.options.stylesheet) { + this.waitingForStylesheet = true; + this.requestedTheme = util.loadStylesheet(this.options.stylesheet, function (success) { + this.waitingForStylesheet = false; + if (this.openAfterStylesheet) { + this.openAfterStylesheet = false; + this.open(); + } + }, function(err) { + console.error('Failed to load stylesheet: ' + this.options.stylesheet); + this.options.enabled = false; + }); + } + // the full markup either contains the wrapper or it does not (for multiple instances) var cookiePopup = this.options.window .replace('{{classes}}', getPopupClasses.call(this).join(' ')) @@ -407,6 +449,16 @@ } this.revokeBtn = null; + if (this.requestedTheme) { + var styleNode = this.requestedTheme.ownerNode; + if (styleNode && styleNode.parentNode) { + styleNode.parentNode.removeChild(styleNode); + } + } + this.requestedTheme = null; + this.waitingForStylesheet = false; + this.openAfterStylesheet = false; + removeCustomStyle(this.options.palette); this.options = null; }; @@ -415,6 +467,13 @@ if (!this.options.enabled) return this; + // If we try and open the popup, and it's style hasn't loaded, set a flag to open it later + if (this.waitingForStylesheet) { + // Setting this to true means that this function will be automatically called when the stylesheet returns + this.openAfterStylesheet = true; + return; + } + if (!this.isOpen()) { if (cc.hasTransition) { this.fadeIn(); From 50fd949b408a2d19c8d7784396dab55d749f5476 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 14:03:21 +0100 Subject: [PATCH 32/70] added hasOwnProperty to the 'for' loops that use the 'in' keyword --- src/cookieconsent.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index c4e08b5b..543a377d 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -57,10 +57,12 @@ // only used for extending the initial options deepExtend: function(target, source) { for (var prop in source) { - if (prop in target && this.isPlainObject(target[prop]) && this.isPlainObject(source[prop])) { - this.deepExtend(target[prop], source[prop]); - } else { - target[prop] = source[prop]; + if (source.hasOwnProperty(prop)) { + if (prop in target && this.isPlainObject(target[prop]) && this.isPlainObject(source[prop])) { + this.deepExtend(target[prop], source[prop]); + } else { + target[prop] = source[prop]; + } } } return target; @@ -84,7 +86,7 @@ hash: function (str) { var hash = 0, i, chr, len; if (str.length === 0) return hash; - for (i = 0, len = str.length; i < len; i++) { + for (i = 0, len = str.length; i < len; ++i) { chr = str.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; @@ -116,7 +118,7 @@ alterLuminance: function(hex, lum) { var rgb = "#", c, i; hex = this.normaliseHex(hex); - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; ++i) { c = parseInt(hex.substr(i*2,2), 16); c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); rgb += ("00"+c).substr(c.length); @@ -843,7 +845,9 @@ var ruleIndex = -1; for (var prop in colorStyles) { - style.sheet.insertRule(prop + '{' + colorStyles[prop].join(';') + '}', ++ruleIndex); + if (colorStyles.hasOwnProperty(prop)) { + style.sheet.insertRule(prop + '{' + colorStyles[prop].join(';') + '}', ++ruleIndex); + } } } From cda884caf613fafd5f7d1f99ed9355ab1c139e15 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Thu, 15 Sep 2016 16:18:35 +0100 Subject: [PATCH 33/70] implemented static layout --- build/cookieconsent.min.css | 4 ++-- build/cookieconsent.min.js | 2 +- examples/example-1-themes.html | 1 - src/cookieconsent.js | 40 ++++++++++++++++++++++++++++++---- src/styles/animation.css | 30 ++++++++++++++++++++----- src/styles/base.css | 4 ++++ 6 files changed, 67 insertions(+), 14 deletions(-) diff --git a/build/cookieconsent.min.css b/build/cookieconsent.min.css index ed5b17da..d62e0d2a 100644 --- a/build/cookieconsent.min.css +++ b/build/cookieconsent.min.css @@ -1,5 +1,5 @@ -.cc-window{opacity:1;transition:opacity .5s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)} -.cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} +.cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s}.cc-grow-active{max-height:4.5em} +.cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} .cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} @media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;-ms-grid-row-align:unset;align-items:unset}} .cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block} diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js index a3bf7577..63168365 100644 --- a/build/cookieconsent.min.js +++ b/build/cookieconsent.min.js @@ -1 +1 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i];return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;n++)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.hasTransition=function(){for(var e=document.documentElement.style,t=["t","OT","msT","MozT","KhtmlT","WebkitT"],i=0,n=t.length;i=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-theme-"+e.theme];i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=h.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+v(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function g(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var k={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onStatusChange:function(e){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},k),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;"string"==typeof n&&n.length&&(i=n),this.element=u.call(this,i),b.call(this),g.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(t){return this.options.enabled?(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),this):this},n.prototype.close=function(t){return this.options.enabled?(this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),this):this},n.prototype.fadeIn=function(){var i=this.element;e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible")&&(i.style.display="",this.openingTimeout=setTimeout(o.bind(this,i),5)))},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file +!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;++n)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object},loadStylesheet:function(e,t){var i=document.createElement("link"),n=function(e){return function(){t.apply(null,[e].concat(arguments))}};return i.rel="stylesheet",i.type="text/css",i.href=e,i.onload=n(!0),i.onerror=n(!1),document.head.appendChild(i),i}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.hasTransition=function(){for(var e=document.documentElement.style,t=["t","OT","msT","MozT","KhtmlT","WebkitT"],i=0,n=t.length;i=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&i.push("cc-static"),i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function h(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=u.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function u(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+f(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var h=-1;for(var u in s)s.hasOwnProperty(u)&&l.sheet.insertRule(u+"{"+s[u].join(";")+"}",++h)}function f(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function v(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=h.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null,stylesheet:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0),this.options.stylesheet&&(this.waitingForStylesheet=!0,this.requestedTheme=t.loadStylesheet(this.options.stylesheet,function(e){this.waitingForStylesheet=!1,this.openAfterStylesheet&&(this.openAfterStylesheet=!1,this.open())},function(e){console.error("Failed to load stylesheet: "+this.options.stylesheet),this.options.enabled=!1}));var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=h.call(this,'
'+i+"
");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=h.call(this,i);b.call(this),y.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,v(this.options.palette),this.options=null},n.prototype.open=function(t){return this.options.enabled?this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),this):this},n.prototype.close=function(t){return this.options.enabled?(this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),this):this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){i.style.display="",this.options["static"]&&t.addClass(this.element.parentNode,"cc-grow-active");var n=20;this.openingTimeout=setTimeout(o.bind(this,i),n)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),this.options["static"]&&t.removeClass(i.parentNode,"cc-grow-active"),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/examples/example-1-themes.html b/examples/example-1-themes.html index 1cc69879..4667efd6 100644 --- a/examples/example-1-themes.html +++ b/examples/example-1-themes.html @@ -59,7 +59,6 @@

Demo 1 Themes

type: 'info', position: 'top', palette: palettes.honeybee, - pushdown: false }, 'Blurple': { type: 'opt-out', diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 543a377d..5b98a1ce 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -408,7 +408,20 @@ cookiePopup = customHTML; } - this.element = appendMarkup.call(this, cookiePopup); + // if static, we need to grow the element from 0 height so it doesn't jump the page + // content. we wrap an element around it which will mask the hidden content + if (this.options.static) { + var wrapper = appendMarkup.call(this, '
' + cookiePopup + '
'); + wrapper.style.display = ''; // set it to visible + + // get the `element` reference from the wrapper + this.element = wrapper.firstChild; + + this.element.style.display = 'none'; + util.addClass(this.element, 'cc-invisible'); + } else { + this.element = appendMarkup.call(this, cookiePopup); + } // uses `dismissOnScroll` and `dismissOnTimeout` applyAutoDismiss.call(this); @@ -528,7 +541,18 @@ if (util.hasClass(el, 'cc-invisible')) { el.style.display = ''; - this.openingTimeout = setTimeout(afterFadeIn.bind(this, el), 5); + if (this.options.static) { + util.addClass(this.element.parentNode, 'cc-grow-active'); + } + + var fadeInTimeout = 20; // (ms) DO NOT MAKE THIS VALUE SMALLER. See below + + // Although most browsers can handle values less than 20ms, it should remain above this value. + // This is because we are waiting for a "browser redraw" before we remove the 'cc-invisible' class. + // If the class is remvoed before a redraw could happen, then the fadeIn effect WILL NOT work, and + // the popup will appear from nothing. Therefore we MUST allow enough time for the browser to do + // it's thing. The actually difference between using 0 and 20 in a set timeout is neglegible anyway + this.openingTimeout = setTimeout(afterFadeIn.bind(this, el), fadeInTimeout); } }; @@ -547,6 +571,10 @@ this.afterTransition = afterFadeOut.bind(this, el); el.addEventListener(cc.transitionEnd, this.afterTransition); + if (this.options.static) { + util.removeClass(el.parentNode, 'cc-grow-active'); + } + util.addClass(el, 'cc-invisible'); } }; @@ -647,11 +675,15 @@ var opts = this.options; var positionStyle = (opts.position == 'top' || opts.position == 'bottom') ? 'banner' : 'floating'; var classes = [ - 'cc-' + positionStyle, // floating or banner + 'cc-' + positionStyle, // floating or banner 'cc-type-' + opts.type, // add the compliance type - 'cc-theme-' + opts.theme, // add the windwowstyle class + 'cc-theme-' + opts.theme, // add the theme ]; + if (opts.static) { + classes.push('cc-static'); + } + classes.push.apply(classes, getPositionClasses.call(this)); // we only add extra styles if `palette` has been set to a valid value diff --git a/src/styles/animation.css b/src/styles/animation.css index 570ce368..bb95bea5 100644 --- a/src/styles/animation.css +++ b/src/styles/animation.css @@ -2,11 +2,11 @@ .cc-window { opacity: 1; - -webkit-transition: opacity .5s ease; - -moz-transition: opacity .5s ease; - -ms-transition: opacity .5s ease; - -o-transition: opacity .5s ease; - transition: opacity .5s ease; + -webkit-transition: opacity 1s ease; + -moz-transition: opacity 1s ease; + -ms-transition: opacity 1s ease; + -o-transition: opacity 1s ease; + transition: opacity 1s ease; } .cc-window.cc-invisible { @@ -35,4 +35,22 @@ } .cc-revoke:hover { transform: translateY(0); -} \ No newline at end of file +} + +.cc-grower { + /* Initially we don't want any height, and we want the contents to be hidden */ + max-height: 0; + overflow: hidden; + + /* Set our transitions up. */ + -webkit-transition: max-height 1s; + -moz-transition: max-height 1s; + -ms-transition: max-height 1s; + -o-transition: max-height 1s; + transition: max-height 1s; +} + +.cc-grow-active { + /* On hover, set the max-height to something large. In this case there's an obvious limit. */ + max-height: 4.5em; +} diff --git a/src/styles/base.css b/src/styles/base.css index 92131b1d..41e04d69 100644 --- a/src/styles/base.css +++ b/src/styles/base.css @@ -16,6 +16,10 @@ z-index: 9999; } +.cc-window.cc-static { + position: static; +} + /* 2 basic types of window - floating / banner */ .cc-window.cc-floating { padding: 2em; From ebc9a7dead2ce38d023af60ac598a3ca69587c19 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 10:59:18 +0100 Subject: [PATCH 34/70] callbacks are now bound to the popup instance --- src/cookieconsent.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 5b98a1ce..2d905b39 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -499,7 +499,7 @@ if (this.options.revokable) { this.toggleRevokeButton(); } - this.options.onPopupOpen(); + this.options.onPopupOpen.call(this); } return this; @@ -519,7 +519,7 @@ if (showRevoke && this.options.revokable) { this.toggleRevokeButton(true); } - this.options.onPopupClose(); + this.options.onPopupClose.call(this); } return this; @@ -604,7 +604,7 @@ if (Object.keys(cc.status).indexOf(status) >= 0) { util.setCookie(c.name, status, c.expiryDays, c.domain, c.path); - this.options.onStatusChange(status, chosenBefore); + this.options.onStatusChange.call(this, status, chosenBefore); } else { this.clearStatus(); } @@ -637,7 +637,7 @@ // this function calls the `onComplete` hook and returns true (if needed) and returns false otherwise function checkCallbackHooks () { - var complete = this.options.onInitialise; + var complete = this.options.onInitialise.call(this); if (!window.navigator.cookieEnabled) { complete(cc.status.deny); @@ -784,7 +784,7 @@ this.close(true); } if (util.hasClass(targ, 'cc-revoke')) { - this.options.onRevokeChoice(); + this.options.onRevokeChoice.call(this); this.clearStatus(); this.open(); } From 7dc687afe4226609e51f71dd842025ea97fddcb2 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 11:03:32 +0100 Subject: [PATCH 35/70] added functions to test consent --- src/cookieconsent.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 2d905b39..e69a1ce2 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -587,12 +587,20 @@ if (this.revokeBtn) this.revokeBtn.style.display = show ? '' : 'none'; }; - CookiePopup.prototype.hasConsented = function (options) { + // returns true if the cookie has a valid value + CookiePopup.prototype.hasAnswered = function (options) { return Object.keys(cc.status).indexOf(this.getStatus()) >= 0; }; + // returns true if the cookie indicates that consent has been given + CookiePopup.prototype.hasConsented = function (options) { + var val = this.getStatus(); + return val == cc.status.allow || val == cc.status.dismiss; + }; + + // opens the popup if no answer has been given CookiePopup.prototype.autoOpen = function (options) { - !this.hasConsented() && this.open(); + !this.hasAnwsered() && this.open(); }; CookiePopup.prototype.setStatus = function (status) { From 8862b755cde66e4ca729fda5705cb193a008f42d Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 11:13:07 +0100 Subject: [PATCH 36/70] minor changes --- src/cookieconsent.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index e69a1ce2..fc231cf3 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -268,14 +268,15 @@ //'my-cool-layout': '
{{message}}{{compliance}}
{{close}}', }, - //default layout + // default layout (see above) layout: 'basic', // this refers to the popup windows position. we currently support: - // banner positions: top, bottom - // floating positions: top-left, top-right, bottom-left, bottom-right - // adds a class `cc-floating` or `cc-banner` which helps when styling - position: 'bottom', + // - banner positions: top, bottom + // - floating positions: top-left, top-right, bottom-left, bottom-right + // + // adds a class `cc-floating` or `cc-banner` which helps when styling + position: 'bottom', // default position is 'bottom' // Available styles // -block (default, no extra classes) @@ -389,7 +390,7 @@ this.waitingForStylesheet = false; if (this.openAfterStylesheet) { this.openAfterStylesheet = false; - this.open(); + this.autoOpen(); } }, function(err) { console.error('Failed to load stylesheet: ' + this.options.stylesheet); @@ -411,19 +412,17 @@ // if static, we need to grow the element from 0 height so it doesn't jump the page // content. we wrap an element around it which will mask the hidden content if (this.options.static) { + // `grower` is a wrapper div with a hidden overflow whose height is animated var wrapper = appendMarkup.call(this, '
' + cookiePopup + '
'); - wrapper.style.display = ''; // set it to visible - - // get the `element` reference from the wrapper - this.element = wrapper.firstChild; + wrapper.style.display = ''; // set it to visible (because appendMarkup hides it) + this.element = wrapper.firstChild; // get the `element` reference from the wrapper this.element.style.display = 'none'; util.addClass(this.element, 'cc-invisible'); } else { this.element = appendMarkup.call(this, cookiePopup); } - // uses `dismissOnScroll` and `dismissOnTimeout` applyAutoDismiss.call(this); applyRevokeButton.call(this); From 3fd9af1611307cb8c6ccc9872d054e57200937d7 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 11:19:11 +0100 Subject: [PATCH 37/70] added comments to the Law module --- src/cookieconsent.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index fc231cf3..92dda512 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -1285,8 +1285,14 @@ cc.Law = (function () { var defaultOptions = { + // countries that enforce some version of a cookie law hasLaw: ['AT', 'BE', 'BG', 'HR', 'CZ', 'CY', 'DK', 'EE', 'FI', 'FR', 'DE', 'EL', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'GB', 'UK'], + + // countries that say that all cookie consent choices must be revokable (a user must be able too change their mind) revokable: ['HR', 'CY', 'DK', 'EE', 'FR', 'DE', 'LV', 'LT', 'NL', 'PT', 'ES'], + + // countries that say that a person can only "consent" if the explicitly click on "I agree". + // in these countries, consent cannot be implied via a timeout or by scrolling down the page explicitAction: ['HR', 'IT', 'ES'], }; From 9c1272a7032e4e9c027f769afe86180d17bcd409 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 11:20:39 +0100 Subject: [PATCH 38/70] added error callback --- src/cookieconsent.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 92dda512..a280be04 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -1366,19 +1366,19 @@ // `options.law.countryCode`, or attempts to make a location service request. This function accepts // options (which can configure the `law` and `location` modules) and fires a callback with which // passes an object `{code: countryCode}` as the first argument (which can have undefined properties) - cc.getCountryCode = function (options, cb) { + cc.getCountryCode = function (options, complete, error) { if (options.law && options.law.countryCode) { - cb({code: options.law.countryCode}); + complete({code: options.law.countryCode}); return; } if (options.location) { var locator = new cc.Location(options.location); locator.locate(function (serviceResult) { - cb(serviceResult || {}); - }); + complete(serviceResult || {}); + }, error); return; } - cb({}); + complete({}); }; // export utils (no point in hiding them, so we may as well expose them) From 6c13c4063ea94dade13f81d8ca3a074c8366b415 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 12:00:21 +0100 Subject: [PATCH 39/70] made location service definitions configurable --- src/cookieconsent.js | 124 ++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index a280be04..23184d6e 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -1001,10 +1001,6 @@ cc.Location = (function () { - var defaultOptions = { - services: ['freegeoip', 'ipinfo', 'maxmind'] - }; - // An object containing all the location services we have already set up. // When using a service, it could either return a data structure in plain text (like a JSON object) or an executable script // When the response needs to be executed by the browser, then `isScript` must be set to true, otherwise it won't work. @@ -1012,60 +1008,78 @@ // When the service uses a script, the chances are that you'll have to use the script to make additional requests. In these // cases, the services `callback` property is called with a `done` function. When performing async operations, this must be called // with the data (or Error), and `cookieconsent.locate` will take care of the rest - var locationServices = { - ipinfo: function (obj) { - return { - // This service responds with JSON, so we simply need to parse it and return the country code - url: 'http://ipinfo.io', - headers: ['Accept: application/json'], - callback: function (done, response) { - var json = JSON.parse(response); - return json.error ? toError(json) : { - code: json.country - }; - } - } - }, - freegeoip: function () { - return { - // This service responds with JSON, but they do not have CORS set, so we must use JSONP and provide a callback - // The callback MUST BE `cookieconsent.locate.jsonp(SERVICE_NAME)` (so cookieconsent.locate.jsonp('freegeoip') for this index) - url: '//freegeoip.net/json/?callback={callback}', - isScript: true, // this is JSONP, therefore we must set it to run as a script - callback: function (done, response) { - var json = JSON.parse(response); - return json.error ? toError(json) : { - code: json.country_code - }; + var defaultOptions = { + // the order that services will be attempted in + services: [ + 'freegeoip', + 'ipinfo', + 'maxmind', + + /* OPTIONAL + + function () { + return serviceDefinition + }, + + {name: 'myService', ...serviceDefinition}, + + */ + ], + serviceDefinitions: { + ipinfo: function () { + return { + // This service responds with JSON, so we simply need to parse it and return the country code + url: 'http://ipinfo.io', + headers: ['Accept: application/json'], + callback: function (done, response) { + var json = JSON.parse(response); + return json.error ? toError(json) : { + code: json.country + }; + } } - } - }, - maxmind: function () { - return { - // This service responds with a JavaScript file which defines additional functionality. Once loaded, we must - // make an additional AJAX call. Therefore we provide a `done` callback that can be called asynchronously - url: '//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js', - isScript: true, // this service responds with a JavaScript file, so it must be run as a script - callback: function (done) { - // if everything went okay then `geoip2` WILL be defined - if (!window.geoip2) { - done(new Error('Unexpected response format. The downloaded script should have exported `geoip2` to the global scope')); - return; + }, + freegeoip: function () { + return { + // This service responds with JSON, but they do not have CORS set, so we must use JSONP and provide a callback + // The callback MUST BE `cookieconsent.locate.jsonp(SERVICE_NAME)` (so cookieconsent.locate.jsonp('freegeoip') for this index) + url: '//freegeoip.net/json/?callback={callback}', + isScript: true, // this is JSONP, therefore we must set it to run as a script + callback: function (done, response) { + var json = JSON.parse(response); + return json.error ? toError(json) : { + code: json.country_code + }; } + } + }, + maxmind: function () { + return { + // This service responds with a JavaScript file which defines additional functionality. Once loaded, we must + // make an additional AJAX call. Therefore we provide a `done` callback that can be called asynchronously + url: '//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js', + isScript: true, // this service responds with a JavaScript file, so it must be run as a script + callback: function (done) { + // if everything went okay then `geoip2` WILL be defined + if (!window.geoip2) { + done(new Error('Unexpected response format. The downloaded script should have exported `geoip2` to the global scope')); + return; + } - geoip2.country(function (location) { - done({ - code: location.country.iso_code + geoip2.country(function (location) { + done({ + code: location.country.iso_code + }); + }, function (err) { + done(toError(err)); }); - }, function (err) { - done(toError(err)); - }); - // We can't return anything, because we need to wait for the second AJAX call to return. - // Then we can 'complete' the service by passing data or an error to the `done` callback. + // We can't return anything, because we need to wait for the second AJAX call to return. + // Then we can 'complete' the service by passing data or an error to the `done` callback. + } } - } - } + }, + }, }; function Location(options) { @@ -1087,12 +1101,12 @@ if (typeof serviceOption === 'function') return serviceOption; // If it's a string, use one of the location services. - if (typeof serviceOption === 'string') return locationServices[serviceOption](); + if (typeof serviceOption === 'string') return this.options.serviceDefinitions[serviceOption](); // If it's an object, assume {name: 'ipinfo', ...otherOptions} // Allows user to pass in API keys etc. if (util.isPlainObject(serviceOption)) { - return locationServices[serviceOption.name](serviceOption); + return this.options.serviceDefinitions[serviceOption.name](serviceOption); } }; @@ -1210,7 +1224,7 @@ console.log('The service[' + idx + '] (' + service.url + ') responded with the following error', err); // if another service exists - if (this.options.locationServices[idx + 1]) { + if (this.options.serviceDefinitions[idx + 1]) { // an error occurred, try the next service this.currentServiceIndex++; this.runService(this.getCurrentService(), this.runNextServiceOnError.bind(this)); From d56247289beb32c783ac81ab2f1ada64b91aeb99 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Fri, 16 Sep 2016 13:00:10 +0100 Subject: [PATCH 40/70] fixed transition end clalback --- build/cookieconsent.min.js | 2 +- examples/example-7-javascript-api.html | 9 +--- src/cookieconsent.js | 58 +++++++++++++++----------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js index 63168365..14248c6f 100644 --- a/build/cookieconsent.min.js +++ b/build/cookieconsent.min.js @@ -1 +1 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;++n)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object},loadStylesheet:function(e,t){var i=document.createElement("link"),n=function(e){return function(){t.apply(null,[e].concat(arguments))}};return i.rel="stylesheet",i.type="text/css",i.href=e,i.onload=n(!0),i.onerror=n(!1),document.head.appendChild(i),i}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.hasTransition=function(){for(var e=document.documentElement.style,t=["t","OT","msT","MozT","KhtmlT","WebkitT"],i=0,n=t.length;i=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&i.push("cc-static"),i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function h(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=u.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function u(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&(this.options.onRevokeChoice(),this.clearStatus(),this.open())}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+f(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var h=-1;for(var u in s)s.hasOwnProperty(u)&&l.sheet.insertRule(u+"{"+s[u].join(";")+"}",++h)}function f(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function v(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=h.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null,stylesheet:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0),this.options.stylesheet&&(this.waitingForStylesheet=!0,this.requestedTheme=t.loadStylesheet(this.options.stylesheet,function(e){this.waitingForStylesheet=!1,this.openAfterStylesheet&&(this.openAfterStylesheet=!1,this.open())},function(e){console.error("Failed to load stylesheet: "+this.options.stylesheet),this.options.enabled=!1}));var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=h.call(this,'
'+i+"
");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=h.call(this,i);b.call(this),y.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,v(this.options.palette),this.options=null},n.prototype.open=function(t){return this.options.enabled?this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen()),this):this},n.prototype.close=function(t){return this.options.enabled?(this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose()),this):this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){i.style.display="",this.options["static"]&&t.addClass(this.element.parentNode,"cc-grow-active");var n=20;this.openingTimeout=setTimeout(o.bind(this,i),n)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),this.options["static"]&&t.removeClass(i.parentNode,"cc-grow-active"),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.hasConsented=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.autoOpen=function(e){!this.hasConsented()&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange(i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},r={ipinfo:function(e){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?r[i]():t.isPlainObject(i)?r[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.locationServices[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var n=new e.Location(t.location);return void n.locate(function(e){i(e||{})})}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file +!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;++n)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object},loadStylesheet:function(e,t){var i=document.createElement("link"),n=function(e){return function(){t.apply(null,[e].concat(arguments))}};return i.rel="stylesheet",i.type="text/css",i.href=e,i.onload=n(!0),i.onerror=n(!1),document.head.appendChild(i),i}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.transitionEnd=function(){var e=document.createElement("div"),t={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in t)if(t.hasOwnProperty(i)&&"undefined"!=typeof e.style[i+"ransition"])return t[i];return""}(),e.hasTransition=!!e.transitionEnd;var i=Object.keys(e.status).map(t.escapeRegExp);e.customStyles={},e.Popup=function(){function n(){this.initialise.apply(this,arguments)}function o(e){this.openingTimeout=null,t.removeClass(e,"cc-invisible")}function s(t){t.style.display="none",t.removeEventListener(e.transitionEnd,this.afterTransition),this.afterTransition=null}function r(){var t=this.options.onInitialise.bind(this);if(!window.navigator.cookieEnabled)return t(e.status.deny),!0;if(window.CookiesOK||window.navigator.CookiesOK)return t(e.status.allow),!0;var i=Object.keys(e.status),n=this.getStatus(),o=i.indexOf(n)>=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,t="top"==e.position||"bottom"==e.position?"banner":"floating",i=["cc-"+t,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&i.push("cc-static"),i.push.apply(i,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&i.push(this.customStyleSelector),i}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function h(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=u.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function u(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&this.revokeChoice()}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],s[o+" .cc-btn:hover"]=["background-color: "+f(a.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var h=-1;for(var u in s)s.hasOwnProperty(u)&&l.sheet.insertRule(u+"{"+s[u].join(";")+"}",++h)}function f(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function v(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function b(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=h.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
Cookie Policy
',compliance:{info:'
{{dismiss}}
',"opt-in":'
{{dismiss}}{{allow}}
',"opt-out":'
{{deny}}{{dismiss}}
'},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null,stylesheet:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,this.requestedTheme=null,t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0),this.options.stylesheet&&(this.waitingForStylesheet=!0,this.requestedTheme=t.loadStylesheet(this.options.stylesheet,function(e){this.waitingForStylesheet=!1,this.openAfterStylesheet&&(this.openAfterStylesheet=!1,this.autoOpen())},function(e){console.error("Failed to load stylesheet: "+this.options.stylesheet),this.options.enabled=!1}));var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=h.call(this,'
'+i+"
");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=h.call(this,i);y.call(this),b.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){if(this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,this.requestedTheme){var e=this.requestedTheme.ownerNode;e&&e.parentNode&&e.parentNode.removeChild(e)}this.requestedTheme=null,this.waitingForStylesheet=!1,this.openAfterStylesheet=!1,v(this.options.palette),this.options=null},n.prototype.open=function(t){return this.waitingForStylesheet?void(this.openAfterStylesheet=!0):(this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this)},n.prototype.close=function(t){return this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){i.style.display="",this.options["static"]&&t.addClass(this.element.parentNode,"cc-grow-active");var n=20;this.openingTimeout=setTimeout(o.bind(this,i),n)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.options["static"]&&t.removeClass(i.parentNode,"cc-grow-active"),this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.revokeChoice=function(e){this.options.onRevokeChoice.call(this),this.clearStatus(),e||this.autoOpen()},n.prototype.hasAnswered=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.hasConsented=function(t){var i=this.getStatus();return i==e.status.allow||i==e.status.dismiss},n.prototype.autoOpen=function(e){!this.hasAnswered()&&this.options.enabled&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange.call(this,i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,r=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"],serviceDefinitions:{ipinfo:function(){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?this.options.serviceDefinitions[i]():t.isPlainObject(i)?this.options.serviceDefinitions[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),this.options.serviceDefinitions[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i,n){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var o=new e.Location(t.location);return void o.locate(function(e){i(e||{})},n)}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file diff --git a/examples/example-7-javascript-api.html b/examples/example-7-javascript-api.html index d64a0168..eb0e210b 100644 --- a/examples/example-7-javascript-api.html +++ b/examples/example-7-javascript-api.html @@ -50,8 +50,8 @@

Console

- + diff --git a/src/cookieconsent.js b/src/cookieconsent.js index b875f89f..a785f744 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -980,22 +980,50 @@ services: [ 'freegeoip', 'ipinfo', - 'maxmind', + 'maxmind' - /* OPTIONAL + /* - TODO test these syntaxes + // 'ipinfodb' requires some options, so we define it using an object + // this object will be passed to the function that defines the service - function () { - return serviceDefinition + { + name: 'ipinfodb', + interpolateUrl: { + key: '488482b7334720b92b6d2242d7e1eacb6e0e6752feac8d8cdb62aa55481e1ae' + }, }, - {name: 'myService', ...serviceDefinition}, + // as well as defining an object, you can define a function that returns an object + + function () { + return {name: 'ipinfodb'}; + }, */ ], serviceDefinitions: { + + freegeoip: function() { + return { + // This service responds with JSON, but they do not have CORS set, so we must use JSONP and provide a callback + // The `{callback}` is automatically rewritten by the tool + url: '//freegeoip.net/json/?callback={callback}', + isScript: true, // this is JSONP, therefore we must set it to run as a script + callback: function(done, response) { + try{ + var json = JSON.parse(response); + return json.error ? toError(json) : { + code: json.country_code + }; + } catch (err) { + return toError({error: 'Invalid response ('+err+')'}); + } + } + } + }, + ipinfo: function() { return { // This service responds with JSON, so we simply need to parse it and return the country code @@ -1008,29 +1036,31 @@ code: json.country }; } catch (err) { - return toError({error: 'Invalid response'}); + return toError({error: 'Invalid response ('+err+')'}); } } } }, - freegeoip: function() { + + // This service requires an option to define `key`. Options are proived using objects or functions + ipinfodb: function(options) { return { - // This service responds with JSON, but they do not have CORS set, so we must use JSONP and provide a callback - // The `{callback}` is automatically rewritten by the tool - url: '//freegeoip.net/json/?callback={callback}', + // This service responds with JSON, so we simply need to parse it and return the country code + url: '//api.ipinfodb.com/v3/ip-country/?key={key}&format=json&callback={callback}', isScript: true, // this is JSONP, therefore we must set it to run as a script callback: function(done, response) { try{ var json = JSON.parse(response); - return json.error ? toError(json) : { - code: json.country_code + return json.statusCode == 'ERROR' ? toError({error: json.statusMessage}) : { + code: json.countryCode }; } catch (err) { - return toError({error: 'Invalid response'}); + return toError({error: 'Invalid response ('+err+')'}); } } } }, + maxmind: function() { return { // This service responds with a JavaScript file which defines additional functionality. Once loaded, we must @@ -1068,38 +1098,54 @@ util.deepExtend(this.options, options); } - this.currentServiceIndex = 0; // the index (in options) of the service we're currently using + this.currentServiceIndex = -1; // the index (in options) of the service we're currently using } + Location.prototype.getNextService = function() { + var service; + + do { + service = this.getServiceByIdx(++this.currentServiceIndex); + } while (!service); + + return service; + }; + Location.prototype.getServiceByIdx = function(idx) { // This can either be the name of a default locationService, or a function. var serviceOption = this.options.services[idx]; - // User can provide their own servives as functions. - if (typeof serviceOption === 'function') return serviceOption; + // If it's a string, use one of the location services. + if (typeof serviceOption === 'function') { + var dynamicOpts = serviceOption(); + if (dynamicOpts.name) { + util.deepExtend(dynamicOpts, this.options.serviceDefinitions[dynamicOpts.name](dynamicOpts)); + } + return dynamicOpts; + } // If it's a string, use one of the location services. - if (typeof serviceOption === 'string') return this.options.serviceDefinitions[serviceOption](); + if (typeof serviceOption === 'string') { + return this.options.serviceDefinitions[serviceOption](); + } // If it's an object, assume {name: 'ipinfo', ...otherOptions} // Allows user to pass in API keys etc. if (util.isPlainObject(serviceOption)) { return this.options.serviceDefinitions[serviceOption.name](serviceOption); } - }; - Location.prototype.getCurrentService = function() { - var idx = this.currentServiceIndex; - return this.getServiceByIdx(idx); + return null; }; // This runs the service located at index `currentServiceIndex`. // If the service fails, `runNextServiceOnError` will continue trying each service until all fail, or one completes successfully Location.prototype.locate = function(complete, error) { - var service = this.getCurrentService(); + var service = this.getNextService(); if (!service) { - return; // TODO should try next service + error(new Error('No services to run')); + return; } this.callbackComplete = complete; @@ -1110,7 +1156,8 @@ // Potentially adds a callback to a url for jsonp. Location.prototype.setupUrl = function(service) { - return service.url.replace(/\{(.*?)\}/, function(_, param) { + var serviceOpts = this.getCurrentServiceOpts(); + return service.url.replace(/\{(.*?)\}/g, function(_, param) { if (param === 'callback') { var tempName = 'callback' + Date.now(); window[tempName] = function(res) { @@ -1118,6 +1165,9 @@ } return tempName; } + if (param in serviceOpts.interpolateUrl) { + return serviceOpts.interpolateUrl[param]; + } }); }; @@ -1125,12 +1175,6 @@ Location.prototype.runService = function(service, complete) { var self = this; - // User defined services are just a function that returns a result. - if (typeof service === 'function') { - service(complete); - return; - } - // basic check to ensure it resembles a `service` if (!service || !service.url || !service.callback) { return; @@ -1139,8 +1183,10 @@ // we call either `getScript` or `makeAsyncRequest` depending on the type of resource var requestFunction = service.isScript ? getScript : makeAsyncRequest; + var url = this.setupUrl(service); + // both functions have similar signatures so we can pass the same arguments to both - requestFunction(this.setupUrl(service), function(xhr) { + requestFunction(url, function(xhr) { // if `!xhr`, then `getScript` function was used, so there is no response text var responseText = xhr ? xhr.responseText : ''; @@ -1197,17 +1243,13 @@ // if `err` is set, the next service handler is called // if `err` is null, the `onComplete` handler is called with `data` Location.prototype.runNextServiceOnError = function(err, data) { - var service = this.getCurrentService(); - var idx = this.currentServiceIndex; - if (err) { - console.log('The service[' + idx + '] (' + service.url + ') responded with the following error', err); + this.logError(err); - // if another service exists - if (this.options.services[idx + 1]) { - // an error occurred, try the next service - this.currentServiceIndex++; - this.runService(this.getCurrentService(), this.runNextServiceOnError.bind(this)); + var nextService = this.getNextService(); + + if (nextService) { + this.runService(nextService, this.runNextServiceOnError.bind(this)); } else { this.completeService.call(this, this.callbackError, new Error('All services failed')); } @@ -1216,13 +1258,38 @@ } }; + Location.prototype.getCurrentServiceOpts = function() { + var val = this.options.services[this.currentServiceIndex]; + + if (typeof val == 'string') { + return {name: val}; + } + + if (typeof val == 'function') { + return val(); + } + + if (util.isPlainObject(val)) { + return val; + } + + return {}; + }; + // calls the `onComplete` callback after resetting the `currentServiceIndex` Location.prototype.completeService = function(fn, data) { - this.currentServiceIndex = 0; + this.currentServiceIndex = -1; fn && fn(data); }; + Location.prototype.logError = function (err) { + var idx = this.currentServiceIndex; + var service = this.getServiceByIdx(idx); + + console.error('The service[' + idx + '] (' + service.url + ') responded with the following error', err); + }; + function getScript(url, callback) { var timeout, s = document.createElement('script'); @@ -1239,7 +1306,7 @@ if (!callback.done && (!state || /loaded|complete/.test(state))) { callback.done = true; callback(); - s = null; + s.onreadystatechange = s.onload = null; } }; @@ -1250,8 +1317,8 @@ timeout = setTimeout(function () { callback.done = true; callback(); - s = null; - }, 3000); + s.onreadystatechange = s.onload = null; + }, 10000); } function makeAsyncRequest(url, onComplete, postData, requestHeaders) { From e949e669c27ff3b87397ffb2a652ef2d0f727eaf Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 12:27:40 +0100 Subject: [PATCH 65/70] remove unneeded example test.html --- examples/test.html | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 examples/test.html diff --git a/examples/test.html b/examples/test.html deleted file mode 100644 index c0660749..00000000 --- a/examples/test.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - Demo 1 - Themes - - - - - - -
-
-
- -

Demo 1 Themes

- -

- See what you can do with some of Cookie Consent's themes: -

- -
    - - - -
    -
    -
    - - - - From 37aaf7b9c75851588418827dfeca19b059f9116d Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 12:38:33 +0100 Subject: [PATCH 66/70] timeout is now configurable --- src/cookieconsent.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index a785f744..cf6e3e14 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -976,6 +976,12 @@ // cases, the services `callback` property is called with a `done` function. When performing async operations, this must be called // with the data (or Error), and `cookieconsent.locate` will take care of the rest var defaultOptions = { + + // The default timeout is 5 seconds. This is mainly needed to catch JSONP requests that error. + // Otherwise there is no easy way to catch JSONP errors. That means that if a JSONP fails, the + // app will take `timeout` milliseconds to react to a JSONP network error. + timeout: 5000, + // the order that services will be attempted in services: [ 'freegeoip', @@ -1201,7 +1207,7 @@ // call the service callback with the response text (so it can parse the response) self.runServiceCallback.call(self, complete, service, responseText); - }, service.data, service.headers); + }, this.options.timeout, service.data, service.headers); // `service.data` and `service.headers` are optional (they only count if `!service.isScript` anyway) }; @@ -1290,8 +1296,8 @@ console.error('The service[' + idx + '] (' + service.url + ') responded with the following error', err); }; - function getScript(url, callback) { - var timeout, s = document.createElement('script'); + function getScript(url, callback, timeout) { + var timeoutIdx, s = document.createElement('script'); s.type = 'text/' + (url.type || 'javascript'); s.src = url.src || url; @@ -1301,7 +1307,7 @@ // this code handles two scenarios, whether called by onload or onreadystatechange var state = s.readyState; - clearTimeout(timeout); + clearTimeout(timeoutIdx); if (!callback.done && (!state || /loaded|complete/.test(state))) { callback.done = true; @@ -1314,14 +1320,14 @@ // You can't catch JSONP Errors, because it's handled by the script tag // one way is to use a timeout - timeout = setTimeout(function () { + timeoutIdx = setTimeout(function () { callback.done = true; callback(); s.onreadystatechange = s.onload = null; - }, 10000); + }, timeout); } - function makeAsyncRequest(url, onComplete, postData, requestHeaders) { + function makeAsyncRequest(url, onComplete, timeout, postData, requestHeaders) { var xhr = new(window.XMLHttpRequest || window.ActiveXObject)('MSXML2.XMLHTTP.3.0'); xhr.open(postData ? 'POST' : 'GET', url, 1); From f8555b80c389d1fbd46c2c1c701035f5b9d33105 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 12:45:49 +0100 Subject: [PATCH 67/70] dynamically set the height --- src/cookieconsent.js | 5 +++-- src/styles/animation.css | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index c4672d75..aade1d05 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -489,7 +489,8 @@ el.style.display = ''; if (this.options.static) { - util.addClass(this.element.parentNode, 'cc-grow-active'); + var height = this.element.clientHeight; + this.element.parentNode.style.maxHeight = height + 'px'; } var fadeInTimeout = 20; // (ms) DO NOT MAKE THIS VALUE SMALLER. See below @@ -516,7 +517,7 @@ if (!util.hasClass(el, 'cc-invisible')) { if (this.options.static) { - util.removeClass(el.parentNode, 'cc-grow-active'); + this.element.parentNode.style.maxHeight = ''; } this.afterTransition = afterFadeOut.bind(this, el); diff --git a/src/styles/animation.css b/src/styles/animation.css index bb95bea5..f1877e13 100644 --- a/src/styles/animation.css +++ b/src/styles/animation.css @@ -49,8 +49,3 @@ -o-transition: max-height 1s; transition: max-height 1s; } - -.cc-grow-active { - /* On hover, set the max-height to something large. In this case there's an obvious limit. */ - max-height: 4.5em; -} From c402a13e205359001e54e974e2ccf8389ad1dbe4 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 12:53:15 +0100 Subject: [PATCH 68/70] removed my actual api key --- src/cookieconsent.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index aade1d05..2a0eee3b 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -995,7 +995,8 @@ { name: 'ipinfodb', interpolateUrl: { - key: '488482b7334720b92b6d2242d7e1eacb6e0e6752feac8d8cdb62aa55481e1ae' + // obviously, this is a fake key + api_key: 'vOgI3748dnIytIrsJcxS7qsDf6kbJkE9lN4yEDrXAqXcKUNvjjZPox3ekXqmMMld' }, }, @@ -1051,7 +1052,7 @@ ipinfodb: function(options) { return { // This service responds with JSON, so we simply need to parse it and return the country code - url: '//api.ipinfodb.com/v3/ip-country/?key={key}&format=json&callback={callback}', + url: '//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}', isScript: true, // this is JSONP, therefore we must set it to run as a script callback: function(done, response) { try{ From d0d7e483cc0a03472285637a802c68b554ba9aa2 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 13:04:03 +0100 Subject: [PATCH 69/70] updated build --- build/cookieconsent.min.css | 2 +- build/cookieconsent.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/cookieconsent.min.css b/build/cookieconsent.min.css index d62e0d2a..7bb46e98 100644 --- a/build/cookieconsent.min.css +++ b/build/cookieconsent.min.css @@ -1,4 +1,4 @@ -.cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s}.cc-grow-active{max-height:4.5em} +.cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s} .cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} .cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} @media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;-ms-grid-row-align:unset;align-items:unset}} diff --git a/build/cookieconsent.min.js b/build/cookieconsent.min.js index 9ea6629c..5ff58e41 100644 --- a/build/cookieconsent.min.js +++ b/build/cookieconsent.min.js @@ -1 +1 @@ -!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var a=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&a.push("domain="+n),document.cookie=a.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},alterLuminance:function(e,t){var i,n,o="#";for(e=this.normaliseHex(e),n=0;n<3;++n)i=parseInt(e.substr(2*n,2),16),i=Math.round(Math.min(Math.max(0,i+i*t),255)).toString(16),o+=("00"+i).substr(i.length);return o},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.transitionEnd=function(){var e=document.createElement("div"),t={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in t)if(t.hasOwnProperty(i)&&"undefined"!=typeof e.style[i+"ransition"])return t[i];return""}(),e.hasTransition=!!e.transitionEnd;var i=Object.keys(e.status).map(t.escapeRegExp);e.customStyles={},e.Popup=function(){function n(){this.initialise.apply(this,arguments)}function o(e){this.openingTimeout=null,t.removeClass(e,"cc-invisible")}function s(t){t.style.display="none",t.removeEventListener(e.transitionEnd,this.afterTransition),this.afterTransition=null}function a(){var t=this.options.onInitialise.bind(this);if(!window.navigator.cookieEnabled)return t(e.status.deny),!0;if(window.CookiesOK||window.navigator.CookiesOK)return t(e.status.allow),!0;var i=Object.keys(e.status),n=this.getStatus(),o=i.indexOf(n)>=0;return o&&t(n),o}function r(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,i="top"==e.position||"bottom"==e.position?"banner":"floating";t.isMobile()&&(i="floating");var n=["cc-"+i,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&n.push("cc-static"),n.push.apply(n,r.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&n.push(this.customStyleSelector),n}function l(){var e={},i=this.options;i.showLink&&(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var a=o.children[0];return a.style.display="none",t.hasClass(a,"cc-window")&&e.hasTransition&&t.addClass(a,"cc-invisible"),this.onButtonClick=h.bind(this),a.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(a,s.firstChild):s.appendChild(a)),a}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),a=s&&s[1]||!1;a&&(this.setStatus(a),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&this.revokeChoice()}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},a=n.popup,r=n.button,c=n.highlight;a&&(a.text=a.text?a.text:t.getContrast(a.background),a.link=a.link?a.link:a.text,s[o+".cc-window"]=["color: "+a.text,"background-color: "+a.background],s[o+".cc-revoke"]=["color: "+a.text,"background-color: "+a.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+a.link],r&&(r.text=r.text?r.text:t.getContrast(r.background),r.border=r.border?r.border:"transparent",s[o+" .cc-btn"]=["color: "+r.text,"border-color: "+r.border,"background-color: "+r.background],s[o+" .cc-btn:hover"]=["background-color: "+v(r.background)],c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+a.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)s.hasOwnProperty(h)&&l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.alterLuminance(e,.2)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=r.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
    Cookie Policy
    ',compliance:{info:'
    {{dismiss}}
    ',"opt-in":'
    {{dismiss}}{{allow}}
    ',"opt-out":'
    {{deny}}{{dismiss}}
    '},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,regionalLaw:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),a.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=u.call(this,'
    '+i+"
    ");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=u.call(this,i);b.call(this),y.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(t){if(this.element)return this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this},n.prototype.close=function(t){if(this.element)return this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&i&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){i.style.display="",this.options["static"]&&t.addClass(this.element.parentNode,"cc-grow-active");var n=20;this.openingTimeout=setTimeout(o.bind(this,i),n)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&i&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.options["static"]&&t.removeClass(i.parentNode,"cc-grow-active"),this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.revokeChoice=function(e){this.options.enabled=!0,this.clearStatus(),this.options.onRevokeChoice.call(this),e||this.autoOpen()},n.prototype.hasAnswered=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.hasConsented=function(t){var i=this.getStatus();return i==e.status.allow||i==e.status.dismiss},n.prototype.autoOpen=function(e){!this.hasAnswered()&&this.options.enabled&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange.call(this,i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=0}function i(e,t){var i=document.createElement("script");i.type="text/"+(e.type||"javascript"),i.src=e.src||e,i.async=!1,i.onreadystatechange=i.onload=function(){var e=i.readyState;t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),i=i.onreadystatechange=i.onload=null)},document.body.appendChild(i)}function n(e,t,i,n){var o=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(o.open(i?"POST":"GET",e,1),o.setRequestHeader("X-Requested-With","XMLHttpRequest"),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(n))for(var s=0,a=n.length;s3&&t(o)}),o.send(i)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={services:["freegeoip","ipinfo","maxmind"]},a={ipinfo:function(){return{url:"http://ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country}}}},freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}};return e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];return"function"==typeof i?i:"string"==typeof i?a[i]():t.isPlainObject(i)?a[i.name](i):void 0},e.prototype.getCurrentService=function(){var e=this.currentServiceIndex;return this.getServiceByIdx(e)},e.prototype.locate=function(e,t){var i=this,n=this.getCurrentService();n&&(i.callbackComplete=e,i.callbackError=t,i.runService(n,i.runNextServiceOnError.bind(i)))},e.prototype.setupUrl=function(e){return e.url.replace(/\{(.*?)\}/,function(t,i){if("callback"===i){var n="callback"+Date.now();return window[n]=function(t){e.__JSONP_DATA=JSON.stringify(t)},n}})},e.prototype.runService=function(e,t){var o=this;if("function"==typeof e)return void e(t);if(e&&e.url&&e.callback){var s=e.isScript?i:n;s(this.setupUrl(e),function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=t.callback(function(t){o||n.onServiceResult.call(n,e,t)},i);o&&this.onServiceResult.call(this,e,o)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){var i=this.getCurrentService(),n=this.currentServiceIndex;e?(console.log("The service["+n+"] ("+i.url+") responded with the following error",e),a[n+1]?(this.currentServiceIndex++,this.runService(this.getCurrentService(),this.runNextServiceOnError.bind(this))):this.completeService.call(this,this.callbackError,new Error("All services failed"))):this.completeService.call(this,this.callbackComplete,t)},e.prototype.completeService=function(e,t){this.currentServiceIndex=0,e&&e(t)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),e.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);i||(i=function(){}),n||(n=function(){}),e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},n)},e.getCountryCode=function(t,i,n){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var o=new e.Location(t.location);return void o.locate(function(e){i(e||{})},n)}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file +!function(e){if(!e.hasInitialised){var t={escapeRegExp:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},hasClass:function(e,t){var i=" ";return 1===e.nodeType&&(i+e.className+i).replace(/[\n\t]/g,i).indexOf(i+t+i)>=0},addClass:function(e,t){e.className+=" "+t},removeClass:function(e,t){var i=new RegExp("\\b"+this.escapeRegExp(t)+"\\b");e.className=e.className.replace(i,"")},interpolateString:function(e,t){var i=/{{([a-z][a-z0-9\-_]*)}}/gi;return e.replace(i,function(e){return t(arguments[1])||""})},getCookie:function(e){var t="; "+document.cookie,i=t.split("; "+e+"=");return 2!=i.length?void 0:i.pop().split(";").shift()},setCookie:function(e,t,i,n,o){var s=new Date;s.setDate(s.getDate()+(i||365));var r=[e+"="+t,"expires="+s.toUTCString(),"path="+(o||"/")];n&&r.push("domain="+n),document.cookie=r.join(";")},deepExtend:function(e,t){for(var i in t)t.hasOwnProperty(i)&&(i in e&&this.isPlainObject(e[i])&&this.isPlainObject(t[i])?this.deepExtend(e[i],t[i]):e[i]=t[i]);return e},throttle:function(e,t){var i=!1;return function(){i||(e.apply(this,arguments),i=!0,setTimeout(function(){i=!1},t))}},hash:function(e){var t,i,n,o=0;if(0===e.length)return o;for(t=0,n=e.length;t=128?"#000":"#fff"},getLuminance:function(e){var t=parseInt(this.normaliseHex(e),16),i=38,n=(t>>16)+i,o=(t>>8&255)+i,s=(255&t)+i,r=(16777216+65536*(n<255?n<1?0:n:255)+256*(o<255?o<1?0:o:255)+(s<255?s<1?0:s:255)).toString(16).slice(1);return"#"+r},isMobile:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)},isPlainObject:function(e){return"object"==typeof e&&null!==e&&e.constructor==Object}};e.status={deny:"deny",allow:"allow",dismiss:"dismiss"},e.transitionEnd=function(){var e=document.createElement("div"),t={t:"transitionend",OT:"oTransitionEnd",msT:"MSTransitionEnd",MozT:"transitionend",WebkitT:"webkitTransitionEnd"};for(var i in t)if(t.hasOwnProperty(i)&&"undefined"!=typeof e.style[i+"ransition"])return t[i];return""}(),e.hasTransition=!!e.transitionEnd;var i=Object.keys(e.status).map(t.escapeRegExp);e.customStyles={},e.Popup=function(){function n(){this.initialise.apply(this,arguments)}function o(e){this.openingTimeout=null,t.removeClass(e,"cc-invisible")}function s(t){t.style.display="none",t.removeEventListener(e.transitionEnd,this.afterTransition),this.afterTransition=null}function r(){var t=this.options.onInitialise.bind(this);if(!window.navigator.cookieEnabled)return t(e.status.deny),!0;if(window.CookiesOK||window.navigator.CookiesOK)return t(e.status.allow),!0;var i=Object.keys(e.status),n=this.getStatus(),o=i.indexOf(n)>=0;return o&&t(n),o}function a(){var e=this.options.position.split("-"),t=[];return e.forEach(function(e){t.push("cc-"+e)}),t}function c(){var e=this.options,i="top"==e.position||"bottom"==e.position?"banner":"floating";t.isMobile()&&(i="floating");var n=["cc-"+i,"cc-type-"+e.type,"cc-theme-"+e.theme];e["static"]&&n.push("cc-static"),n.push.apply(n,a.call(this));p.call(this,this.options.palette);return this.customStyleSelector&&n.push(this.customStyleSelector),n}function l(){var e={},i=this.options;i.showLink||(i.elements.link="",i.elements.messagelink=i.elements.message),Object.keys(i.elements).forEach(function(n){e[n]=t.interpolateString(i.elements[n],function(e){var t=i.content[e];return e&&"string"==typeof t&&t.length?t:""})});var n=i.compliance[i.type];n||(n=i.compliance.info),e.compliance=t.interpolateString(n,function(t){return e[t]});var o=i.layouts[i.layout];return o||(o=i.layouts.basic),t.interpolateString(o,function(t){return e[t]})}function u(i){var n=this.options,o=document.createElement("div"),s=n.container&&1===n.container.nodeType?n.container:document.body;o.innerHTML=i;var r=o.children[0];return r.style.display="none",t.hasClass(r,"cc-window")&&e.hasTransition&&t.addClass(r,"cc-invisible"),this.onButtonClick=h.bind(this),r.addEventListener("click",this.onButtonClick),n.autoAttach&&(s.firstChild?s.insertBefore(r,s.firstChild):s.appendChild(r)),r}function h(n){var o=n.target;if(t.hasClass(o,"cc-btn")){var s=o.className.match(new RegExp("\\bcc-("+i.join("|")+")\\b")),r=s&&s[1]||!1;r&&(this.setStatus(r),this.close(!0))}t.hasClass(o,"cc-close")&&(this.setStatus(e.status.dismiss),this.close(!0)),t.hasClass(o,"cc-revoke")&&this.revokeChoice()}function p(e){var i=t.hash(JSON.stringify(e)),n="cc-color-override-"+i,o=t.isPlainObject(e);return this.customStyleSelector=o?n:null,o&&d(i,e,"."+n),o}function d(i,n,o){if(e.customStyles[i])return void++e.customStyles[i].references;var s={},r=n.popup,a=n.button,c=n.highlight;r&&(r.text=r.text?r.text:t.getContrast(r.background),r.link=r.link?r.link:r.text,s[o+".cc-window"]=["color: "+r.text,"background-color: "+r.background],s[o+".cc-revoke"]=["color: "+r.text,"background-color: "+r.background],s[o+" .cc-link,"+o+" .cc-link:active,"+o+" .cc-link:visited"]=["color: "+r.link],a&&(a.text=a.text?a.text:t.getContrast(a.background),a.border=a.border?a.border:"transparent",s[o+" .cc-btn"]=["color: "+a.text,"border-color: "+a.border,"background-color: "+a.background],"transparent"!=a.background&&(s[o+" .cc-btn:hover"]=["background-color: "+v(a.background)]),c?(c.text=c.text?c.text:t.getContrast(c.background),c.border=c.border?c.border:"transparent",s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+c.text,"border-color: "+c.border,"background-color: "+c.background]):s[o+" .cc-highlight .cc-btn:first-child"]=["color: "+r.text]));var l=document.createElement("style");document.head.appendChild(l),e.customStyles[i]={references:1,element:l.sheet};var u=-1;for(var h in s)s.hasOwnProperty(h)&&l.sheet.insertRule(h+"{"+s[h].join(";")+"}",++u)}function v(e){return e=t.normaliseHex(e),"000000"==e?"#222":t.getLuminance(e)}function f(i){if(t.isPlainObject(i)){var n=t.hash(JSON.stringify(i)),o=e.customStyles[n];if(o&&!--o.references){var s=o.element.ownerNode;s&&s.parentNode&&s.parentNode.removeChild(s),e.customStyles[n]=null}}}function m(e,t){for(var i=0,n=e.length;i=0&&(this.dismissTimeout=window.setTimeout(function(){t(e.status.dismiss)},Math.floor(i)));var n=this.options.dismissOnScroll;if("number"==typeof n&&n>=0){var o=function(i){window.pageYOffset>Math.floor(n)&&(t(e.status.dismiss),window.removeEventListener("scroll",o),this.onWindowScroll=null)};this.onWindowScroll=o,window.addEventListener("scroll",o)}}function y(){if("info"!=this.options.type&&(this.options.revokable=!0),t.isMobile()&&(this.options.animateRevokable=!1),this.options.revokable){var e=a.call(this);this.options.animateRevokable&&e.push("cc-animate"),this.customStyleSelector&&e.push(this.customStyleSelector);var i=this.options.revokeBtn.replace("{{classes}}",e.join(" "));this.revokeBtn=u.call(this,i);var n=this.revokeBtn;if(this.options.animateRevokable){var o=t.throttle(function(e){var i=!1,o=20,s=window.innerHeight-20;t.hasClass(n,"cc-top")&&e.clientYs&&(i=!0),i?t.hasClass(n,"cc-active")||t.addClass(n,"cc-active"):t.hasClass(n,"cc-active")&&t.removeClass(n,"cc-active")},200);this.onMouseMove=o,window.addEventListener("mousemove",o)}}}var g={enabled:!0,container:null,cookie:{name:"cookieconsent_status",path:"/",domain:"",expiryDays:365},onPopupOpen:function(){},onPopupClose:function(){},onInitialise:function(e){},onStatusChange:function(e,t){},onRevokeChoice:function(){},content:{header:"Cookies used on the website!",message:"This website uses cookies to ensure you get the best experience on our website.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",href:"http://cookiesandyou.com",close:"❌"},elements:{header:'{{header}} ',message:'{{message}}',messagelink:'{{message}} {{link}}',dismiss:'{{dismiss}}',allow:'{{allow}}',deny:'{{deny}}',link:'{{link}}',close:'{{close}}'},window:'',revokeBtn:'
    Cookie Policy
    ',compliance:{info:'
    {{dismiss}}
    ',"opt-in":'
    {{dismiss}}{{allow}}
    ',"opt-out":'
    {{deny}}{{dismiss}}
    '},type:"info",layouts:{basic:"{{messagelink}}{{compliance}}","basic-close":"{{messagelink}}{{compliance}}{{close}}","basic-header":"{{header}}{{message}}{{link}}{{compliance}}"},layout:"basic",position:"bottom",theme:"block",palette:null,revokable:!1,animateRevokable:!0,showLink:!0,dismissOnScroll:!1,dismissOnTimeout:!1,autoOpen:!0,autoAttach:!0,whitelistPage:[],blacklistPage:[],overrideHTML:null};return n.prototype.initialise=function(e){this.options&&this.destroy(),t.deepExtend(this.options={},g),t.isPlainObject(e)&&t.deepExtend(this.options,e),r.call(this)&&(this.options.enabled=!1),m(this.options.blacklistPage,location.pathname)&&(this.options.enabled=!1),m(this.options.whitelistPage,location.pathname)&&(this.options.enabled=!0);var i=this.options.window.replace("{{classes}}",c.call(this).join(" ")).replace("{{children}}",l.call(this)),n=this.options.overrideHTML;if("string"==typeof n&&n.length&&(i=n),this.options["static"]){var o=u.call(this,'
    '+i+"
    ");o.style.display="",this.element=o.firstChild,this.element.style.display="none",t.addClass(this.element,"cc-invisible")}else this.element=u.call(this,i);b.call(this),y.call(this),this.options.autoOpen&&this.autoOpen()},n.prototype.destroy=function(){this.onButtonClick&&this.element&&(this.element.removeEventListener("click",this.onButtonClick),this.onButtonClick=null),this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.onWindowScroll&&(window.removeEventListener("scroll",this.onWindowScroll),this.onWindowScroll=null),this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.revokeBtn&&this.revokeBtn.parentNode&&this.revokeBtn.parentNode.removeChild(this.revokeBtn),this.revokeBtn=null,f(this.options.palette),this.options=null},n.prototype.open=function(t){if(this.element)return this.isOpen()||(e.hasTransition?this.fadeIn():this.element.style.display="",this.options.revokable&&this.toggleRevokeButton(),this.options.onPopupOpen.call(this)),this},n.prototype.close=function(t){if(this.element)return this.isOpen()&&(e.hasTransition?this.fadeOut():this.element.style.display="none",t&&this.options.revokable&&this.toggleRevokeButton(!0),this.options.onPopupClose.call(this)),this},n.prototype.fadeIn=function(){var i=this.element;if(e.hasTransition&&i&&(this.afterTransition&&s.call(this,i),t.hasClass(i,"cc-invisible"))){if(i.style.display="",this.options["static"]){var n=this.element.clientHeight;this.element.parentNode.style.maxHeight=n+"px"}var r=20;this.openingTimeout=setTimeout(o.bind(this,i),r)}},n.prototype.fadeOut=function(){var i=this.element;e.hasTransition&&i&&(this.openingTimeout&&(clearTimeout(this.openingTimeout),o.bind(this,i)),t.hasClass(i,"cc-invisible")||(this.options["static"]&&(this.element.parentNode.style.maxHeight=""),this.afterTransition=s.bind(this,i),i.addEventListener(e.transitionEnd,this.afterTransition),t.addClass(i,"cc-invisible")))},n.prototype.isOpen=function(){return this.element&&""==this.element.style.display&&(!e.hasTransition||!t.hasClass(this.element,"cc-invisible"))},n.prototype.toggleRevokeButton=function(e){this.revokeBtn&&(this.revokeBtn.style.display=e?"":"none")},n.prototype.revokeChoice=function(e){this.options.enabled=!0,this.clearStatus(),this.options.onRevokeChoice.call(this),e||this.autoOpen()},n.prototype.hasAnswered=function(t){return Object.keys(e.status).indexOf(this.getStatus())>=0},n.prototype.hasConsented=function(t){var i=this.getStatus();return i==e.status.allow||i==e.status.dismiss},n.prototype.autoOpen=function(e){!this.hasAnswered()&&this.options.enabled&&this.open()},n.prototype.setStatus=function(i){var n=this.options.cookie,o=t.getCookie(n.name),s=Object.keys(e.status).indexOf(o)>=0;Object.keys(e.status).indexOf(i)>=0?(t.setCookie(n.name,i,n.expiryDays,n.domain,n.path),this.options.onStatusChange.call(this,i,s)):this.clearStatus()},n.prototype.getStatus=function(){return t.getCookie(this.options.cookie.name)},n.prototype.clearStatus=function(){var e=this.options.cookie;t.setCookie(e.name,"",-1,e.domain,e.path)},n}(),e.Location=function(){function e(e){t.deepExtend(this.options={},s),t.isPlainObject(e)&&t.deepExtend(this.options,e),this.currentServiceIndex=-1}function i(e,t,i){var n,o=document.createElement("script");o.type="text/"+(e.type||"javascript"),o.src=e.src||e,o.async=!1,o.onreadystatechange=o.onload=function(){var e=o.readyState;clearTimeout(n),t.done||e&&!/loaded|complete/.test(e)||(t.done=!0,t(),o.onreadystatechange=o.onload=null)},document.body.appendChild(o),n=setTimeout(function(){t.done=!0,t(),o.onreadystatechange=o.onload=null},i)}function n(e,t,i,n,o){var s=new(window.XMLHttpRequest||window.ActiveXObject)("MSXML2.XMLHTTP.3.0");if(s.open(n?"POST":"GET",e,1),s.setRequestHeader("X-Requested-With","XMLHttpRequest"),s.setRequestHeader("Content-type","application/x-www-form-urlencoded"),Array.isArray(o))for(var r=0,a=o.length;r3&&t(s)}),s.send(n)}function o(e){return new Error("Error ["+(e.code||"UNKNOWN")+"]: "+e.error)}var s={timeout:5e3,services:["freegeoip","ipinfo","maxmind"],serviceDefinitions:{freegeoip:function(){return{url:"//freegeoip.net/json/?callback={callback}",isScript:!0,callback:function(e,t){try{var i=JSON.parse(t);return i.error?o(i):{code:i.country_code}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},ipinfo:function(){return{url:"//ipinfo.io",headers:["Accept: application/json"],callback:function(e,t){try{var i=JSON.parse(t);return i.error?o(i):{code:i.country}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},ipinfodb:function(e){return{url:"//api.ipinfodb.com/v3/ip-country/?key={api_key}&format=json&callback={callback}",isScript:!0,callback:function(e,t){try{var i=JSON.parse(t);return"ERROR"==i.statusCode?o({error:i.statusMessage}):{code:i.countryCode}}catch(n){return o({error:"Invalid response ("+n+")"})}}}},maxmind:function(){return{url:"//js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js",isScript:!0,callback:function(e){return window.geoip2?void geoip2.country(function(t){e({code:t.country.iso_code})},function(t){e(o(t))}):void e(new Error("Unexpected response format. The downloaded script should have exported `geoip2` to the global scope"))}}}}};return e.prototype.getNextService=function(){var e;do e=this.getServiceByIdx(++this.currentServiceIndex);while(!e);return e},e.prototype.getServiceByIdx=function(e){var i=this.options.services[e];if("function"==typeof i){var n=i();return n.name&&t.deepExtend(n,this.options.serviceDefinitions[n.name](n)),n}return"string"==typeof i?this.options.serviceDefinitions[i]():t.isPlainObject(i)?this.options.serviceDefinitions[i.name](i):null},e.prototype.locate=function(e,t){var i=this.getNextService();return i?(this.callbackComplete=e,this.callbackError=t,void this.runService(i,this.runNextServiceOnError.bind(this))):void t(new Error("No services to run"))},e.prototype.setupUrl=function(e){var t=this.getCurrentServiceOpts();return e.url.replace(/\{(.*?)\}/g,function(i,n){if("callback"===n){var o="callback"+Date.now();return window[o]=function(t){e.__JSONP_DATA=JSON.stringify(t)},o}if(n in t.interpolateUrl)return t.interpolateUrl[n]})},e.prototype.runService=function(e,t){var o=this;if(e&&e.url&&e.callback){var s=e.isScript?i:n,r=this.setupUrl(e);s(r,function(i){var n=i?i.responseText:"";e.__JSONP_DATA&&(n=e.__JSONP_DATA,delete e.__JSONP_DATA),o.runServiceCallback.call(o,t,e,n)},this.options.timeout,e.data,e.headers)}},e.prototype.runServiceCallback=function(e,t,i){var n=this,o=function(t){s||n.onServiceResult.call(n,e,t)},s=t.callback(o,i);s&&this.onServiceResult.call(this,e,s)},e.prototype.onServiceResult=function(e,t){t instanceof Error||t&&t.error?e.call(this,t,null):e.call(this,null,t)},e.prototype.runNextServiceOnError=function(e,t){if(e){this.logError(e);var i=this.getNextService();i?this.runService(i,this.runNextServiceOnError.bind(this)):this.completeService.call(this,this.callbackError,new Error("All services failed"))}else this.completeService.call(this,this.callbackComplete,t)},e.prototype.getCurrentServiceOpts=function(){var e=this.options.services[this.currentServiceIndex];return"string"==typeof e?{name:e}:"function"==typeof e?e():t.isPlainObject(e)?e:{}},e.prototype.completeService=function(e,t){this.currentServiceIndex=-1,e&&e(t)},e.prototype.logError=function(e){var t=this.currentServiceIndex,i=this.getServiceByIdx(t);console.error("The service["+t+"] ("+i.url+") responded with the following error",e)},e}(),e.Law=function(){function e(e){this.initialise.apply(this,arguments)}var i={regionalLaw:!0,hasLaw:["AT","BE","BG","HR","CZ","CY","DK","EE","FI","FR","DE","EL","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","SK","SI","ES","SE","GB","UK"],revokable:["HR","CY","DK","EE","FR","DE","LV","LT","NL","PT","ES"],explicitAction:["HR","IT","ES"]};return e.prototype.initialise=function(e){t.deepExtend(this.options={},i),t.isPlainObject(e)&&t.deepExtend(this.options,e)},e.prototype.get=function(e){var t=this.options;return{hasLaw:t.hasLaw.indexOf(e)>=0,revokable:t.revokable.indexOf(e)>=0,explicitAction:t.explicitAction.indexOf(e)>=0}},e.prototype.applyLaw=function(e,t){var i=this.get(t);return i.hasLaw||(e.enabled=!1),this.options.regionalLaw&&(i.revokable&&(e.revokable=!0),i.explicitAction&&(e.dismissOnScroll=!1,e.dismissOnTimeout=!1)),e},e}(),e.initialise=function(t,i,n){var o=new e.Law(t.law);i||(i=function(){}),n||(n=function(){}),e.getCountryCode(t,function(n){delete t.law,delete t.location,n.code&&(t=o.applyLaw(t,n.code)),i(new e.Popup(t))},function(i){delete t.law,delete t.location,n(i,new e.Popup(t))})},e.getCountryCode=function(t,i,n){if(t.law&&t.law.countryCode)return void i({code:t.law.countryCode});if(t.location){var o=new e.Location(t.location);return void o.locate(function(e){i(e||{})},n)}i({})},e.utils=t,e.hasInitialised=!0,window.cookieconsent=e}}(window.cookieconsent||{}); \ No newline at end of file From 098a715f08deea53ed7bd3d6933a720e79b5c3b8 Mon Sep 17 00:00:00 2001 From: Alex Morley-Finch Date: Mon, 19 Sep 2016 14:38:04 +0100 Subject: [PATCH 70/70] added default option of false for 'static' --- src/cookieconsent.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cookieconsent.js b/src/cookieconsent.js index 0829a1aa..83cd03de 100644 --- a/src/cookieconsent.js +++ b/src/cookieconsent.js @@ -280,6 +280,10 @@ // Note: style "wire" is used for the configurator, but has no CSS styles of it's own, only palette is used. theme: 'block', + // The popup is `fixed` by default, but if you want it to be static (inline with the page content), set this to false + // Note: by default, we animate the height of the popup from 0 to full size + static: false, + // if you want custom colours, pass them in here. this object should look like this. // ideally, any custom colours/themes should be created in a separate style sheet, as this is more efficient. // {