tarteaucitron.js 70 KB

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