tarteaucitron.js 100 KB

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