tarteaucitron.js 73 KB

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