tarteaucitron.js 108 KB

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