tarteaucitron.js 110 KB

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