tarteaucitron.js 109 KB

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