tarteaucitron.js 110 KB

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