tarteaucitron.js 110 KB

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