PageSourceSearch

https://www.hfsp.org/modules/custom/hfsp_rgpd/js/hfsp_rgpd_tarteaucitron_init.js?v=1.2

js hfsp.org collected 2026-09-24 08:40:19 UTC 5,126 bytes, 163 lines download raw bytes

1/**
2 * @file
3 * HFSP RGPD Tarteaucitron initializing script.
4 */
5
6(function ($, Drupal) {
7
8  'use strict';
9
10  // Store videos.
11  var hfsp_rgpd_videos = [];
12
13  /**
14   * Initialize Tarteaucitron lib.
15   */
16  Drupal.behaviors.hfsp_rgpd_tarteaucitron_init = {
17    attach: function (context, settings) {
18      this.addServices(settings);
19      this.initialize(settings);
20    },
21
22    // Custom function for hidding youtube videos if consent was not given.
23    youtubeProcess: function (status, context) {
24      // Default context.
25      if (typeof context === 'undefined') {
26        context = $('body');
27      }
28
29      // Hide videos to avoid cookies definition.
30      $('.video-embed-field-provider-youtube', context).each(function() {
31        const video = $(this);
32        if (!status) {
33          // Hide video to avoid cookies definition.
34          const content = $(video).html();
35
36          // Generate an unique ID and add it to the video.
37          const videoId = hfspGenerateUniqueCssClass('hfsp-rgpd-video--');
38          $(video).attr('id', videoId);
39
40          // Store previous video content.
41          hfsp_rgpd_videos[videoId] = content;
42
43          // Insert the RGPD disabled notice.
44          $(video).html(tarteaucitron.engage('youtube')).addClass('rgpd-disabled');
45        } else {
46          // Display video (again).
47          const videoId = $(video).attr('id');
48          if (videoId !== 'undefined' && hfsp_rgpd_videos[videoId] !== 'undefined') {
49            $(video).html(hfsp_rgpd_videos[videoId]).removeClass('rgpd-disabled');
50          }
51        }
52      });
53    },
54
55    /**
56     * Add custom services for Tarteaucitron.
57     *
58     * @param settings
59     */
60    addServices: function (settings) {
61      tarteaucitron.services.youtube = {
62        "key": "youtube",
63        "type": "video",
64        "name": "YouTube",
65        "uri": "https://www.google.com/intl/en/policies/privacy/",
66        "needConsent": true,
67        "cookies": ['VISITOR_INFO1_LIVE', 'YSC', 'PREF', 'GEUP'],
68        "js": function () {
69          Drupal.behaviors.hfsp_rgpd_tarteaucitron_init.youtubeProcess(true);
70        },
71        "fallback": function () {
72          Drupal.behaviors.hfsp_rgpd_tarteaucitron_init.youtubeProcess(false);
73        }
74      };
75    },
76
77    /**
78     * Initialize the Tarteaucitron plugin.
79     *
80     * @param settings
81     */
82    initialize: function(settings) {
83      const cookies = tarteaucitron.cookie.read();
84
85      // Define text language.
86      window.tarteaucitronForceLanguage = settings.hfsp_rgpd.language;
87
88      // Customize header text.
89      window.tarteaucitronCustomText = {
90        'disclaimer': settings.hfsp_rgpd.popup_header,
91        'alertBigPrivacy': settings.hfsp_rgpd.popup_short
92      };
93
94      // Customize expiration of 6 months.
95      window.tarteaucitronForceExpire = 182;
96      window.tarteaucitronExpireInDay = true;
97
98      // Initialize.
99      tarteaucitron.init({
100        "privacyUrl": settings.hfsp_rgpd.privacy_policy_url,
101        "cookiesUrl": settings.hfsp_rgpd.cookies_policy_url,
102        "hashtag": "#cookies-control",
103        "cookieName": "hfsp-cookie-control",
104
105        "orientation": "bottom",
106        "showAlertSmall": false,
107        "cookieslist": false,
108
109        "showIcon": true,
110        "iconPosition": "BottomRight",
111        "adblocker": false,
112
113        "DenyAllCta" : true,
114        "AcceptAllCta" : true,
115        "highPrivacy": true,
116        "handleBrowserDNTRequest": false,
117
118        "removeCredit": false,
119        "moreInfoLink": true,
120        "useExternalCss": false,
121        "useExternalJs": false,
122
123        "mandatory": true,
124      });
125
126      // Add Matomo service.
127      if (settings.hfsp_rgpd.matomo_identifier && settings.hfsp_rgpd.matomo_url) {
128        tarteaucitron.user.matomoId = settings.hfsp_rgpd.matomo_identifier;
129        (tarteaucitron.job = tarteaucitron.job || []).push('matomocloud');
130        tarteaucitron.user.matomoHost = settings.hfsp_rgpd.matomo_url;
131      }
132
133      // Add Matomo tag manager service.
134      if (settings.hfsp_rgpd.matomo_tag_manager_url) {
135        tarteaucitron.user.matomotmUrl = settings.hfsp_rgpd.matomo_tag_manager_url;
136        (tarteaucitron.job = tarteaucitron.job || []).push('matomotm');
137      }
138
139      // Add Google Analytics service.
140      if (settings.hfsp_rgpd.google_analytics_identifier) {
141        tarteaucitron.user.gajsUa = settings.hfsp_rgpd.google_analytics_identifier;
142        (tarteaucitron.job = tarteaucitron.job || []).push('gajs');
143      }
144
145      // Add Google tag manager service.
146      if (settings.hfsp_rgpd.google_tag_manager_identifier) {
147        tarteaucitron.user.googletagmanagerId = settings.hfsp_rgpd.google_tag_manager_identifier;
148        (tarteaucitron.job = tarteaucitron.job || []).push('googletagmanager');
149      }
150
151      // Add Youtube service.
152      if (settings.hfsp_rgpd.youtube_enable) {
153        (tarteaucitron.job = tarteaucitron.job || []).push('youtube');
154      }
155
156      // Add reCaptcha service.
157      if (settings.hfsp_rgpd.google_recaptcha_api_key) {
158        (tarteaucitron.job = tarteaucitron.job || []).push('recaptcha');
159      }
160    }
161  };
162
163})(jQuery, Drupal);

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.