tarteaucitron.js 98 KB

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