tarteaucitron.js 99 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979
  1. /*jslint browser: true, evil: true */
  2. var scripts = document.getElementsByTagName('script'),
  3. path = scripts[scripts.length - 1].src.split('?')[0],
  4. tarteaucitronForceCDN = (tarteaucitronForceCDN === undefined) ? '' : tarteaucitronForceCDN,
  5. cdn = (tarteaucitronForceCDN === '') ? path.split('/').slice(0, -1).join('/') + '/' : tarteaucitronForceCDN,
  6. alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
  7. tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
  8. tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
  9. tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
  10. // tarteaucitronExpireInDay: true for day(s) value - false for hour(s) value
  11. tarteaucitronExpireInDay = (tarteaucitronExpireInDay === undefined || typeof tarteaucitronExpireInDay !== "boolean") ? true : tarteaucitronExpireInDay,
  12. timeExpire = 31536000000,
  13. tarteaucitronProLoadServices,
  14. tarteaucitronNoAdBlocker = false;
  15. var tarteaucitron = {
  16. "version": 20210422,
  17. "cdn": cdn,
  18. "user": {},
  19. "lang": {},
  20. "services": {},
  21. "added": [],
  22. "idprocessed": [],
  23. "state": [],
  24. "launch": [],
  25. "parameters": {},
  26. "isAjax": false,
  27. "reloadThePage": false,
  28. "events": {
  29. "init": function () {},
  30. "load": function () {},
  31. },
  32. "init": function (params) {
  33. "use strict";
  34. var origOpen;
  35. tarteaucitron.parameters = params;
  36. if (alreadyLaunch === 0) {
  37. alreadyLaunch = 1;
  38. if (window.addEventListener) {
  39. window.addEventListener("load", function () {
  40. tarteaucitron.initEvents.loadEvent(false);
  41. }, false);
  42. window.addEventListener("scroll", function () {
  43. tarteaucitron.initEvents.scrollEvent();
  44. }, false);
  45. window.addEventListener("keydown", function (evt) {
  46. tarteaucitron.initEvents.keydownEvent(false, evt);
  47. }, false);
  48. window.addEventListener("hashchange", function () {
  49. tarteaucitron.initEvents.hashchangeEvent();
  50. }, false);
  51. window.addEventListener("resize", function () {
  52. tarteaucitron.initEvents.resizeEvent();
  53. }, false);
  54. } else {
  55. window.attachEvent("onload", function () {
  56. tarteaucitron.initEvents.loadEvent(true);
  57. });
  58. window.attachEvent("onscroll", function () {
  59. tarteaucitron.initEvents.scrollEvent();
  60. });
  61. window.attachEvent("onkeydown", function (evt) {
  62. tarteaucitron.initEvents.keydownEvent(true, evt);
  63. });
  64. window.attachEvent("onhashchange", function () {
  65. tarteaucitron.initEvents.hashchangeEvent();
  66. });
  67. window.attachEvent("onresize", function () {
  68. tarteaucitron.initEvents.resizeEvent();
  69. });
  70. }
  71. if (typeof XMLHttpRequest !== 'undefined') {
  72. origOpen = XMLHttpRequest.prototype.open;
  73. XMLHttpRequest.prototype.open = function () {
  74. if (window.addEventListener) {
  75. this.addEventListener("load", function () {
  76. if (typeof tarteaucitronProLoadServices === 'function') {
  77. tarteaucitronProLoadServices();
  78. }
  79. }, false);
  80. } else if (typeof this.attachEvent !== 'undefined') {
  81. this.attachEvent("onload", function () {
  82. if (typeof tarteaucitronProLoadServices === 'function') {
  83. tarteaucitronProLoadServices();
  84. }
  85. });
  86. } else {
  87. if (typeof tarteaucitronProLoadServices === 'function') {
  88. setTimeout(tarteaucitronProLoadServices, 1000);
  89. }
  90. }
  91. try {
  92. origOpen.apply(this, arguments);
  93. } catch (err) {}
  94. };
  95. }
  96. }
  97. if(tarteaucitron.events.init) {
  98. tarteaucitron.events.init();
  99. }
  100. },
  101. "initEvents": {
  102. "loadEvent": function (isOldBrowser) {
  103. tarteaucitron.load();
  104. tarteaucitron.fallback(['tarteaucitronOpenPanel'], function (elem) {
  105. if (isOldBrowser) {
  106. elem.attachEvent("onclick", function (event) {
  107. tarteaucitron.userInterface.openPanel();
  108. event.preventDefault();
  109. });
  110. } else {
  111. elem.addEventListener("click", function (event) {
  112. tarteaucitron.userInterface.openPanel();
  113. event.preventDefault();
  114. }, false);
  115. }
  116. }, true);
  117. },
  118. "keydownEvent": function (isOldBrowser, evt) {
  119. if (evt.keyCode === 27) {
  120. tarteaucitron.userInterface.closePanel();
  121. }
  122. if (isOldBrowser) {
  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. },
  138. "hashchangeEvent": function () {
  139. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  140. tarteaucitron.userInterface.openPanel();
  141. }
  142. },
  143. "resizeEvent": function () {
  144. var tacElem = document.getElementById('tarteaucitron');
  145. var tacCookieContainer = document.getElementById('tarteaucitronCookiesListContainer');
  146. if (tacElem && tacElem.style.display === 'block') {
  147. tarteaucitron.userInterface.jsSizing('main');
  148. }
  149. if (tacCookieContainer && tacCookieContainer.style.display === 'block') {
  150. tarteaucitron.userInterface.jsSizing('cookie');
  151. }
  152. },
  153. "scrollEvent": function () {
  154. var scrollPos = window.pageYOffset || document.documentElement.scrollTop;
  155. var heightPosition;
  156. var tacPercentage = document.getElementById('tarteaucitronPercentage');
  157. var tacAlertBig = document.getElementById('tarteaucitronAlertBig');
  158. if (tacAlertBig && !tarteaucitron.highPrivacy) {
  159. if (tacAlertBig.style.display === 'block') {
  160. heightPosition = tacAlertBig.offsetHeight + 'px';
  161. if (scrollPos > (screen.height * 2)) {
  162. tarteaucitron.userInterface.respondAll(true);
  163. } else if (scrollPos > (screen.height / 2)) {
  164. document.getElementById('tarteaucitronDisclaimerAlert').innerHTML = '<strong>' + tarteaucitron.lang.alertBigScroll + '</strong> ' + tarteaucitron.lang.alertBig;
  165. }
  166. if (tacPercentage) {
  167. if (tarteaucitron.orientation === 'top') {
  168. tacPercentage.style.top = heightPosition;
  169. } else {
  170. tacPercentage.style.bottom = heightPosition;
  171. }
  172. tacPercentage.style.width = ((100 / (screen.height * 2)) * scrollPos) + '%';
  173. }
  174. }
  175. }
  176. },
  177. },
  178. "load": function () {
  179. "use strict";
  180. var cdn = tarteaucitron.cdn,
  181. language = tarteaucitron.getLanguage(),
  182. useJSDelivrMinifiedJS = (cdn.indexOf('cdn.jsdelivr.net') >= 0),
  183. pathToLang = cdn + 'lang/tarteaucitron.' + language + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version,
  184. pathToServices = cdn + 'tarteaucitron.services' + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version,
  185. linkElement = document.createElement('link'),
  186. defaults = {
  187. "adblocker": false,
  188. "hashtag": '#tarteaucitron',
  189. "cookieName": 'tarteaucitron',
  190. "highPrivacy": true,
  191. "orientation": "middle",
  192. "bodyPosition": "bottom",
  193. "removeCredit": false,
  194. "showAlertSmall": false,
  195. "showIcon": true,
  196. "iconPosition": "BottomRight",
  197. "cookieslist": false,
  198. "handleBrowserDNTRequest": false,
  199. "DenyAllCta": true,
  200. "AcceptAllCta" : true,
  201. "moreInfoLink": true,
  202. "privacyUrl": "",
  203. "useExternalCss": false,
  204. "useExternalJs": false,
  205. "mandatory": true,
  206. "closePopup": false,
  207. "groupServices": false
  208. },
  209. params = tarteaucitron.parameters;
  210. // Don't show the middle bar if we are on the privacy policy or more page
  211. if (((tarteaucitron.parameters.readmoreLink !== undefined && window.location.href == tarteaucitron.parameters.readmoreLink) || window.location.href == tarteaucitron.parameters.privacyUrl) && tarteaucitron.parameters.orientation == "middle") {
  212. tarteaucitron.parameters.orientation = "bottom";
  213. }
  214. // Step -1
  215. if (typeof tarteaucitronCustomPremium !== 'undefined') {
  216. tarteaucitronCustomPremium();
  217. }
  218. // Step 0: get params
  219. if (params !== undefined) {
  220. for (var k in defaults) {
  221. if(!tarteaucitron.parameters.hasOwnProperty(k)) {
  222. tarteaucitron.parameters[k] = defaults[k];
  223. }
  224. }
  225. }
  226. // global
  227. tarteaucitron.orientation = tarteaucitron.parameters.orientation;
  228. tarteaucitron.hashtag = tarteaucitron.parameters.hashtag;
  229. tarteaucitron.highPrivacy = tarteaucitron.parameters.highPrivacy;
  230. tarteaucitron.handleBrowserDNTRequest = tarteaucitron.parameters.handleBrowserDNTRequest;
  231. // Step 1: load css
  232. if ( !tarteaucitron.parameters.useExternalCss ) {
  233. linkElement.rel = 'stylesheet';
  234. linkElement.type = 'text/css';
  235. linkElement.href = cdn + 'css/tarteaucitron' + (useJSDelivrMinifiedJS ? '.min' : '') + '.css?v=' + tarteaucitron.version;
  236. document.getElementsByTagName('head')[0].appendChild(linkElement);
  237. }
  238. // Step 2: load language and services
  239. tarteaucitron.addInternalScript(pathToLang, '', function () {
  240. if(tarteaucitronCustomText !== ''){
  241. tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
  242. }
  243. tarteaucitron.addInternalScript(pathToServices, '', function () {
  244. // css for the middle bar TODO: add it on the css file
  245. if (tarteaucitron.orientation === 'middle') {
  246. var customThemeMiddle = document.createElement('style'),
  247. cssRuleMiddle = 'div#tarteaucitronRoot.tarteaucitronBeforeVisible:before {content: \'\';position: fixed;width: 100%;height: 100%;background: white;top: 0;left: 0;z-index: 999;opacity: 0.5;}div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 35px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {width: 60%;min-width: 285px;height: auto;margin: auto;left: 50%;top: 50%;transform: translate(-50%, -50%);box-shadow: 0 0 9000px #000;border-radius: 20px;padding: 35px 25px;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 10px 0 30px;display: block;text-align: center;font-size: 21px;}@media screen and (max-width: 900px) {div#tarteaucitronAlertBig button {margin: 0 auto 10px!important;display: block!important;}}';
  248. customThemeMiddle.type = 'text/css';
  249. if (customThemeMiddle.styleSheet) {
  250. customThemeMiddle.styleSheet.cssText = cssRuleMiddle;
  251. } else {
  252. customThemeMiddle.appendChild(document.createTextNode(cssRuleMiddle));
  253. }
  254. document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);
  255. }
  256. // css for the popup bar TODO: add it on the css file
  257. if (tarteaucitron.orientation === 'popup') {
  258. var customThemePopup = document.createElement('style'),
  259. cssRulePopup = 'div#tarteaucitronAlertBig:before {content: \'' + tarteaucitron.lang.middleBarHead + '\';font-size: 22px;}body #tarteaucitronRoot div#tarteaucitronAlertBig {bottom: 0;top: auto!important;left: 8px!important;right: auto!important;transform: initial!important;border-radius: 5px 5px 0 0!important;max-width: 250px!important;width: Calc(100% - 16px)!important;min-width: 0!important;padding: 25px 0;}span#tarteaucitronDisclaimerAlert {padding: 0 30px;font-size: 15px!important;}#tarteaucitronRoot span#tarteaucitronDisclaimerAlert {margin: 10px 0 30px;display: block;text-align: center;font-size: 21px;}div#tarteaucitronAlertBig button {margin: 0 auto 10px!important;display: block!important;width: Calc(100% - 60px);box-sizing: border-box;}';
  260. customThemePopup.type = 'text/css';
  261. if (customThemePopup.styleSheet) {
  262. customThemePopup.styleSheet.cssText = cssRulePopup;
  263. } else {
  264. customThemePopup.appendChild(document.createTextNode(cssRulePopup));
  265. }
  266. document.getElementsByTagName('head')[0].appendChild(customThemePopup);
  267. }
  268. var body = document.body,
  269. div = document.createElement('div'),
  270. html = '',
  271. index,
  272. orientation = 'Top',
  273. cat = ['ads', 'analytic', 'api', 'comment', 'social', 'support', 'video', 'other'],
  274. i;
  275. cat = cat.sort(function (a, b) {
  276. if (tarteaucitron.lang[a].title > tarteaucitron.lang[b].title) { return 1; }
  277. if (tarteaucitron.lang[a].title < tarteaucitron.lang[b].title) { return -1; }
  278. return 0;
  279. });
  280. // Step 3: prepare the html
  281. html += '<div id="tarteaucitronPremium"></div>';
  282. html += '<button type="button" id="tarteaucitronBack" aria-label="' + tarteaucitron.lang.close + '"></button>';
  283. html += '<div id="tarteaucitron" role="dialog" aria-labelledby="dialogTitle">';
  284. html += ' <button type="button" id="tarteaucitronClosePanel">';
  285. html += ' ' + tarteaucitron.lang.close;
  286. html += ' </button>';
  287. html += ' <div id="tarteaucitronServices">';
  288. html += ' <div class="tarteaucitronLine tarteaucitronMainLine" id="tarteaucitronMainLineOffset">';
  289. html += ' <span class="tarteaucitronH1" role="heading" aria-level="1" id="dialogTitle">'+ tarteaucitron.lang.title + '</span>';
  290. html += ' <div id="tarteaucitronInfo">';
  291. html += ' ' + tarteaucitron.lang.disclaimer;
  292. if (tarteaucitron.parameters.privacyUrl !== "") {
  293. html += ' <br/><br/>';
  294. html += ' <button type="button" id="tarteaucitronPrivacyUrlDialog">';
  295. html += ' ' + tarteaucitron.lang.privacyUrl;
  296. html += ' </button>';
  297. }
  298. html += ' </div>';
  299. html += ' <div class="tarteaucitronName">';
  300. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2">' + tarteaucitron.lang.all + '</span>';
  301. html += ' </div>';
  302. html += ' <div class="tarteaucitronAsk" id="tarteaucitronScrollbarAdjust">';
  303. html += ' <button type="button" id="tarteaucitronAllAllowed" class="tarteaucitronAllow">';
  304. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allowAll;
  305. html += ' </button> ';
  306. html += ' <button type="button" id="tarteaucitronAllDenied" class="tarteaucitronDeny">';
  307. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  308. html += ' </button>';
  309. html += ' </div>';
  310. html += ' </div>';
  311. html += ' <div class="tarteaucitronBorder">';
  312. html += ' <div class="clear"></div><ul>';
  313. if (tarteaucitron.parameters.mandatory == true) {
  314. html += '<li id="tarteaucitronServicesTitle_mandatory">';
  315. html += '<div class="tarteaucitronTitle">';
  316. html += ' <button type="button" tabindex="-1"><span class="tarteaucitronPlus"></span> ' + tarteaucitron.lang.mandatoryTitle + '</button>';
  317. html += '</div>';
  318. html += '<ul id="tarteaucitronServices_mandatory">';
  319. html += '<li class="tarteaucitronLine">';
  320. html += ' <div class="tarteaucitronName">';
  321. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + tarteaucitron.lang.mandatoryText + '</span>';
  322. html += ' <span class="tarteaucitronListCookies"></span><br/>';
  323. html += ' </div>';
  324. html += ' <div class="tarteaucitronAsk">';
  325. html += ' <button type="button" class="tarteaucitronAllow" tabindex="-1" disabled>';
  326. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  327. html += ' </button> ';
  328. html += ' <button type="button" class="tarteaucitronDeny" style="visibility:hidden" tabindex="-1">';
  329. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  330. html += ' </button> ';
  331. html += ' </div>';
  332. html += '</li>';
  333. html += '</ul></li>';
  334. }
  335. for (i = 0; i < cat.length; i += 1) {
  336. html += ' <li id="tarteaucitronServicesTitle_' + cat[i] + '" class="tarteaucitronHidden">';
  337. html += ' <div class="tarteaucitronTitle">';
  338. html += ' <button type="button" class="catToggleBtn" data-cat="tarteaucitronDetails' + cat[i] + '"><span class="tarteaucitronPlus"></span> ' + tarteaucitron.lang[cat[i]].title + '</button>';
  339. html += ' </div>';
  340. html += ' <div id="tarteaucitronDetails' + cat[i] + '" class="tarteaucitronDetails tarteaucitronInfoBox">';
  341. html += ' ' + tarteaucitron.lang[cat[i]].details;
  342. html += ' </div>';
  343. html += ' <ul id="tarteaucitronServices_' + cat[i] + '"></ul></li>';
  344. }
  345. html += ' <li id="tarteaucitronNoServicesTitle" class="tarteaucitronLine">' + tarteaucitron.lang.noServices + '</li>';
  346. html += ' </ul>';
  347. html += ' <div class="tarteaucitronHidden tarteaucitron-spacer-20" id="tarteaucitronScrollbarChild"></div>';
  348. if (tarteaucitron.parameters.removeCredit === false) {
  349. html += ' <a class="tarteaucitronSelfLink" href="https://tarteaucitron.io/" rel="nofollow noreferrer noopener" target="_blank" title="tarteaucitron ' + tarteaucitron.lang.newWindow + '"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHcAAAAeCAYAAAAWwoEYAAADl0lEQVRoge1Y0W3bQAx9CjKARlC+9GVUmqDJBHEmiDyB6wkcTxBngtgTxJ0gzgQW4C/9aYOmE6g4lTQo+k6y3Rb94QOERNQd+cjj8XiGwWAwGAwGg8FgMBgMBoPB8F8RNRXe+whEKe7c36ZCAeCRxC9Rig2PUd8kPgAsoxSfQ3YAzAA8D/HwYYCb05kBKKO0teFkmbC1jlKsAnq/Abjn+QBqAIsoRS30ttwG/HNz1wH/XIxWTicLdvtW7xTAGEAMtP685CNsBTe2d/BLydfXAG57SEnMAST0zgYZSUCPk02bCvkJduIzuJzDLfPolbY+tLKmar+/8+IRePy4qdpE03qHuH8fipFb4N2+XdA3AJ/0vaQxt7s9FvkIS2XvtqnwM0rxpOQfbnE5G2LhTCmUO2fHIngOmcv+KG3HafDchB6ntwjYqenR2PqC7sOZ3E7FXHB0vqxoFyUyLh7OEH7LOGouvhhN3eIBeKXv0n5MsufdHqXcwYR5U2EbpV35lSspVPJmQj4TcgRK7jTg5IzmPUhhwM5a2WHUFCx+NgiDucmgh7idikLovHFlL0pxQ9xzX+IIP9Y6FrJsqhjlQpZRAkFVDCjZfcCHt6bqJDmuh5ylCWx0RVnk3oumaknqTH5sqrY0fBWyULaHUIgAgxb46MxV3DbieAhxOxUxjSuljig9lMQ/Bcfoi9BTEv9aLORSndVxYOH525sUDC6u2gWxcNzBNRxPanyh3ktKinOgy3WoxPbtUM0t6RkbQnzBnFPgi9GCOEubY9UffIryz9iKRe8s/FUfEWosJJGxagp85bpUO3VywQ46lOtAWfNxKwa4JXQ+628+bpxYGXXMzp5rXH401VEyXwIdowXFaKWSMFHvMTVmGnc+P3oXV2QOiBCfgex8QtcQCbcQE/H+eoHzrkFo1KM7zVO4jVVj5s6lRiWF7zyXyfRMc97J3tzj87mYqZ7E2YjzUct9GUi4tjHLR8dVkBLjQcuHFleWvQfRNEhFR7uX7pkctOwvZXsft7sAtyldEUIN2UTeLxnEfxKYswzdi88BdbZ8hifUoSMftQvP+muRwN6+Q3DeqqRExP9QmTtcheiHh0Ot1x2i2km1bP9pbufw5zZdyWsOrh7vQae5OZWbsMv30pi7cd/CKj3coPEVaCP4Zhx4eQWhOZ1Y9MTXGyP8/iGjEyfa1T4fO/4Lea9vBoPBYDAYDAaDwWAwGAwGwz8GgF8siXCCbrSRhgAAAABJRU5ErkJggg==" alt="tarteaucitron.io" /></a>';
  350. }
  351. html += ' </div>';
  352. html += ' </div>';
  353. html += '</div>';
  354. if (tarteaucitron.parameters.orientation === 'bottom') {
  355. orientation = 'Bottom';
  356. }
  357. if (tarteaucitron.parameters.highPrivacy && !tarteaucitron.parameters.AcceptAllCta) {
  358. html += '<div tabindex="-1" id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  359. //html += '<div class="tarteaucitronAlertBigWrapper">';
  360. html += ' <span id="tarteaucitronDisclaimerAlert">';
  361. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  362. html += ' </span>';
  363. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  364. html += ' <button type="button" id="tarteaucitronPersonalize">';
  365. html += ' ' + tarteaucitron.lang.personalize;
  366. html += ' </button>';
  367. if (tarteaucitron.parameters.privacyUrl !== "") {
  368. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  369. html += ' ' + tarteaucitron.lang.privacyUrl;
  370. html += ' </button>';
  371. }
  372. //html += ' </span>';
  373. //html += '</div>';
  374. html += '</div>';
  375. } else {
  376. html += '<div tabindex="-1" id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + '">';
  377. //html += '<div class="tarteaucitronAlertBigWrapper">';
  378. html += ' <span id="tarteaucitronDisclaimerAlert">';
  379. if (tarteaucitron.parameters.highPrivacy) {
  380. html += ' ' + tarteaucitron.lang.alertBigPrivacy;
  381. } else {
  382. html += ' ' + tarteaucitron.lang.alertBigClick + ' ' + tarteaucitron.lang.alertBig;
  383. }
  384. html += ' </span>';
  385. //html += ' <span class="tarteaucitronAlertBigBtnWrapper">';
  386. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronAllow" id="tarteaucitronPersonalize2">';
  387. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.acceptAll;
  388. html += ' </button>';
  389. if (tarteaucitron.parameters.DenyAllCta) {
  390. html += ' <button type="button" class="tarteaucitronCTAButton tarteaucitronDeny" id="tarteaucitronAllDenied2">';
  391. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.denyAll;
  392. html += ' </button>';
  393. //html += ' <br/><br/>';
  394. }
  395. html += ' <button type="button" id="tarteaucitronCloseAlert">';
  396. html += ' ' + tarteaucitron.lang.personalize;
  397. html += ' </button>';
  398. if (tarteaucitron.parameters.privacyUrl !== "") {
  399. html += ' <button type="button" id="tarteaucitronPrivacyUrl">';
  400. html += ' ' + tarteaucitron.lang.privacyUrl;
  401. html += ' </button>';
  402. }
  403. //html += ' </span>';
  404. //html += '</div>';
  405. html += '</div>';
  406. html += '<div id="tarteaucitronPercentage"></div>';
  407. }
  408. if (tarteaucitron.parameters.showIcon === true) {
  409. html += '<div id="tarteaucitronIcon" class="tarteaucitronIcon' + tarteaucitron.parameters.iconPosition + '">';
  410. html += ' <button type="button" id="tarteaucitronManager">';
  411. html += ' <img src="' + (tarteaucitron.parameters.iconSrc ? tarteaucitron.parameters.iconSrc : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAGA0lEQVRoge1a207bWBRdBtJwLYZhKDMVmlSK1LxNkPo+ZH6g8B6p5AuALwC+APoFoVLeoT8whPeRSt+CZKmZVu3AiIsRlEtCktGyjy8xzuXYhvahS0JJHJ/4rLP3XnuffcAPfGdQ7mM6jRLSAF4BxqsbewB2lRS2o35mpEQaJcwCyANIdLi1DGBNSWEzqmdHRqRRwjqAJclhtExOSUEP+/xIiDRKhhUWfL7ShTtBuJnqcw+/z4Ql0xNmMEwSSz4kuNIzSgpjSsqYJP/GeE185wYJroedRyiLNEpGLLzzrHSuk+83SgbxvOcyyRaDziWsRVZkSRDinpzPbwVGWIucuohsKynMS47fAQyls/BMSRmKJo3AFhG5wm2N1wF+Zs3zebbFfR0RxrXcJHQlgH+LMW616pR/WiIMEXfW3mtzXyeEGWsjKot8c4TOI98L+iKaR5PS6IUk88RLAO9F8UjrbYoYMOosNavpfmODIiwRXRR/G3ohaWVo1RU/c30jV8ab2mV8qVGzHWBOLyTLZiWs5Rolg/C3ySOi0tXP/k4aEwOwSBKPJs7Rp16ABJTe+p1xVX0It/owqqdDEMRoqd3RFxqDPh20Ig6VEPVC0i5RSCD+6wl6HlW7GksSlUMV11/GrUs5NasFLusDE9ELSVphXemtJwaT/8JyIRvxNNCfBmIiNdR04LII3DSrbe0yjqvyJF/ppptqVlt+MCLCEh/oOkPPP6N38Mb5cnQBGFsEqmXg5j3QMwoMzwGnr4HYbybBq13gZAOom/FO63zdf2qQArCsZrUN2TlJy69eSDKYV+6Q4MpP75ivHzPA53ngaBW4eGuSOt0A/lsGPmXMz0+3TFJcTfFbPfFbfnwlhON+iQhlWmA82CQ4ocQ7c6KcfL3DHuls0yT6Sx4YnLXJDCQOIRRv5yGIJBgP8Sdisj2qubpc5UGJmo+W49ifVmzL8HcpGhQPvZCUKiCliIhEN0tr2OCqHuSA8gwQ/92MkU7gxEmeVqGrTTgpxPXbUrtGWYus0I9thRIraagRQUIDf7Qn4yZhKRiFQIyhfMfUr3yblokVWSJ6k8xSnc7eNN/RjowfCYiFoDUFer1S3gW6JiJ8Nt30EMbEhU+vzSIztuRYjRLsR8IHLjlf7HZ+MrWWEXxNmbvapt4jGSqZRYSkGUetSNTPzHsui5YMQ2ajJUNks6mw4wT54Ok2ShnzzIPCUGshzawCRKy5FqvrTZe0RWzQGvw79m67XZjKmxJrLsICjtZa55gxXy+6F4sYsEtxTqhXdRTLC8ulSDaWoCLsolfN+8YUhOsJV709H7Cudr0LlVEtzqBcN+shEyThdR941OnAbF8pirKJqXyupTRTtQSReiVmXW1j7oBErB0d9xM2WEd5J9ZKYtuR4WKwwBSoORbpGrJ5ZI9lt71irJmGX1px0JYE26uNErawr2zfIcP4OHEKXm66PA3wjpCNEfpJunI4muifPjKvsFCkGjExTq63yxMJsZNMYF/J4HmDC5A3Yq36jy0ClePHVhwuu/b1HSFlEfHD5ZtD1bEK44Qu1mWys6tbWmZyPWckzlPTGiRw/XHCuk+q4Rek+mVrVL/UppwrdDEGNV2kpyuhccgc5Oxm9vWnn+19vJrVpLor0kTUrGacMplb1CfOFyTD4o9uNrHqr2Z+ZMSp1c2XcVSORnh9Q81q3k599ETgkNnjg0nGzi10K7rX+bZpHbrblPcY5A4Zxk2xcjzCvTpd9027Aa0QtouyyrKFRR6D/04DwkFGvHPXM3Qda/Jb4nPgI7hQLVM1q5HIBt2MzQNa57Z1DiiLAGa5Mi+O4Sz3Mpp6laPHO6InII3ITnX1QtI+EOX+m9ZxleOZ/j9PiuKoLi3aqXPuEoSye/Vhkm+LalbLtHhMS0R6zu7aZ3vP2jOjL7QVv4McxhcDnZIelAQibGIbULOapf3PuE1Vs9qeaOTdkVKr00gCQiw4NlBzDvf1Lxx+uP5r3Dgv5KQZRzWn+GRwz8jmDS8itUg7iB6vLuJCF5Uty4A9mVKkFR6MiJDachST/oHvHgD+B4SoUIitpF05AAAAAElFTkSuQmCC') + '" alt="' + tarteaucitron.lang.icon + '" title="' + tarteaucitron.lang.icon + '">';
  412. html += ' </button>';
  413. html += '</div>';
  414. }
  415. if (tarteaucitron.parameters.showAlertSmall === true) {
  416. html += '<div id="tarteaucitronAlertSmall" class="tarteaucitronAlertSmall' + orientation + '">';
  417. html += ' <button type="button" id="tarteaucitronManager">';
  418. html += ' ' + tarteaucitron.lang.alertSmall;
  419. html += ' <span id="tarteaucitronDot">';
  420. html += ' <span id="tarteaucitronDotGreen"></span>';
  421. html += ' <span id="tarteaucitronDotYellow"></span>';
  422. html += ' <span id="tarteaucitronDotRed"></span>';
  423. html += ' </span>';
  424. if (tarteaucitron.parameters.cookieslist === true) {
  425. html += ' </button><!-- @whitespace';
  426. html += ' --><button type="button" id="tarteaucitronCookiesNumber">0</button>';
  427. html += ' <div id="tarteaucitronCookiesListContainer">';
  428. html += ' <button type="button" id="tarteaucitronClosePanelCookie">';
  429. html += ' ' + tarteaucitron.lang.close;
  430. html += ' </button>';
  431. html += ' <div class="tarteaucitronCookiesListMain" id="tarteaucitronCookiesTitle">';
  432. html += ' <span class="tarteaucitronH2" role="heading" aria-level="2" id="tarteaucitronCookiesNumberBis">0 cookie</span>';
  433. html += ' </div>';
  434. html += ' <div id="tarteaucitronCookiesList"></div>';
  435. html += ' </div>';
  436. } else {
  437. html += ' </div>';
  438. }
  439. html += '</div>';
  440. }
  441. tarteaucitron.addInternalScript(tarteaucitron.cdn + 'advertising' + (useJSDelivrMinifiedJS ? '.min' : '') + '.js?v=' + tarteaucitron.version, '', function () {
  442. if (tarteaucitronNoAdBlocker === true || tarteaucitron.parameters.adblocker === false) {
  443. // create a wrapper container at the same level than tarteaucitron so we can add an aria-hidden when tarteaucitron is opened
  444. /*var wrapper = document.createElement('div');
  445. wrapper.id = "tarteaucitronContentWrapper";
  446. while (document.body.firstChild)
  447. {
  448. wrapper.appendChild(document.body.firstChild);
  449. }
  450. // Append the wrapper to the body
  451. document.body.appendChild(wrapper);*/
  452. div.id = 'tarteaucitronRoot';
  453. if (tarteaucitron.parameters.bodyPosition === 'top') {
  454. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  455. var bodyFirstChild = body.firstChild;
  456. body.insertBefore(div, bodyFirstChild);
  457. }
  458. else {
  459. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  460. body.appendChild(div, body);
  461. }
  462. div.innerHTML = html;
  463. //ie compatibility
  464. var tacRootAvailableEvent;
  465. if(typeof(Event) === 'function') {
  466. tacRootAvailableEvent = new Event("tac.root_available");
  467. }else{
  468. tacRootAvailableEvent = document.createEvent('Event');
  469. tacRootAvailableEvent.initEvent("tac.root_available", true, true);
  470. }
  471. //end ie compatibility
  472. window.dispatchEvent(tacRootAvailableEvent);
  473. if (tarteaucitron.job !== undefined) {
  474. tarteaucitron.job = tarteaucitron.cleanArray(tarteaucitron.job);
  475. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  476. tarteaucitron.addService(tarteaucitron.job[index]);
  477. }
  478. } else {
  479. tarteaucitron.job = [];
  480. }
  481. if (tarteaucitron.job.length === 0) {
  482. tarteaucitron.userInterface.closeAlert();
  483. }
  484. tarteaucitron.isAjax = true;
  485. tarteaucitron.job.push = function (id) {
  486. // ie <9 hack
  487. if (typeof tarteaucitron.job.indexOf === 'undefined') {
  488. tarteaucitron.job.indexOf = function (obj, start) {
  489. var i,
  490. j = this.length;
  491. for (i = (start || 0); i < j; i += 1) {
  492. if (this[i] === obj) { return i; }
  493. }
  494. return -1;
  495. };
  496. }
  497. if (tarteaucitron.job.indexOf(id) === -1) {
  498. Array.prototype.push.call(this, id);
  499. }
  500. tarteaucitron.launch[id] = false;
  501. tarteaucitron.addService(id);
  502. };
  503. if (document.location.hash === tarteaucitron.hashtag && tarteaucitron.hashtag !== '') {
  504. tarteaucitron.userInterface.openPanel();
  505. }
  506. tarteaucitron.cookie.number();
  507. setInterval(tarteaucitron.cookie.number, 60000);
  508. }
  509. }, tarteaucitron.parameters.adblocker);
  510. if (tarteaucitron.parameters.adblocker === true) {
  511. setTimeout(function () {
  512. if (tarteaucitronNoAdBlocker === false) {
  513. html = '<div id="tarteaucitronAlertBig" class="tarteaucitronAlertBig' + orientation + ' tarteaucitron-display-block" role="alert" aria-live="polite">';
  514. html += ' <p id="tarteaucitronDisclaimerAlert">';
  515. html += ' ' + tarteaucitron.lang.adblock + '<br/>';
  516. html += ' <strong>' + tarteaucitron.lang.adblock_call + '</strong>';
  517. html += ' </p>';
  518. html += ' <button type="button" class="tarteaucitronCTAButton" id="tarteaucitronCTAButton">';
  519. html += ' ' + tarteaucitron.lang.reload;
  520. html += ' </button>';
  521. html += '</div>';
  522. html += '<div id="tarteaucitronPremium"></div>';
  523. div.id = 'tarteaucitronRoot';
  524. if (tarteaucitron.parameters.bodyPosition === 'top') {
  525. // Prepend tarteaucitron: #tarteaucitronRoot first-child of the body for better accessibility
  526. var bodyFirstChild = body.firstChild;
  527. body.insertBefore(div, bodyFirstChild);
  528. }
  529. else {
  530. // Append tarteaucitron: #tarteaucitronRoot last-child of the body
  531. body.appendChild(div, body);
  532. }
  533. div.innerHTML = html;
  534. }
  535. }, 1500);
  536. }
  537. if(tarteaucitron.parameters.closePopup === true){
  538. setTimeout(function() {
  539. var closeElement = document.getElementById('tarteaucitronAlertBig'),
  540. closeSpan = document.createElement('span');
  541. if (closeElement) {
  542. closeSpan.textContent = 'X';
  543. closeSpan.setAttribute('id', "tarteaucitronCloseCross");
  544. closeElement.insertBefore(closeSpan, closeElement.firstElementChild);
  545. }
  546. }, 100);
  547. }
  548. if(tarteaucitron.parameters.groupServices === true) {
  549. var tac_group_style = document.createElement('style');
  550. tac_group_style.innerHTML = '.tarteaucitronTitle{display:none}';
  551. document.head.appendChild(tac_group_style);
  552. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  553. Array.prototype.forEach.call(cats, function(item) {
  554. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, "");
  555. if (cat !== "mandatory") {
  556. var html = '';
  557. html += '<li class="tarteaucitronLine">';
  558. html += ' <div class="tarteaucitronName">';
  559. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">'+tarteaucitron.lang[cat].title+'</span>';
  560. html += ' <span>'+tarteaucitron.lang[cat].details+'</span>';
  561. html += ' <button type="button" class="tarteaucitron-toggle-group" id="tarteaucitron-toggle-group-'+cat+'">'+tarteaucitron.lang.alertSmall+' ('+document.getElementById("tarteaucitronServices_"+cat).childElementCount+')</button>';
  562. html += ' </div>';
  563. html += ' <div class="tarteaucitronAsk" id="tarteaucitron-group-'+cat+'">';
  564. html += ' <button type="button" class="tarteaucitronAllow" id="tarteaucitron-accept-group-'+cat+'">';
  565. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  566. html += ' </button> ';
  567. html += ' <button type="button" class="tarteaucitronDeny" id="tarteaucitron-reject-group-'+cat+'">';
  568. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  569. html += ' </button>';
  570. html += ' </div>';
  571. html += '</li>';
  572. var ul = document.createElement('ul');
  573. ul.innerHTML = html;
  574. item.insertBefore(ul, item.querySelector('#tarteaucitronServices_'+cat+''));
  575. document.querySelector('#tarteaucitronServices_' + cat).style.display = 'none';
  576. tarteaucitron.addClickEventToId("tarteaucitron-toggle-group-" + cat, function () {
  577. tarteaucitron.userInterface.toggle('tarteaucitronServices_' + cat);
  578. if (document.getElementById('tarteaucitronServices_' + cat).style.display == 'block') {
  579. tarteaucitron.userInterface.addClass('tarteaucitronServicesTitle_' + cat, 'tarteaucitronIsExpanded');
  580. } else {
  581. tarteaucitron.userInterface.removeClass('tarteaucitronServicesTitle_' + cat, 'tarteaucitronIsExpanded');
  582. }
  583. });
  584. tarteaucitron.addClickEventToId("tarteaucitron-accept-group-" + cat, function () {
  585. tarteaucitron.userInterface.respondAll(true, cat);
  586. });
  587. tarteaucitron.addClickEventToId("tarteaucitron-reject-group-" + cat, function () {
  588. tarteaucitron.userInterface.respondAll(false, cat);
  589. });
  590. }
  591. });
  592. }
  593. tarteaucitron.userInterface.color("", true);
  594. // add a little timeout to be sure everything is accessible
  595. setTimeout(function () {
  596. // Setup events
  597. tarteaucitron.addClickEventToId("tarteaucitronCloseCross", function () {
  598. tarteaucitron.userInterface.closeAlert();
  599. });
  600. tarteaucitron.addClickEventToId("tarteaucitronPersonalize", function () {
  601. tarteaucitron.userInterface.openPanel();
  602. });
  603. tarteaucitron.addClickEventToId("tarteaucitronPersonalize2", function () {
  604. tarteaucitron.userInterface.respondAll(true);
  605. });
  606. tarteaucitron.addClickEventToId("tarteaucitronManager", function () {
  607. tarteaucitron.userInterface.openPanel();
  608. });
  609. tarteaucitron.addClickEventToId("tarteaucitronBack", function () {
  610. tarteaucitron.userInterface.closePanel();
  611. });
  612. tarteaucitron.addClickEventToId("tarteaucitronClosePanel", function () {
  613. tarteaucitron.userInterface.closePanel();
  614. });
  615. tarteaucitron.addClickEventToId("tarteaucitronClosePanelCookie", function () {
  616. tarteaucitron.userInterface.closePanel();
  617. });
  618. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrl", function () {
  619. document.location = tarteaucitron.parameters.privacyUrl;
  620. });
  621. tarteaucitron.addClickEventToId("tarteaucitronPrivacyUrlDialog", function () {
  622. document.location = tarteaucitron.parameters.privacyUrl;
  623. });
  624. tarteaucitron.addClickEventToId("tarteaucitronCookiesNumber", function () {
  625. tarteaucitron.userInterface.toggleCookiesList();
  626. });
  627. tarteaucitron.addClickEventToId("tarteaucitronAllAllowed", function () {
  628. tarteaucitron.userInterface.respondAll(true);
  629. });
  630. tarteaucitron.addClickEventToId("tarteaucitronAllDenied", function () {
  631. tarteaucitron.userInterface.respondAll(false);
  632. });
  633. tarteaucitron.addClickEventToId("tarteaucitronAllDenied2", function () {
  634. tarteaucitron.userInterface.respondAll(false, '', true);
  635. if (tarteaucitron.reloadThePage === true) {
  636. window.location.reload();
  637. }
  638. });
  639. tarteaucitron.addClickEventToId("tarteaucitronCloseAlert", function () {
  640. tarteaucitron.userInterface.openPanel();
  641. });
  642. tarteaucitron.addClickEventToId("tarteaucitronCTAButton", function () {
  643. location.reload();
  644. });
  645. var i,
  646. toggleBtns = document.getElementsByClassName("catToggleBtn"), i;
  647. for (i = 0; i < toggleBtns.length; i++) {
  648. toggleBtns[i].dataset.index = i;
  649. tarteaucitron.addClickEventToElement(toggleBtns[i], function () {
  650. tarteaucitron.userInterface.toggle('tarteaucitronDetails' + cat[this.dataset.index], 'tarteaucitronInfoBox');
  651. return false;
  652. });
  653. }
  654. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  655. for (i = 0; i < allowBtns.length; i++) {
  656. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  657. tarteaucitron.userInterface.respond(this, true);
  658. });
  659. }
  660. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  661. for (i = 0; i < denyBtns.length; i++) {
  662. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  663. tarteaucitron.userInterface.respond(this, false);
  664. });
  665. }
  666. if(tarteaucitron.events.load) {
  667. tarteaucitron.events.load();
  668. }
  669. }, 500);
  670. });
  671. });
  672. },
  673. "addService": function (serviceId) {
  674. "use strict";
  675. var html = '',
  676. s = tarteaucitron.services,
  677. service = s[serviceId],
  678. cookie = tarteaucitron.cookie.read(),
  679. hostname = document.location.hostname,
  680. hostRef = document.referrer.split('/')[2],
  681. isNavigating = (hostRef === hostname && window.location.href !== tarteaucitron.parameters.privacyUrl),
  682. isAutostart = (!service.needConsent),
  683. isWaiting = (cookie.indexOf(service.key + '=wait') >= 0),
  684. isDenied = (cookie.indexOf(service.key + '=false') >= 0),
  685. isAllowed = ((cookie.indexOf(service.key + '=true') >= 0) || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)),
  686. isResponded = (cookie.indexOf(service.key + '=false') >= 0 || cookie.indexOf(service.key + '=true') >= 0),
  687. isDNTRequested = (navigator.doNotTrack === "1" || navigator.doNotTrack === "yes" || navigator.msDoNotTrack === "1" || window.doNotTrack === "1"),
  688. currentStatus = (isAllowed) ? tarteaucitron.lang.allowed : tarteaucitron.lang.disallowed;
  689. if (tarteaucitron.added[service.key] !== true) {
  690. tarteaucitron.added[service.key] = true;
  691. html += '<li id="' + service.key + 'Line" class="tarteaucitronLine">';
  692. html += ' <div class="tarteaucitronName">';
  693. html += ' <span class="tarteaucitronH3" role="heading" aria-level="3">' + service.name + ' (<span id="tacCurrentStatus' + service.key + '">'+currentStatus+'</span>)</span>';
  694. html += ' <span id="tacCL' + service.key + '" class="tarteaucitronListCookies"></span><br/>';
  695. if (tarteaucitron.parameters.moreInfoLink == true) {
  696. var link = 'https://tarteaucitron.io/service/' + service.key + '/';
  697. if (service.readmoreLink !== undefined && service.readmoreLink !== '') {
  698. link = service.readmoreLink;
  699. }
  700. if (tarteaucitron.parameters.readmoreLink !== undefined && tarteaucitron.parameters.readmoreLink !== '') {
  701. link = tarteaucitron.parameters.readmoreLink;
  702. }
  703. html += ' <a href="' + link + '" target="_blank" rel="noreferrer noopener nofollow" title="'+ tarteaucitron.lang.cookieDetail + ' ' + service.name + ' ' + tarteaucitron.lang.ourSite + ' ' + tarteaucitron.lang.newWindow +'" class="tarteaucitronReadmoreInfo">';
  704. html += ' ' + tarteaucitron.lang.more;
  705. html += ' </a>';
  706. html += ' <span class="tarteaucitronReadmoreSeparator"> - </span>';
  707. html += ' <a href="' + service.uri + '" target="_blank" rel="noreferrer noopener" title="' + service.name + ' ' + tarteaucitron.lang.newWindow + '" class="tarteaucitronReadmoreOfficial">';
  708. html += ' ' + tarteaucitron.lang.source;
  709. html += ' </a>';
  710. }
  711. html += ' </div>';
  712. html += ' <div class="tarteaucitronAsk">';
  713. html += ' <button type="button" id="' + service.key + 'Allowed" class="tarteaucitronAllow">';
  714. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  715. html += ' </button> ';
  716. html += ' <button type="button" id="' + service.key + 'Denied" class="tarteaucitronDeny">';
  717. html += ' <span class="tarteaucitronCross"></span> ' + tarteaucitron.lang.deny;
  718. html += ' </button>';
  719. html += ' </div>';
  720. html += '</li>';
  721. tarteaucitron.userInterface.css('tarteaucitronServicesTitle_' + service.type, 'display', 'block');
  722. if (document.getElementById('tarteaucitronServices_' + service.type) !== null) {
  723. document.getElementById('tarteaucitronServices_' + service.type).innerHTML += html;
  724. }
  725. tarteaucitron.userInterface.css('tarteaucitronNoServicesTitle', 'display', 'none');
  726. tarteaucitron.userInterface.order(service.type);
  727. tarteaucitron.addClickEventToId(service.key + 'Allowed', function () {
  728. tarteaucitron.userInterface.respond(this, true);
  729. });
  730. tarteaucitron.addClickEventToId(service.key + 'Denied', function () {
  731. tarteaucitron.userInterface.respond(this, false);
  732. });
  733. }
  734. tarteaucitron.pro('!' + service.key + '=' + isAllowed);
  735. // allow by default for non EU
  736. if (isResponded === false && tarteaucitron.user.bypass === true) {
  737. isAllowed = true;
  738. tarteaucitron.cookie.create(service.key, true);
  739. }
  740. if ((!isResponded && (isAutostart || (isNavigating && isWaiting)) && !tarteaucitron.highPrivacy) || isAllowed) {
  741. if (!isAllowed || (!service.needConsent && cookie.indexOf(service.key + '=false') < 0)) {
  742. tarteaucitron.cookie.create(service.key, true);
  743. }
  744. if (tarteaucitron.launch[service.key] !== true) {
  745. tarteaucitron.launch[service.key] = true;
  746. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.js(); }
  747. tarteaucitron.sendEvent(service.key + '_loaded');
  748. }
  749. tarteaucitron.state[service.key] = true;
  750. tarteaucitron.userInterface.color(service.key, true);
  751. } else if (isDenied) {
  752. if (typeof service.fallback === 'function') {
  753. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  754. }
  755. tarteaucitron.state[service.key] = false;
  756. tarteaucitron.userInterface.color(service.key, false);
  757. } else if (!isResponded && isDNTRequested && tarteaucitron.handleBrowserDNTRequest) {
  758. tarteaucitron.cookie.create(service.key, 'false');
  759. if (typeof service.fallback === 'function') {
  760. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  761. }
  762. tarteaucitron.state[service.key] = false;
  763. tarteaucitron.userInterface.color(service.key, false);
  764. } else if (!isResponded) {
  765. tarteaucitron.cookie.create(service.key, 'wait');
  766. if (typeof service.fallback === 'function') {
  767. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + service.key + "_") < 0) { service.fallback(); }
  768. }
  769. tarteaucitron.userInterface.color(service.key, 'wait');
  770. tarteaucitron.userInterface.openAlert();
  771. }
  772. tarteaucitron.cookie.checkCount(service.key);
  773. tarteaucitron.sendEvent(service.key + '_added')
  774. },
  775. "sendEvent" : function(event_key) {
  776. if(event_key !== undefined) {
  777. //ie compatibility
  778. var send_event_item;
  779. if(typeof(Event) === 'function') {
  780. send_event_item = new Event(event_key);
  781. }else{
  782. send_event_item = document.createEvent('Event');
  783. send_event_item.initEvent(event_key, true, true);
  784. }
  785. //end ie compatibility
  786. document.dispatchEvent(send_event_item);
  787. }
  788. },
  789. "cleanArray": function cleanArray(arr) {
  790. "use strict";
  791. var i,
  792. len = arr.length,
  793. out = [],
  794. obj = {},
  795. s = tarteaucitron.services;
  796. for (i = 0; i < len; i += 1) {
  797. if (!obj[arr[i]]) {
  798. obj[arr[i]] = {};
  799. if (tarteaucitron.services[arr[i]] !== undefined) {
  800. out.push(arr[i]);
  801. }
  802. }
  803. }
  804. out = out.sort(function (a, b) {
  805. if (s[a].type + s[a].key > s[b].type + s[b].key) { return 1; }
  806. if (s[a].type + s[a].key < s[b].type + s[b].key) { return -1; }
  807. return 0;
  808. });
  809. return out;
  810. },
  811. "userInterface": {
  812. "css": function (id, property, value) {
  813. "use strict";
  814. if (document.getElementById(id) !== null) {
  815. if (property == "display" && value == "none" && (id == "tarteaucitron" || id == "tarteaucitronBack" || id == "tarteaucitronAlertBig")) {
  816. document.getElementById(id).style["opacity"] = "0";
  817. setTimeout(function() {document.getElementById(id).style[property] = value;}, 200);
  818. } else {
  819. document.getElementById(id).style[property] = value;
  820. if (property == "display" && value == "block" && (id == "tarteaucitron" || id == "tarteaucitronAlertBig")) {
  821. document.getElementById(id).style["opacity"] = "0";
  822. setTimeout(function() {document.getElementById(id).style["opacity"] = "1";}, 1);
  823. }
  824. if (property == "display" && value == "block" && id == "tarteaucitronBack") {
  825. document.getElementById(id).style["opacity"] = "0";
  826. setTimeout(function() {document.getElementById(id).style["opacity"] = "0.7";}, 1);
  827. }
  828. }
  829. }
  830. },
  831. "addClass": function (id, className) {
  832. "use strict";
  833. if (document.getElementById(id) !== null) {
  834. document.getElementById(id).classList.add(className);
  835. }
  836. },
  837. "removeClass": function (id, className) {
  838. "use strict";
  839. if (document.getElementById(id) !== null) {
  840. document.getElementById(id).classList.remove(className);
  841. }
  842. },
  843. "respondAll": function (status, type, allowSafeAnalytics) {
  844. "use strict";
  845. var s = tarteaucitron.services,
  846. service,
  847. key,
  848. index = 0;
  849. for (index = 0; index < tarteaucitron.job.length; index += 1) {
  850. if (typeof type !== 'undefined' && type !== '' && s[tarteaucitron.job[index]].type !== type) {
  851. continue;
  852. }
  853. if (allowSafeAnalytics && typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  854. continue;
  855. }
  856. service = s[tarteaucitron.job[index]];
  857. key = service.key;
  858. if (tarteaucitron.state[key] !== status) {
  859. if (status === false && tarteaucitron.launch[key] === true) {
  860. tarteaucitron.reloadThePage = true;
  861. }
  862. if (tarteaucitron.launch[key] !== true && status === true) {
  863. tarteaucitron.pro('!' + key + '=engage');
  864. tarteaucitron.launch[key] = true;
  865. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  866. tarteaucitron.sendEvent(key + '_loaded');
  867. }
  868. var itemStatusElem = document.getElementById('tacCurrentStatus'+key);
  869. if(status == true){
  870. itemStatusElem.innerHTML = tarteaucitron.lang.allowed;
  871. }else{
  872. itemStatusElem.innerHTML = tarteaucitron.lang.disallowed;
  873. }
  874. tarteaucitron.state[key] = status;
  875. tarteaucitron.cookie.create(key, status);
  876. tarteaucitron.userInterface.color(key, status);
  877. }
  878. }
  879. },
  880. "respond": function (el, status) {
  881. "use strict";
  882. if (el.id === '') {
  883. return;
  884. }
  885. var key = el.id.replace(new RegExp("(Eng[0-9]+|Allow|Deni)ed", "g"), '');
  886. if (key.substring(0, 13) === 'tarteaucitron' || key === '') {return;}
  887. // return if same state
  888. if (tarteaucitron.state[key] === status) {
  889. return;
  890. }
  891. if (status === false && tarteaucitron.launch[key] === true) {
  892. tarteaucitron.reloadThePage = true;
  893. }
  894. // if not already launched... launch the service
  895. if (status === true) {
  896. if (tarteaucitron.launch[key] !== true) {
  897. tarteaucitron.pro('!' + key + '=engage');
  898. tarteaucitron.launch[key] = true;
  899. tarteaucitron.sendEvent(key + '_loaded');
  900. if (typeof tarteaucitronMagic === 'undefined' || tarteaucitronMagic.indexOf("_" + key + "_") < 0) { tarteaucitron.services[key].js(); }
  901. }
  902. }
  903. var itemStatusElem = document.getElementById('tacCurrentStatus'+key);
  904. if(status == true){
  905. itemStatusElem.innerHTML = tarteaucitron.lang.allowed;
  906. }else{
  907. itemStatusElem.innerHTML = tarteaucitron.lang.disallowed;
  908. }
  909. tarteaucitron.state[key] = status;
  910. tarteaucitron.cookie.create(key, status);
  911. tarteaucitron.userInterface.color(key, status);
  912. },
  913. "color": function (key, status) {
  914. "use strict";
  915. var c = 'tarteaucitron',
  916. nbDenied = 0,
  917. nbPending = 0,
  918. nbAllowed = 0,
  919. sum = tarteaucitron.job.length,
  920. index,
  921. s = tarteaucitron.services;
  922. if (key !== "") {
  923. if (status === true) {
  924. document.getElementById(key + 'Line').classList.add('tarteaucitronIsAllowed');
  925. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsDenied');
  926. } else if (status === false) {
  927. document.getElementById(key + 'Line').classList.remove('tarteaucitronIsAllowed');
  928. document.getElementById(key + 'Line').classList.add('tarteaucitronIsDenied');
  929. }
  930. // check if all services are allowed
  931. var sumToRemove = 0;
  932. for (index = 0; index < sum; index += 1) {
  933. if (typeof s[tarteaucitron.job[index]].safeanalytic !== "undefined" && s[tarteaucitron.job[index]].safeanalytic === true) {
  934. sumToRemove += 1;
  935. continue;
  936. }
  937. if (tarteaucitron.state[tarteaucitron.job[index]] === false) {
  938. nbDenied += 1;
  939. } else if (tarteaucitron.state[tarteaucitron.job[index]] === undefined) {
  940. nbPending += 1;
  941. } else if (tarteaucitron.state[tarteaucitron.job[index]] === true) {
  942. nbAllowed += 1;
  943. }
  944. }
  945. sum -= sumToRemove;
  946. tarteaucitron.userInterface.css(c + 'DotGreen', 'width', ((100 / sum) * nbAllowed) + '%');
  947. tarteaucitron.userInterface.css(c + 'DotYellow', 'width', ((100 / sum) * nbPending) + '%');
  948. tarteaucitron.userInterface.css(c + 'DotRed', 'width', ((100 / sum) * nbDenied) + '%');
  949. if (nbDenied === 0 && nbPending === 0) {
  950. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  951. tarteaucitron.userInterface.addClass(c + 'AllAllowed', c + 'IsSelected');
  952. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsAllowed');
  953. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  954. } else if (nbAllowed === 0 && nbPending === 0) {
  955. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  956. tarteaucitron.userInterface.addClass(c + 'AllDenied', c + 'IsSelected');
  957. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  958. tarteaucitron.userInterface.addClass(c + 'MainLineOffset', c + 'IsDenied');
  959. } else {
  960. tarteaucitron.userInterface.removeClass(c + 'AllAllowed', c + 'IsSelected');
  961. tarteaucitron.userInterface.removeClass(c + 'AllDenied', c + 'IsSelected');
  962. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsAllowed');
  963. tarteaucitron.userInterface.removeClass(c + 'MainLineOffset', c + 'IsDenied');
  964. }
  965. // close the alert if all service have been reviewed
  966. if (nbPending === 0) {
  967. tarteaucitron.userInterface.closeAlert();
  968. }
  969. if (tarteaucitron.services[key].cookies.length > 0 && status === false) {
  970. tarteaucitron.cookie.purge(tarteaucitron.services[key].cookies);
  971. }
  972. if (status === true) {
  973. if (document.getElementById('tacCL' + key) !== null) {
  974. document.getElementById('tacCL' + key).innerHTML = '...';
  975. }
  976. setTimeout(function () {
  977. tarteaucitron.cookie.checkCount(key);
  978. }, 2500);
  979. } else {
  980. tarteaucitron.cookie.checkCount(key);
  981. }
  982. }
  983. // groups
  984. var cats = document.querySelectorAll('[id^="tarteaucitronServicesTitle_"]')
  985. Array.prototype.forEach.call(cats, function(item) {
  986. var cat = item.getAttribute('id').replace(/^(tarteaucitronServicesTitle_)/, ""),
  987. total = document.getElementById("tarteaucitronServices_"+cat).childElementCount;
  988. var doc = document.getElementById("tarteaucitronServices_"+cat),
  989. groupdenied = 0,
  990. groupallowed = 0;
  991. for (var ii = 0; ii < doc.children.length; ii++) {
  992. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsDenied") {
  993. groupdenied++;
  994. }
  995. if (doc.children[ii].className == "tarteaucitronLine tarteaucitronIsAllowed") {
  996. groupallowed++;
  997. }
  998. }
  999. if (total === groupallowed) {
  1000. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  1001. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  1002. }
  1003. if (total === groupdenied) {
  1004. tarteaucitron.userInterface.addClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  1005. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  1006. }
  1007. if (total !== groupdenied && total !== groupallowed) {
  1008. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsDenied');
  1009. tarteaucitron.userInterface.removeClass('tarteaucitron-group-'+cat, 'tarteaucitronIsAllowed');
  1010. }
  1011. groupdenied = 0;
  1012. groupallowed = 0;
  1013. });
  1014. },
  1015. "openPanel": function () {
  1016. "use strict";
  1017. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'block');
  1018. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1019. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  1020. document.getElementById('tarteaucitronClosePanel').focus();
  1021. document.getElementsByTagName('body')[0].classList.add('tarteaucitron-modal-open');
  1022. tarteaucitron.userInterface.focusTrap();
  1023. tarteaucitron.userInterface.jsSizing('main');
  1024. //ie compatibility
  1025. var tacOpenPanelEvent;
  1026. if(typeof(Event) === 'function') {
  1027. tacOpenPanelEvent = new Event("tac.open_panel");
  1028. }else{
  1029. tacOpenPanelEvent = document.createEvent('Event');
  1030. tacOpenPanelEvent.initEvent("tac.open_panel", true, true);
  1031. }
  1032. //end ie compatibility
  1033. window.dispatchEvent(tacOpenPanelEvent);
  1034. },
  1035. "closePanel": function () {
  1036. "use strict";
  1037. if (document.location.hash === tarteaucitron.hashtag) {
  1038. if (window.history) {
  1039. window.history.replaceState('', document.title, window.location.pathname + window.location.search);
  1040. } else {
  1041. document.location.hash = '';
  1042. }
  1043. }
  1044. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1045. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'display', 'none');
  1046. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1047. elem.style.display = 'none';
  1048. }, true);
  1049. if (tarteaucitron.reloadThePage === true) {
  1050. window.location.reload();
  1051. } else {
  1052. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1053. }
  1054. if (document.getElementById('tarteaucitronCloseAlert') !== null) {
  1055. document.getElementById('tarteaucitronCloseAlert').focus();
  1056. }
  1057. document.getElementsByTagName('body')[0].classList.remove('tarteaucitron-modal-open');
  1058. //ie compatibility
  1059. var tacClosePanelEvent;
  1060. if(typeof(Event) === 'function') {
  1061. tacClosePanelEvent = new Event("tac.close_panel");
  1062. }else{
  1063. tacClosePanelEvent = document.createEvent('Event');
  1064. tacClosePanelEvent.initEvent("tac.close_panel", true, true);
  1065. }
  1066. //end ie compatibility
  1067. window.dispatchEvent(tacClosePanelEvent);
  1068. },
  1069. "focusTrap": function() {
  1070. "use strict";
  1071. var focusableEls,
  1072. firstFocusableEl,
  1073. lastFocusableEl,
  1074. filtered;
  1075. focusableEls = document.getElementById('tarteaucitron').querySelectorAll('a[href], button');
  1076. filtered = [];
  1077. // get only visible items
  1078. for (var i = 0, max = focusableEls.length; i < max; i++) {
  1079. if (focusableEls[i].offsetHeight > 0) {
  1080. filtered.push(focusableEls[i]);
  1081. }
  1082. }
  1083. firstFocusableEl = filtered[0];
  1084. lastFocusableEl = filtered[filtered.length - 1];
  1085. //loop focus inside tarteaucitron
  1086. document.getElementById('tarteaucitron').addEventListener("keydown", function (evt) {
  1087. if ( evt.key === 'Tab' || evt.keyCode === 9 ) {
  1088. if ( evt.shiftKey ) /* shift + tab */ {
  1089. if (document.activeElement === firstFocusableEl) {
  1090. lastFocusableEl.focus();
  1091. evt.preventDefault();
  1092. }
  1093. } else /* tab */ {
  1094. if (document.activeElement === lastFocusableEl) {
  1095. firstFocusableEl.focus();
  1096. evt.preventDefault();
  1097. }
  1098. }
  1099. }
  1100. })
  1101. },
  1102. "openAlert": function () {
  1103. "use strict";
  1104. var c = 'tarteaucitron';
  1105. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'block');
  1106. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'none');
  1107. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'none');
  1108. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'block');
  1109. tarteaucitron.userInterface.addClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1110. //ie compatibility
  1111. var tacOpenAlertEvent;
  1112. if(typeof(Event) === 'function') {
  1113. tacOpenAlertEvent = new Event("tac.open_alert");
  1114. }else{
  1115. tacOpenAlertEvent = document.createEvent('Event');
  1116. tacOpenAlertEvent.initEvent("tac.open_alert", true, true);
  1117. }
  1118. //end ie compatibility
  1119. if (document.getElementById('tarteaucitronAlertBig') !== null) {
  1120. document.getElementById('tarteaucitronAlertBig').focus();
  1121. }
  1122. window.dispatchEvent(tacOpenAlertEvent);
  1123. },
  1124. "closeAlert": function () {
  1125. "use strict";
  1126. var c = 'tarteaucitron';
  1127. tarteaucitron.userInterface.css(c + 'Percentage', 'display', 'none');
  1128. tarteaucitron.userInterface.css(c + 'AlertSmall', 'display', 'block');
  1129. tarteaucitron.userInterface.css(c + 'Icon', 'display', 'block');
  1130. tarteaucitron.userInterface.css(c + 'AlertBig', 'display', 'none');
  1131. tarteaucitron.userInterface.removeClass(c + 'Root', 'tarteaucitronBeforeVisible');
  1132. tarteaucitron.userInterface.jsSizing('box');
  1133. //ie compatibility
  1134. var tacCloseAlertEvent;
  1135. if(typeof(Event) === 'function') {
  1136. tacCloseAlertEvent = new Event("tac.close_alert");
  1137. }else{
  1138. tacCloseAlertEvent = document.createEvent('Event');
  1139. tacCloseAlertEvent.initEvent("tac.close_alert", true, true);
  1140. }
  1141. //end ie compatibility
  1142. window.dispatchEvent(tacCloseAlertEvent);
  1143. },
  1144. "toggleCookiesList": function () {
  1145. "use strict";
  1146. var div = document.getElementById('tarteaucitronCookiesListContainer');
  1147. if (div === null) {
  1148. return;
  1149. }
  1150. if (div.style.display !== 'block') {
  1151. tarteaucitron.cookie.number();
  1152. div.style.display = 'block';
  1153. tarteaucitron.userInterface.jsSizing('cookie');
  1154. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1155. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'block');
  1156. tarteaucitron.fallback(['tarteaucitronInfoBox'], function (elem) {
  1157. elem.style.display = 'none';
  1158. }, true);
  1159. } else {
  1160. div.style.display = 'none';
  1161. tarteaucitron.userInterface.css('tarteaucitron', 'display', 'none');
  1162. tarteaucitron.userInterface.css('tarteaucitronBack', 'display', 'none');
  1163. }
  1164. },
  1165. "toggle": function (id, closeClass) {
  1166. "use strict";
  1167. var div = document.getElementById(id);
  1168. if (div === null) {
  1169. return;
  1170. }
  1171. if (closeClass !== undefined) {
  1172. tarteaucitron.fallback([closeClass], function (elem) {
  1173. if (elem.id !== id) {
  1174. elem.style.display = 'none';
  1175. }
  1176. }, true);
  1177. }
  1178. if (div.style.display !== 'block') {
  1179. div.style.display = 'block';
  1180. } else {
  1181. div.style.display = 'none';
  1182. }
  1183. },
  1184. "order": function (id) {
  1185. "use strict";
  1186. var main = document.getElementById('tarteaucitronServices_' + id),
  1187. allDivs,
  1188. store = [],
  1189. i;
  1190. if (main === null) {
  1191. return;
  1192. }
  1193. allDivs = main.childNodes;
  1194. if (typeof Array.prototype.map === 'function' && typeof Enumerable === 'undefined') {
  1195. Array.prototype.map.call(main.children, Object).sort(function (a, b) {
  1196. //var mainChildren = Array.from(main.children);
  1197. //mainChildren.sort(function (a, b) {
  1198. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name > tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return 1; }
  1199. if (tarteaucitron.services[a.id.replace(/Line/g, '')].name < tarteaucitron.services[b.id.replace(/Line/g, '')].name) { return -1; }
  1200. return 0;
  1201. }).forEach(function (element) {
  1202. main.appendChild(element);
  1203. });
  1204. }
  1205. },
  1206. "jsSizing": function (type) {
  1207. "use strict";
  1208. var scrollbarMarginRight = 10,
  1209. scrollbarWidthParent,
  1210. scrollbarWidthChild,
  1211. servicesHeight,
  1212. e = window,
  1213. a = 'inner',
  1214. windowInnerHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  1215. mainTop,
  1216. mainHeight,
  1217. closeButtonHeight,
  1218. headerHeight,
  1219. cookiesListHeight,
  1220. cookiesCloseHeight,
  1221. cookiesTitleHeight,
  1222. paddingBox,
  1223. alertSmallHeight,
  1224. cookiesNumberHeight;
  1225. if (type === 'box') {
  1226. if (document.getElementById('tarteaucitronAlertSmall') !== null && document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1227. // reset
  1228. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', '0px 10px');
  1229. // calculate
  1230. alertSmallHeight = document.getElementById('tarteaucitronAlertSmall').offsetHeight;
  1231. cookiesNumberHeight = document.getElementById('tarteaucitronCookiesNumber').offsetHeight;
  1232. paddingBox = (alertSmallHeight - cookiesNumberHeight) / 2;
  1233. // apply
  1234. tarteaucitron.userInterface.css('tarteaucitronCookiesNumber', 'padding', paddingBox + 'px 10px');
  1235. }
  1236. } else if (type === 'main') {
  1237. // get the real window width for media query
  1238. if (window.innerWidth === undefined) {
  1239. a = 'client';
  1240. e = document.documentElement || document.body;
  1241. }
  1242. // height of the services list container
  1243. if (document.getElementById('tarteaucitron') !== null && document.getElementById('tarteaucitronClosePanel') !== null && document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1244. // reset
  1245. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', 'auto');
  1246. // calculate
  1247. mainHeight = document.getElementById('tarteaucitron').offsetHeight;
  1248. closeButtonHeight = document.getElementById('tarteaucitronClosePanel').offsetHeight;
  1249. // apply
  1250. servicesHeight = (mainHeight - closeButtonHeight + 2);
  1251. tarteaucitron.userInterface.css('tarteaucitronServices', 'height', servicesHeight + 'px');
  1252. tarteaucitron.userInterface.css('tarteaucitronServices', 'overflow-x', 'auto');
  1253. }
  1254. // align the main allow/deny button depending on scrollbar width
  1255. if (document.getElementById('tarteaucitronServices') !== null && document.getElementById('tarteaucitronScrollbarChild') !== null) {
  1256. // media query
  1257. if (e[a + 'Width'] <= 479) {
  1258. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginLeft', '11px');
  1259. } else if (e[a + 'Width'] <= 767) {
  1260. scrollbarMarginRight = 12;
  1261. }
  1262. scrollbarWidthParent = document.getElementById('tarteaucitronServices').offsetWidth;
  1263. scrollbarWidthChild = document.getElementById('tarteaucitronScrollbarChild').offsetWidth;
  1264. //tarteaucitron.userInterface.css('tarteaucitronScrollbarAdjust', 'marginRight', ((scrollbarWidthParent - scrollbarWidthChild) + scrollbarMarginRight) + 'px');
  1265. }
  1266. // center the main panel
  1267. if (document.getElementById('tarteaucitron') !== null) {
  1268. // media query
  1269. if (e[a + 'Width'] <= 767) {
  1270. mainTop = 0;
  1271. } else {
  1272. mainTop = ((windowInnerHeight - document.getElementById('tarteaucitron').offsetHeight) / 2) - 21;
  1273. }
  1274. if (document.getElementById('tarteaucitronMainLineOffset') !== null) {
  1275. if (document.getElementById('tarteaucitron').offsetHeight < (windowInnerHeight / 2)) {
  1276. mainTop -= document.getElementById('tarteaucitronMainLineOffset').offsetHeight;
  1277. }
  1278. }
  1279. // correct
  1280. if (mainTop < 0) {
  1281. mainTop = 0;
  1282. }
  1283. // apply
  1284. tarteaucitron.userInterface.css('tarteaucitron', 'top', mainTop + 'px');
  1285. }
  1286. } else if (type === 'cookie') {
  1287. // put cookies list at bottom
  1288. if (document.getElementById('tarteaucitronAlertSmall') !== null) {
  1289. tarteaucitron.userInterface.css('tarteaucitronCookiesListContainer', 'bottom', (document.getElementById('tarteaucitronAlertSmall').offsetHeight) + 'px');
  1290. }
  1291. // height of cookies list
  1292. if (document.getElementById('tarteaucitronCookiesListContainer') !== null) {
  1293. // reset
  1294. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', 'auto');
  1295. // calculate
  1296. cookiesListHeight = document.getElementById('tarteaucitronCookiesListContainer').offsetHeight;
  1297. cookiesCloseHeight = document.getElementById('tarteaucitronClosePanelCookie').offsetHeight;
  1298. cookiesTitleHeight = document.getElementById('tarteaucitronCookiesTitle').offsetHeight;
  1299. // apply
  1300. tarteaucitron.userInterface.css('tarteaucitronCookiesList', 'height', (cookiesListHeight - cookiesCloseHeight - cookiesTitleHeight - 2) + 'px');
  1301. }
  1302. }
  1303. }
  1304. },
  1305. "cookie": {
  1306. "owner": {},
  1307. "create": function (key, status) {
  1308. "use strict";
  1309. if (tarteaucitronForceExpire !== '') {
  1310. // The number of day(s)/hour(s) can't be higher than 1 year
  1311. if ((tarteaucitronExpireInDay && tarteaucitronForceExpire < 365) || (!tarteaucitronExpireInDay && tarteaucitronForceExpire < 8760)) {
  1312. if (tarteaucitronExpireInDay) {
  1313. // Multiplication to tranform the number of days to milliseconds
  1314. timeExpire = tarteaucitronForceExpire * 86400000;
  1315. } else {
  1316. // Multiplication to tranform the number of hours to milliseconds
  1317. timeExpire = tarteaucitronForceExpire * 3600000;
  1318. }
  1319. }
  1320. }
  1321. var d = new Date(),
  1322. time = d.getTime(),
  1323. expireTime = time + timeExpire, // 365 days
  1324. regex = new RegExp("!" + key + "=(wait|true|false)", "g"),
  1325. cookie = tarteaucitron.cookie.read().replace(regex, ""),
  1326. value = tarteaucitron.parameters.cookieName + '=' + cookie + '!' + key + '=' + status,
  1327. domain = (tarteaucitron.parameters.cookieDomain !== undefined && tarteaucitron.parameters.cookieDomain !== '') ? '; domain=' + tarteaucitron.parameters.cookieDomain : '',
  1328. secure = location.protocol === 'https:' ? '; Secure' : '';
  1329. d.setTime(expireTime);
  1330. document.cookie = value + '; expires=' + d.toGMTString() + '; path=/' + domain + secure + '; samesite=lax';
  1331. },
  1332. "read": function () {
  1333. "use strict";
  1334. var nameEQ = tarteaucitron.parameters.cookieName + "=",
  1335. ca = document.cookie.split(';'),
  1336. i,
  1337. c;
  1338. for (i = 0; i < ca.length; i += 1) {
  1339. c = ca[i];
  1340. while (c.charAt(0) === ' ') {
  1341. c = c.substring(1, c.length);
  1342. }
  1343. if (c.indexOf(nameEQ) === 0) {
  1344. return c.substring(nameEQ.length, c.length);
  1345. }
  1346. }
  1347. return '';
  1348. },
  1349. "purge": function (arr) {
  1350. "use strict";
  1351. var i;
  1352. for (i = 0; i < arr.length; i += 1) {
  1353. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/;';
  1354. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname + ';';
  1355. document.cookie = arr[i] + '=; expires=Thu, 01 Jan 2000 00:00:00 GMT; path=/; domain=.' + location.hostname.split('.').slice(-2).join('.') + ';';
  1356. }
  1357. },
  1358. "checkCount": function (key) {
  1359. "use strict";
  1360. var arr = tarteaucitron.services[key].cookies,
  1361. nb = arr.length,
  1362. nbCurrent = 0,
  1363. html = '',
  1364. i,
  1365. status = document.cookie.indexOf(key + '=true');
  1366. if (status >= 0 && nb === 0) {
  1367. html += tarteaucitron.lang.useNoCookie;
  1368. } else if (status >= 0) {
  1369. for (i = 0; i < nb; i += 1) {
  1370. if (document.cookie.indexOf(arr[i] + '=') !== -1) {
  1371. nbCurrent += 1;
  1372. if (tarteaucitron.cookie.owner[arr[i]] === undefined) {
  1373. tarteaucitron.cookie.owner[arr[i]] = [];
  1374. }
  1375. if (tarteaucitron.cookie.crossIndexOf(tarteaucitron.cookie.owner[arr[i]], tarteaucitron.services[key].name) === false) {
  1376. tarteaucitron.cookie.owner[arr[i]].push(tarteaucitron.services[key].name);
  1377. }
  1378. }
  1379. }
  1380. if (nbCurrent > 0) {
  1381. html += tarteaucitron.lang.useCookieCurrent + ' ' + nbCurrent + ' cookie';
  1382. if (nbCurrent > 1) {
  1383. html += 's';
  1384. }
  1385. html += '.';
  1386. } else {
  1387. html += tarteaucitron.lang.useNoCookie;
  1388. }
  1389. } else if (nb === 0) {
  1390. html = tarteaucitron.lang.noCookie;
  1391. } else {
  1392. html += tarteaucitron.lang.useCookie + ' ' + nb + ' cookie';
  1393. if (nb > 1) {
  1394. html += 's';
  1395. }
  1396. html += '.';
  1397. }
  1398. if (document.getElementById('tacCL' + key) !== null) {
  1399. document.getElementById('tacCL' + key).innerHTML = html;
  1400. }
  1401. },
  1402. "crossIndexOf": function (arr, match) {
  1403. "use strict";
  1404. var i;
  1405. for (i = 0; i < arr.length; i += 1) {
  1406. if (arr[i] === match) {
  1407. return true;
  1408. }
  1409. }
  1410. return false;
  1411. },
  1412. "number": function () {
  1413. "use strict";
  1414. var cookies = document.cookie.split(';'),
  1415. nb = (document.cookie !== '') ? cookies.length : 0,
  1416. html = '',
  1417. i,
  1418. name,
  1419. namea,
  1420. nameb,
  1421. c,
  1422. d,
  1423. s = (nb > 1) ? 's' : '',
  1424. savedname,
  1425. regex = /^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i,
  1426. regexedDomain = (tarteaucitron.cdn.match(regex) !== null) ? tarteaucitron.cdn.match(regex)[1] : tarteaucitron.cdn,
  1427. host = (tarteaucitron.domain !== undefined) ? tarteaucitron.domain : regexedDomain;
  1428. cookies = cookies.sort(function (a, b) {
  1429. namea = a.split('=', 1).toString().replace(/ /g, '');
  1430. nameb = b.split('=', 1).toString().replace(/ /g, '');
  1431. c = (tarteaucitron.cookie.owner[namea] !== undefined) ? tarteaucitron.cookie.owner[namea] : '0';
  1432. d = (tarteaucitron.cookie.owner[nameb] !== undefined) ? tarteaucitron.cookie.owner[nameb] : '0';
  1433. if (c + a > d + b) { return 1; }
  1434. if (c + a < d + b) { return -1; }
  1435. return 0;
  1436. });
  1437. if (document.cookie !== '') {
  1438. for (i = 0; i < nb; i += 1) {
  1439. name = cookies[i].split('=', 1).toString().replace(/ /g, '');
  1440. if (tarteaucitron.cookie.owner[name] !== undefined && tarteaucitron.cookie.owner[name].join(' // ') !== savedname) {
  1441. savedname = tarteaucitron.cookie.owner[name].join(' // ');
  1442. html += '<div class="tarteaucitronHidden">';
  1443. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1444. html += ' ' + tarteaucitron.cookie.owner[name].join(' // ');
  1445. html += ' </span>';
  1446. html += '</div><ul class="cookie-list">';
  1447. } else if (tarteaucitron.cookie.owner[name] === undefined && host !== savedname) {
  1448. savedname = host;
  1449. html += '<div class="tarteaucitronHidden">';
  1450. html += ' <span class="tarteaucitronTitle tarteaucitronH3" role="heading" aria-level="3">';
  1451. html += ' ' + host;
  1452. html += ' </span>';
  1453. html += '</div><ul class="cookie-list">';
  1454. }
  1455. html += '<li class="tarteaucitronCookiesListMain">';
  1456. html += ' <div class="tarteaucitronCookiesListLeft"><button type="button" class="purgeBtn" data-cookie="' + tarteaucitron.fixSelfXSS(cookies[i].split('=', 1)) + '"><strong>&times;</strong></button> <strong>' + tarteaucitron.fixSelfXSS(name) + '</strong>';
  1457. html += ' </div>';
  1458. html += ' <div class="tarteaucitronCookiesListRight">' + tarteaucitron.fixSelfXSS(cookies[i].split('=').slice(1).join('=')) + '</div>';
  1459. html += '</li>';
  1460. }
  1461. html += '</ul>';
  1462. } else {
  1463. html += '<div class="tarteaucitronCookiesListMain">';
  1464. html += ' <div class="tarteaucitronCookiesListLeft"><strong>-</strong></div>';
  1465. html += ' <div class="tarteaucitronCookiesListRight"></div>';
  1466. html += '</div>';
  1467. }
  1468. html += '<div class="tarteaucitronHidden tarteaucitron-spacer-20"></div>';
  1469. if (document.getElementById('tarteaucitronCookiesList') !== null) {
  1470. document.getElementById('tarteaucitronCookiesList').innerHTML = html;
  1471. }
  1472. if (document.getElementById('tarteaucitronCookiesNumber') !== null) {
  1473. document.getElementById('tarteaucitronCookiesNumber').innerHTML = nb;
  1474. }
  1475. if (document.getElementById('tarteaucitronCookiesNumberBis') !== null) {
  1476. document.getElementById('tarteaucitronCookiesNumberBis').innerHTML = nb + ' cookie' + s;
  1477. }
  1478. var purgeBtns = document.getElementsByClassName("purgeBtn");
  1479. for (i = 0; i < purgeBtns.length; i++) {
  1480. tarteaucitron.addClickEventToElement(purgeBtns[i], function () {
  1481. tarteaucitron.cookie.purge([this.dataset.cookie]);
  1482. tarteaucitron.cookie.number();
  1483. tarteaucitron.userInterface.jsSizing('cookie');
  1484. return false;
  1485. });
  1486. }
  1487. for (i = 0; i < tarteaucitron.job.length; i += 1) {
  1488. tarteaucitron.cookie.checkCount(tarteaucitron.job[i]);
  1489. }
  1490. }
  1491. },
  1492. "fixSelfXSS": function(html) {
  1493. return html.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
  1494. },
  1495. "getLanguage": function () {
  1496. "use strict";
  1497. var availableLanguages = 'bg,ca,cn,cs,da,de,el,en,es,fi,fr,hu,it,ja,lv,nl,no,oc,pl,pt,ro,ru,se,sk,sv,tr,vi,zh',
  1498. defaultLanguage = 'en';
  1499. if (tarteaucitronForceLanguage !== '') {
  1500. if (availableLanguages.indexOf(tarteaucitronForceLanguage) !== -1) {
  1501. return tarteaucitronForceLanguage;
  1502. }
  1503. }
  1504. if (!navigator) { return 'en'; }
  1505. var lang = navigator.language || navigator.browserLanguage ||
  1506. navigator.systemLanguage || navigator.userLang || null,
  1507. userLanguage = lang ? lang.substr(0, 2) : null;
  1508. if (availableLanguages.indexOf(userLanguage) === -1) {
  1509. return defaultLanguage;
  1510. }
  1511. return userLanguage;
  1512. },
  1513. "getLocale": function () {
  1514. "use strict";
  1515. if (!navigator) { return 'en_US'; }
  1516. var lang = navigator.language || navigator.browserLanguage ||
  1517. navigator.systemLanguage || navigator.userLang || null,
  1518. userLanguage = lang ? lang.substr(0, 2) : null;
  1519. if (userLanguage === 'fr') {
  1520. return 'fr_FR';
  1521. } else if (userLanguage === 'en') {
  1522. return 'en_US';
  1523. } else if (userLanguage === 'de') {
  1524. return 'de_DE';
  1525. } else if (userLanguage === 'es') {
  1526. return 'es_ES';
  1527. } else if (userLanguage === 'it') {
  1528. return 'it_IT';
  1529. } else if (userLanguage === 'pt') {
  1530. return 'pt_PT';
  1531. } else if (userLanguage === 'nl') {
  1532. return 'nl_NL';
  1533. } else if (userLanguage === 'el') {
  1534. return 'el_EL';
  1535. } else {
  1536. return 'en_US';
  1537. }
  1538. },
  1539. "addScript": function (url, id, callback, execute, attrName, attrVal, internal) {
  1540. "use strict";
  1541. var script,
  1542. done = false;
  1543. if (execute === false) {
  1544. if (typeof callback === 'function') {
  1545. callback();
  1546. }
  1547. } else {
  1548. script = document.createElement('script');
  1549. script.id = (id !== undefined) ? id : '';
  1550. script.async = true;
  1551. script.src = url;
  1552. if (attrName !== undefined && attrVal !== undefined) {
  1553. script.setAttribute(attrName, attrVal);
  1554. }
  1555. if (typeof callback === 'function') {
  1556. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1557. script.onreadystatechange = script.onload = function () {
  1558. var state = script.readyState;
  1559. if (!done && (!state || /loaded|complete/.test(state))) {
  1560. done = true;
  1561. callback();
  1562. }
  1563. };
  1564. } else {
  1565. callback();
  1566. }
  1567. }
  1568. if ( !tarteaucitron.parameters.useExternalJs || !internal ) {
  1569. document.getElementsByTagName('head')[0].appendChild(script);
  1570. }
  1571. }
  1572. },
  1573. "addInternalScript": function (url, id, callback, execute, attrName, attrVal) {
  1574. tarteaucitron.addScript(url, id, callback, execute, attrName, attrVal, true);
  1575. },
  1576. "makeAsync": {
  1577. "antiGhost": 0,
  1578. "buffer": '',
  1579. "init": function (url, id) {
  1580. "use strict";
  1581. var savedWrite = document.write,
  1582. savedWriteln = document.writeln;
  1583. document.write = function (content) {
  1584. tarteaucitron.makeAsync.buffer += content;
  1585. };
  1586. document.writeln = function (content) {
  1587. tarteaucitron.makeAsync.buffer += content.concat("\n");
  1588. };
  1589. setTimeout(function () {
  1590. document.write = savedWrite;
  1591. document.writeln = savedWriteln;
  1592. }, 20000);
  1593. tarteaucitron.makeAsync.getAndParse(url, id);
  1594. },
  1595. "getAndParse": function (url, id) {
  1596. "use strict";
  1597. if (tarteaucitron.makeAsync.antiGhost > 9) {
  1598. tarteaucitron.makeAsync.antiGhost = 0;
  1599. return;
  1600. }
  1601. tarteaucitron.makeAsync.antiGhost += 1;
  1602. tarteaucitron.addInternalScript(url, '', function () {
  1603. if (document.getElementById(id) !== null) {
  1604. document.getElementById(id).innerHTML += "<span class='tarteaucitron-display-none'>&nbsp;</span>" + tarteaucitron.makeAsync.buffer;
  1605. tarteaucitron.makeAsync.buffer = '';
  1606. tarteaucitron.makeAsync.execJS(id);
  1607. }
  1608. });
  1609. },
  1610. "execJS": function (id) {
  1611. /* not strict because third party scripts may have errors */
  1612. var i,
  1613. scripts,
  1614. childId,
  1615. type;
  1616. if (document.getElementById(id) === null) {
  1617. return;
  1618. }
  1619. scripts = document.getElementById(id).getElementsByTagName('script');
  1620. for (i = 0; i < scripts.length; i += 1) {
  1621. type = (scripts[i].getAttribute('type') !== null) ? scripts[i].getAttribute('type') : '';
  1622. if (type === '') {
  1623. type = (scripts[i].getAttribute('language') !== null) ? scripts[i].getAttribute('language') : '';
  1624. }
  1625. if (scripts[i].getAttribute('src') !== null && scripts[i].getAttribute('src') !== '') {
  1626. childId = id + Math.floor(Math.random() * 99999999999);
  1627. document.getElementById(id).innerHTML += '<div id="' + childId + '"></div>';
  1628. tarteaucitron.makeAsync.getAndParse(scripts[i].getAttribute('src'), childId);
  1629. } else if (type.indexOf('javascript') !== -1 || type === '') {
  1630. eval(scripts[i].innerHTML);
  1631. }
  1632. }
  1633. }
  1634. },
  1635. "fallback": function (matchClass, content, noInner) {
  1636. "use strict";
  1637. var elems = document.getElementsByTagName('*'),
  1638. i,
  1639. index = 0;
  1640. for (i in elems) {
  1641. if (elems[i] !== undefined) {
  1642. for (index = 0; index < matchClass.length; index += 1) {
  1643. if ((' ' + elems[i].className + ' ')
  1644. .indexOf(' ' + matchClass[index] + ' ') > -1) {
  1645. if (typeof content === 'function') {
  1646. if (noInner === true) {
  1647. content(elems[i]);
  1648. } else {
  1649. elems[i].innerHTML = content(elems[i]);
  1650. }
  1651. } else {
  1652. elems[i].innerHTML = content;
  1653. }
  1654. }
  1655. }
  1656. }
  1657. }
  1658. },
  1659. "engage": function (id) {
  1660. "use strict";
  1661. var html = '',
  1662. r = Math.floor(Math.random() * 100000),
  1663. engage = tarteaucitron.services[id].name + ' ' + tarteaucitron.lang.fallback;
  1664. if (tarteaucitron.lang['engage-' + id] !== undefined) {
  1665. engage = tarteaucitron.lang['engage-' + id];
  1666. }
  1667. html += '<div class="tac_activate tac_activate_' + id + '">';
  1668. html += ' <div class="tac_float">';
  1669. html += ' ' + engage;
  1670. html += ' <button type="button" class="tarteaucitronAllow" id="Eng' + r + 'ed' + id + '">';
  1671. html += ' <span class="tarteaucitronCheck"></span> ' + tarteaucitron.lang.allow;
  1672. html += ' </button>';
  1673. html += ' </div>';
  1674. html += '</div>';
  1675. return html;
  1676. },
  1677. "extend": function (a, b) {
  1678. "use strict";
  1679. var prop;
  1680. for (prop in b) {
  1681. if (b.hasOwnProperty(prop)) {
  1682. a[prop] = b[prop];
  1683. }
  1684. }
  1685. },
  1686. "proTemp": '',
  1687. "proTimer": function () {
  1688. "use strict";
  1689. setTimeout(tarteaucitron.proPing, 500);
  1690. },
  1691. "pro": function (list) {
  1692. "use strict";
  1693. tarteaucitron.proTemp += list;
  1694. clearTimeout(tarteaucitron.proTimer);
  1695. tarteaucitron.proTimer = setTimeout(tarteaucitron.proPing, 500);
  1696. },
  1697. "proPing": function () {
  1698. "use strict";
  1699. if (tarteaucitron.uuid !== '' && tarteaucitron.uuid !== undefined && tarteaucitron.proTemp !== '') {
  1700. var div = document.getElementById('tarteaucitronPremium'),
  1701. timestamp = new Date().getTime(),
  1702. url = 'https://tarteaucitron.io/log/?';
  1703. if (div === null) {
  1704. return;
  1705. }
  1706. url += 'account=' + tarteaucitron.uuid + '&';
  1707. url += 'domain=' + tarteaucitron.domain + '&';
  1708. url += 'status=' + encodeURIComponent(tarteaucitron.proTemp) + '&';
  1709. url += '_time=' + timestamp;
  1710. div.innerHTML = '<img src="' + url + '" class="tarteaucitron-display-none" alt="" />';
  1711. tarteaucitron.proTemp = '';
  1712. }
  1713. tarteaucitron.cookie.number();
  1714. },
  1715. "AddOrUpdate" : function(source, custom){
  1716. /**
  1717. Utility function to Add or update the fields of obj1 with the ones in obj2
  1718. */
  1719. var key;
  1720. for(key in custom){
  1721. if(custom[key] instanceof Object){
  1722. source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
  1723. }else{
  1724. source[key] = custom[key];
  1725. }
  1726. }
  1727. return source;
  1728. },
  1729. "getElemWidth": function(elem) {
  1730. return elem.getAttribute('width') || elem.clientWidth;
  1731. },
  1732. "getElemHeight": function(elem) {
  1733. return elem.getAttribute('height') || elem.clientHeight;
  1734. },
  1735. "addClickEventToId": function (elemId, func) {
  1736. tarteaucitron.addClickEventToElement(document.getElementById(elemId), func);
  1737. },
  1738. "addClickEventToElement": function (e, func) {
  1739. if (e) {
  1740. if (e.addEventListener) {
  1741. e.addEventListener("click", func);
  1742. } else {
  1743. e.attachEvent("onclick", func);
  1744. }
  1745. }
  1746. },
  1747. "triggerJobsAfterAjaxCall": function() {
  1748. tarteaucitron.job.forEach(function(e) { tarteaucitron.job.push(e) });
  1749. var i;
  1750. var allowBtns = document.getElementsByClassName("tarteaucitronAllow");
  1751. for (i = 0; i < allowBtns.length; i++) {
  1752. tarteaucitron.addClickEventToElement(allowBtns[i], function () {
  1753. tarteaucitron.userInterface.respond(this, true);
  1754. });
  1755. }
  1756. var denyBtns = document.getElementsByClassName("tarteaucitronDeny");
  1757. for (i = 0; i < denyBtns.length; i++) {
  1758. tarteaucitron.addClickEventToElement(denyBtns[i], function () {
  1759. tarteaucitron.userInterface.respond(this, false);
  1760. });
  1761. }
  1762. }
  1763. };