tarteaucitron.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. /*jslint browser: true, evil: true */
  2. var scripts = document.getElementsByTagName('script'),
  3. path = scripts[scripts.length - 1].src.split('?')[0],
  4. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  5. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  6. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  7. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  8. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  9. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  10. // tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
  11. tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || typeof tarteaucitronExpireInDay !== "boolean") ? true : tarteaucitronExpireInDay,
  12. timeExpire = 31536000000,
  13. tarteaucitronProLoadServices,
  14. tarteaucitronNoAdBlocker = false;
  15. var tarteaucitron = {
  16. "version": 20201110,
  17. "cdn": cdn,
  18. "user": {},
  19. "lang": {},
  20. "services": {},
  21. "added": [],
  22. "idprocessed": [],
  23. "state": [],
  24. "launch": [],
  25. "parameters": {},
  26. "isAjax": false,
  27. "reloadThePage": false,
  28. "events": {
  29. "init": function () {},
  30. "load": function () {},
  31. },
  32. "init": function (params) {
  33. "use strict";
  34. var origOpen;
  35. tarteaucitron.parameters = params;
  36. if (alreadyLaunch === 0) {
  37. alreadyLaunch = 1;
  38. if (window.addEventListener) {
  39. window.addEventListener("load", function () {
  40. tarteaucitron.initEvents.loadEvent(false);
  41. }, false);
  42. window.addEventListener("scroll", function () {
  43. tarteaucitron.initEvents.scrollEvent();
  44. }, false);
  45. window.addEventListener("keydown", function (evt) {
  46. tarteaucitron.initEvents.keydownEvent(false, evt);
  47. }, false);
  48. window.addEventListener("hashchange", function () {
  49. tarteaucitron.initEvents.hashchangeEvent();
  50. }, false);
  51. window.addEventListener("resize", function () {
  52. tarteaucitron.initEvents.resizeEvent();
  53. }, false);
  54. } else {
  55. window.attachEvent("onload", function () {
  56. tarteaucitron.initEvents.loadEvent(true);
  57. });
  58. window.attachEvent("onscroll", function () {
  59. tarteaucitron.initEvents.scrollEvent();
  60. });
  61. window.attachEvent("onkeydown", function (evt) {
  62. tarteaucitron.initEvents.keydownEvent(true, evt);
  63. });
  64. window.attachEvent("onhashchange", function () {
  65. tarteaucitron.initEvents.hashchangeEvent();
  66. });
  67. window.attachEvent("onresize", function () {
  68. tarteaucitron.initEvents.resizeEvent();
  69. });
  70. }
  71. if (typeof XMLHttpRequest !== 'undefined') {
  72. origOpen = XMLHttpRequest.prototype.open;
  73. XMLHttpRequest.prototype.open = function () {
  74. if (window.addEventListener) {
  75. this.addEventListener("load", function () {
  76. if (typeof tarteaucitronProLoadServices === 'function') {
  77. tarteaucitronProLoadServices();
  78. }
  79. }, false);
  80. } else if (typeof this.attachEvent !== 'undefined') {
  81. this.attachEvent("onload", function () {
  82. if (typeof tarteaucitronProLoadServices === 'function') {
  83. tarteaucitronProLoadServices();
  84. }
  85. });
  86. } else {
  87. if (typeof tarteaucitronProLoadServices === 'function') {
  88. setTimeout(tarteaucitronProLoadServices, 1000);
  89. }
  90. }
  91. try {
  92. origOpen.apply(this, arguments);
  93. } catch (err) {}
  94. };
  95. }
  96. }
  97. if(tarteaucitron.events.init) {
  98. tarteaucitron.events.init();
  99. }
  100. },
  101. "initEvents": {
  102. "loadEvent": function (isOldBrowser) {
  103. tarteaucitron.load();
  104. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  105. if (isOldBrowser) {
  106. elem.attachEvent("onclick", function (event) {
  107. tarteaucitron.userInterface.openPanel();
  108. event.preventDefault();
  109. });
  110. } else {
  111. elem.addEventListener("click", function (event) {
  112. tarteaucitron.userInterface.openPanel();
  113. event.preventDefault();
  114. }, false);
  115. }
  116. }, true);
  117. },
  118. "keydownEvent": function (isOldBrowser, evt) {
  119. if (evt.keyCode === 27) {
  120. tarteaucitron.userInterface.closePanel();
  121. }
  122. if (isOldBrowser) {
  123. if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
  124. if ( evt.shiftKey ) /* shift + tab */ {
  125. if (document.activeElement === firstFocusableEl) {
  126. lastFocusableEl.focus();
  127. evt.preventDefault();
  128. }
  129. } else /* tab */ {
  130. if (document.activeElement === lastFocusableEl) {
  131. firstFocusableEl.focus();
  132. evt.preventDefault();
  133. }
  134. }
  135. }
  136. }
  137. },
  138. "hashchangeEvent": function () {
  139. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  140. tarteaucitron.userInterface.openPanel();
  141. }
  142. },
  143. "resizeEvent": function () {
  144. var tacElem = document.getElementById('tarteaucitron');
  145. var tacCookieContainer = document.getElementById('tarteaucitronCookiesListContainer');
  146. if (tacElem && tacElem.style.display === 'block') {
  147. tarteaucitron.userInterface.jsSizing('main');
  148. }
  149. if (tacCookieContainer && tacCookieContainer.style.display === 'block') {
  150. tarteaucitron.userInterface.jsSizing('cookie');
  151. }
  152. },
  153. "scrollEvent": function () {
  154. var scrollPos = window.pageYOffset || document.documentElement.scrollTop;
  155. var heightPosition;
  156. var tacPercentage = document.getElementById('tarteaucitronPercentage');
  157. var tacAlertBig = document.getElementById('tarteaucitronAlertBig');
  158. if (tacAlertBig && !tarteaucitron.highPrivacy) {
  159. if (tacAlertBig.style.display === 'block') {
  160. heightPosition = tacAlertBig.offsetHeight + 'px';
  161. if (scrollPos > (screen.height * 2)) {
  162. tarteaucitron.userInterface.respondAll(true);
  163. } else if (scrollPos > (screen.height / 2)) {
  164. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  165. }
  166. if (tacPercentage) {
  167. if (tarteaucitron.orientation === 'top') {
  168. tacPercentage.style.top = heightPosition;
  169. } else {
  170. tacPercentage.style.bottom = heightPosition;
  171. }
  172. tacPercentage.style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  173. }
  174. }
  175. }
  176. },
  177. },
  178. "load": function () {
  179. "use strict";
  180. var cdn = tarteaucitron.cdn,
  181. language = tarteaucitron.getLanguage(),
  182. pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
  183. pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
  184. linkElement = document.createElement('link'),
  185. defaults = {
  186. "adblocker": false,
  187. "hashtag": '#tarteaucitron',
  188. "cookieName": 'tarteaucitron',
  189. "highPrivacy": true,
  190. "orientation": "middle",
  191. "bodyPosition": "bottom",
  192. "removeCredit": false,
  193. "showAlertSmall": false,
  194. "showIcon": true,
  195. "iconPosition": "BottomRight",
  196. "cookieslist": false,
  197. "handleBrowserDNTRequest": false,
  198. "DenyAllCta": true,
  199. "AcceptAllCta" : true,
  200. "moreInfoLink": true,
  201. "privacyUrl": "",
  202. "useExternalCss": false,
  203. "useExternalJs": false,
  204. "mandatory": true,
  205. "closePopup": false
  206. },
  207. params = tarteaucitron.parameters;
  208. // Don't show the middle bar if we are on the privacy policy or more page
  209. if (((tarteaucitron.parameters.readmoreLink !== undefined && window.location.href == tarteaucitron.parameters.readmoreLink) || window.location.href == tarteaucitron.parameters.privacyUrl) && tarteaucitron.parameters.orientation == "middle") {
  210. tarteaucitron.parameters.orientation = "bottom";
  211. }
  212. // Step -1
  213. if (typeof tarteaucitronCustomPremium !== 'undefined') {
  214. tarteaucitronCustomPremium();
  215. }
  216. // Step 0: get params
  217. if (params !== undefined) {
  218. for (var k in defaults) {
  219. if(!tarteaucitron.parameters.hasOwnProperty(k)) {
  220. tarteaucitron.parameters[k] = defaults[k];
  221. }
  222. }
  223. }
  224. // global
  225. tarteaucitron.orientation = tarteaucitron.parameters.orientation;
  226. tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
  227. tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
  228. tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
  229. // Step 1: load css
  230. if ( !tarteaucitron.parameters.useExternalCss ) {
  231. linkElement.rel = 'stylesheet';
  232. linkElement.type = 'text/css';
  233. linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
  234. document.getElementsByTagName('head')[0].appendChild(linkElement);
  235. }
  236. // Step 2: load language and services
  237. tarteaucitron.addInternalScript(pathToLang, '', function () {
  238. if(tarteaucitronCustomText !== ''){
  239. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  240. }
  241. tarteaucitron.addInternalScript(pathToServices, '', function () {
  242. // css for new middle bar
  243. if (tarteaucitron.orientation === 'middle') {
  244. var customThemeMiddle = document.createElement('style'),
  245. cssRuleMiddle = 'div#tarteaucitronRoot.tarteaucitronBeforeVisible:before {content: \'\';position: fixed;width: 100%;height: 100%;background: white;top: 0;left: 0;z-index: 999;opacity: 0.5;}div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 35px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {width: 60%;min-width: 285px;height: auto;margin: auto;left: 50%;top: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 9000px #000;border-radius: 20px;padding: 35px 25px;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 10px 0 30px;display: block;text-align: center;font-size: 21px;}@media screen and (max-width: 900px) {div#tarteaucitronAlertBig button {margin: 0 auto 10px!important;display: block!important;}}';
  246. customThemeMiddle.type = 'text/css';
  247. if (customThemeMiddle.styleSheet) {
  248. customThemeMiddle.styleSheet.cssText = cssRuleMiddle;
  249. } else {
  250. customThemeMiddle.appendChild(document.createTextNode(cssRuleMiddle));
  251. }
  252. document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);
  253. }
  254. var body = document.body,
  255. div = document.createElement('div'),
  256. html = '',
  257. index,
  258. orientation = 'Top',
  259. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  260. i;
  261. cat = cat.sort(function (a, b) {
  262. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  263. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  264. return 0;
  265. });
  266. // Step 3: prepare the html
  267. html += '<div id="tarteaucitronPremium"></div>';
  268. html += '<button type="button" id="tarteaucitronBack" aria-label="' + tarteaucitron.lang.close + '"></button>';
  269. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  270. html += ' <button type="button" id="tarteaucitronClosePanel">';
  271. html += ' ' + tarteaucitron.lang.close;
  272. html += ' </button>';
  273. html += ' <div id="tarteaucitronServices">';
  274. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  275. html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
  276. html += ' <div id="tarteaucitronInfo">';
  277. html += ' ' + tarteaucitron.lang.disclaimer;
  278. if (tarteaucitron.parameters.privacyUrl !== "") {
  279. html += ' <br/><br/>';
  280. html += ' <button type="button" id="tarteaucitronPrivacyUrlDialog">';
  281. html += ' ' + tarteaucitron.lang.privacyUrl;
  282. html += ' </button>';
  283. }
  284. html += ' </div>';
  285. html += ' <div class="tarteaucitronName">';
  286. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2">' + tarteaucitron.lang.all + '</span>';
  287. html += ' </div>';
  288. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  289. html += ' <button type="button" id="tarteaucitronAllAllowed" class="tarteaucitronAllow">';
  290. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allowAll;
  291. html += ' </button> ';
  292. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny">';
  293. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  294. html += ' </button>';
  295. html += ' </div>';
  296. html += ' </div>';
  297. html += ' <div class="tarteaucitronBorder">';
  298. html += ' <div class="clear"></div><ul>';
  299. if (tarteaucitron.parameters.mandatory == true) {
  300. html += '<li id="tarteaucitronServicesTitle_mandatory">';
  301. html += '<div class="tarteaucitronTitle">';
  302. html += ' <button type="button" tabindex="-1">&nbsp; ' + tarteaucitron.lang.mandatoryTitle + '</button>';
  303. html += '</div>';
  304. html += '<ul id="tarteaucitronServices_mandatory">';
  305. html += '<li class="tarteaucitronLine">';
  306. html += ' <div class="tarteaucitronName">';
  307. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + tarteaucitron.lang.mandatoryText + '</span>';
  308. html += ' <span class="tarteaucitronListCookies"></span><br/>';
  309. html += ' </div>';
  310. html += ' <div class="tarteaucitronAsk">';
  311. html += ' <button type="button" class="tarteaucitronAllow" tabindex="-1">';
  312. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  313. html += ' </button> ';
  314. html += ' <button type="button" class="tarteaucitronDeny" style="visibility:hidden" tabindex="-1">';
  315. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  316. html += ' </button> ';
  317. html += ' </div>';
  318. html += '</li>';
  319. html += '</ul></li>';
  320. }
  321. for (i = 0; i < cat.length; i += 1) {
  322. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  323. html += ' <div class="tarteaucitronTitle">';
  324. html += ' <button type="button" class="catToggleBtn" data-cat="tarteaucitronDetails' + cat[i] + '"><span class="tarteaucitronPlus"></span> ' + tarteaucitron.lang[cat[i]].title + '</button>';
  325. html += ' </div>';
  326. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  327. html += ' ' + tarteaucitron.lang[cat[i]].details;
  328. html += ' </div>';
  329. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  330. }
  331. html += ' <li id="tarteaucitronNoServicesTitle" class="tarteaucitronLine">' + tarteaucitron.lang.noServices + '</li>';
  332. html += ' </ul>';
  333. html += ' <div class="tarteaucitronHidden tarteaucitron-spacer-20" id="tarteaucitronScrollbarChild"></div>';
  334. if (tarteaucitron.parameters.removeCredit === false) {
  335. html += ' <a class="tarteaucitronSelfLink" href="https://tarteaucitron.io/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHcAAAAeCAYAAAAWwoEYAAADl0lEQVRoge1Y0W3bQAx9CjKARlC+9GVUmqDJBHEmiDyB6wkcTxBngtgTxJ0gzgQW4C/9aYOmE6g4lTQo+k6y3Rb94QOERNQd+cjj8XiGwWAwGAwGg8FgMBgMBoPB8F8RNRXe+whEKe7c36ZCAeCRxC9Rig2PUd8kPgAsoxSfQ3YAzAA8D/HwYYCb05kBKKO0teFkmbC1jlKsAnq/Abjn+QBqAIsoRS30ttwG/HNz1wH/XIxWTicLdvtW7xTAGEAMtP685CNsBTe2d/BLydfXAG57SEnMAST0zgYZSUCPk02bCvkJduIzuJzDLfPolbY+tLKmar+/8+IRePy4qdpE03qHuH8fipFb4N2+XdA3AJ/0vaQxt7s9FvkIS2XvtqnwM0rxpOQfbnE5G2LhTCmUO2fHIngOmcv+KG3HafDchB6ntwjYqenR2PqC7sOZ3E7FXHB0vqxoFyUyLh7OEH7LOGouvhhN3eIBeKXv0n5MsufdHqXcwYR5U2EbpV35lSspVPJmQj4TcgRK7jTg5IzmPUhhwM5a2WHUFCx+NgiDucmgh7idikLovHFlL0pxQ9xzX+IIP9Y6FrJsqhjlQpZRAkFVDCjZfcCHt6bqJDmuh5ylCWx0RVnk3oumaknqTH5sqrY0fBWyULaHUIgAgxb46MxV3DbieAhxOxUxjSuljig9lMQ/Bcfoi9BTEv9aLORSndVxYOH525sUDC6u2gWxcNzBNRxPanyh3ktKinOgy3WoxPbtUM0t6RkbQnzBnFPgi9GCOEubY9UffIryz9iKRe8s/FUfEWosJJGxagp85bpUO3VywQ46lOtAWfNxKwa4JXQ+628+bpxYGXXMzp5rXH401VEyXwIdowXFaKWSMFHvMTVmGnc+P3oXV2QOiBCfgex8QtcQCbcQE/H+eoHzrkFo1KM7zVO4jVVj5s6lRiWF7zyXyfRMc97J3tzj87mYqZ7E2YjzUct9GUi4tjHLR8dVkBLjQcuHFleWvQfRNEhFR7uX7pkctOwvZXsft7sAtyldEUIN2UTeLxnEfxKYswzdi88BdbZ8hifUoSMftQvP+muRwN6+Q3DeqqRExP9QmTtcheiHh0Ot1x2i2km1bP9pbufw5zZdyWsOrh7vQae5OZWbsMv30pi7cd/CKj3coPEVaCP4Zhx4eQWhOZ1Y9MTXGyP8/iGjEyfa1T4fO/4Lea9vBoPBYDAYDAaDwWAwGAwGwz8GgF8siXCCbrSRhgAAAABJRU5ErkJggg==" alt="tarteaucitron.io" /></a>';
  336. }
  337. html += ' </div>';
  338. html += ' </div>';
  339. html += '</div>';
  340. if (tarteaucitron.parameters.orientation === 'bottom') {
  341. orientation = 'Bottom';
  342. }
  343. if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
  344. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  345. //html += '<div class="tarteaucitronAlertBigWrapper">';
  346. html += ' <span id="tarteaucitronDisclaimerAlert">';
  347. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  348. html += ' </span>';
  349. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  350. html += ' <button type="button" id="tarteaucitronPersonalize">';
  351. html += ' ' + tarteaucitron.lang.personalize;
  352. html += ' </button>';
  353. if (tarteaucitron.parameters.privacyUrl !== "") {
  354. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  355. html += ' ' + tarteaucitron.lang.privacyUrl;
  356. html += ' </button>';
  357. }
  358. //html += ' </span>';
  359. //html += '</div>';
  360. html += '</div>';
  361. } else {
  362. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  363. //html += '<div class="tarteaucitronAlertBigWrapper">';
  364. html += ' <span id="tarteaucitronDisclaimerAlert">';
  365. if (tarteaucitron.parameters.highPrivacy) {
  366. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  367. } else {
  368. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  369. }
  370. html += ' </span>';
  371. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  372. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronAllow" id="tarteaucitronPersonalize2">';
  373. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.acceptAll;
  374. html += ' </button>';
  375. if (tarteaucitron.parameters.DenyAllCta) {
  376. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" id="tarteaucitronAllDenied2">';
  377. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  378. html += ' </button>';
  379. //html += ' <br/><br/>';
  380. }
  381. html += ' <button type="button" id="tarteaucitronCloseAlert">';
  382. html += ' ' + tarteaucitron.lang.personalize;
  383. html += ' </button>';
  384. if (tarteaucitron.parameters.privacyUrl !== "") {
  385. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  386. html += ' ' + tarteaucitron.lang.privacyUrl;
  387. html += ' </button>';
  388. }
  389. //html += ' </span>';
  390. //html += '</div>';
  391. html += '</div>';
  392. html += '<div id="tarteaucitronPercentage"></div>';
  393. }
  394. if (tarteaucitron.parameters.showIcon === true) {
  395. html += '<div id="tarteaucitronIcon" class="tarteaucitronIcon' + tarteaucitron.parameters.iconPosition + '">';
  396. html += ' <button type="button" id="tarteaucitronManager">';
  397. html += ' <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAGA0lEQVRoge1a207bWBRdBtJwLYZhKDMVmlSK1LxNkPo+ZH6g8B6p5AuALwC+APoFoVLeoT8whPeRSt+CZKmZVu3AiIsRlEtCktGyjy8xzuXYhvahS0JJHJ/4rLP3XnuffcAPfGdQ7mM6jRLSAF4BxqsbewB2lRS2o35mpEQaJcwCyANIdLi1DGBNSWEzqmdHRqRRwjqAJclhtExOSUEP+/xIiDRKhhUWfL7ShTtBuJnqcw+/z4Ql0xNmMEwSSz4kuNIzSgpjSsqYJP/GeE185wYJroedRyiLNEpGLLzzrHSuk+83SgbxvOcyyRaDziWsRVZkSRDinpzPbwVGWIucuohsKynMS47fAQyls/BMSRmKJo3AFhG5wm2N1wF+Zs3zebbFfR0RxrXcJHQlgH+LMW616pR/WiIMEXfW3mtzXyeEGWsjKot8c4TOI98L+iKaR5PS6IUk88RLAO9F8UjrbYoYMOosNavpfmODIiwRXRR/G3ohaWVo1RU/c30jV8ab2mV8qVGzHWBOLyTLZiWs5Rolg/C3ySOi0tXP/k4aEwOwSBKPJs7Rp16ABJTe+p1xVX0It/owqqdDEMRoqd3RFxqDPh20Ig6VEPVC0i5RSCD+6wl6HlW7GksSlUMV11/GrUs5NasFLusDE9ELSVphXemtJwaT/8JyIRvxNNCfBmIiNdR04LII3DSrbe0yjqvyJF/ppptqVlt+MCLCEh/oOkPPP6N38Mb5cnQBGFsEqmXg5j3QMwoMzwGnr4HYbybBq13gZAOom/FO63zdf2qQArCsZrUN2TlJy69eSDKYV+6Q4MpP75ivHzPA53ngaBW4eGuSOt0A/lsGPmXMz0+3TFJcTfFbPfFbfnwlhON+iQhlWmA82CQ4ocQ7c6KcfL3DHuls0yT6Sx4YnLXJDCQOIRRv5yGIJBgP8Sdisj2qubpc5UGJmo+W49ifVmzL8HcpGhQPvZCUKiCliIhEN0tr2OCqHuSA8gwQ/92MkU7gxEmeVqGrTTgpxPXbUrtGWYus0I9thRIraagRQUIDf7Qn4yZhKRiFQIyhfMfUr3yblokVWSJ6k8xSnc7eNN/RjowfCYiFoDUFer1S3gW6JiJ8Nt30EMbEhU+vzSIztuRYjRLsR8IHLjlf7HZ+MrWWEXxNmbvapt4jGSqZRYSkGUetSNTPzHsui5YMQ2ajJUNks6mw4wT54Ok2ShnzzIPCUGshzawCRKy5FqvrTZe0RWzQGvw79m67XZjKmxJrLsICjtZa55gxXy+6F4sYsEtxTqhXdRTLC8ulSDaWoCLsolfN+8YUhOsJV709H7Cudr0LlVEtzqBcN+shEyThdR941OnAbF8pirKJqXyupTRTtQSReiVmXW1j7oBErB0d9xM2WEd5J9ZKYtuR4WKwwBSoORbpGrJ5ZI9lt71irJmGX1px0JYE26uNErawr2zfIcP4OHEKXm66PA3wjpCNEfpJunI4muifPjKvsFCkGjExTq63yxMJsZNMYF/J4HmDC5A3Yq36jy0ClePHVhwuu/b1HSFlEfHD5ZtD1bEK44Qu1mWys6tbWmZyPWckzlPTGiRw/XHCuk+q4Rek+mVrVL/UppwrdDEGNV2kpyuhccgc5Oxm9vWnn+19vJrVpLor0kTUrGacMplb1CfOFyTD4o9uNrHqr2Z+ZMSp1c2XcVSORnh9Q81q3k599ETgkNnjg0nGzi10K7rX+bZpHbrblPcY5A4Zxk2xcjzCvTpd9027Aa0QtouyyrKFRR6D/04DwkFGvHPXM3Qda/Jb4nPgI7hQLVM1q5HIBt2MzQNa57Z1DiiLAGa5Mi+O4Sz3Mpp6laPHO6InII3ITnX1QtI+EOX+m9ZxleOZ/j9PiuKoLi3aqXPuEoSye/Vhkm+LalbLtHhMS0R6zu7aZ3vP2jOjL7QVv4McxhcDnZIelAQibGIbULOapf3PuE1Vs9qeaOTdkVKr00gCQiw4NlBzDvf1Lxx+uP5r3Dgv5KQZRzWn+GRwz8jmDS8itUg7iB6vLuJCF5Uty4A9mVKkFR6MiJDachST/oHvHgD+B4SoUIitpF05AAAAAElFTkSuQmCC" alt="Cookies">';
  398. html += ' </button>';
  399. html += '</div>';
  400. }
  401. if (tarteaucitron.parameters.showAlertSmall === true) {
  402. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  403. html += ' <button type="button" id="tarteaucitronManager">';
  404. html += ' ' + tarteaucitron.lang.alertSmall;
  405. html += ' <span id="tarteaucitronDot">';
  406. html += ' <span id="tarteaucitronDotGreen"></span>';
  407. html += ' <span id="tarteaucitronDotYellow"></span>';
  408. html += ' <span id="tarteaucitronDotRed"></span>';
  409. html += ' </span>';
  410. if (tarteaucitron.parameters.cookieslist === true) {
  411. html += ' </button><!-- @whitespace';
  412. html += ' --><button type="button" id="tarteaucitronCookiesNumber">0</button>';
  413. html += ' <div id="tarteaucitronCookiesListContainer">';
  414. html += ' <button type="button" id="tarteaucitronClosePanelCookie">';
  415. html += ' ' + tarteaucitron.lang.close;
  416. html += ' </button>';
  417. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  418. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2" id="tarteaucitronCookiesNumberBis">0 cookie</span>';
  419. html += ' </div>';
  420. html += ' <div id="tarteaucitronCookiesList"></div>';
  421. html += ' </div>';
  422. } else {
  423. html += ' </div>';
  424. }
  425. html += '</div>';
  426. }
  427. tarteaucitron.addInternalScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
  428. if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
  429. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  430. /*var wrapper = document.createElement('div');
  431. wrapper.id = "tarteaucitronContentWrapper";
  432. while (document.body.firstChild)
  433. {
  434. wrapper.appendChild(document.body.firstChild);
  435. }
  436. // Append the wrapper to the body
  437. document.body.appendChild(wrapper);*/
  438. div.id = 'tarteaucitronRoot';
  439. if (tarteaucitron.parameters.bodyPosition === 'top') {
  440. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  441. var bodyFirstChild = body.firstChild;
  442. body.insertBefore(div, bodyFirstChild);
  443. }
  444. else {
  445. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  446. body.appendChild(div, body);
  447. }
  448. div.innerHTML = html;
  449. //ie compatibility
  450. var tacRootAvailableEvent;
  451. if(typeof(Event) === 'function') {
  452. tacRootAvailableEvent = new Event("tac.root_available");
  453. }else{
  454. tacRootAvailableEvent = document.createEvent('Event');
  455. tacRootAvailableEvent.initEvent("tac.root_available", true, true);
  456. }
  457. //end ie compatibility
  458. window.dispatchEvent(tacRootAvailableEvent);
  459. if (tarteaucitron.job !== undefined) {
  460. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  461. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  462. tarteaucitron.addService(tarteaucitron.job[index]);
  463. }
  464. } else {
  465. tarteaucitron.job = []
  466. }
  467. tarteaucitron.isAjax = true;
  468. tarteaucitron.job.push = function (id) {
  469. // ie <9 hack
  470. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  471. tarteaucitron.job.indexOf = function (obj, start) {
  472. var i,
  473. j = this.length;
  474. for (i = (start || 0); i < j; i += 1) {
  475. if (this[i] === obj) { return i; }
  476. }
  477. return -1;
  478. };
  479. }
  480. if (tarteaucitron.job.indexOf(id) === -1) {
  481. Array.prototype.push.call(this, id);
  482. }
  483. tarteaucitron.launch[id] = false;
  484. tarteaucitron.addService(id);
  485. };
  486. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  487. tarteaucitron.userInterface.openPanel();
  488. }
  489. tarteaucitron.cookie.number();
  490. setInterval(tarteaucitron.cookie.number, 60000);
  491. }
  492. }, tarteaucitron.parameters.adblocker);
  493. if (tarteaucitron.parameters.adblocker === true) {
  494. setTimeout(function () {
  495. if (tarteaucitronNoAdBlocker === false) {
  496. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + ' tarteaucitron-display-block" role="alert" aria-live="polite">';
  497. html += ' <p id="tarteaucitronDisclaimerAlert">';
  498. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  499. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  500. html += ' </p>';
  501. html += ' <button type="button" class="tarteaucitronCTAButton" id="tarteaucitronCTAButton">';
  502. html += ' ' + tarteaucitron.lang.reload;
  503. html += ' </button>';
  504. html += '</div>';
  505. html += '<div id="tarteaucitronPremium"></div>';
  506. div.id = 'tarteaucitronRoot';
  507. if (tarteaucitron.parameters.bodyPosition === 'top') {
  508. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  509. var bodyFirstChild = body.firstChild;
  510. body.insertBefore(div, bodyFirstChild);
  511. }
  512. else {
  513. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  514. body.appendChild(div, body);
  515. }
  516. div.innerHTML = html;
  517. }
  518. }, 1500);
  519. }
  520. if(tarteaucitron.parameters.closePopup === true){
  521. let element = document.getElementById('tarteaucitronAlertBig');
  522. let span = document.createElement('span')
  523. span.textContent = 'X';
  524. span.setAttribute('id', "tarteaucitronCloseCross")
  525. element.insertBefore(span, element.firstElementChild)
  526. }
  527. // add a little timeout to be sure everything is accessible
  528. setTimeout(function () {
  529. // Setup events
  530. tarteaucitron.addClickEventToId("tarteaucitronCloseCross", function () {
  531. tarteaucitron.userInterface.closeAlert();
  532. });
  533. tarteaucitron.addClickEventToId("tarteaucitronPersonalize", function () {
  534. tarteaucitron.userInterface.openPanel();
  535. });
  536. tarteaucitron.addClickEventToId("tarteaucitronPersonalize2", function () {
  537. tarteaucitron.userInterface.respondAll(true);
  538. });
  539. tarteaucitron.addClickEventToId("tarteaucitronManager", function () {
  540. tarteaucitron.userInterface.openPanel();
  541. });
  542. tarteaucitron.addClickEventToId("tarteaucitronBack", function () {
  543. tarteaucitron.userInterface.closePanel();
  544. });
  545. tarteaucitron.addClickEventToId("tarteaucitronClosePanel", function () {
  546. tarteaucitron.userInterface.closePanel();
  547. });
  548. tarteaucitron.addClickEventToId("tarteaucitronClosePanelCookie", function () {
  549. tarteaucitron.userInterface.closePanel();
  550. });
  551. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrl", function () {
  552. document.location = tarteaucitron.parameters.privacyUrl;
  553. });
  554. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrlDialog", function () {
  555. document.location = tarteaucitron.parameters.privacyUrl;
  556. });
  557. tarteaucitron.addClickEventToId("tarteaucitronCookiesNumber", function () {
  558. tarteaucitron.userInterface.toggleCookiesList();
  559. });
  560. tarteaucitron.addClickEventToId("tarteaucitronAllAllowed", function () {
  561. tarteaucitron.userInterface.respondAll(true);
  562. });
  563. tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () {
  564. tarteaucitron.userInterface.respondAll(false, '', true);
  565. });
  566. tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () {
  567. tarteaucitron.userInterface.respondAll(false, '', true);
  568. if (tarteaucitron.reloadThePage === true) {
  569. window.location.reload();
  570. }
  571. });
  572. tarteaucitron.addClickEventToId("tarteaucitronCloseAlert", function () {
  573. tarteaucitron.userInterface.openPanel();
  574. });
  575. tarteaucitron.addClickEventToId("tarteaucitronCTAButton", function () {
  576. location.reload();
  577. });
  578. var toggleBtns = document.getElementsByClassName("catToggleBtn"), i;
  579. for (i = 0; i < toggleBtns.length; i++) {
  580. toggleBtns[i].dataset.index = i;
  581. tarteaucitron.addClickEventToElement(toggleBtns[i], function () {
  582. tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox');
  583. return false;
  584. });
  585. }
  586. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  587. for (i = 0; i < allowBtns.length; i++) {
  588. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  589. tarteaucitron.userInterface.respond(this, true);
  590. });
  591. }
  592. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  593. for (i = 0; i < denyBtns.length; i++) {
  594. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  595. tarteaucitron.userInterface.respond(this, false);
  596. });
  597. }
  598. }, 500);
  599. });
  600. });
  601. if(tarteaucitron.events.load) {
  602. tarteaucitron.events.load();
  603. }
  604. },
  605. "addService": function (serviceId) {
  606. "use strict";
  607. var html = '',
  608. s = tarteaucitron.services,
  609. service = s[serviceId],
  610. cookie = tarteaucitron.cookie.read(),
  611. hostname = document.location.hostname,
  612. hostRef = document.referrer.split('/')[2],
  613. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  614. isAutostart = (!service.needConsent),
  615. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  616. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  617. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  618. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  619. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1");
  620. if (tarteaucitron.added[service.key] !== true) {
  621. tarteaucitron.added[service.key] = true;
  622. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  623. html += ' <div class="tarteaucitronName">';
  624. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  625. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  626. if (tarteaucitron.parameters.moreInfoLink == true) {
  627. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  628. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  629. link = service.readmoreLink;
  630. }
  631. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  632. link = tarteaucitron.parameters.readmoreLink;
  633. }
  634. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener nofollow" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  635. html += ' ' + tarteaucitron.lang.more;
  636. html += ' </a>';
  637. html += ' - ';
  638. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  639. html += ' ' + tarteaucitron.lang.source;
  640. html += ' </a>';
  641. }
  642. html += ' </div>';
  643. html += ' <div class="tarteaucitronAsk">';
  644. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow">';
  645. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  646. html += ' </button> ';
  647. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny">';
  648. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  649. html += ' </button>';
  650. html += ' </div>';
  651. html += '</li>';
  652. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  653. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  654. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  655. }
  656. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  657. tarteaucitron.userInterface.order(service.type);
  658. tarteaucitron.addClickEventToId(service.key + 'Allowed', function () {
  659. tarteaucitron.userInterface.respond(this, true);
  660. });
  661. tarteaucitron.addClickEventToId(service.key + 'Denied', function () {
  662. tarteaucitron.userInterface.respond(this, false);
  663. });
  664. }
  665. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  666. // allow by default for non EU
  667. if (isResponded === false && tarteaucitron.user.bypass === true) {
  668. isAllowed = true;
  669. tarteaucitron.cookie.create(service.key, true);
  670. }
  671. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  672. if (!isAllowed || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)) {
  673. tarteaucitron.cookie.create(service.key, true);
  674. }
  675. if (tarteaucitron.launch[service.key] !== true) {
  676. tarteaucitron.launch[service.key] = true;
  677. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.js(); }
  678. tarteaucitron.sendEvent(service.key + '_loaded');
  679. }
  680. tarteaucitron.state[service.key] = true;
  681. tarteaucitron.userInterface.color(service.key, true);
  682. } else if (isDenied) {
  683. if (typeof service.fallback === 'function') {
  684. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  685. }
  686. tarteaucitron.state[service.key] = false;
  687. tarteaucitron.userInterface.color(service.key, false);
  688. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  689. tarteaucitron.cookie.create(service.key, 'false');
  690. if (typeof service.fallback === 'function') {
  691. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  692. }
  693. tarteaucitron.state[service.key] = false;
  694. tarteaucitron.userInterface.color(service.key, false);
  695. } else if (!isResponded) {
  696. tarteaucitron.cookie.create(service.key, 'wait');
  697. if (typeof service.fallback === 'function') {
  698. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  699. }
  700. tarteaucitron.userInterface.color(service.key, 'wait');
  701. tarteaucitron.userInterface.openAlert();
  702. }
  703. tarteaucitron.cookie.checkCount(service.key);
  704. tarteaucitron.sendEvent(service.key + '_added')
  705. },
  706. "sendEvent" : function(event_key) {
  707. if(event_key !== undefined) {
  708. //ie compatibility
  709. var send_event_item;
  710. if(typeof(Event) === 'function') {
  711. send_event_item = new Event(event_key);
  712. }else{
  713. send_event_item = document.createEvent('Event');
  714. send_event_item.initEvent(event_key, true, true);
  715. }
  716. //end ie compatibility
  717. document.dispatchEvent(send_event_item);
  718. }
  719. },
  720. "cleanArray": function cleanArray(arr) {
  721. "use strict";
  722. var i,
  723. len = arr.length,
  724. out = [],
  725. obj = {},
  726. s = tarteaucitron.services;
  727. for (i = 0; i < len; i += 1) {
  728. if (!obj[arr[i]]) {
  729. obj[arr[i]] = {};
  730. if (tarteaucitron.services[arr[i]] !== undefined) {
  731. out.push(arr[i]);
  732. }
  733. }
  734. }
  735. out = out.sort(function (a, b) {
  736. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  737. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  738. return 0;
  739. });
  740. return out;
  741. },
  742. "userInterface": {
  743. "css": function (id, property, value) {
  744. "use strict";
  745. if (document.getElementById(id) !== null) {
  746. if (property == "display" && value == "none" && (id == "tarteaucitron" || id == "tarteaucitronBack" || id == "tarteaucitronAlertBig")) {
  747. document.getElementById(id).style["opacity"] = "0";
  748. setTimeout(function() {document.getElementById(id).style[property] = value;}, 200);
  749. } else {
  750. document.getElementById(id).style[property] = value;
  751. if (property == "display" && value == "block" && (id == "tarteaucitron" || id == "tarteaucitronAlertBig")) {
  752. document.getElementById(id).style["opacity"] = "0";
  753. setTimeout(function() {document.getElementById(id).style["opacity"] = "1";}, 1);
  754. }
  755. if (property == "display" && value == "block" && id == "tarteaucitronBack") {
  756. document.getElementById(id).style["opacity"] = "0";
  757. setTimeout(function() {document.getElementById(id).style["opacity"] = "0.7";}, 1);
  758. }
  759. }
  760. }
  761. },
  762. "addClass": function (id, className) {
  763. "use strict";
  764. if (document.getElementById(id) !== null) {
  765. document.getElementById(id).classList.add(className);
  766. }
  767. },
  768. "removeClass": function (id, className) {
  769. "use strict";
  770. if (document.getElementById(id) !== null) {
  771. document.getElementById(id).classList.remove(className);
  772. }
  773. },
  774. "respondAll": function (status, type, allowSafeAnalytics) {
  775. "use strict";
  776. var s = tarteaucitron.services,
  777. service,
  778. key,
  779. index = 0;
  780. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  781. if (typeof type !== 'undefined' && type !== '' && s[tarteaucitron.job[index]].type !== type) {
  782. continue;
  783. }
  784. if (allowSafeAnalytics && typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  785. continue;
  786. }
  787. service = s[tarteaucitron.job[index]];
  788. key = service.key;
  789. if (tarteaucitron.state[key] !== status) {
  790. if (status === false && tarteaucitron.launch[key] === true) {
  791. tarteaucitron.reloadThePage = true;
  792. }
  793. if (tarteaucitron.launch[key] !== true && status === true) {
  794. tarteaucitron.pro('!' + key + '=engage');
  795. tarteaucitron.launch[key] = true;
  796. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  797. tarteaucitron.sendEvent(key + '_loaded');
  798. }
  799. tarteaucitron.state[key] = status;
  800. tarteaucitron.cookie.create(key, status);
  801. tarteaucitron.userInterface.color(key, status);
  802. }
  803. }
  804. },
  805. "respond": function (el, status) {
  806. "use strict";
  807. if (el.id === '') {
  808. return;
  809. }
  810. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  811. if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;}
  812. // return if same state
  813. if (tarteaucitron.state[key] === status) {
  814. return;
  815. }
  816. if (status === false && tarteaucitron.launch[key] === true) {
  817. tarteaucitron.reloadThePage = true;
  818. }
  819. // if not already launched... launch the service
  820. if (status === true) {
  821. if (tarteaucitron.launch[key] !== true) {
  822. tarteaucitron.pro('!' + key + '=engage');
  823. tarteaucitron.launch[key] = true;
  824. tarteaucitron.sendEvent(key + '_loaded');
  825. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  826. }
  827. }
  828. tarteaucitron.state[key] = status;
  829. tarteaucitron.cookie.create(key, status);
  830. tarteaucitron.userInterface.color(key, status);
  831. },
  832. "color": function (key, status) {
  833. "use strict";
  834. var c = 'tarteaucitron',
  835. nbDenied = 0,
  836. nbPending = 0,
  837. nbAllowed = 0,
  838. sum = tarteaucitron.job.length,
  839. index,
  840. s = tarteaucitron.services;
  841. if (status === true) {
  842. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  843. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  844. } else if (status === false) {
  845. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  846. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  847. }
  848. // check if all services are allowed
  849. for (index = 0; index < sum; index += 1) {
  850. if (typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  851. sum -= 1;
  852. continue;
  853. }
  854. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  855. nbDenied += 1;
  856. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  857. nbPending += 1;
  858. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  859. nbAllowed += 1;
  860. }
  861. }
  862. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  863. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  864. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  865. if (nbDenied === 0 && nbPending === 0) {
  866. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  867. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  868. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  869. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  870. } else if (nbAllowed === 0 && nbPending === 0) {
  871. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  872. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  873. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  874. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  875. } else {
  876. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  877. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  878. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  879. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  880. }
  881. // close the alert if all service have been reviewed
  882. if (nbPending === 0) {
  883. tarteaucitron.userInterface.closeAlert();
  884. }
  885. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  886. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  887. }
  888. if (status === true) {
  889. if (document.getElementById('tacCL' + key) !== null) {
  890. document.getElementById('tacCL' + key).innerHTML = '...';
  891. }
  892. setTimeout(function () {
  893. tarteaucitron.cookie.checkCount(key);
  894. }, 2500);
  895. } else {
  896. tarteaucitron.cookie.checkCount(key);
  897. }
  898. },
  899. "openPanel": function () {
  900. "use strict";
  901. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  902. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  903. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  904. document.getElementById('tarteaucitronClosePanel').focus();
  905. document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open');
  906. tarteaucitron.userInterface.focusTrap();
  907. tarteaucitron.userInterface.jsSizing('main');
  908. //ie compatibility
  909. var tacOpenPanelEvent;
  910. if(typeof(Event) === 'function') {
  911. tacOpenPanelEvent = new Event("tac.open_panel");
  912. }else{
  913. tacOpenPanelEvent = document.createEvent('Event');
  914. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  915. }
  916. //end ie compatibility
  917. window.dispatchEvent(tacOpenPanelEvent);
  918. },
  919. "closePanel": function () {
  920. "use strict";
  921. if (document.location.hash === tarteaucitron.hashtag) {
  922. if (window.history) {
  923. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  924. } else {
  925. document.location.hash = '';
  926. }
  927. }
  928. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  929. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  930. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  931. elem.style.display = 'none';
  932. }, true);
  933. if (tarteaucitron.reloadThePage === true) {
  934. window.location.reload();
  935. } else {
  936. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  937. }
  938. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  939. document.getElementById('tarteaucitronCloseAlert').focus();
  940. }
  941. document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open');
  942. //ie compatibility
  943. var tacClosePanelEvent;
  944. if(typeof(Event) === 'function') {
  945. tacClosePanelEvent = new Event("tac.close_panel");
  946. }else{
  947. tacClosePanelEvent = document.createEvent('Event');
  948. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  949. }
  950. //end ie compatibility
  951. window.dispatchEvent(tacClosePanelEvent);
  952. },
  953. "focusTrap": function() {
  954. "use strict";
  955. var focusableEls,
  956. firstFocusableEl,
  957. lastFocusableEl,
  958. filtered;
  959. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  960. filtered = [];
  961. // get only visible items
  962. for (var i = 0, max = focusableEls.length; i < max; i++) {
  963. if (focusableEls[i].offsetHeight > 0) {
  964. filtered.push(focusableEls[i]);
  965. }
  966. }
  967. firstFocusableEl = filtered[0];
  968. lastFocusableEl = filtered[filtered.length - 1];
  969. //loop focus inside tarteaucitron
  970. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  971. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  972. if ( evt.shiftKey ) /* shift + tab */ {
  973. if (document.activeElement === firstFocusableEl) {
  974. lastFocusableEl.focus();
  975. evt.preventDefault();
  976. }
  977. } else /* tab */ {
  978. if (document.activeElement === lastFocusableEl) {
  979. firstFocusableEl.focus();
  980. evt.preventDefault();
  981. }
  982. }
  983. }
  984. })
  985. },
  986. "openAlert": function () {
  987. "use strict";
  988. var c = 'tarteaucitron';
  989. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  990. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  991. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'none');
  992. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  993. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  994. //ie compatibility
  995. var tacOpenAlertEvent;
  996. if(typeof(Event) === 'function') {
  997. tacOpenAlertEvent = new Event("tac.open_alert");
  998. }else{
  999. tacOpenAlertEvent = document.createEvent('Event');
  1000. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  1001. }
  1002. //end ie compatibility
  1003. window.dispatchEvent(tacOpenAlertEvent);
  1004. },
  1005. "closeAlert": function () {
  1006. "use strict";
  1007. var c = 'tarteaucitron';
  1008. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  1009. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  1010. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'block');
  1011. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  1012. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1013. tarteaucitron.userInterface.jsSizing('box');
  1014. //ie compatibility
  1015. var tacCloseAlertEvent;
  1016. if(typeof(Event) === 'function') {
  1017. tacCloseAlertEvent = new Event("tac.close_alert");
  1018. }else{
  1019. tacCloseAlertEvent = document.createEvent('Event');
  1020. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  1021. }
  1022. //end ie compatibility
  1023. window.dispatchEvent(tacCloseAlertEvent);
  1024. },
  1025. "toggleCookiesList": function () {
  1026. "use strict";
  1027. var div = document.getElementById('tarteaucitronCookiesListContainer');
  1028. if (div === null) {
  1029. return;
  1030. }
  1031. if (div.style.display !== 'block') {
  1032. tarteaucitron.cookie.number();
  1033. div.style.display = 'block';
  1034. tarteaucitron.userInterface.jsSizing('cookie');
  1035. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1036. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1037. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1038. elem.style.display = 'none';
  1039. }, true);
  1040. } else {
  1041. div.style.display = 'none';
  1042. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1043. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1044. }
  1045. },
  1046. "toggle": function (id, closeClass) {
  1047. "use strict";
  1048. var div = document.getElementById(id);
  1049. if (div === null) {
  1050. return;
  1051. }
  1052. if (closeClass !== undefined) {
  1053. tarteaucitron.fallback([closeClass], function (elem) {
  1054. if (elem.id !== id) {
  1055. elem.style.display = 'none';
  1056. }
  1057. }, true);
  1058. }
  1059. if (div.style.display !== 'block') {
  1060. div.style.display = 'block';
  1061. } else {
  1062. div.style.display = 'none';
  1063. }
  1064. },
  1065. "order": function (id) {
  1066. "use strict";
  1067. var main = document.getElementById('tarteaucitronServices_' + id),
  1068. allDivs,
  1069. store = [],
  1070. i;
  1071. if (main === null) {
  1072. return;
  1073. }
  1074. allDivs = main.childNodes;
  1075. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  1076. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  1077. //var mainChildren = Array.from(main.children);
  1078. //mainChildren.sort(function (a, b) {
  1079. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  1080. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  1081. return 0;
  1082. }).forEach(function (element) {
  1083. main.appendChild(element);
  1084. });
  1085. }
  1086. },
  1087. "jsSizing": function (type) {
  1088. "use strict";
  1089. var scrollbarMarginRight = 10,
  1090. scrollbarWidthParent,
  1091. scrollbarWidthChild,
  1092. servicesHeight,
  1093. e = window,
  1094. a = 'inner',
  1095. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  1096. mainTop,
  1097. mainHeight,
  1098. closeButtonHeight,
  1099. headerHeight,
  1100. cookiesListHeight,
  1101. cookiesCloseHeight,
  1102. cookiesTitleHeight,
  1103. paddingBox,
  1104. alertSmallHeight,
  1105. cookiesNumberHeight;
  1106. if (type === 'box') {
  1107. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1108. // reset
  1109. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  1110. // calculate
  1111. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  1112. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  1113. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  1114. // apply
  1115. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  1116. }
  1117. } else if (type === 'main') {
  1118. // get the real window width for media query
  1119. if (window.innerWidth === undefined) {
  1120. a = 'client';
  1121. e = document.documentElement || document.body;
  1122. }
  1123. // height of the services list container
  1124. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1125. // reset
  1126. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  1127. // calculate
  1128. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1129. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1130. // apply
  1131. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1132. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1133. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1134. }
  1135. // align the main allow/deny button depending on scrollbar width
  1136. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1137. // media query
  1138. if (e[a + 'Width'] <= 479) {
  1139. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1140. } else if (e[a + 'Width'] <= 767) {
  1141. scrollbarMarginRight = 12;
  1142. }
  1143. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1144. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1145. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1146. }
  1147. // center the main panel
  1148. if (document.getElementById('tarteaucitron') !== null) {
  1149. // media query
  1150. if (e[a + 'Width'] <= 767) {
  1151. mainTop = 0;
  1152. } else {
  1153. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1154. }
  1155. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1156. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1157. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1158. }
  1159. }
  1160. // correct
  1161. if (mainTop < 0) {
  1162. mainTop = 0;
  1163. }
  1164. // apply
  1165. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1166. }
  1167. } else if (type === 'cookie') {
  1168. // put cookies list at bottom
  1169. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1170. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1171. }
  1172. // height of cookies list
  1173. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1174. // reset
  1175. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1176. // calculate
  1177. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1178. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1179. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1180. // apply
  1181. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1182. }
  1183. }
  1184. }
  1185. },
  1186. "cookie": {
  1187. "owner": {},
  1188. "create": function (key, status) {
  1189. "use strict";
  1190. if (tarteaucitronForceExpire !== '') {
  1191. // The number of day(s)/hour(s) can't be higher than 1 year
  1192. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1193. if (tarteaucitronExpireInDay) {
  1194. // Multiplication to tranform the number of days to milliseconds
  1195. timeExpire = tarteaucitronForceExpire * 86400000;
  1196. } else {
  1197. // Multiplication to tranform the number of hours to milliseconds
  1198. timeExpire = tarteaucitronForceExpire * 3600000;
  1199. }
  1200. }
  1201. }
  1202. var d = new Date(),
  1203. time = d.getTime(),
  1204. expireTime = time + timeExpire, // 365 days
  1205. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1206. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1207. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1208. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? '; domain=' + tarteaucitron.parameters.cookieDomain : '',
  1209. secure = location.protocol === 'https:' ? '; Secure' : '';
  1210. d.setTime(expireTime);
  1211. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/' + domain + secure + '; samesite=lax';
  1212. },
  1213. "read": function () {
  1214. "use strict";
  1215. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1216. ca = document.cookie.split(';'),
  1217. i,
  1218. c;
  1219. for (i = 0; i < ca.length; i += 1) {
  1220. c = ca[i];
  1221. while (c.charAt(0) === ' ') {
  1222. c = c.substring(1, c.length);
  1223. }
  1224. if (c.indexOf(nameEQ) === 0) {
  1225. return c.substring(nameEQ.length, c.length);
  1226. }
  1227. }
  1228. return '';
  1229. },
  1230. "purge": function (arr) {
  1231. "use strict";
  1232. var i;
  1233. for (i = 0; i < arr.length; i += 1) {
  1234. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1235. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1236. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1237. }
  1238. },
  1239. "checkCount": function (key) {
  1240. "use strict";
  1241. var arr = tarteaucitron.services[key].cookies,
  1242. nb = arr.length,
  1243. nbCurrent = 0,
  1244. html = '',
  1245. i,
  1246. status = document.cookie.indexOf(key + '=true');
  1247. if (status >= 0 && nb === 0) {
  1248. html += tarteaucitron.lang.useNoCookie;
  1249. } else if (status >= 0) {
  1250. for (i = 0; i < nb; i += 1) {
  1251. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1252. nbCurrent += 1;
  1253. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1254. tarteaucitron.cookie.owner[arr[i]] = [];
  1255. }
  1256. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1257. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1258. }
  1259. }
  1260. }
  1261. if (nbCurrent > 0) {
  1262. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1263. if (nbCurrent > 1) {
  1264. html += 's';
  1265. }
  1266. html += '.';
  1267. } else {
  1268. html += tarteaucitron.lang.useNoCookie;
  1269. }
  1270. } else if (nb === 0) {
  1271. html = tarteaucitron.lang.noCookie;
  1272. } else {
  1273. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1274. if (nb > 1) {
  1275. html += 's';
  1276. }
  1277. html += '.';
  1278. }
  1279. if (document.getElementById('tacCL' + key) !== null) {
  1280. document.getElementById('tacCL' + key).innerHTML = html;
  1281. }
  1282. },
  1283. "crossIndexOf": function (arr, match) {
  1284. "use strict";
  1285. var i;
  1286. for (i = 0; i < arr.length; i += 1) {
  1287. if (arr[i] === match) {
  1288. return true;
  1289. }
  1290. }
  1291. return false;
  1292. },
  1293. "number": function () {
  1294. "use strict";
  1295. var cookies = document.cookie.split(';'),
  1296. nb = (document.cookie !== '') ? cookies.length : 0,
  1297. html = '',
  1298. i,
  1299. name,
  1300. namea,
  1301. nameb,
  1302. c,
  1303. d,
  1304. s = (nb > 1) ? 's' : '',
  1305. savedname,
  1306. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1307. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1308. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1309. cookies = cookies.sort(function (a, b) {
  1310. namea = a.split('=', 1).toString().replace(/ /g, '');
  1311. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1312. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1313. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1314. if (c + a > d + b) { return 1; }
  1315. if (c + a < d + b) { return -1; }
  1316. return 0;
  1317. });
  1318. if (document.cookie !== '') {
  1319. for (i = 0; i < nb; i += 1) {
  1320. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1321. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1322. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1323. html += '<div class="tarteaucitronHidden">';
  1324. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1325. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1326. html += ' </span>';
  1327. html += '</div><ul class="cookie-list">';
  1328. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1329. savedname = host;
  1330. html += '<div class="tarteaucitronHidden">';
  1331. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1332. html += ' ' + host;
  1333. html += ' </span>';
  1334. html += '</div><ul class="cookie-list">';
  1335. }
  1336. html += '<li class="tarteaucitronCookiesListMain">';
  1337. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" class="purgeBtn" data-cookie="' + tarteaucitron.fixSelfXSS(cookies[i].split('=', 1)) + '"><strong>&times;</strong></button> <strong>' + tarteaucitron.fixSelfXSS(name) + '</strong>';
  1338. html += ' </div>';
  1339. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1340. html += '</li>';
  1341. }
  1342. html += '</ul>';
  1343. } else {
  1344. html += '<div class="tarteaucitronCookiesListMain">';
  1345. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1346. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1347. html += '</div>';
  1348. }
  1349. html += '<div class="tarteaucitronHidden tarteaucitron-spacer-20"></div>';
  1350. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1351. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1352. }
  1353. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1354. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1355. }
  1356. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1357. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1358. }
  1359. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1360. for (i = 0; i < purgeBtns.length; i++) {
  1361. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1362. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1363. tarteaucitron.cookie.number();
  1364. tarteaucitron.userInterface.jsSizing('cookie');
  1365. return false;
  1366. });
  1367. }
  1368. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1369. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1370. }
  1371. }
  1372. },
  1373. "fixSelfXSS": function(html) {
  1374. fixed = html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1375. return fixed;
  1376. },
  1377. "getLanguage": function () {
  1378. "use strict";
  1379. var availableLanguages = 'bg,ca,cn,cs,da,de,el,en,es,fi,fr,hu,it,ja,lv,nl,no,oc,pl,pt,ro,ru,se,sk,sv,tr,vi,zh',
  1380. defaultLanguage = 'en';
  1381. if (tarteaucitronForceLanguage !== '') {
  1382. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1383. return tarteaucitronForceLanguage;
  1384. }
  1385. }
  1386. if (!navigator) { return 'en'; }
  1387. var lang = navigator.language || navigator.browserLanguage ||
  1388. navigator.systemLanguage || navigator.userLang || null,
  1389. userLanguage = lang ? lang.substr(0, 2) : null;
  1390. if (availableLanguages.indexOf(userLanguage) === -1) {
  1391. return defaultLanguage;
  1392. }
  1393. return userLanguage;
  1394. },
  1395. "getLocale": function () {
  1396. "use strict";
  1397. if (!navigator) { return 'en_US'; }
  1398. var lang = navigator.language || navigator.browserLanguage ||
  1399. navigator.systemLanguage || navigator.userLang || null,
  1400. userLanguage = lang ? lang.substr(0, 2) : null;
  1401. if (userLanguage === 'fr') {
  1402. return 'fr_FR';
  1403. } else if (userLanguage === 'en') {
  1404. return 'en_US';
  1405. } else if (userLanguage === 'de') {
  1406. return 'de_DE';
  1407. } else if (userLanguage === 'es') {
  1408. return 'es_ES';
  1409. } else if (userLanguage === 'it') {
  1410. return 'it_IT';
  1411. } else if (userLanguage === 'pt') {
  1412. return 'pt_PT';
  1413. } else if (userLanguage === 'nl') {
  1414. return 'nl_NL';
  1415. } else if (userLanguage === 'el') {
  1416. return 'el_EL';
  1417. } else {
  1418. return 'en_US';
  1419. }
  1420. },
  1421. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1422. "use strict";
  1423. var script,
  1424. done = false;
  1425. if (execute === false) {
  1426. if (typeof callback === 'function') {
  1427. callback();
  1428. }
  1429. } else {
  1430. script = document.createElement('script');
  1431. script.id = (id !== undefined) ? id : '';
  1432. script.async = true;
  1433. script.src = url;
  1434. if (attrName !== undefined && attrVal !== undefined) {
  1435. script.setAttribute(attrName, attrVal);
  1436. }
  1437. if (typeof callback === 'function') {
  1438. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1439. script.onreadystatechange = script.onload = function () {
  1440. var state = script.readyState;
  1441. if (!done && (!state || /loaded|complete/.test(state))) {
  1442. done = true;
  1443. callback();
  1444. }
  1445. };
  1446. } else {
  1447. callback();
  1448. }
  1449. }
  1450. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1451. document.getElementsByTagName('head')[0].appendChild(script);
  1452. }
  1453. }
  1454. },
  1455. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1456. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1457. },
  1458. "makeAsync": {
  1459. "antiGhost": 0,
  1460. "buffer": '',
  1461. "init": function (url, id) {
  1462. "use strict";
  1463. var savedWrite = document.write,
  1464. savedWriteln = document.writeln;
  1465. document.write = function (content) {
  1466. tarteaucitron.makeAsync.buffer += content;
  1467. };
  1468. document.writeln = function (content) {
  1469. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1470. };
  1471. setTimeout(function () {
  1472. document.write = savedWrite;
  1473. document.writeln = savedWriteln;
  1474. }, 20000);
  1475. tarteaucitron.makeAsync.getAndParse(url, id);
  1476. },
  1477. "getAndParse": function (url, id) {
  1478. "use strict";
  1479. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1480. tarteaucitron.makeAsync.antiGhost = 0;
  1481. return;
  1482. }
  1483. tarteaucitron.makeAsync.antiGhost += 1;
  1484. tarteaucitron.addInternalScript(url, '', function () {
  1485. if (document.getElementById(id) !== null) {
  1486. document.getElementById(id).innerHTML += "<span class='tarteaucitron-display-none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1487. tarteaucitron.makeAsync.buffer = '';
  1488. tarteaucitron.makeAsync.execJS(id);
  1489. }
  1490. });
  1491. },
  1492. "execJS": function (id) {
  1493. /* not strict because third party scripts may have errors */
  1494. var i,
  1495. scripts,
  1496. childId,
  1497. type;
  1498. if (document.getElementById(id) === null) {
  1499. return;
  1500. }
  1501. scripts = document.getElementById(id).getElementsByTagName('script');
  1502. for (i = 0; i < scripts.length; i += 1) {
  1503. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1504. if (type === '') {
  1505. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1506. }
  1507. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1508. childId = id + Math.floor(Math.random() * 99999999999);
  1509. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1510. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1511. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1512. eval(scripts[i].innerHTML);
  1513. }
  1514. }
  1515. }
  1516. },
  1517. "fallback": function (matchClass, content, noInner) {
  1518. "use strict";
  1519. var elems = document.getElementsByTagName('*'),
  1520. i,
  1521. index = 0;
  1522. for (i in elems) {
  1523. if (elems[i] !== undefined) {
  1524. for (index = 0; index < matchClass.length; index += 1) {
  1525. if ((' ' + elems[i].className + ' ')
  1526. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1527. if (typeof content === 'function') {
  1528. if (noInner === true) {
  1529. content(elems[i]);
  1530. } else {
  1531. elems[i].innerHTML = content(elems[i]);
  1532. }
  1533. } else {
  1534. elems[i].innerHTML = content;
  1535. }
  1536. }
  1537. }
  1538. }
  1539. }
  1540. },
  1541. "engage": function (id) {
  1542. "use strict";
  1543. var html = '',
  1544. r = Math.floor(Math.random() * 100000),
  1545. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1546. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1547. engage = tarteaucitron.lang['engage-' + id];
  1548. }
  1549. html += '<div class="tac_activate tac_activate_' + id + '">';
  1550. html += ' <div class="tac_float">';
  1551. html += ' ' + engage;
  1552. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1553. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  1554. html += ' </button>';
  1555. html += ' </div>';
  1556. html += '</div>';
  1557. return html;
  1558. },
  1559. "extend": function (a, b) {
  1560. "use strict";
  1561. var prop;
  1562. for (prop in b) {
  1563. if (b.hasOwnProperty(prop)) {
  1564. a[prop] = b[prop];
  1565. }
  1566. }
  1567. },
  1568. "proTemp": '',
  1569. "proTimer": function () {
  1570. "use strict";
  1571. setTimeout(tarteaucitron.proPing, 500);
  1572. },
  1573. "pro": function (list) {
  1574. "use strict";
  1575. tarteaucitron.proTemp += list;
  1576. clearTimeout(tarteaucitron.proTimer);
  1577. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1578. },
  1579. "proPing": function () {
  1580. "use strict";
  1581. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1582. var div = document.getElementById('tarteaucitronPremium'),
  1583. timestamp = new Date().getTime(),
  1584. url = 'https://tarteaucitron.io/log/?';
  1585. if (div === null) {
  1586. return;
  1587. }
  1588. url += 'account=' + tarteaucitron.uuid + '&';
  1589. url += 'domain=' + tarteaucitron.domain + '&';
  1590. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1591. url += '_time=' + timestamp;
  1592. div.innerHTML = '<img src="' + url + '" class="tarteaucitron-display-none" alt="" />';
  1593. tarteaucitron.proTemp = '';
  1594. }
  1595. tarteaucitron.cookie.number();
  1596. },
  1597. "AddOrUpdate" : function(source, custom){
  1598. /**
  1599. Utility function to Add or update the fields of obj1 with the ones in obj2
  1600. */
  1601. for(key in custom){
  1602. if(custom[key] instanceof Object){
  1603. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1604. }else{
  1605. source[key] = custom[key];
  1606. }
  1607. }
  1608. return source;
  1609. },
  1610. "getElemWidth": function(elem) {
  1611. return elem.getAttribute('width') || elem.clientWidth;
  1612. },
  1613. "getElemHeight": function(elem) {
  1614. return elem.getAttribute('height') || elem.clientHeight;
  1615. },
  1616. "addClickEventToId": function (elemId, func) {
  1617. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1618. },
  1619. "addClickEventToElement": function (e, func) {
  1620. if (e) {
  1621. if (e.addEventListener) {
  1622. e.addEventListener("click", func);
  1623. } else {
  1624. e.attachEvent("onclick", func);
  1625. }
  1626. }
  1627. }
  1628. };