tarteaucitron.js 76 KB

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