tarteaucitron.js 71 KB

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