PageSourceSearch

https://skoven-i-skolen.dk/modules/contrib/cookiebot/js/cookiebot.js?tfdu59

js skoven-i-skolen.dk collected 2026-10-02 11:19:39 UTC 5,085 bytes, 151 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7
8(function ($, Drupal, cookies, once) {
9  'use strict';
10
11  var $window = $(window);
12  var renewConsentTriggerEventName = 'cookiebotConsentRenew';
13
14  /**
15   * Capitalize the first character of a given string.
16   *
17   * @param {string} string
18   *   The string to capitalize the first character of.
19   *
20   * @return {string}
21   *   The string with the first letter capitalized.
22   */
23  var capitalizeFirstCharacter = function (string) {
24    return string[0].toUpperCase() + string.substring(1);
25  };
26
27  /**
28   * Listens to event of a user accepting the use of cookies.
29   *
30   * This is also called on every page load when cookies are already accepted.
31   */
32  $window.on('CookiebotOnAccept', function () {
33    Drupal.cookiebot.updateCookies();
34  });
35
36  /**
37   * Listens to the event of a user declining the use of cookies.
38   *
39   * This is also called on every page load when cookies are already declined.
40   */
41  $window.on('CookiebotOnDecline', function () {
42    Drupal.cookiebot.updateCookies();
43  });
44
45  /**
46   * Listens to event of a user wanting to change their cookies consent.
47   */
48  $window.on(renewConsentTriggerEventName, function () {
49    if (typeof Cookiebot === 'undefined') {
50      return;
51    }
52
53    Cookiebot.renew();
54  });
55
56  /**
57   * jQuery document ready handler.
58   */
59  jQuery(function () {
60    /*
61      See: https://www.drupal.org/project/cookiebot/issues/3091260
62
63      This part is only required when auto-blocking functionality is enabled
64      data-blockingmode="auto" (https://www.cookiebot.com/en/developer/).
65
66      If that mode is enabled, all scripts are deferred and Drupals
67      attachBehaviors is not executed in any <scripts> element, Cookiebots
68      auto-blocking relies on jQuery
69      https://www.lullabot.com/articles/understanding-javascript-behaviors-in-drupal
70    */
71    if(typeof Drupal.cookiebot !== 'undefined' && !Drupal.cookiebot.attachedBehaviorsInAutoBlockingmode){
72      Drupal.attachBehaviors(document, Drupal.settings);
73      // Set global variable to only execute once on page load
74      Drupal.cookiebot.attachedBehaviorsInAutoBlockingmode = true;
75    }
76  });
77
78
79  /**
80   * Attach Cookiebot renew click event listener.
81   *
82   * @type {Drupal~behavior}
83   */
84  Drupal.behaviors.cookiebot = {
85    attach: function attach(context) {
86      Drupal.cookiebot.updateCookies(context);
87
88      $('.cookiebot-renew', context).on('click', (event) => {
89        event.preventDefault();
90        $window.trigger(renewConsentTriggerEventName);
91      });
92    }
93  };
94
95  /**
96   * Updates cookies for Cookiebot.
97   *
98   * We set our own cookies to be able to provide integration with other Drupal
99   * modules, without relying on the cookies of Cookiebot, since those are not
100   * part of the public API.
101   */
102  Drupal.cookiebot = {
103    attachedBehaviorsInAutoBlockingmode: false,
104    updateCookies: function updateCookies(context) {
105      var cookieNames = [
106        'necessary',
107        'preferences',
108        'statistics',
109        'marketing'
110      ];
111
112      // Set global variable to only execute once on page load
113      if (context === document) {
114        Drupal.cookiebot.attachedBehaviorsInAutoBlockingmode = true;
115      }
116
117      if (typeof Cookiebot === 'undefined' || Cookiebot.consent === void (0)) {
118        return;
119      }
120
121      $.each(cookieNames, function (index, cookieName) {
122        if (Cookiebot.consent[cookieName] === true && cookies.get('cookiebot-consent--' + cookieName) !== '1') {
123          cookies.set('cookiebot-consent--' + cookieName, '1', JSON.stringify({
124            path: '/'
125          }));
126          $window.trigger('cookiebotConsentAccept' + capitalizeFirstCharacter(cookieName));
127          return;
128        }
129
130        if (Cookiebot.consent[cookieName] === false && cookies.get('cookiebot-consent--' + cookieName) !== '0') {
131          cookies.set('cookiebot-consent--' + cookieName, '0', JSON.stringify({
132            path: '/'
133          }));
134          $window.trigger('cookiebotConsentDecline' + capitalizeFirstCharacter(cookieName));
135        }
136      });
137
138      if (drupalSettings.cookiebot.message_placeholder_cookieconsent_optout_marketing_show && drupalSettings.cookiebot.message_placeholder_cookieconsent_optout_marketing.length > 0) {
139        var message_placeholder_cookieconsent_optout_marketing = drupalSettings.cookiebot.message_placeholder_cookieconsent_optout_marketing.replace('!cookiebot_renew', 'javascript:Cookiebot.renew()');
140        $('[data-cookieconsent="marketing"][data-src]').each(function () {
141          var cookiebot_from_src_url = '';
142          if ($(this).attr('data-src').length) {
143            cookiebot_from_src_url = $(this).attr('data-src');
144          }
145          $(once('cb-message-placeholder-cookieconsent-optout-marketing', this)).after(message_placeholder_cookieconsent_optout_marketing.replace(new RegExp('!cookiebot_from_src_url', 'g'), cookiebot_from_src_url));
146        });
147      }
148    }
149  };
150
151})(jQuery, Drupal, window.Cookies, once);

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.