Sha256: 901859316eea79f8bdc3657ceab103270fe4bbbd840a6053fba4692f9b27cad1

Contents?: true

Size: 1.1 KB

Versions: 4

Compression:

Stored size: 1.1 KB

Contents

//= require js.cookie
'use strict';

var cookiesEu = {
  init: function() {
    var cookiesEuOKButton = document.querySelector('.js-cookies-eu-ok');

    if (cookiesEuOKButton) {
      this.addListener(cookiesEuOKButton);
    }
  },

  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() {
  var isCalled = false;

  function isReady() {
    if (isCalled) return;
    isCalled = true;

    cookiesEu.init();
  }

  if (document.addEventListener) {
    document.addEventListener('DOMContentLoaded', isReady, false);
  }

  // Old browsers IE < 9
  if (window.addEventListener) {
    window.addEventListener('load', isReady, false);
  } else if (window.attachEvent) {
    window.attachEvent('onload', isReady);
  }
})();

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cookies_eu-1.6.3 app/assets/javascripts/cookies_eu.js
cookies_eu-1.6.2 app/assets/javascripts/cookies_eu.js
cookies_eu-1.6.1 app/assets/javascripts/cookies_eu.js
cookies_eu-1.6.0 app/assets/javascripts/cookies_eu.js