tarteaucitron.js 69 KB

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