tarteaucitron.js 106 KB

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