tarteaucitron.js 111 KB

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