tarteaucitron.js 77 KB

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