1(function ($) { 2 Drupal.behaviors.simpleCookie = { 3 attach: function (context, settings) { 4 var cookieName = 'simple_cookie_hidden'; 5 var cookieDays = 365; 6 7 if (settings.simpleCookie && settings.simpleCookie.cookieName) { 8 cookieName = settings.simpleCookie.cookieName; 9 } 10 11 if (settings.simpleCookie && settings.simpleCookie.cookieDays) { 12 cookieDays = settings.simpleCookie.cookieDays; 13 } 14 15 function setCookie(name, value, days) { 16 var expires = ''; 17 18 if (days) { 19 var date = new Date(); 20 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 21 expires = '; expires=' + date.toUTCString(); 22 } 23 24 document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/; SameSite=Lax'; 25 } 26 27 function getCookie(name) { 28 var nameEQ = name + '='; 29 var ca = document.cookie.split(';'); 30 31 for (var i = 0; i < ca.length; i++) { 32 var c = ca[i]; 33 34 while (c.charAt(0) === ' ') { 35 c = c.substring(1, c.length); 36 } 37 38 if (c.indexOf(nameEQ) === 0) { 39 return decodeURIComponent(c.substring(nameEQ.length, c.length)); 40 } 41 } 42 43 return null; 44 } 45 46 function hideBanner($banner) { 47 $banner.addClass('is-hiding'); 48 49 setTimeout(function () { 50 $banner.remove(); 51 }, 350); 52 } 53 54 var hidden = getCookie(cookieName); 55 56 $('.cookie-banner', context).once('simple-cookie-init').each(function () { 57 var $banner = $(this); 58 59 if (hidden === '1') { 60 $banner.remove(); 61 return; 62 } 63 64 $banner.find('.js-simple-cookie-accept').once('simple-cookie-accept').on('click', function (e) { 65 e.preventDefault(); 66 setCookie(cookieName, '1', cookieDays); 67 hideBanner($banner); 68 }); 69 70 $banner.find('.js-simple-cookie-close').once('simple-cookie-close').on('click', function (e) { 71 e.preventDefault(); 72 setCookie(cookieName, '1', cookieDays); 73 hideBanner($banner); 74 }); 75 }); 76 } 77 }; 78})(jQuery);
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.