tarteaucitron.js 97 KB

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