tarteaucitron.js 97 KB

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