tarteaucitron.js 111 KB

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