tarteaucitron.js 108 KB

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