tarteaucitron.js 73 KB

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