PageSourceSearch

https://www.iddri.org/themes/custom/iddri/js/tacjs.js?tm84gb

js iddri.org collected 2026-10-01 10:21:31 UTC 4,792 bytes, 137 lines download raw bytes

1/**
2 * @file
3 * Init tarteaucitron.js script.
4 */
5
6(function (Drupal, drupalSettings, tarteaucitron) {
7  /**
8   * Init tarteaucitron.js script.
9   *
10   * @type {Drupal~behavior}
11   *
12   * @prop {Drupal~behaviorAttach} attach
13   *   Attaches the script.
14   */
15  Drupal.behaviors.tacjs = {
16    attach: function attach() {
17      // Add custom texts to tarteaucitron.
18      tarteaucitronCustomText = drupalSettings.tacjs.texts;
19
20      // Set expiration time in day(s)
21      if (drupalSettings.tacjs.expire) {
22        window.tarteaucitronExpireInDay = true;
23        window.tarteaucitronForceExpire = drupalSettings.tacjs.expire;
24      }
25
26      if (drupalSettings.tacjs.user) {
27        // Workaround for #3120915: convert multiplegtagUa into a Array
28        // See https://github.com/AmauriC/tarteaucitron.js/pull/394
29        if (
30          drupalSettings.tacjs.user.multiplegtagUa &&
31          typeof drupalSettings.tacjs.user.multiplegtagUa === "string"
32        )
33          drupalSettings.tacjs.user.multiplegtagUa =
34            drupalSettings.tacjs.user.multiplegtagUa.split(", ");
35
36        // Workaround for #3204238: convert googleFonts into a Array
37        // See https://www.drupal.org/project/tacjs/issues/3204238
38        if (
39          drupalSettings.tacjs.user.googleFonts &&
40          typeof drupalSettings.tacjs.user.googleFonts === "string"
41        )
42          drupalSettings.tacjs.user.googleFonts =
43            drupalSettings.tacjs.user.googleFonts.split(", ");
44
45        // Add consent to tarteaucitron services.
46        Object.keys(drupalSettings.tacjs.services).forEach(function (service) {
47          if (
48            drupalSettings.tacjs.services[service].status &&
49            drupalSettings.tacjs.services[service].needConsent !== undefined
50          ) {
51            tarteaucitron.services[service].needConsent =
52              drupalSettings.tacjs.services[service].needConsent;
53          }
54        });
55
56        // Add users identification to tarteaucitron.
57        tarteaucitron.user = drupalSettings.tacjs.user;
58      }
59
60      // Add enabled services to tarteaucitron services.
61      Object.keys(drupalSettings.tacjs.services)
62        .filter(function (service) {
63          // Filter enabled services.
64          return drupalSettings.tacjs.services[service].status;
65        })
66        .forEach(function (service) {
67          (tarteaucitron.job = tarteaucitron.job || []).push(service);
68        });
69
70      // IDDRI Custom
71      // generic iframe
72      tarteaucitron.services.googlemapsiframe = {
73        key: "googlemapsiframe",
74        type: "other",
75        name: "Google Maps",
76        uri: "https://policies.google.com/privacy",
77        needConsent: true,
78        cookies: [],
79        js: function () {
80          "use strict";
81          tarteaucitron.fallback(["tac_googlemapsiframe"], function (x) {
82            var width = x.getAttribute("width"),
83              height = x.getAttribute("height"),
84              url = x.getAttribute("data-url");
85
86            return (
87              '<iframe src="' +
88              url +
89              '" width="' +
90              width +
91              '" height="' +
92              height +
93              '" frameborder="0" scrolling="no" allowtransparency allowfullscreen></iframe>'
94            );
95          });
96        },
97        fallback: function () {
98          "use strict";
99          var id = "googlemapsiframe";
100          tarteaucitron.fallback(["tac_googlemapsiframe"], function (elem) {
101            elem.style.width = elem.getAttribute("width") + "px";
102            elem.style.height = elem.getAttribute("height") + "px";
103            return tarteaucitron.engage(id);
104          });
105        },
106      };
107
108      (tarteaucitron.job = tarteaucitron.job || []).push("googlemapsiframe");
109      tarteaucitron.user.analyticsAnonymizeIp = true;
110      tarteaucitron.user.analyticsUaCreate = {
111        cookieDomain: "auto",
112        allowLinker: true,
113      };
114      tarteaucitron.user.analyticsPrepare = function () {
115        ga("require", "linker");
116        ga("linker:autoLink", ["www.iddri.org"]);
117      };
118
119      // Bridge Drupal reCAPTCHA ↔ tarteaucitron.
120      // TAC clears .g-recaptcha then loads api.js with onload=tacRecaptchaOnLoad.
121      // Without this bridge the widget stays empty after consent.
122      tarteaucitron.user.recaptchaapi = "explicit";
123      tarteaucitron.user.recaptchaOnLoad = function () {
124        if (typeof window.jQuery === "undefined") {
125          return;
126        }
127        window.jQuery(".g-recaptcha").removeClass("recaptcha-processed");
128        if (typeof window.drupalRecaptchaOnload === "function") {
129          window.drupalRecaptchaOnload();
130        }
131      };
132
133      // Initiate tarteaucitron
134      tarteaucitron.init(drupalSettings.tacjs.dialog);
135    },
136  };
137})(Drupal, drupalSettings, tarteaucitron);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.