tarteaucitron.js 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584
  1. /*jslint browser: true, evil: true */
  2. // define correct path for files inclusion
  3. var scripts = document.getElementsByTagName('script'),
  4. path = scripts[scripts.length - 1].src.split('?')[0],
  5. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  6. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  7. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  8. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  9. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  10. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  11. // tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
  12. tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || typeof tarteaucitronExpireInDay !== "boolean") ? true : tarteaucitronExpireInDay,
  13. timeExpire = 31536000000,
  14. tarteaucitronProLoadServices,
  15. tarteaucitronNoAdBlocker = false;
  16. var tarteaucitron = {
  17. "version": 20191029,
  18. "cdn": cdn,
  19. "user": {},
  20. "lang": {},
  21. "services": {},
  22. "added": [],
  23. "idprocessed": [],
  24. "state": [],
  25. "launch": [],
  26. "parameters": {},
  27. "isAjax": false,
  28. "reloadThePage": false,
  29. "events": {
  30. "init": function () {},
  31. "load": function () {},
  32. },
  33. "init": function (params) {
  34. "use strict";
  35. var origOpen;
  36. tarteaucitron.parameters = params;
  37. if (alreadyLaunch === 0) {
  38. alreadyLaunch = 1;
  39. if (window.addEventListener) {
  40. window.addEventListener("load", function () {
  41. tarteaucitron.load();
  42. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  43. elem.addEventListener("click", function (event) {
  44. tarteaucitron.userInterface.openPanel();
  45. event.preventDefault();
  46. }, false);
  47. }, true);
  48. }, false);
  49. window.addEventListener("scroll", function () {
  50. var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
  51. heightPosition;
  52. if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
  53. if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
  54. heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
  55. if (scrollPos > (screen.height * 2)) {
  56. tarteaucitron.userInterface.respondAll(true);
  57. } else if (scrollPos > (screen.height / 2)) {
  58. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  59. }
  60. if (tarteaucitron.orientation === 'top') {
  61. document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
  62. } else {
  63. document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
  64. }
  65. document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  66. }
  67. }
  68. }, false);
  69. window.addEventListener("keydown", function (evt) {
  70. if (evt.keyCode === 27) {
  71. tarteaucitron.userInterface.closePanel();
  72. }
  73. }, false);
  74. window.addEventListener("hashchange", function () {
  75. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  76. tarteaucitron.userInterface.openPanel();
  77. }
  78. }, false);
  79. window.addEventListener("resize", function () {
  80. if (document.getElementById('tarteaucitron') !== null) {
  81. if (document.getElementById('tarteaucitron').style.display === 'block') {
  82. tarteaucitron.userInterface.jsSizing('main');
  83. }
  84. }
  85. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  86. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  87. tarteaucitron.userInterface.jsSizing('cookie');
  88. }
  89. }
  90. }, false);
  91. } else {
  92. window.attachEvent("onload", function () {
  93. tarteaucitron.load();
  94. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  95. elem.attachEvent("onclick", function (event) {
  96. tarteaucitron.userInterface.openPanel();
  97. event.preventDefault();
  98. });
  99. }, true);
  100. });
  101. window.attachEvent("onscroll", function () {
  102. var scrollPos = window.pageYOffset || document.documentElement.scrollTop,
  103. heightPosition;
  104. if (document.getElementById('tarteaucitronAlertBig') !== null && !tarteaucitron.highPrivacy) {
  105. if (document.getElementById('tarteaucitronAlertBig').style.display === 'block') {
  106. heightPosition = document.getElementById('tarteaucitronAlertBig').offsetHeight + 'px';
  107. if (scrollPos > (screen.height * 2)) {
  108. tarteaucitron.userInterface.respondAll(true);
  109. } else if (scrollPos > (screen.height / 2)) {
  110. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  111. }
  112. if (tarteaucitron.orientation === 'top') {
  113. document.getElementById('tarteaucitronPercentage').style.top = heightPosition;
  114. } else {
  115. document.getElementById('tarteaucitronPercentage').style.bottom = heightPosition;
  116. }
  117. document.getElementById('tarteaucitronPercentage').style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  118. }
  119. }
  120. });
  121. window.attachEvent("onkeydown", function (evt) {
  122. if (evt.keyCode === 27) {
  123. tarteaucitron.userInterface.closePanel();
  124. }
  125. if ( evt.keyCode === 9 && focusableEls.indexOf(evt.target) >= 0) {
  126. if ( evt.shiftKey ) /* shift + tab */ {
  127. if (document.activeElement === firstFocusableEl) {
  128. lastFocusableEl.focus();
  129. evt.preventDefault();
  130. }
  131. } else /* tab */ {
  132. if (document.activeElement === lastFocusableEl) {
  133. firstFocusableEl.focus();
  134. evt.preventDefault();
  135. }
  136. }
  137. }
  138. });
  139. window.attachEvent("onhashchange", function () {
  140. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  141. tarteaucitron.userInterface.openPanel();
  142. }
  143. });
  144. window.attachEvent("onresize", function () {
  145. if (document.getElementById('tarteaucitron') !== null) {
  146. if (document.getElementById('tarteaucitron').style.display === 'block') {
  147. tarteaucitron.userInterface.jsSizing('main');
  148. }
  149. }
  150. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  151. if (document.getElementById('tarteaucitronCookiesListContainer').style.display === 'block') {
  152. tarteaucitron.userInterface.jsSizing('cookie');
  153. }
  154. }
  155. });
  156. }
  157. if (typeof XMLHttpRequest !== 'undefined') {
  158. origOpen = XMLHttpRequest.prototype.open;
  159. XMLHttpRequest.prototype.open = function () {
  160. if (window.addEventListener) {
  161. this.addEventListener("load", function () {
  162. if (typeof tarteaucitronProLoadServices === 'function') {
  163. tarteaucitronProLoadServices();
  164. }
  165. }, false);
  166. } else if (typeof this.attachEvent !== 'undefined') {
  167. this.attachEvent("onload", function () {
  168. if (typeof tarteaucitronProLoadServices === 'function') {
  169. tarteaucitronProLoadServices();
  170. }
  171. });
  172. } else {
  173. if (typeof tarteaucitronProLoadServices === 'function') {
  174. setTimeout(tarteaucitronProLoadServices, 1000);
  175. }
  176. }
  177. try {
  178. origOpen.apply(this, arguments);
  179. } catch (err) {}
  180. };
  181. }
  182. }
  183. if(tarteaucitron.events.init) {
  184. tarteaucitron.events.init();
  185. }
  186. },
  187. "load": function () {
  188. "use strict";
  189. var cdn = tarteaucitron.cdn,
  190. language = tarteaucitron.getLanguage(),
  191. pathToLang = cdn + 'lang/tarteaucitron.' + language + '.js?v=' + tarteaucitron.version,
  192. pathToServices = cdn + 'tarteaucitron.services.js?v=' + tarteaucitron.version,
  193. linkElement = document.createElement('link'),
  194. defaults = {
  195. "adblocker": false,
  196. "hashtag": '#tarteaucitron',
  197. "cookieName": 'tarteaucitron',
  198. "highPrivacy": false,
  199. "orientation": "top",
  200. "removeCredit": false,
  201. "showAlertSmall": true,
  202. "cookieslist": true,
  203. "handleBrowserDNTRequest": false,
  204. "AcceptAllCta" : false,
  205. "moreInfoLink": true,
  206. "privacyUrl": "",
  207. "useExternalCss": false
  208. },
  209. params = tarteaucitron.parameters;
  210. // Step -1
  211. if (typeof tarteaucitronCustomPremium !== 'undefined') {
  212. tarteaucitronCustomPremium();
  213. }
  214. // Step 0: get params
  215. if (params !== undefined) {
  216. for (var k in defaults) {
  217. if(!tarteaucitron.parameters.hasOwnProperty(k)) {
  218. tarteaucitron.parameters[k] = defaults[k];
  219. }
  220. }
  221. }
  222. // global
  223. tarteaucitron.orientation = tarteaucitron.parameters.orientation;
  224. tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
  225. tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
  226. tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
  227. // Step 1: load css
  228. if ( !tarteaucitron.parameters.useExternalCss ) {
  229. linkElement.rel = 'stylesheet';
  230. linkElement.type = 'text/css';
  231. linkElement.href = cdn + 'css/tarteaucitron.css?v=' + tarteaucitron.version;
  232. document.getElementsByTagName('head')[0].appendChild(linkElement);
  233. }
  234. // Step 2: load language and services
  235. tarteaucitron.addScript(pathToLang, '', function () {
  236. if(tarteaucitronCustomText !== ''){
  237. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  238. }
  239. tarteaucitron.addScript(pathToServices, '', function () {
  240. var body = document.body,
  241. div = document.createElement('div'),
  242. html = '',
  243. index,
  244. orientation = 'Top',
  245. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  246. i;
  247. cat = cat.sort(function (a, b) {
  248. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  249. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  250. return 0;
  251. });
  252. // Step 3: prepare the html
  253. html += '<div id="tarteaucitronPremium"></div>';
  254. html += '<button type="button" id="tarteaucitronBack" onclick="tarteaucitron.userInterface.closePanel();" aria-label="' + tarteaucitron.lang.close + '"></button>';
  255. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  256. html += ' <button type="button" id="tarteaucitronClosePanel" onclick="tarteaucitron.userInterface.closePanel();">';
  257. html += ' ' + tarteaucitron.lang.close;
  258. html += ' </button>';
  259. html += ' <div id="tarteaucitronServices">';
  260. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  261. html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
  262. html += ' <div id="tarteaucitronInfo" class="tarteaucitronInfoBox">';
  263. html += ' ' + tarteaucitron.lang.disclaimer;
  264. if (tarteaucitron.parameters.privacyUrl !== "") {
  265. html += ' <br/><br/>';
  266. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  267. html += ' ' + tarteaucitron.lang.privacyUrl;
  268. html += ' </button>';
  269. }
  270. html += ' </div>';
  271. html += ' <div class="tarteaucitronName">';
  272. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2">' + tarteaucitron.lang.all + '</span>';
  273. html += ' </div>';
  274. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  275. html += ' <button type="button" id="tarteaucitronAllAllowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respondAll(true);">';
  276. html += ' &#10003; ' + tarteaucitron.lang.allowAll;
  277. html += ' </button> ';
  278. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respondAll(false);">';
  279. html += ' &#10007; ' + tarteaucitron.lang.denyAll;
  280. html += ' </button>';
  281. html += ' </div>';
  282. html += ' </div>';
  283. html += ' <div class="tarteaucitronBorder">';
  284. html += ' <div class="clear"></div><ul>';
  285. for (i = 0; i < cat.length; i += 1) {
  286. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  287. html += ' <div class="tarteaucitronTitle">';
  288. html += ' <button type="button" onclick="tarteaucitron.userInterface.toggle(\'tarteaucitronDetails' + cat[i] + '\', \'tarteaucitronInfoBox\');return false">&#10011; ' + tarteaucitron.lang[cat[i]].title + '</button>';
  289. html += ' </div>';
  290. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  291. html += ' ' + tarteaucitron.lang[cat[i]].details;
  292. html += ' </div>';
  293. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  294. }
  295. html += ' </ul>';
  296. html += ' <div class="tarteaucitronHidden" id="tarteaucitronScrollbarChild" style="height:20px;display:block"></div>';
  297. if (tarteaucitron.parameters.removeCredit === false) {
  298. html += ' <a class="tarteaucitronSelfLink" href="https://opt-out.ferank.eu/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '">🍋 ' + tarteaucitron.lang.credit + '</a>';
  299. }
  300. html += ' </div>';
  301. html += ' </div>';
  302. html += '</div>';
  303. if (tarteaucitron.parameters.orientation === 'bottom') {
  304. orientation = 'Bottom';
  305. }
  306. if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
  307. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  308. html += '<div class="tarteaucitronAlertBigWrapper">';
  309. html += ' <span id="tarteaucitronDisclaimerAlert">';
  310. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  311. html += ' </span>';
  312. html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  313. html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.openPanel();">';
  314. html += ' ' + tarteaucitron.lang.personalize;
  315. html += ' </button>';
  316. if (tarteaucitron.parameters.privacyUrl !== "") {
  317. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  318. html += ' ' + tarteaucitron.lang.privacyUrl;
  319. html += ' </button>';
  320. }
  321. html += ' </span>';
  322. html += '</div>';
  323. html += '</div>';
  324. } else {
  325. html += '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  326. html += '<div class="tarteaucitronAlertBigWrapper">';
  327. html += ' <span id="tarteaucitronDisclaimerAlert">';
  328. if (tarteaucitron.parameters.highPrivacy) {
  329. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  330. } else {
  331. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  332. }
  333. html += ' </span>';
  334. html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  335. html += ' <button type="button" id="tarteaucitronPersonalize" onclick="tarteaucitron.userInterface.respondAll(true);">';
  336. html += ' &#10003; ' + tarteaucitron.lang.acceptAll;
  337. html += ' </button>';
  338. html += ' <button type="button" id="tarteaucitronCloseAlert" onclick="tarteaucitron.userInterface.openPanel();">';
  339. html += ' ' + tarteaucitron.lang.personalize;
  340. html += ' </button>';
  341. if (tarteaucitron.parameters.privacyUrl !== "") {
  342. html += ' <button type="button" id="tarteaucitronPrivacyUrl" onclick="document.location = tarteaucitron.parameters.privacyUrl">';
  343. html += ' ' + tarteaucitron.lang.privacyUrl;
  344. html += ' </button>';
  345. }
  346. html += ' </span>';
  347. html += '</div>';
  348. html += '</div>';
  349. html += '<div id="tarteaucitronPercentage"></div>';
  350. }
  351. if (tarteaucitron.parameters.showAlertSmall === true) {
  352. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  353. html += ' <button type="button" id="tarteaucitronManager" onclick="tarteaucitron.userInterface.openPanel();">';
  354. html += ' ' + tarteaucitron.lang.alertSmall;
  355. html += ' <span id="tarteaucitronDot">';
  356. html += ' <span id="tarteaucitronDotGreen"></span>';
  357. html += ' <span id="tarteaucitronDotYellow"></span>';
  358. html += ' <span id="tarteaucitronDotRed"></span>';
  359. html += ' </span>';
  360. if (tarteaucitron.parameters.cookieslist === true) {
  361. html += ' </button><!-- @whitespace';
  362. html += ' --><button type="button" id="tarteaucitronCookiesNumber" onclick="tarteaucitron.userInterface.toggleCookiesList();">0</button>';
  363. html += ' <div id="tarteaucitronCookiesListContainer">';
  364. html += ' <button type="button" id="tarteaucitronClosePanelCookie" onclick="tarteaucitron.userInterface.closePanel();">';
  365. html += ' ' + tarteaucitron.lang.close;
  366. html += ' </button>';
  367. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  368. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2" id="tarteaucitronCookiesNumberBis">0 cookie</span>';
  369. html += ' </div>';
  370. html += ' <div id="tarteaucitronCookiesList"></div>';
  371. html += ' </div>';
  372. } else {
  373. html += ' </div>';
  374. }
  375. html += '</div>';
  376. }
  377. tarteaucitron.addScript(tarteaucitron.cdn + 'advertising.js?v=' + tarteaucitron.version, '', function () {
  378. if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
  379. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  380. /*var wrapper = document.createElement('div');
  381. wrapper.id = "contentWrapper";
  382. while (document.body.firstChild)
  383. {
  384. wrapper.appendChild(document.body.firstChild);
  385. }
  386. // Append the wrapper to the body
  387. document.body.appendChild(wrapper);*/
  388. div.id = 'tarteaucitronRoot';
  389. body.appendChild(div, body);
  390. div.innerHTML = html;
  391. //ie compatibility
  392. var tacRootAvailableEvent;
  393. if(typeof(Event) === 'function') {
  394. tacRootAvailableEvent = new Event("tac.root_available");
  395. }else{
  396. tacRootAvailableEvent = document.createEvent('Event');
  397. tacRootAvailableEvent.initEvent("tac.root_available", true, true);
  398. }
  399. //end ie compatibility
  400. window.dispatchEvent(tacRootAvailableEvent);
  401. if (tarteaucitron.job !== undefined) {
  402. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  403. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  404. tarteaucitron.addService(tarteaucitron.job[index]);
  405. }
  406. } else {
  407. tarteaucitron.job = []
  408. }
  409. tarteaucitron.isAjax = true;
  410. tarteaucitron.job.push = function (id) {
  411. // ie <9 hack
  412. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  413. tarteaucitron.job.indexOf = function (obj, start) {
  414. var i,
  415. j = this.length;
  416. for (i = (start || 0); i < j; i += 1) {
  417. if (this[i] === obj) { return i; }
  418. }
  419. return -1;
  420. };
  421. }
  422. if (tarteaucitron.job.indexOf(id) === -1) {
  423. Array.prototype.push.call(this, id);
  424. }
  425. tarteaucitron.launch[id] = false;
  426. tarteaucitron.addService(id);
  427. };
  428. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  429. tarteaucitron.userInterface.openPanel();
  430. }
  431. tarteaucitron.cookie.number();
  432. setInterval(tarteaucitron.cookie.number, 60000);
  433. }
  434. }, tarteaucitron.parameters.adblocker);
  435. if (tarteaucitron.parameters.adblocker === true) {
  436. setTimeout(function () {
  437. if (tarteaucitronNoAdBlocker === false) {
  438. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '" style="display:block" role="alert" aria-live="polite">';
  439. html += ' <p id="tarteaucitronDisclaimerAlert">';
  440. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  441. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  442. html += ' </p>';
  443. html += ' <button type="button" id="tarteaucitronPersonalize" onclick="location.reload();">';
  444. html += ' ' + tarteaucitron.lang.reload;
  445. html += ' </button>';
  446. html += '</div>';
  447. html += '<div id="tarteaucitronPremium"></div>';
  448. // create wrapper container
  449. /*var wrapper = document.createElement('div');
  450. wrapper.id = "contentWrapper";
  451. while (document.body.firstChild)
  452. {
  453. wrapper.appendChild(document.body.firstChild);
  454. }
  455. // Append the wrapper to the body
  456. document.body.appendChild(wrapper);*/
  457. div.id = 'tarteaucitronRoot';
  458. body.appendChild(div, body);
  459. div.innerHTML = html;
  460. }
  461. }, 1500);
  462. }
  463. });
  464. });
  465. if(tarteaucitron.events.load) {
  466. tarteaucitron.events.load();
  467. }
  468. },
  469. "addService": function (serviceId) {
  470. "use strict";
  471. var html = '',
  472. s = tarteaucitron.services,
  473. service = s[serviceId],
  474. cookie = tarteaucitron.cookie.read(),
  475. hostname = document.location.hostname,
  476. hostRef = document.referrer.split('/')[2],
  477. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl) ? true : false,
  478. isAutostart = (!service.needConsent) ? true : false,
  479. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0) ? true : false,
  480. isDenied = (cookie.indexOf(service.key + '=false') >= 0) ? true : false,
  481. isAllowed = (cookie.indexOf(service.key + '=true') >= 0) ? true : false,
  482. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0) ? true : false,
  483. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1") ? true : false;
  484. if (tarteaucitron.added[service.key] !== true) {
  485. tarteaucitron.added[service.key] = true;
  486. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  487. html += ' <div class="tarteaucitronName">';
  488. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + '</span>';
  489. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  490. if (tarteaucitron.parameters.moreInfoLink == true) {
  491. var link = 'https://opt-out.ferank.eu/service/' + service.key + '/';
  492. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  493. link = service.readmoreLink;
  494. }
  495. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  496. link = tarteaucitron.parameters.readmoreLink;
  497. }
  498. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'">';
  499. html += ' ' + tarteaucitron.lang.more;
  500. html += ' </a>';
  501. html += ' - ';
  502. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '">';
  503. html += ' ' + tarteaucitron.lang.source;
  504. html += ' </a>';
  505. }
  506. html += ' </div>';
  507. html += ' <div class="tarteaucitronAsk">';
  508. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow" onclick="tarteaucitron.userInterface.respond(this, true);">';
  509. html += ' &#10003; ' + tarteaucitron.lang.allow;
  510. html += ' </button> ';
  511. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny" onclick="tarteaucitron.userInterface.respond(this, false);">';
  512. html += ' &#10007; ' + tarteaucitron.lang.deny;
  513. html += ' </button>';
  514. html += ' </div>';
  515. html += '</li>';
  516. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  517. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  518. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  519. }
  520. tarteaucitron.userInterface.order(service.type);
  521. }
  522. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  523. // allow by default for non EU
  524. if (isResponded === false && tarteaucitron.user.bypass === true) {
  525. isAllowed = true;
  526. tarteaucitron.cookie.create(service.key, true);
  527. }
  528. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  529. if (!isAllowed) {
  530. tarteaucitron.cookie.create(service.key, true);
  531. }
  532. if (tarteaucitron.launch[service.key] !== true) {
  533. tarteaucitron.launch[service.key] = true;
  534. service.js();
  535. }
  536. tarteaucitron.state[service.key] = true;
  537. tarteaucitron.userInterface.color(service.key, true);
  538. } else if (isDenied) {
  539. if (typeof service.fallback === 'function') {
  540. service.fallback();
  541. }
  542. tarteaucitron.state[service.key] = false;
  543. tarteaucitron.userInterface.color(service.key, false);
  544. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  545. tarteaucitron.cookie.create(service.key, 'false');
  546. if (typeof service.fallback === 'function') {
  547. service.fallback();
  548. }
  549. tarteaucitron.state[service.key] = false;
  550. tarteaucitron.userInterface.color(service.key, false);
  551. } else if (!isResponded) {
  552. tarteaucitron.cookie.create(service.key, 'wait');
  553. if (typeof service.fallback === 'function') {
  554. service.fallback();
  555. }
  556. tarteaucitron.userInterface.color(service.key, 'wait');
  557. tarteaucitron.userInterface.openAlert();
  558. }
  559. tarteaucitron.cookie.checkCount(service.key);
  560. },
  561. "cleanArray": function cleanArray(arr) {
  562. "use strict";
  563. var i,
  564. len = arr.length,
  565. out = [],
  566. obj = {},
  567. s = tarteaucitron.services;
  568. for (i = 0; i < len; i += 1) {
  569. if (!obj[arr[i]]) {
  570. obj[arr[i]] = {};
  571. if (tarteaucitron.services[arr[i]] !== undefined) {
  572. out.push(arr[i]);
  573. }
  574. }
  575. }
  576. out = out.sort(function (a, b) {
  577. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  578. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  579. return 0;
  580. });
  581. return out;
  582. },
  583. "userInterface": {
  584. "css": function (id, property, value) {
  585. "use strict";
  586. if (document.getElementById(id) !== null) {
  587. document.getElementById(id).style[property] = value;
  588. }
  589. },
  590. "addClass": function (id, className) {
  591. "use strict";
  592. if (document.getElementById(id) !== null) {
  593. document.getElementById(id).classList.add(className);
  594. }
  595. },
  596. "removeClass": function (id, className) {
  597. "use strict";
  598. if (document.getElementById(id) !== null) {
  599. document.getElementById(id).classList.remove(className);
  600. }
  601. },
  602. "respondAll": function (status) {
  603. "use strict";
  604. var s = tarteaucitron.services,
  605. service,
  606. key,
  607. index = 0;
  608. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  609. service = s[tarteaucitron.job[index]];
  610. key = service.key;
  611. if (tarteaucitron.state[key] !== status) {
  612. if (status === false && tarteaucitron.launch[key] === true) {
  613. tarteaucitron.reloadThePage = true;
  614. }
  615. if (tarteaucitron.launch[key] !== true && status === true) {
  616. tarteaucitron.pro('!' + key + '=engage');
  617. tarteaucitron.launch[key] = true;
  618. tarteaucitron.services[key].js();
  619. }
  620. tarteaucitron.state[key] = status;
  621. tarteaucitron.cookie.create(key, status);
  622. tarteaucitron.userInterface.color(key, status);
  623. }
  624. }
  625. },
  626. "respond": function (el, status) {
  627. "use strict";
  628. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  629. // return if same state
  630. if (tarteaucitron.state[key] === status) {
  631. return;
  632. }
  633. if (status === false && tarteaucitron.launch[key] === true) {
  634. tarteaucitron.reloadThePage = true;
  635. }
  636. // if not already launched... launch the service
  637. if (status === true) {
  638. if (tarteaucitron.launch[key] !== true) {
  639. tarteaucitron.pro('!' + key + '=engage');
  640. tarteaucitron.launch[key] = true;
  641. tarteaucitron.services[key].js();
  642. }
  643. }
  644. tarteaucitron.state[key] = status;
  645. tarteaucitron.cookie.create(key, status);
  646. tarteaucitron.userInterface.color(key, status);
  647. },
  648. "color": function (key, status) {
  649. "use strict";
  650. var c = 'tarteaucitron',
  651. nbDenied = 0,
  652. nbPending = 0,
  653. nbAllowed = 0,
  654. sum = tarteaucitron.job.length,
  655. index;
  656. if (status === true) {
  657. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  658. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  659. } else if (status === false) {
  660. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  661. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  662. }
  663. // check if all services are allowed
  664. for (index = 0; index < sum; index += 1) {
  665. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  666. nbDenied += 1;
  667. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  668. nbPending += 1;
  669. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  670. nbAllowed += 1;
  671. }
  672. }
  673. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  674. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  675. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  676. if (nbDenied === 0 && nbPending === 0) {
  677. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  678. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  679. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  680. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  681. } else if (nbAllowed === 0 && nbPending === 0) {
  682. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  683. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  684. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  685. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  686. } else {
  687. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  688. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  689. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  690. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  691. }
  692. // close the alert if all service have been reviewed
  693. if (nbPending === 0) {
  694. tarteaucitron.userInterface.closeAlert();
  695. }
  696. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  697. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  698. }
  699. if (status === true) {
  700. if (document.getElementById('tacCL' + key) !== null) {
  701. document.getElementById('tacCL' + key).innerHTML = '...';
  702. }
  703. setTimeout(function () {
  704. tarteaucitron.cookie.checkCount(key);
  705. }, 2500);
  706. } else {
  707. tarteaucitron.cookie.checkCount(key);
  708. }
  709. },
  710. "openPanel": function () {
  711. "use strict";
  712. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  713. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  714. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  715. document.getElementById('tarteaucitronClosePanel').focus();
  716. //document.getElementById('contentWrapper').setAttribute("aria-hidden", "true");
  717. document.getElementsByTagName('body')[0].classList.add('modal-open');
  718. tarteaucitron.userInterface.focusTrap();
  719. tarteaucitron.userInterface.jsSizing('main');
  720. //ie compatibility
  721. var tacOpenPanelEvent;
  722. if(typeof(Event) === 'function') {
  723. tacOpenPanelEvent = new Event("tac.open_panel");
  724. }else{
  725. tacOpenPanelEvent = document.createEvent('Event');
  726. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  727. }
  728. //end ie compatibility
  729. window.dispatchEvent(tacOpenPanelEvent);
  730. },
  731. "closePanel": function () {
  732. "use strict";
  733. if (document.location.hash === tarteaucitron.hashtag) {
  734. if (window.history) {
  735. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  736. } else {
  737. document.location.hash = '';
  738. }
  739. }
  740. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  741. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  742. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  743. elem.style.display = 'none';
  744. }, true);
  745. if (tarteaucitron.reloadThePage === true) {
  746. window.location.reload();
  747. } else {
  748. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  749. }
  750. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  751. document.getElementById('tarteaucitronCloseAlert').focus();
  752. }
  753. //document.getElementById('contentWrapper').setAttribute("aria-hidden", "false");
  754. document.getElementsByTagName('body')[0].classList.remove('modal-open');
  755. //ie compatibility
  756. var tacClosePanelEvent;
  757. if(typeof(Event) === 'function') {
  758. tacClosePanelEvent = new Event("tac.close_panel");
  759. }else{
  760. tacClosePanelEvent = document.createEvent('Event');
  761. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  762. }
  763. //end ie compatibility
  764. window.dispatchEvent(tacClosePanelEvent);
  765. },
  766. "focusTrap": function() {
  767. "use strict";
  768. var focusableEls,
  769. firstFocusableEl,
  770. lastFocusableEl,
  771. filtered;
  772. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  773. filtered = [];
  774. // get only visible items
  775. for (var i = 0, max = focusableEls.length; i < max; i++) {
  776. if (focusableEls[i].offsetHeight > 0) {
  777. filtered.push(focusableEls[i]);
  778. }
  779. }
  780. firstFocusableEl = filtered[0];
  781. lastFocusableEl = filtered[filtered.length - 1];
  782. //loop focus inside tarteaucitron
  783. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  784. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  785. if ( evt.shiftKey ) /* shift + tab */ {
  786. if (document.activeElement === firstFocusableEl) {
  787. lastFocusableEl.focus();
  788. evt.preventDefault();
  789. }
  790. } else /* tab */ {
  791. if (document.activeElement === lastFocusableEl) {
  792. firstFocusableEl.focus();
  793. evt.preventDefault();
  794. }
  795. }
  796. }
  797. })
  798. },
  799. "openAlert": function () {
  800. "use strict";
  801. var c = 'tarteaucitron';
  802. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  803. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  804. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  805. //ie compatibility
  806. var tacOpenAlertEvent;
  807. if(typeof(Event) === 'function') {
  808. tacOpenAlertEvent = new Event("tac.open_alert");
  809. }else{
  810. tacOpenAlertEvent = document.createEvent('Event');
  811. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  812. }
  813. //end ie compatibility
  814. window.dispatchEvent(tacOpenAlertEvent);
  815. },
  816. "closeAlert": function () {
  817. "use strict";
  818. var c = 'tarteaucitron';
  819. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  820. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  821. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  822. tarteaucitron.userInterface.jsSizing('box');
  823. //ie compatibility
  824. var tacCloseAlertEvent;
  825. if(typeof(Event) === 'function') {
  826. tacCloseAlertEvent = new Event("tac.close_alert");
  827. }else{
  828. tacCloseAlertEvent = document.createEvent('Event');
  829. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  830. }
  831. //end ie compatibility
  832. window.dispatchEvent(tacCloseAlertEvent);
  833. },
  834. "toggleCookiesList": function () {
  835. "use strict";
  836. var div = document.getElementById('tarteaucitronCookiesListContainer');
  837. if (div === null) {
  838. return;
  839. }
  840. if (div.style.display !== 'block') {
  841. tarteaucitron.cookie.number();
  842. div.style.display = 'block';
  843. tarteaucitron.userInterface.jsSizing('cookie');
  844. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  845. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  846. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  847. elem.style.display = 'none';
  848. }, true);
  849. } else {
  850. div.style.display = 'none';
  851. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  852. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  853. }
  854. },
  855. "toggle": function (id, closeClass) {
  856. "use strict";
  857. var div = document.getElementById(id);
  858. if (div === null) {
  859. return;
  860. }
  861. if (closeClass !== undefined) {
  862. tarteaucitron.fallback([closeClass], function (elem) {
  863. if (elem.id !== id) {
  864. elem.style.display = 'none';
  865. }
  866. }, true);
  867. }
  868. if (div.style.display !== 'block') {
  869. div.style.display = 'block';
  870. } else {
  871. div.style.display = 'none';
  872. }
  873. },
  874. "order": function (id) {
  875. "use strict";
  876. var main = document.getElementById('tarteaucitronServices_' + id),
  877. allDivs,
  878. store = [],
  879. i;
  880. if (main === null) {
  881. return;
  882. }
  883. allDivs = main.childNodes;
  884. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  885. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  886. //var mainChildren = Array.from(main.children);
  887. //mainChildren.sort(function (a, b) {
  888. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  889. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  890. return 0;
  891. }).forEach(function (element) {
  892. main.appendChild(element);
  893. });
  894. }
  895. },
  896. "jsSizing": function (type) {
  897. "use strict";
  898. var scrollbarMarginRight = 10,
  899. scrollbarWidthParent,
  900. scrollbarWidthChild,
  901. servicesHeight,
  902. e = window,
  903. a = 'inner',
  904. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  905. mainTop,
  906. mainHeight,
  907. closeButtonHeight,
  908. headerHeight,
  909. cookiesListHeight,
  910. cookiesCloseHeight,
  911. cookiesTitleHeight,
  912. paddingBox,
  913. alertSmallHeight,
  914. cookiesNumberHeight;
  915. if (type === 'box') {
  916. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  917. // reset
  918. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  919. // calculate
  920. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  921. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  922. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  923. // apply
  924. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  925. }
  926. } else if (type === 'main') {
  927. // get the real window width for media query
  928. if (window.innerWidth === undefined) {
  929. a = 'client';
  930. e = document.documentElement || document.body;
  931. }
  932. // height of the services list container
  933. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  934. // reset
  935. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  936. // calculate
  937. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  938. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  939. // apply
  940. servicesHeight = (mainHeight - closeButtonHeight + 2);
  941. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  942. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  943. }
  944. // align the main allow/deny button depending on scrollbar width
  945. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  946. // media query
  947. if (e[a + 'Width'] <= 479) {
  948. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  949. } else if (e[a + 'Width'] <= 767) {
  950. scrollbarMarginRight = 12;
  951. }
  952. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  953. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  954. tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  955. }
  956. // center the main panel
  957. if (document.getElementById('tarteaucitron') !== null) {
  958. // media query
  959. if (e[a + 'Width'] <= 767) {
  960. mainTop = 0;
  961. } else {
  962. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  963. }
  964. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  965. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  966. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  967. }
  968. }
  969. // correct
  970. if (mainTop < 0) {
  971. mainTop = 0;
  972. }
  973. // apply
  974. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  975. }
  976. } else if (type === 'cookie') {
  977. // put cookies list at bottom
  978. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  979. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  980. }
  981. // height of cookies list
  982. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  983. // reset
  984. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  985. // calculate
  986. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  987. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  988. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  989. // apply
  990. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  991. }
  992. }
  993. }
  994. },
  995. "cookie": {
  996. "owner": {},
  997. "create": function (key, status) {
  998. "use strict";
  999. if (tarteaucitronForceExpire !== '') {
  1000. // The number of day(s)/hour(s) can't be higher than 1 year
  1001. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1002. if (tarteaucitronExpireInDay) {
  1003. // Multiplication to tranform the number of days to milliseconds
  1004. timeExpire = tarteaucitronForceExpire * 86400000;
  1005. } else {
  1006. // Multiplication to tranform the number of hours to milliseconds
  1007. timeExpire = tarteaucitronForceExpire * 3600000;
  1008. }
  1009. }
  1010. }
  1011. var d = new Date(),
  1012. time = d.getTime(),
  1013. expireTime = time + timeExpire, // 365 days
  1014. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1015. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1016. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1017. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? 'domain=' + tarteaucitron.parameters.cookieDomain + ';' : '';
  1018. d.setTime(expireTime);
  1019. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/;' + domain;
  1020. },
  1021. "read": function () {
  1022. "use strict";
  1023. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1024. ca = document.cookie.split(';'),
  1025. i,
  1026. c;
  1027. for (i = 0; i < ca.length; i += 1) {
  1028. c = ca[i];
  1029. while (c.charAt(0) === ' ') {
  1030. c = c.substring(1, c.length);
  1031. }
  1032. if (c.indexOf(nameEQ) === 0) {
  1033. return c.substring(nameEQ.length, c.length);
  1034. }
  1035. }
  1036. return '';
  1037. },
  1038. "purge": function (arr) {
  1039. "use strict";
  1040. var i;
  1041. for (i = 0; i < arr.length; i += 1) {
  1042. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1043. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1044. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1045. }
  1046. },
  1047. "checkCount": function (key) {
  1048. "use strict";
  1049. var arr = tarteaucitron.services[key].cookies,
  1050. nb = arr.length,
  1051. nbCurrent = 0,
  1052. html = '',
  1053. i,
  1054. status = document.cookie.indexOf(key + '=true');
  1055. if (status >= 0 && nb === 0) {
  1056. html += tarteaucitron.lang.useNoCookie;
  1057. } else if (status >= 0) {
  1058. for (i = 0; i < nb; i += 1) {
  1059. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1060. nbCurrent += 1;
  1061. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1062. tarteaucitron.cookie.owner[arr[i]] = [];
  1063. }
  1064. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1065. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1066. }
  1067. }
  1068. }
  1069. if (nbCurrent > 0) {
  1070. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1071. if (nbCurrent > 1) {
  1072. html += 's';
  1073. }
  1074. html += '.';
  1075. } else {
  1076. html += tarteaucitron.lang.useNoCookie;
  1077. }
  1078. } else if (nb === 0) {
  1079. html = tarteaucitron.lang.noCookie;
  1080. } else {
  1081. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1082. if (nb > 1) {
  1083. html += 's';
  1084. }
  1085. html += '.';
  1086. }
  1087. if (document.getElementById('tacCL' + key) !== null) {
  1088. document.getElementById('tacCL' + key).innerHTML = html;
  1089. }
  1090. },
  1091. "crossIndexOf": function (arr, match) {
  1092. "use strict";
  1093. var i;
  1094. for (i = 0; i < arr.length; i += 1) {
  1095. if (arr[i] === match) {
  1096. return true;
  1097. }
  1098. }
  1099. return false;
  1100. },
  1101. "number": function () {
  1102. "use strict";
  1103. var cookies = document.cookie.split(';'),
  1104. nb = (document.cookie !== '') ? cookies.length : 0,
  1105. html = '',
  1106. i,
  1107. name,
  1108. namea,
  1109. nameb,
  1110. c,
  1111. d,
  1112. s = (nb > 1) ? 's' : '',
  1113. savedname,
  1114. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1115. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1116. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1117. cookies = cookies.sort(function (a, b) {
  1118. namea = a.split('=', 1).toString().replace(/ /g, '');
  1119. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1120. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1121. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1122. if (c + a > d + b) { return 1; }
  1123. if (c + a < d + b) { return -1; }
  1124. return 0;
  1125. });
  1126. if (document.cookie !== '') {
  1127. for (i = 0; i < nb; i += 1) {
  1128. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1129. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1130. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1131. html += '<div class="tarteaucitronHidden">';
  1132. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1133. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1134. html += ' </span>';
  1135. html += '</div><ul class="cookie-list">';
  1136. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1137. savedname = host;
  1138. html += '<div class="tarteaucitronHidden">';
  1139. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1140. html += ' ' + host;
  1141. html += ' </span>';
  1142. html += '</div><ul class="cookie-list">';
  1143. }
  1144. html += '<li class="tarteaucitronCookiesListMain">';
  1145. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" onclick="tarteaucitron.cookie.purge([\'' + cookies[i].split('=', 1) + '\']);tarteaucitron.cookie.number();tarteaucitron.userInterface.jsSizing(\'cookie\');return false"><strong>&times;</strong></button> <strong>' + name + '</strong>';
  1146. html += ' </div>';
  1147. html += ' <div class="tarteaucitronCookiesListRight">' + cookies[i].split('=').slice(1).join('=') + '</div>';
  1148. html += '</li>';
  1149. }
  1150. html += '</ul>';
  1151. } else {
  1152. html += '<div class="tarteaucitronCookiesListMain">';
  1153. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1154. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1155. html += '</div>';
  1156. }
  1157. html += '<div class="tarteaucitronHidden" style="height:20px;display:block"></div>';
  1158. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1159. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1160. }
  1161. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1162. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1163. }
  1164. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1165. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1166. }
  1167. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1168. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1169. }
  1170. }
  1171. },
  1172. "getLanguage": function () {
  1173. "use strict";
  1174. var availableLanguages = 'cs,en,fr,es,it,de,nl,pt,pl,ru,el',
  1175. defaultLanguage = 'en';
  1176. if (tarteaucitronForceLanguage !== '') {
  1177. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1178. return tarteaucitronForceLanguage;
  1179. }
  1180. }
  1181. if (!navigator) { return 'en'; }
  1182. var lang = navigator.language || navigator.browserLanguage ||
  1183. navigator.systemLanguage || navigator.userLang || null,
  1184. userLanguage = lang ? lang.substr(0, 2) : null;
  1185. if (availableLanguages.indexOf(userLanguage) === -1) {
  1186. return defaultLanguage;
  1187. }
  1188. return userLanguage;
  1189. },
  1190. "getLocale": function () {
  1191. "use strict";
  1192. if (!navigator) { return 'en_US'; }
  1193. var lang = navigator.language || navigator.browserLanguage ||
  1194. navigator.systemLanguage || navigator.userLang || null,
  1195. userLanguage = lang ? lang.substr(0, 2) : null;
  1196. if (userLanguage === 'fr') {
  1197. return 'fr_FR';
  1198. } else if (userLanguage === 'en') {
  1199. return 'en_US';
  1200. } else if (userLanguage === 'de') {
  1201. return 'de_DE';
  1202. } else if (userLanguage === 'es') {
  1203. return 'es_ES';
  1204. } else if (userLanguage === 'it') {
  1205. return 'it_IT';
  1206. } else if (userLanguage === 'pt') {
  1207. return 'pt_PT';
  1208. } else if (userLanguage === 'nl') {
  1209. return 'nl_NL';
  1210. } else if (userLanguage === 'el') {
  1211. return 'el_EL';
  1212. } else {
  1213. return 'en_US';
  1214. }
  1215. },
  1216. "addScript": function (url, id, callback, execute, attrName, attrVal) {
  1217. "use strict";
  1218. var script,
  1219. done = false;
  1220. if (execute === false) {
  1221. if (typeof callback === 'function') {
  1222. callback();
  1223. }
  1224. } else {
  1225. script = document.createElement('script');
  1226. script.type = 'text/javascript';
  1227. script.id = (id !== undefined) ? id : '';
  1228. script.async = true;
  1229. script.src = url;
  1230. if (attrName !== undefined && attrVal !== undefined) {
  1231. script.setAttribute(attrName, attrVal);
  1232. }
  1233. if (typeof callback === 'function') {
  1234. script.onreadystatechange = script.onload = function () {
  1235. var state = script.readyState;
  1236. if (!done && (!state || /loaded|complete/.test(state))) {
  1237. done = true;
  1238. callback();
  1239. }
  1240. };
  1241. }
  1242. document.getElementsByTagName('head')[0].appendChild(script);
  1243. }
  1244. },
  1245. "makeAsync": {
  1246. "antiGhost": 0,
  1247. "buffer": '',
  1248. "init": function (url, id) {
  1249. "use strict";
  1250. var savedWrite = document.write,
  1251. savedWriteln = document.writeln;
  1252. document.write = function (content) {
  1253. tarteaucitron.makeAsync.buffer += content;
  1254. };
  1255. document.writeln = function (content) {
  1256. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1257. };
  1258. setTimeout(function () {
  1259. document.write = savedWrite;
  1260. document.writeln = savedWriteln;
  1261. }, 20000);
  1262. tarteaucitron.makeAsync.getAndParse(url, id);
  1263. },
  1264. "getAndParse": function (url, id) {
  1265. "use strict";
  1266. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1267. tarteaucitron.makeAsync.antiGhost = 0;
  1268. return;
  1269. }
  1270. tarteaucitron.makeAsync.antiGhost += 1;
  1271. tarteaucitron.addScript(url, '', function () {
  1272. if (document.getElementById(id) !== null) {
  1273. document.getElementById(id).innerHTML += "<span style='display:none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1274. tarteaucitron.makeAsync.buffer = '';
  1275. tarteaucitron.makeAsync.execJS(id);
  1276. }
  1277. });
  1278. },
  1279. "execJS": function (id) {
  1280. /* not strict because third party scripts may have errors */
  1281. var i,
  1282. scripts,
  1283. childId,
  1284. type;
  1285. if (document.getElementById(id) === null) {
  1286. return;
  1287. }
  1288. scripts = document.getElementById(id).getElementsByTagName('script');
  1289. for (i = 0; i < scripts.length; i += 1) {
  1290. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1291. if (type === '') {
  1292. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1293. }
  1294. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1295. childId = id + Math.floor(Math.random() * 99999999999);
  1296. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1297. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1298. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1299. eval(scripts[i].innerHTML);
  1300. }
  1301. }
  1302. }
  1303. },
  1304. "fallback": function (matchClass, content, noInner) {
  1305. "use strict";
  1306. var elems = document.getElementsByTagName('*'),
  1307. i,
  1308. index = 0;
  1309. for (i in elems) {
  1310. if (elems[i] !== undefined) {
  1311. for (index = 0; index < matchClass.length; index += 1) {
  1312. if ((' ' + elems[i].className + ' ')
  1313. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1314. if (typeof content === 'function') {
  1315. if (noInner === true) {
  1316. content(elems[i]);
  1317. } else {
  1318. elems[i].innerHTML = content(elems[i]);
  1319. }
  1320. } else {
  1321. elems[i].innerHTML = content;
  1322. }
  1323. }
  1324. }
  1325. }
  1326. }
  1327. },
  1328. "engage": function (id) {
  1329. "use strict";
  1330. var html = '',
  1331. r = Math.floor(Math.random() * 100000),
  1332. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1333. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1334. engage = tarteaucitron.lang['engage-' + id];
  1335. }
  1336. html += '<div class="tac_activate">';
  1337. html += ' <div class="tac_float">';
  1338. html += ' ' + engage;
  1339. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '" onclick="tarteaucitron.userInterface.respond(this, true);">';
  1340. html += ' &#10003; ' + tarteaucitron.lang.allow;
  1341. html += ' </button>';
  1342. html += ' </div>';
  1343. html += '</div>';
  1344. return html;
  1345. },
  1346. "extend": function (a, b) {
  1347. "use strict";
  1348. var prop;
  1349. for (prop in b) {
  1350. if (b.hasOwnProperty(prop)) {
  1351. a[prop] = b[prop];
  1352. }
  1353. }
  1354. },
  1355. "proTemp": '',
  1356. "proTimer": function () {
  1357. "use strict";
  1358. setTimeout(tarteaucitron.proPing, 500);
  1359. },
  1360. "pro": function (list) {
  1361. "use strict";
  1362. tarteaucitron.proTemp += list;
  1363. clearTimeout(tarteaucitron.proTimer);
  1364. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1365. },
  1366. "proPing": function () {
  1367. "use strict";
  1368. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1369. var div = document.getElementById('tarteaucitronPremium'),
  1370. timestamp = new Date().getTime(),
  1371. url = 'https://opt-out.ferank.eu/log/?';
  1372. if (div === null) {
  1373. return;
  1374. }
  1375. url += 'account=' + tarteaucitron.uuid + '&';
  1376. url += 'domain=' + tarteaucitron.domain + '&';
  1377. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1378. url += '_time=' + timestamp;
  1379. div.innerHTML = '<img src="' + url + '" style="display:none" />';
  1380. tarteaucitron.proTemp = '';
  1381. }
  1382. tarteaucitron.cookie.number();
  1383. },
  1384. "AddOrUpdate" : function(source, custom){
  1385. /**
  1386. Utility function to Add or update the fields of obj1 with the ones in obj2
  1387. */
  1388. for(key in custom){
  1389. if(custom[key] instanceof Object){
  1390. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1391. }else{
  1392. source[key] = custom[key];
  1393. }
  1394. }
  1395. return source;
  1396. },
  1397. "getElemWidth": function(elem) {
  1398. return elem.getAttribute('width') || elem.clientWidth;
  1399. },
  1400. "getElemHeight": function(elem) {
  1401. return elem.getAttribute('height') || elem.clientHeight;
  1402. }
  1403. };