tarteaucitron.js 73 KB

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