tarteaucitron.js 90 KB

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