app/assets/javascripts/cookies_eu.js in cookies_eu-1.3.0 vs app/assets/javascripts/cookies_eu.js in cookies_eu-1.4.0
- old
+ new
@@ -1,9 +1,33 @@
-//= require jquery.cookie
+//= require js.cookie
+'use strict';
-$(document).ready( function(){
- $('.cookies-eu-ok').click(function(e){
- e.preventDefault();
- $.cookie('cookie_eu_consented', true, { path: '/', expires: 365 });
- $('.cookies-eu').remove();
- });
+document.addEventListener('DOMContentLoaded', function() {
+
+ 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 });
+
+ document.querySelector('.js-cookies-eu').remove();
+ }
+ }
+
+ cookiesEu.init();
+
});