tarteaucitron.js 109 KB

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