tarteaucitron.js 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973
  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": 20210422,
  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 tabindex="-1" 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 tabindex="-1" 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. setTimeout(function() {
  536. var closeElement = document.getElementById('tarteaucitronAlertBig'),
  537. closeSpan = document.createElement('span');
  538. if (closeElement) {
  539. closeSpan.textContent = 'X';
  540. closeSpan.setAttribute('id', "tarteaucitronCloseCross");
  541. closeElement.insertBefore(closeSpan, closeElement.firstElementChild);
  542. }
  543. }, 100);
  544. }
  545. if(tarteaucitron.parameters.groupServices === true) {
  546. var tac_group_style = document.createElement('style');
  547. tac_group_style.innerHTML = '.tarteaucitronTitle{display:none}';
  548. document.head.appendChild(tac_group_style);
  549. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  550. Array.prototype.forEach.call(cats, function(item) {
  551. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, "");
  552. if (cat !== "mandatory") {
  553. var html = '';
  554. html += '<li class="tarteaucitronLine">';
  555. html += ' <div class="tarteaucitronName">';
  556. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">'+tarteaucitron.lang[cat].title+'</span>';
  557. html += ' <span>'+tarteaucitron.lang[cat].details+'</span>';
  558. html += ' <button type="button" class="tarteaucitron-toggle-group" id="tarteaucitron-toggle-group-'+cat+'">'+tarteaucitron.lang.alertSmall+' ('+document.getElementById("tarteaucitronServices_"+cat).childElementCount+')</button>';
  559. html += ' </div>';
  560. html += ' <div class="tarteaucitronAsk" id="tarteaucitron-group-'+cat+'">';
  561. html += ' <button type="button" class="tarteaucitronAllow" id="tarteaucitron-accept-group-'+cat+'">';
  562. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  563. html += ' </button> ';
  564. html += ' <button type="button" class="tarteaucitronDeny" id="tarteaucitron-reject-group-'+cat+'">';
  565. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  566. html += ' </button>';
  567. html += ' </div>';
  568. html += '</li>';
  569. var ul = document.createElement('ul');
  570. ul.innerHTML = html;
  571. item.insertBefore(ul, item.querySelector('#tarteaucitronServices_'+cat+''));
  572. document.querySelector('#tarteaucitronServices_' + cat).style.display = 'none';
  573. tarteaucitron.addClickEventToId("tarteaucitron-toggle-group-" + cat, function () {
  574. tarteaucitron.userInterface.toggle('tarteaucitronServices_' + cat);
  575. if (document.getElementById('tarteaucitronServices_' + cat).style.display == 'block') {
  576. tarteaucitron.userInterface.addClass('tarteaucitronServicesTitle_' + cat, 'tarteaucitronIsExpanded');
  577. } else {
  578. tarteaucitron.userInterface.removeClass('tarteaucitronServicesTitle_' + cat, 'tarteaucitronIsExpanded');
  579. }
  580. });
  581. tarteaucitron.addClickEventToId("tarteaucitron-accept-group-" + cat, function () {
  582. tarteaucitron.userInterface.respondAll(true, cat);
  583. });
  584. tarteaucitron.addClickEventToId("tarteaucitron-reject-group-" + cat, function () {
  585. tarteaucitron.userInterface.respondAll(false, cat);
  586. });
  587. }
  588. });
  589. }
  590. tarteaucitron.userInterface.color("", true);
  591. // add a little timeout to be sure everything is accessible
  592. setTimeout(function () {
  593. // Setup events
  594. tarteaucitron.addClickEventToId("tarteaucitronCloseCross", function () {
  595. tarteaucitron.userInterface.closeAlert();
  596. });
  597. tarteaucitron.addClickEventToId("tarteaucitronPersonalize", function () {
  598. tarteaucitron.userInterface.openPanel();
  599. });
  600. tarteaucitron.addClickEventToId("tarteaucitronPersonalize2", function () {
  601. tarteaucitron.userInterface.respondAll(true);
  602. });
  603. tarteaucitron.addClickEventToId("tarteaucitronManager", function () {
  604. tarteaucitron.userInterface.openPanel();
  605. });
  606. tarteaucitron.addClickEventToId("tarteaucitronBack", function () {
  607. tarteaucitron.userInterface.closePanel();
  608. });
  609. tarteaucitron.addClickEventToId("tarteaucitronClosePanel", function () {
  610. tarteaucitron.userInterface.closePanel();
  611. });
  612. tarteaucitron.addClickEventToId("tarteaucitronClosePanelCookie", function () {
  613. tarteaucitron.userInterface.closePanel();
  614. });
  615. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrl", function () {
  616. document.location = tarteaucitron.parameters.privacyUrl;
  617. });
  618. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrlDialog", function () {
  619. document.location = tarteaucitron.parameters.privacyUrl;
  620. });
  621. tarteaucitron.addClickEventToId("tarteaucitronCookiesNumber", function () {
  622. tarteaucitron.userInterface.toggleCookiesList();
  623. });
  624. tarteaucitron.addClickEventToId("tarteaucitronAllAllowed", function () {
  625. tarteaucitron.userInterface.respondAll(true);
  626. });
  627. tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () {
  628. tarteaucitron.userInterface.respondAll(false);
  629. });
  630. tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () {
  631. tarteaucitron.userInterface.respondAll(false, '', true);
  632. if (tarteaucitron.reloadThePage === true) {
  633. window.location.reload();
  634. }
  635. });
  636. tarteaucitron.addClickEventToId("tarteaucitronCloseAlert", function () {
  637. tarteaucitron.userInterface.openPanel();
  638. });
  639. tarteaucitron.addClickEventToId("tarteaucitronCTAButton", function () {
  640. location.reload();
  641. });
  642. var toggleBtns = document.getElementsByClassName("catToggleBtn"), i;
  643. for (i = 0; i < toggleBtns.length; i++) {
  644. toggleBtns[i].dataset.index = i;
  645. tarteaucitron.addClickEventToElement(toggleBtns[i], function () {
  646. tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox');
  647. return false;
  648. });
  649. }
  650. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  651. for (i = 0; i < allowBtns.length; i++) {
  652. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  653. tarteaucitron.userInterface.respond(this, true);
  654. });
  655. }
  656. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  657. for (i = 0; i < denyBtns.length; i++) {
  658. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  659. tarteaucitron.userInterface.respond(this, false);
  660. });
  661. }
  662. if(tarteaucitron.events.load) {
  663. tarteaucitron.events.load();
  664. }
  665. }, 500);
  666. });
  667. });
  668. },
  669. "addService": function (serviceId) {
  670. "use strict";
  671. var html = '',
  672. s = tarteaucitron.services,
  673. service = s[serviceId],
  674. cookie = tarteaucitron.cookie.read(),
  675. hostname = document.location.hostname,
  676. hostRef = document.referrer.split('/')[2],
  677. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  678. isAutostart = (!service.needConsent),
  679. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  680. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  681. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  682. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  683. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1"),
  684. currentStatus = (isAllowed) ? tarteaucitron.lang.allowed : tarteaucitron.lang.disallowed;
  685. if (tarteaucitron.added[service.key] !== true) {
  686. tarteaucitron.added[service.key] = true;
  687. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  688. html += ' <div class="tarteaucitronName">';
  689. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + ' (<span id="tacCurrentStatus' + service.key + '">'+currentStatus+'</span>)</span>';
  690. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  691. if (tarteaucitron.parameters.moreInfoLink == true) {
  692. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  693. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  694. link = service.readmoreLink;
  695. }
  696. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  697. link = tarteaucitron.parameters.readmoreLink;
  698. }
  699. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener nofollow" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'" class="tarteaucitronReadmoreInfo">';
  700. html += ' ' + tarteaucitron.lang.more;
  701. html += ' </a>';
  702. html += ' <span class="tarteaucitronReadmoreSeparator"> - </span>';
  703. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '" class="tarteaucitronReadmoreOfficial">';
  704. html += ' ' + tarteaucitron.lang.source;
  705. html += ' </a>';
  706. }
  707. html += ' </div>';
  708. html += ' <div class="tarteaucitronAsk">';
  709. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow">';
  710. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  711. html += ' </button> ';
  712. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny">';
  713. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  714. html += ' </button>';
  715. html += ' </div>';
  716. html += '</li>';
  717. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  718. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  719. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  720. }
  721. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  722. tarteaucitron.userInterface.order(service.type);
  723. tarteaucitron.addClickEventToId(service.key + 'Allowed', function () {
  724. tarteaucitron.userInterface.respond(this, true);
  725. });
  726. tarteaucitron.addClickEventToId(service.key + 'Denied', function () {
  727. tarteaucitron.userInterface.respond(this, false);
  728. });
  729. }
  730. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  731. // allow by default for non EU
  732. if (isResponded === false && tarteaucitron.user.bypass === true) {
  733. isAllowed = true;
  734. tarteaucitron.cookie.create(service.key, true);
  735. }
  736. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  737. if (!isAllowed || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)) {
  738. tarteaucitron.cookie.create(service.key, true);
  739. }
  740. if (tarteaucitron.launch[service.key] !== true) {
  741. tarteaucitron.launch[service.key] = true;
  742. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.js(); }
  743. tarteaucitron.sendEvent(service.key + '_loaded');
  744. }
  745. tarteaucitron.state[service.key] = true;
  746. tarteaucitron.userInterface.color(service.key, true);
  747. } else if (isDenied) {
  748. if (typeof service.fallback === 'function') {
  749. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  750. }
  751. tarteaucitron.state[service.key] = false;
  752. tarteaucitron.userInterface.color(service.key, false);
  753. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  754. tarteaucitron.cookie.create(service.key, 'false');
  755. if (typeof service.fallback === 'function') {
  756. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  757. }
  758. tarteaucitron.state[service.key] = false;
  759. tarteaucitron.userInterface.color(service.key, false);
  760. } else if (!isResponded) {
  761. tarteaucitron.cookie.create(service.key, 'wait');
  762. if (typeof service.fallback === 'function') {
  763. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  764. }
  765. tarteaucitron.userInterface.color(service.key, 'wait');
  766. tarteaucitron.userInterface.openAlert();
  767. }
  768. tarteaucitron.cookie.checkCount(service.key);
  769. tarteaucitron.sendEvent(service.key + '_added')
  770. },
  771. "sendEvent" : function(event_key) {
  772. if(event_key !== undefined) {
  773. //ie compatibility
  774. var send_event_item;
  775. if(typeof(Event) === 'function') {
  776. send_event_item = new Event(event_key);
  777. }else{
  778. send_event_item = document.createEvent('Event');
  779. send_event_item.initEvent(event_key, true, true);
  780. }
  781. //end ie compatibility
  782. document.dispatchEvent(send_event_item);
  783. }
  784. },
  785. "cleanArray": function cleanArray(arr) {
  786. "use strict";
  787. var i,
  788. len = arr.length,
  789. out = [],
  790. obj = {},
  791. s = tarteaucitron.services;
  792. for (i = 0; i < len; i += 1) {
  793. if (!obj[arr[i]]) {
  794. obj[arr[i]] = {};
  795. if (tarteaucitron.services[arr[i]] !== undefined) {
  796. out.push(arr[i]);
  797. }
  798. }
  799. }
  800. out = out.sort(function (a, b) {
  801. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  802. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  803. return 0;
  804. });
  805. return out;
  806. },
  807. "userInterface": {
  808. "css": function (id, property, value) {
  809. "use strict";
  810. if (document.getElementById(id) !== null) {
  811. if (property == "display" && value == "none" && (id == "tarteaucitron" || id == "tarteaucitronBack" || id == "tarteaucitronAlertBig")) {
  812. document.getElementById(id).style["opacity"] = "0";
  813. setTimeout(function() {document.getElementById(id).style[property] = value;}, 200);
  814. } else {
  815. document.getElementById(id).style[property] = value;
  816. if (property == "display" && value == "block" && (id == "tarteaucitron" || id == "tarteaucitronAlertBig")) {
  817. document.getElementById(id).style["opacity"] = "0";
  818. setTimeout(function() {document.getElementById(id).style["opacity"] = "1";}, 1);
  819. }
  820. if (property == "display" && value == "block" && id == "tarteaucitronBack") {
  821. document.getElementById(id).style["opacity"] = "0";
  822. setTimeout(function() {document.getElementById(id).style["opacity"] = "0.7";}, 1);
  823. }
  824. }
  825. }
  826. },
  827. "addClass": function (id, className) {
  828. "use strict";
  829. if (document.getElementById(id) !== null) {
  830. document.getElementById(id).classList.add(className);
  831. }
  832. },
  833. "removeClass": function (id, className) {
  834. "use strict";
  835. if (document.getElementById(id) !== null) {
  836. document.getElementById(id).classList.remove(className);
  837. }
  838. },
  839. "respondAll": function (status, type, allowSafeAnalytics) {
  840. "use strict";
  841. var s = tarteaucitron.services,
  842. service,
  843. key,
  844. index = 0;
  845. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  846. if (typeof type !== 'undefined' && type !== '' && s[tarteaucitron.job[index]].type !== type) {
  847. continue;
  848. }
  849. if (allowSafeAnalytics && typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  850. continue;
  851. }
  852. service = s[tarteaucitron.job[index]];
  853. key = service.key;
  854. if (tarteaucitron.state[key] !== status) {
  855. if (status === false && tarteaucitron.launch[key] === true) {
  856. tarteaucitron.reloadThePage = true;
  857. }
  858. if (tarteaucitron.launch[key] !== true && status === true) {
  859. tarteaucitron.pro('!' + key + '=engage');
  860. tarteaucitron.launch[key] = true;
  861. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  862. tarteaucitron.sendEvent(key + '_loaded');
  863. }
  864. var itemStatusElem = document.getElementById('tacCurrentStatus'+key);
  865. if(status == true){
  866. itemStatusElem.innerHTML = tarteaucitron.lang.allowed;
  867. }else{
  868. itemStatusElem.innerHTML = tarteaucitron.lang.disallowed;
  869. }
  870. tarteaucitron.state[key] = status;
  871. tarteaucitron.cookie.create(key, status);
  872. tarteaucitron.userInterface.color(key, status);
  873. }
  874. }
  875. },
  876. "respond": function (el, status) {
  877. "use strict";
  878. if (el.id === '') {
  879. return;
  880. }
  881. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  882. if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;}
  883. // return if same state
  884. if (tarteaucitron.state[key] === status) {
  885. return;
  886. }
  887. if (status === false && tarteaucitron.launch[key] === true) {
  888. tarteaucitron.reloadThePage = true;
  889. }
  890. // if not already launched... launch the service
  891. if (status === true) {
  892. if (tarteaucitron.launch[key] !== true) {
  893. tarteaucitron.pro('!' + key + '=engage');
  894. tarteaucitron.launch[key] = true;
  895. tarteaucitron.sendEvent(key + '_loaded');
  896. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  897. }
  898. }
  899. var itemStatusElem = document.getElementById('tacCurrentStatus'+key);
  900. if(status == true){
  901. itemStatusElem.innerHTML = tarteaucitron.lang.allowed;
  902. }else{
  903. itemStatusElem.innerHTML = tarteaucitron.lang.disallowed;
  904. }
  905. tarteaucitron.state[key] = status;
  906. tarteaucitron.cookie.create(key, status);
  907. tarteaucitron.userInterface.color(key, status);
  908. },
  909. "color": function (key, status) {
  910. "use strict";
  911. var c = 'tarteaucitron',
  912. nbDenied = 0,
  913. nbPending = 0,
  914. nbAllowed = 0,
  915. sum = tarteaucitron.job.length,
  916. index,
  917. s = tarteaucitron.services;
  918. if (key !== "") {
  919. if (status === true) {
  920. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  921. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  922. } else if (status === false) {
  923. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  924. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  925. }
  926. // check if all services are allowed
  927. var sumToRemove = 0;
  928. for (index = 0; index < sum; index += 1) {
  929. if (typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  930. sumToRemove += 1;
  931. continue;
  932. }
  933. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  934. nbDenied += 1;
  935. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  936. nbPending += 1;
  937. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  938. nbAllowed += 1;
  939. }
  940. }
  941. sum -= sumToRemove;
  942. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  943. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  944. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  945. if (nbDenied === 0 && nbPending === 0) {
  946. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  947. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  948. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  949. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  950. } else if (nbAllowed === 0 && nbPending === 0) {
  951. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  952. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  953. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  954. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  955. } else {
  956. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  957. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  958. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  959. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  960. }
  961. // close the alert if all service have been reviewed
  962. if (nbPending === 0) {
  963. tarteaucitron.userInterface.closeAlert();
  964. }
  965. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  966. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  967. }
  968. if (status === true) {
  969. if (document.getElementById('tacCL' + key) !== null) {
  970. document.getElementById('tacCL' + key).innerHTML = '...';
  971. }
  972. setTimeout(function () {
  973. tarteaucitron.cookie.checkCount(key);
  974. }, 2500);
  975. } else {
  976. tarteaucitron.cookie.checkCount(key);
  977. }
  978. }
  979. // groups
  980. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  981. Array.prototype.forEach.call(cats, function(item) {
  982. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, ""),
  983. total = document.getElementById("tarteaucitronServices_"+cat).childElementCount;
  984. var doc = document.getElementById("tarteaucitronServices_"+cat),
  985. groupdenied = 0,
  986. groupallowed = 0;
  987. for (var ii = 0; ii < doc.children.length; ii++) {
  988. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsDenied") {
  989. groupdenied++;
  990. }
  991. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsAllowed") {
  992. groupallowed++;
  993. }
  994. }
  995. if (total === groupallowed) {
  996. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  997. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  998. }
  999. if (total === groupdenied) {
  1000. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  1001. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  1002. }
  1003. if (total !== groupdenied && total !== groupallowed) {
  1004. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  1005. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  1006. }
  1007. groupdenied = 0;
  1008. groupallowed = 0;
  1009. });
  1010. },
  1011. "openPanel": function () {
  1012. "use strict";
  1013. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  1014. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1015. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  1016. document.getElementById('tarteaucitronClosePanel').focus();
  1017. document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open');
  1018. tarteaucitron.userInterface.focusTrap();
  1019. tarteaucitron.userInterface.jsSizing('main');
  1020. //ie compatibility
  1021. var tacOpenPanelEvent;
  1022. if(typeof(Event) === 'function') {
  1023. tacOpenPanelEvent = new Event("tac.open_panel");
  1024. }else{
  1025. tacOpenPanelEvent = document.createEvent('Event');
  1026. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  1027. }
  1028. //end ie compatibility
  1029. window.dispatchEvent(tacOpenPanelEvent);
  1030. },
  1031. "closePanel": function () {
  1032. "use strict";
  1033. if (document.location.hash === tarteaucitron.hashtag) {
  1034. if (window.history) {
  1035. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  1036. } else {
  1037. document.location.hash = '';
  1038. }
  1039. }
  1040. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1041. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  1042. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1043. elem.style.display = 'none';
  1044. }, true);
  1045. if (tarteaucitron.reloadThePage === true) {
  1046. window.location.reload();
  1047. } else {
  1048. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1049. }
  1050. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  1051. document.getElementById('tarteaucitronCloseAlert').focus();
  1052. }
  1053. document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open');
  1054. //ie compatibility
  1055. var tacClosePanelEvent;
  1056. if(typeof(Event) === 'function') {
  1057. tacClosePanelEvent = new Event("tac.close_panel");
  1058. }else{
  1059. tacClosePanelEvent = document.createEvent('Event');
  1060. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  1061. }
  1062. //end ie compatibility
  1063. window.dispatchEvent(tacClosePanelEvent);
  1064. },
  1065. "focusTrap": function() {
  1066. "use strict";
  1067. var focusableEls,
  1068. firstFocusableEl,
  1069. lastFocusableEl,
  1070. filtered;
  1071. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  1072. filtered = [];
  1073. // get only visible items
  1074. for (var i = 0, max = focusableEls.length; i < max; i++) {
  1075. if (focusableEls[i].offsetHeight > 0) {
  1076. filtered.push(focusableEls[i]);
  1077. }
  1078. }
  1079. firstFocusableEl = filtered[0];
  1080. lastFocusableEl = filtered[filtered.length - 1];
  1081. //loop focus inside tarteaucitron
  1082. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  1083. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  1084. if ( evt.shiftKey ) /* shift + tab */ {
  1085. if (document.activeElement === firstFocusableEl) {
  1086. lastFocusableEl.focus();
  1087. evt.preventDefault();
  1088. }
  1089. } else /* tab */ {
  1090. if (document.activeElement === lastFocusableEl) {
  1091. firstFocusableEl.focus();
  1092. evt.preventDefault();
  1093. }
  1094. }
  1095. }
  1096. })
  1097. },
  1098. "openAlert": function () {
  1099. "use strict";
  1100. var c = 'tarteaucitron';
  1101. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  1102. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  1103. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'none');
  1104. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  1105. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1106. //ie compatibility
  1107. var tacOpenAlertEvent;
  1108. if(typeof(Event) === 'function') {
  1109. tacOpenAlertEvent = new Event("tac.open_alert");
  1110. }else{
  1111. tacOpenAlertEvent = document.createEvent('Event');
  1112. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  1113. }
  1114. //end ie compatibility
  1115. if (document.getElementById('tarteaucitronAlertBig') !== null) {
  1116. document.getElementById('tarteaucitronAlertBig').focus();
  1117. }
  1118. window.dispatchEvent(tacOpenAlertEvent);
  1119. },
  1120. "closeAlert": function () {
  1121. "use strict";
  1122. var c = 'tarteaucitron';
  1123. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  1124. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  1125. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'block');
  1126. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  1127. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1128. tarteaucitron.userInterface.jsSizing('box');
  1129. //ie compatibility
  1130. var tacCloseAlertEvent;
  1131. if(typeof(Event) === 'function') {
  1132. tacCloseAlertEvent = new Event("tac.close_alert");
  1133. }else{
  1134. tacCloseAlertEvent = document.createEvent('Event');
  1135. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  1136. }
  1137. //end ie compatibility
  1138. window.dispatchEvent(tacCloseAlertEvent);
  1139. },
  1140. "toggleCookiesList": function () {
  1141. "use strict";
  1142. var div = document.getElementById('tarteaucitronCookiesListContainer');
  1143. if (div === null) {
  1144. return;
  1145. }
  1146. if (div.style.display !== 'block') {
  1147. tarteaucitron.cookie.number();
  1148. div.style.display = 'block';
  1149. tarteaucitron.userInterface.jsSizing('cookie');
  1150. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1151. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1152. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1153. elem.style.display = 'none';
  1154. }, true);
  1155. } else {
  1156. div.style.display = 'none';
  1157. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1158. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1159. }
  1160. },
  1161. "toggle": function (id, closeClass) {
  1162. "use strict";
  1163. var div = document.getElementById(id);
  1164. if (div === null) {
  1165. return;
  1166. }
  1167. if (closeClass !== undefined) {
  1168. tarteaucitron.fallback([closeClass], function (elem) {
  1169. if (elem.id !== id) {
  1170. elem.style.display = 'none';
  1171. }
  1172. }, true);
  1173. }
  1174. if (div.style.display !== 'block') {
  1175. div.style.display = 'block';
  1176. } else {
  1177. div.style.display = 'none';
  1178. }
  1179. },
  1180. "order": function (id) {
  1181. "use strict";
  1182. var main = document.getElementById('tarteaucitronServices_' + id),
  1183. allDivs,
  1184. store = [],
  1185. i;
  1186. if (main === null) {
  1187. return;
  1188. }
  1189. allDivs = main.childNodes;
  1190. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  1191. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  1192. //var mainChildren = Array.from(main.children);
  1193. //mainChildren.sort(function (a, b) {
  1194. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  1195. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  1196. return 0;
  1197. }).forEach(function (element) {
  1198. main.appendChild(element);
  1199. });
  1200. }
  1201. },
  1202. "jsSizing": function (type) {
  1203. "use strict";
  1204. var scrollbarMarginRight = 10,
  1205. scrollbarWidthParent,
  1206. scrollbarWidthChild,
  1207. servicesHeight,
  1208. e = window,
  1209. a = 'inner',
  1210. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  1211. mainTop,
  1212. mainHeight,
  1213. closeButtonHeight,
  1214. headerHeight,
  1215. cookiesListHeight,
  1216. cookiesCloseHeight,
  1217. cookiesTitleHeight,
  1218. paddingBox,
  1219. alertSmallHeight,
  1220. cookiesNumberHeight;
  1221. if (type === 'box') {
  1222. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1223. // reset
  1224. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  1225. // calculate
  1226. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  1227. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  1228. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  1229. // apply
  1230. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  1231. }
  1232. } else if (type === 'main') {
  1233. // get the real window width for media query
  1234. if (window.innerWidth === undefined) {
  1235. a = 'client';
  1236. e = document.documentElement || document.body;
  1237. }
  1238. // height of the services list container
  1239. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1240. // reset
  1241. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  1242. // calculate
  1243. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1244. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1245. // apply
  1246. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1247. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1248. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1249. }
  1250. // align the main allow/deny button depending on scrollbar width
  1251. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1252. // media query
  1253. if (e[a + 'Width'] <= 479) {
  1254. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1255. } else if (e[a + 'Width'] <= 767) {
  1256. scrollbarMarginRight = 12;
  1257. }
  1258. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1259. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1260. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1261. }
  1262. // center the main panel
  1263. if (document.getElementById('tarteaucitron') !== null) {
  1264. // media query
  1265. if (e[a + 'Width'] <= 767) {
  1266. mainTop = 0;
  1267. } else {
  1268. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1269. }
  1270. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1271. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1272. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1273. }
  1274. }
  1275. // correct
  1276. if (mainTop < 0) {
  1277. mainTop = 0;
  1278. }
  1279. // apply
  1280. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1281. }
  1282. } else if (type === 'cookie') {
  1283. // put cookies list at bottom
  1284. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1285. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1286. }
  1287. // height of cookies list
  1288. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1289. // reset
  1290. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1291. // calculate
  1292. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1293. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1294. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1295. // apply
  1296. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1297. }
  1298. }
  1299. }
  1300. },
  1301. "cookie": {
  1302. "owner": {},
  1303. "create": function (key, status) {
  1304. "use strict";
  1305. if (tarteaucitronForceExpire !== '') {
  1306. // The number of day(s)/hour(s) can't be higher than 1 year
  1307. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1308. if (tarteaucitronExpireInDay) {
  1309. // Multiplication to tranform the number of days to milliseconds
  1310. timeExpire = tarteaucitronForceExpire * 86400000;
  1311. } else {
  1312. // Multiplication to tranform the number of hours to milliseconds
  1313. timeExpire = tarteaucitronForceExpire * 3600000;
  1314. }
  1315. }
  1316. }
  1317. var d = new Date(),
  1318. time = d.getTime(),
  1319. expireTime = time + timeExpire, // 365 days
  1320. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1321. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1322. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1323. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? '; domain=' + tarteaucitron.parameters.cookieDomain : '',
  1324. secure = location.protocol === 'https:' ? '; Secure' : '';
  1325. d.setTime(expireTime);
  1326. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/' + domain + secure + '; samesite=lax';
  1327. },
  1328. "read": function () {
  1329. "use strict";
  1330. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1331. ca = document.cookie.split(';'),
  1332. i,
  1333. c;
  1334. for (i = 0; i < ca.length; i += 1) {
  1335. c = ca[i];
  1336. while (c.charAt(0) === ' ') {
  1337. c = c.substring(1, c.length);
  1338. }
  1339. if (c.indexOf(nameEQ) === 0) {
  1340. return c.substring(nameEQ.length, c.length);
  1341. }
  1342. }
  1343. return '';
  1344. },
  1345. "purge": function (arr) {
  1346. "use strict";
  1347. var i;
  1348. for (i = 0; i < arr.length; i += 1) {
  1349. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1350. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1351. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1352. }
  1353. },
  1354. "checkCount": function (key) {
  1355. "use strict";
  1356. var arr = tarteaucitron.services[key].cookies,
  1357. nb = arr.length,
  1358. nbCurrent = 0,
  1359. html = '',
  1360. i,
  1361. status = document.cookie.indexOf(key + '=true');
  1362. if (status >= 0 && nb === 0) {
  1363. html += tarteaucitron.lang.useNoCookie;
  1364. } else if (status >= 0) {
  1365. for (i = 0; i < nb; i += 1) {
  1366. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1367. nbCurrent += 1;
  1368. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1369. tarteaucitron.cookie.owner[arr[i]] = [];
  1370. }
  1371. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1372. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1373. }
  1374. }
  1375. }
  1376. if (nbCurrent > 0) {
  1377. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1378. if (nbCurrent > 1) {
  1379. html += 's';
  1380. }
  1381. html += '.';
  1382. } else {
  1383. html += tarteaucitron.lang.useNoCookie;
  1384. }
  1385. } else if (nb === 0) {
  1386. html = tarteaucitron.lang.noCookie;
  1387. } else {
  1388. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1389. if (nb > 1) {
  1390. html += 's';
  1391. }
  1392. html += '.';
  1393. }
  1394. if (document.getElementById('tacCL' + key) !== null) {
  1395. document.getElementById('tacCL' + key).innerHTML = html;
  1396. }
  1397. },
  1398. "crossIndexOf": function (arr, match) {
  1399. "use strict";
  1400. var i;
  1401. for (i = 0; i < arr.length; i += 1) {
  1402. if (arr[i] === match) {
  1403. return true;
  1404. }
  1405. }
  1406. return false;
  1407. },
  1408. "number": function () {
  1409. "use strict";
  1410. var cookies = document.cookie.split(';'),
  1411. nb = (document.cookie !== '') ? cookies.length : 0,
  1412. html = '',
  1413. i,
  1414. name,
  1415. namea,
  1416. nameb,
  1417. c,
  1418. d,
  1419. s = (nb > 1) ? 's' : '',
  1420. savedname,
  1421. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1422. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1423. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1424. cookies = cookies.sort(function (a, b) {
  1425. namea = a.split('=', 1).toString().replace(/ /g, '');
  1426. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1427. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1428. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1429. if (c + a > d + b) { return 1; }
  1430. if (c + a < d + b) { return -1; }
  1431. return 0;
  1432. });
  1433. if (document.cookie !== '') {
  1434. for (i = 0; i < nb; i += 1) {
  1435. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1436. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1437. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1438. html += '<div class="tarteaucitronHidden">';
  1439. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1440. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1441. html += ' </span>';
  1442. html += '</div><ul class="cookie-list">';
  1443. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1444. savedname = host;
  1445. html += '<div class="tarteaucitronHidden">';
  1446. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1447. html += ' ' + host;
  1448. html += ' </span>';
  1449. html += '</div><ul class="cookie-list">';
  1450. }
  1451. html += '<li class="tarteaucitronCookiesListMain">';
  1452. 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>';
  1453. html += ' </div>';
  1454. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1455. html += '</li>';
  1456. }
  1457. html += '</ul>';
  1458. } else {
  1459. html += '<div class="tarteaucitronCookiesListMain">';
  1460. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1461. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1462. html += '</div>';
  1463. }
  1464. html += '<div class="tarteaucitronHidden tarteaucitron-spacer-20"></div>';
  1465. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1466. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1467. }
  1468. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1469. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1470. }
  1471. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1472. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1473. }
  1474. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1475. for (i = 0; i < purgeBtns.length; i++) {
  1476. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1477. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1478. tarteaucitron.cookie.number();
  1479. tarteaucitron.userInterface.jsSizing('cookie');
  1480. return false;
  1481. });
  1482. }
  1483. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1484. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1485. }
  1486. }
  1487. },
  1488. "fixSelfXSS": function(html) {
  1489. return html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1490. },
  1491. "getLanguage": function () {
  1492. "use strict";
  1493. 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',
  1494. defaultLanguage = 'en';
  1495. if (tarteaucitronForceLanguage !== '') {
  1496. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1497. return tarteaucitronForceLanguage;
  1498. }
  1499. }
  1500. if (!navigator) { return 'en'; }
  1501. var lang = navigator.language || navigator.browserLanguage ||
  1502. navigator.systemLanguage || navigator.userLang || null,
  1503. userLanguage = lang ? lang.substr(0, 2) : null;
  1504. if (availableLanguages.indexOf(userLanguage) === -1) {
  1505. return defaultLanguage;
  1506. }
  1507. return userLanguage;
  1508. },
  1509. "getLocale": function () {
  1510. "use strict";
  1511. if (!navigator) { return 'en_US'; }
  1512. var lang = navigator.language || navigator.browserLanguage ||
  1513. navigator.systemLanguage || navigator.userLang || null,
  1514. userLanguage = lang ? lang.substr(0, 2) : null;
  1515. if (userLanguage === 'fr') {
  1516. return 'fr_FR';
  1517. } else if (userLanguage === 'en') {
  1518. return 'en_US';
  1519. } else if (userLanguage === 'de') {
  1520. return 'de_DE';
  1521. } else if (userLanguage === 'es') {
  1522. return 'es_ES';
  1523. } else if (userLanguage === 'it') {
  1524. return 'it_IT';
  1525. } else if (userLanguage === 'pt') {
  1526. return 'pt_PT';
  1527. } else if (userLanguage === 'nl') {
  1528. return 'nl_NL';
  1529. } else if (userLanguage === 'el') {
  1530. return 'el_EL';
  1531. } else {
  1532. return 'en_US';
  1533. }
  1534. },
  1535. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1536. "use strict";
  1537. var script,
  1538. done = false;
  1539. if (execute === false) {
  1540. if (typeof callback === 'function') {
  1541. callback();
  1542. }
  1543. } else {
  1544. script = document.createElement('script');
  1545. script.id = (id !== undefined) ? id : '';
  1546. script.async = true;
  1547. script.src = url;
  1548. if (attrName !== undefined && attrVal !== undefined) {
  1549. script.setAttribute(attrName, attrVal);
  1550. }
  1551. if (typeof callback === 'function') {
  1552. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1553. script.onreadystatechange = script.onload = function () {
  1554. var state = script.readyState;
  1555. if (!done && (!state || /loaded|complete/.test(state))) {
  1556. done = true;
  1557. callback();
  1558. }
  1559. };
  1560. } else {
  1561. callback();
  1562. }
  1563. }
  1564. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1565. document.getElementsByTagName('head')[0].appendChild(script);
  1566. }
  1567. }
  1568. },
  1569. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1570. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1571. },
  1572. "makeAsync": {
  1573. "antiGhost": 0,
  1574. "buffer": '',
  1575. "init": function (url, id) {
  1576. "use strict";
  1577. var savedWrite = document.write,
  1578. savedWriteln = document.writeln;
  1579. document.write = function (content) {
  1580. tarteaucitron.makeAsync.buffer += content;
  1581. };
  1582. document.writeln = function (content) {
  1583. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1584. };
  1585. setTimeout(function () {
  1586. document.write = savedWrite;
  1587. document.writeln = savedWriteln;
  1588. }, 20000);
  1589. tarteaucitron.makeAsync.getAndParse(url, id);
  1590. },
  1591. "getAndParse": function (url, id) {
  1592. "use strict";
  1593. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1594. tarteaucitron.makeAsync.antiGhost = 0;
  1595. return;
  1596. }
  1597. tarteaucitron.makeAsync.antiGhost += 1;
  1598. tarteaucitron.addInternalScript(url, '', function () {
  1599. if (document.getElementById(id) !== null) {
  1600. document.getElementById(id).innerHTML += "<span class='tarteaucitron-display-none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1601. tarteaucitron.makeAsync.buffer = '';
  1602. tarteaucitron.makeAsync.execJS(id);
  1603. }
  1604. });
  1605. },
  1606. "execJS": function (id) {
  1607. /* not strict because third party scripts may have errors */
  1608. var i,
  1609. scripts,
  1610. childId,
  1611. type;
  1612. if (document.getElementById(id) === null) {
  1613. return;
  1614. }
  1615. scripts = document.getElementById(id).getElementsByTagName('script');
  1616. for (i = 0; i < scripts.length; i += 1) {
  1617. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1618. if (type === '') {
  1619. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1620. }
  1621. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1622. childId = id + Math.floor(Math.random() * 99999999999);
  1623. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1624. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1625. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1626. eval(scripts[i].innerHTML);
  1627. }
  1628. }
  1629. }
  1630. },
  1631. "fallback": function (matchClass, content, noInner) {
  1632. "use strict";
  1633. var elems = document.getElementsByTagName('*'),
  1634. i,
  1635. index = 0;
  1636. for (i in elems) {
  1637. if (elems[i] !== undefined) {
  1638. for (index = 0; index < matchClass.length; index += 1) {
  1639. if ((' ' + elems[i].className + ' ')
  1640. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1641. if (typeof content === 'function') {
  1642. if (noInner === true) {
  1643. content(elems[i]);
  1644. } else {
  1645. elems[i].innerHTML = content(elems[i]);
  1646. }
  1647. } else {
  1648. elems[i].innerHTML = content;
  1649. }
  1650. }
  1651. }
  1652. }
  1653. }
  1654. },
  1655. "engage": function (id) {
  1656. "use strict";
  1657. var html = '',
  1658. r = Math.floor(Math.random() * 100000),
  1659. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1660. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1661. engage = tarteaucitron.lang['engage-' + id];
  1662. }
  1663. html += '<div class="tac_activate tac_activate_' + id + '">';
  1664. html += ' <div class="tac_float">';
  1665. html += ' ' + engage;
  1666. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1667. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  1668. html += ' </button>';
  1669. html += ' </div>';
  1670. html += '</div>';
  1671. return html;
  1672. },
  1673. "extend": function (a, b) {
  1674. "use strict";
  1675. var prop;
  1676. for (prop in b) {
  1677. if (b.hasOwnProperty(prop)) {
  1678. a[prop] = b[prop];
  1679. }
  1680. }
  1681. },
  1682. "proTemp": '',
  1683. "proTimer": function () {
  1684. "use strict";
  1685. setTimeout(tarteaucitron.proPing, 500);
  1686. },
  1687. "pro": function (list) {
  1688. "use strict";
  1689. tarteaucitron.proTemp += list;
  1690. clearTimeout(tarteaucitron.proTimer);
  1691. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1692. },
  1693. "proPing": function () {
  1694. "use strict";
  1695. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1696. var div = document.getElementById('tarteaucitronPremium'),
  1697. timestamp = new Date().getTime(),
  1698. url = 'https://tarteaucitron.io/log/?';
  1699. if (div === null) {
  1700. return;
  1701. }
  1702. url += 'account=' + tarteaucitron.uuid + '&';
  1703. url += 'domain=' + tarteaucitron.domain + '&';
  1704. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1705. url += '_time=' + timestamp;
  1706. div.innerHTML = '<img src="' + url + '" class="tarteaucitron-display-none" alt="" />';
  1707. tarteaucitron.proTemp = '';
  1708. }
  1709. tarteaucitron.cookie.number();
  1710. },
  1711. "AddOrUpdate" : function(source, custom){
  1712. /**
  1713. Utility function to Add or update the fields of obj1 with the ones in obj2
  1714. */
  1715. for(key in custom){
  1716. if(custom[key] instanceof Object){
  1717. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1718. }else{
  1719. source[key] = custom[key];
  1720. }
  1721. }
  1722. return source;
  1723. },
  1724. "getElemWidth": function(elem) {
  1725. return elem.getAttribute('width') || elem.clientWidth;
  1726. },
  1727. "getElemHeight": function(elem) {
  1728. return elem.getAttribute('height') || elem.clientHeight;
  1729. },
  1730. "addClickEventToId": function (elemId, func) {
  1731. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1732. },
  1733. "addClickEventToElement": function (e, func) {
  1734. if (e) {
  1735. if (e.addEventListener) {
  1736. e.addEventListener("click", func);
  1737. } else {
  1738. e.attachEvent("onclick", func);
  1739. }
  1740. }
  1741. },
  1742. "triggerJobsAfterAjaxCall": function() {
  1743. tarteaucitron.job.forEach(function(e) { tarteaucitron.job.push(e) });
  1744. var i;
  1745. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  1746. for (i = 0; i < allowBtns.length; i++) {
  1747. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  1748. tarteaucitron.userInterface.respond(this, true);
  1749. });
  1750. }
  1751. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  1752. for (i = 0; i < denyBtns.length; i++) {
  1753. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  1754. tarteaucitron.userInterface.respond(this, false);
  1755. });
  1756. }
  1757. }
  1758. };