Sha256: 9bb6a1ff57abffbc070673b106863a4bc181039a4f15c70686db6b594602055d
Contents?: true
Size: 1.62 KB
Versions: 5
Compression:
Stored size: 1.62 KB
Contents
//= require js.cookie 'use strict'; var windowIsTurbolinked = 'Turbolinks' in window; var cookiesEu = { init: function() { var cookiesEuOKButton = document.querySelector('.js-cookies-eu-ok'); if (cookiesEuOKButton) { this.addListener(cookiesEuOKButton); // clear turbolinks cache so cookie banner does not reappear windowIsTurbolinked && window.Turbolinks.clearCache(); } }, addListener: function(target) { // Support for IE < 9 if (target.attachEvent) { target.attachEvent('onclick', this.setCookie); } else { target.addEventListener('click', this.setCookie, false); } }, setCookie: function() { Cookies.set('cookie_eu_consented', true, { path: '/', expires: 365 }); var container = document.querySelector('.js-cookies-eu'); container.parentNode.removeChild(container); } }; (function() { function eventName(fallback) { return windowIsTurbolinked ? 'turbolinks:load' : fallback } var isCalled = false; function isReady() { // return early when cookiesEu.init has been called AND Turbolinks is NOT included // when Turbolinks is included cookiesEu.init has to be called on every page load if (isCalled && !windowIsTurbolinked) { return } isCalled = true; cookiesEu.init(); } if (document.addEventListener) { return document.addEventListener(eventName('DOMContentLoaded'), isReady, false); } // Old browsers IE < 9 if (window.addEventListener) { window.addEventListener(eventName('load'), isReady, false); } else if (window.attachEvent) { window.attachEvent(eventName('onload'), isReady); } })();
Version data entries
5 entries across 5 versions & 1 rubygems