tarteaucitron.js 98 KB

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