You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
3.8 KiB
10 lines
3.8 KiB
/*!
|
|
* ihavecookies - jQuery plugin for displaying cookie/privacy message
|
|
* v0.3.1
|
|
*
|
|
* Copyright (c) 2018 Ketan Mistry (https://iamketan.com.au)
|
|
* Licensed under the MIT license:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
*/
|
|
!function(e){e.fn.ihavecookies=function(n){var a=e(this),c=e.extend({cookieTypes:[{type:"Site Preferences",value:"preferences",description:"These are cookies that are related to your site preferences, e.g. remembering your username, site colours, etc."},{type:"Analytics",value:"analytics",description:"Cookies related to site visits, browser types, etc."},{type:"Marketing",value:"marketing",description:"Cookies related to marketing, e.g. newsletters, social media, etc"}],title:"Cookies & Privacy",message:"Cookies enable you to use shopping carts and to personalize your experience on our sites, tell us which parts of our websites people have visited, help us measure the effectiveness of ads and web searches, and give us insights into user behavior so we can improve our communications and products.",link:"/privacy-policy",delay:2e3,expires:30,moreInfoLabel:"More information",acceptBtnLabel:"Accept Cookies",advancedBtnLabel:"Customise Cookies",cookieTypesTitle:"Select cookies to accept",fixedCookieTypeLabel:"Necessary",fixedCookieTypeDesc:"These are cookies that are essential for the website to work correctly.",onAccept:function(){},uncheckBoxes:!1},n),r=t("cookieControl"),s=t("cookieControlPrefs");if(r&&s){var p=!0;"false"==r&&(p=!1),o(p,c.expires)}else{var d='<li><input type="checkbox" name="gdpr[]" value="necessary" checked="checked" disabled="disabled"> <label title="'+c.fixedCookieTypeDesc+'">'+c.fixedCookieTypeLabel+"</label></li>";e.each(c.cookieTypes,function(e,o){if(""!==o.type&&""!==o.value){var i="";o.description!==!1&&(i=' title="'+o.description+'"'),d+='<li><input type="checkbox" id="gdpr-cookietype-'+o.value+'" name="gdpr[]" value="'+o.value+'" data-auto="on"> <label for="gdpr-cookietype-'+o.value+'"'+i+">"+o.type+"</label></li>"}});var l='<div id="gdpr-cookie-message"><h4>'+c.title+"</h4><p>"+c.message+' <a href="'+c.link+'">'+c.moreInfoLabel+'</a><div id="gdpr-cookie-types" style="display:none;"><h5>'+c.cookieTypesTitle+"</h5><ul>"+d+'</ul></div><p><button id="gdpr-cookie-accept" type="button">'+c.acceptBtnLabel+'</button><button id="gdpr-cookie-advanced" type="button">'+c.advancedBtnLabel+"</button></p></div>";setTimeout(function(){e(a).append(l),e("#gdpr-cookie-message").hide().fadeIn("slow")},c.delay),e("body").on("click","#gdpr-cookie-accept",function(){o(!0,c.expires),e('input[name="gdpr[]"][data-auto="on"]').prop("checked",!0);var t=[];e.each(e('input[name="gdpr[]"]').serializeArray(),function(e,o){t.push(o.value)}),i("cookieControlPrefs",JSON.stringify(t),365),c.onAccept.call(this)}),e("body").on("click","#gdpr-cookie-advanced",function(){e('input[name="gdpr[]"]:not(:disabled)').attr("data-auto","off").prop("checked",!1),e("#gdpr-cookie-types").slideDown("fast",function(){e("#gdpr-cookie-advanced").prop("disabled",!0)})})}c.uncheckBoxes===!0&&e('input[type="checkbox"].ihavecookies').prop("checked",!1)},e.fn.ihavecookies.cookie=function(){var e=t("cookieControlPrefs");return JSON.parse(e)},e.fn.ihavecookies.preference=function(e){var o=t("cookieControl"),i=t("cookieControlPrefs");return i=JSON.parse(i),o!==!1&&(i!==!1&&i.indexOf(e)!==-1)};var o=function(o,t){i("cookieControl",o,t),e("#gdpr-cookie-message").fadeOut("fast",function(){e(this).remove()})},i=function(e,o,i){var n=new Date;n.setTime(n.getTime()+24*i*60*60*1e3);var a="expires="+n.toUTCString();return document.cookie=e+"="+o+";"+a+";path=/",t(e)},t=function(e){for(var o=e+"=",i=decodeURIComponent(document.cookie),t=i.split(";"),n=0;n<t.length;n++){for(var a=t[n];" "==a.charAt(0);)a=a.substring(1);if(0===a.indexOf(o))return a.substring(o.length,a.length)}return!1}}(jQuery);
|