1/*! 2 * jQuery Cookiebar Plugin 3 * https://github.com/carlwoodhouse/jquery.cookieBar 4 * 5 */ 6 7(function ($) { 8 $.cookie = function (key, value, options) { 9 if (arguments.length > 1 && (!/Object/.test(Object.prototype.toString.call(value)) || value === null || value === undefined)) { 10 options = $.extend({}, options); 11 12 if (value === null || value === undefined) { 13 options.expires = -1; 14 } 15 16 if (typeof options.expires === 'number') { 17 var days = options.expires, t = options.expires = new Date(); 18 t.setDate(t.getDate() + days); 19 } 20 21 value = String(value); 22 23 return (document.cookie = [ 24 encodeURIComponent(key), '=', options.raw ? value : encodeURIComponent(value), 25 options.expires ? '; expires=' + options.expires.toUTCString() : '', // max-age is not supported by IE 26 options.path ? '; path=' + options.path : '', 27 options.domain ? '; domain=' + options.domain : '', 28 options.secure ? '; secure' : '' 29 ].join('')); 30 } 31 options = value || {}; 32 var decode = options.raw ? function (s) { return s; } : decodeURIComponent; 33 34 var pairs = document.cookie.split('; '); 35 for (var i = 0, pair; pair = pairs[i] && pairs[i].split('='); i++) { 36 // IE 37 if (decode(pair[0]) === key) return decode(pair[1] || ''); 38 } 39 return null; 40 }; 41 42 $.fn.cookieBar = function (options) { 43 var settings = $.extend({ 44 'closeButton': '.cookiebar-close', 45 'hideOnClose': true, 46 'secure': false, 47 'path': '/', 48 'domain': '', 49 'name': 'cookiestatus', 50 'expiresDays': 365 51 }, options); 52 53 return this.each(function () { 54 var cookiebar = $(this); 55 56 // just in case they didnt hide it by default. 57 cookiebar.hide(); 58 59 // if close button not defined. define it! 60 if (settings.closeButton == 'none') { 61 cookiebar.append('<a class="cookiebar-close">OK</a>'); 62 $.extend(settings, { 'closeButton': '.cookiebar-close' }); 63 } 64 65 if ($.cookie(settings.name) != 'accepted') { 66 cookiebar.show(); 67 } 68 69 cookiebar.find(settings.closeButton).click(function () { 70 if (settings.hideOnClose) { 71 cookiebar.hide(); 72 } 73 $.cookie(settings.name, 'accepted', { path: settings.path, secure: settings.secure, domain: settings.domain, expires: settings.expiresDays }); 74 // tell matomo consent is given 75 _paq.push(['rememberConsentGiven', settings.expiresDays*24]); 76 cookiebar.trigger('cookiebar-close'); 77 return false; 78 }); 79 }); 80 }; 81 82 // self injection init 83 $.cookieBar = function (options) { 84 $('.cookie-bar').cookieBar(options); 85 }; 86})(jQuery); 87 88$(document).ready(function() { 89 $('.cookie-bar').cookieBar(); 90});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.