tarteaucitron.js 74 KB

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