tarteaucitron.js 97 KB

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