diff --git a/tarteaucitron.js b/tarteaucitron.js index 698397a..0eb4bc4 100644 --- a/tarteaucitron.js +++ b/tarteaucitron.js @@ -17,7 +17,7 @@ var scripts = document.getElementsByTagName('script'), var tarteaucitron = { - "version": 20210422, + "version": 20210509, "cdn": cdn, "user": {}, "lang": {}, @@ -517,13 +517,13 @@ var tarteaucitron = { var tacRootAvailableEvent; if(typeof(Event) === 'function') { tacRootAvailableEvent = new Event("tac.root_available"); - }else{ + }else if (typeof(document.createEvent) === 'function'){ tacRootAvailableEvent = document.createEvent('Event'); tacRootAvailableEvent.initEvent("tac.root_available", true, true); } //end ie compatibility - window.dispatchEvent(tacRootAvailableEvent); + if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacRootAvailableEvent);} if (tarteaucitron.job !== undefined) { tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job); @@ -862,7 +862,7 @@ var tarteaucitron = { var send_event_item; if(typeof(Event) === 'function') { send_event_item = new Event(event_key); - }else{ + }else if (typeof(document.createEvent) === 'function'){ send_event_item = document.createEvent('Event'); send_event_item.initEvent(event_key, true, true); } @@ -923,13 +923,13 @@ var tarteaucitron = { }, "addClass": function (id, className) { "use strict"; - if (document.getElementById(id) !== null) { + if (document.getElementById(id) !== null && document.getElementById(id).classList !== undefined) { document.getElementById(id).classList.add(className); } }, "removeClass": function (id, className) { "use strict"; - if (document.getElementById(id) !== null) { + if (document.getElementById(id) !== null && document.getElementById(id).classList !== undefined) { document.getElementById(id).classList.remove(className); } }, @@ -1028,11 +1028,11 @@ var tarteaucitron = { if (key !== "") { if (status === true) { - document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed'); - document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied'); + tarteaucitron.userInterface.addClass(key + 'Line', 'tarteaucitronIsAllowed'); + tarteaucitron.userInterface.removeClass(key + 'Line', 'tarteaucitronIsDenied'); } else if (status === false) { - document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed'); - document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied'); + tarteaucitron.userInterface.removeClass(key + 'Line', 'tarteaucitronIsAllowed'); + tarteaucitron.userInterface.addClass(key + 'Line', 'tarteaucitronIsDenied'); } // check if all services are allowed @@ -1141,7 +1141,9 @@ var tarteaucitron = { tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none'); document.getElementById('tarteaucitronClosePanel').focus(); - document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open'); + if (document.getElementsByTagName('body')[0].classList !== undefined) { + document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open'); + } tarteaucitron.userInterface.focusTrap(); tarteaucitron.userInterface.jsSizing('main'); @@ -1149,13 +1151,13 @@ var tarteaucitron = { var tacOpenPanelEvent; if(typeof(Event) === 'function') { tacOpenPanelEvent = new Event("tac.open_panel"); - }else{ + }else if (typeof(document.createEvent) === 'function'){ tacOpenPanelEvent = document.createEvent('Event'); tacOpenPanelEvent.initEvent("tac.open_panel", true, true); } //end ie compatibility - window.dispatchEvent(tacOpenPanelEvent); + if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacOpenPanelEvent);} }, "closePanel": function () { "use strict"; @@ -1182,19 +1184,21 @@ var tarteaucitron = { if (document.getElementById('tarteaucitronCloseAlert') !== null) { document.getElementById('tarteaucitronCloseAlert').focus(); } - document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open'); + if (document.getElementsByTagName('body')[0].classList !== undefined) { + document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open'); + } //ie compatibility var tacClosePanelEvent; if(typeof(Event) === 'function') { tacClosePanelEvent = new Event("tac.close_panel"); - }else{ + }else if (typeof(document.createEvent) === 'function'){ tacClosePanelEvent = document.createEvent('Event'); tacClosePanelEvent.initEvent("tac.close_panel", true, true); } //end ie compatibility - window.dispatchEvent(tacClosePanelEvent); + if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacClosePanelEvent);} }, "focusTrap": function() { "use strict"; @@ -1249,7 +1253,7 @@ var tarteaucitron = { var tacOpenAlertEvent; if(typeof(Event) === 'function') { tacOpenAlertEvent = new Event("tac.open_alert"); - }else{ + }else if (typeof(document.createEvent) === 'function'){ tacOpenAlertEvent = document.createEvent('Event'); tacOpenAlertEvent.initEvent("tac.open_alert", true, true); } @@ -1259,7 +1263,7 @@ var tarteaucitron = { document.getElementById('tarteaucitronAlertBig').focus(); } - window.dispatchEvent(tacOpenAlertEvent); + if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacOpenAlertEvent);} }, "closeAlert": function () { "use strict"; @@ -1275,13 +1279,13 @@ var tarteaucitron = { var tacCloseAlertEvent; if(typeof(Event) === 'function') { tacCloseAlertEvent = new Event("tac.close_alert"); - }else{ + }else if (typeof(document.createEvent) === 'function'){ tacCloseAlertEvent = document.createEvent('Event'); tacCloseAlertEvent.initEvent("tac.close_alert", true, true); } //end ie compatibility - window.dispatchEvent(tacCloseAlertEvent); + if (typeof(window.dispatchEvent) === 'function') {window.dispatchEvent(tacCloseAlertEvent);} }, "toggleCookiesList": function () { "use strict"; diff --git a/tarteaucitron.services.js b/tarteaucitron.services.js index 76e9337..fb2fe59 100644 --- a/tarteaucitron.services.js +++ b/tarteaucitron.services.js @@ -357,7 +357,7 @@ tarteaucitron.services.facebookpost = { "js": function () { "use strict"; tarteaucitron.fallback(['tac_facebookpost'], function (x) { - var frame_title = tarteaucitron.fixSelfXSS(x.getAttribute("title") || 'Michel'), + var frame_title = tarteaucitron.fixSelfXSS(x.getAttribute("title") || 'Facebook iframe'), width = x.getAttribute("width"), height = x.getAttribute("height"), url = x.getAttribute("data-url"), @@ -1826,14 +1826,7 @@ tarteaucitron.services.gtag = { * https://support.google.com/analytics/answer/7476333?hl=en * https://developers.google.com/analytics/devguides/collection/gtagjs/cross-domain */ - gtag( - 'config', - tarteaucitron.user.gtagUa, - { 'anonymize_ip': true }, - {linker: { - domains: tarteaucitron.user.gtagCrossdomain, - }}, - ); + gtag('config',tarteaucitron.user.gtagUa,{ 'anonymize_ip': true },{linker: {domains: tarteaucitron.user.gtagCrossdomain,}}); } else { gtag('config', tarteaucitron.user.gtagUa, { 'anonymize_ip': true }); } @@ -3158,7 +3151,7 @@ tarteaucitron.services.verizondottag = { }); tarteaucitron.addScript('https://s.yimg.com/wi/ytc.js', '', function () { - const items = window.dotq; + //const items = window.dotq; window.dotq = []; window.dotq.push = function (item) { YAHOO.ywa.I13N.fireBeacon([item])