PageSourceSearch

https://safety-work.org/typo3conf/ext/we_cookie_consent/Resources/…/JavaScript/Controller/ConsentController.js

js safety-work.org collected 2026-10-02 07:59:45 UTC 4,185 bytes, 114 lines download raw bytes

1// Consent class
2let ConsentApp = new function ConsentController() {
3    //-- global variables ---
4    window.dataLayer = window.dataLayer || [];
5
6    //--- public functions ---
7    /**
8     * Callback function for GoogleTagManager Script to fire the dataLayer trigger
9     * @param bool state
10     * @param object service
11     */
12    this.consentChanged = function (state, service) {
13        if (state === true) {
14            if (service.name.indexOf('google-tagmanager-service') !== -1) {
15                let tempObj = {
16                    event: service.gtm.trigger
17                };
18                tempObj[service.gtm.variable] = true;
19                window.dataLayer.push(tempObj);
20
21                /*
22                //ES6 - https://stackoverflow.com/questions/11508463/javascript-set-object-key-by-variable
23                window.dataLayer.push({
24                    event: service.name,
25                    [service.name]: true
26                });
27                */
28            }
29        } else if (state === false) {
30            if (service.name.indexOf('google-tagmanager-service') !== -1) {
31                let tempObj = {
32                    //event: service.gtm.trigger
33                    event: service.gtm.trigger
34                };
35                tempObj[service.gtm.variable] = false;
36                window.dataLayer.push(tempObj);
37            }
38        }
39    
40        //Check if the own callback function is allready defined
41        if (typeof window[service.ownCallback] === "function") {
42            window[service.ownCallback](state, service);
43        } else if (service.ownCallback !== '') {
44            console.error('The Callback function ' + service.ownCallback + ' is not yet defined. Please create it first.');
45        }
46    };
47
48    //--- constructor ---
49    (function contruct() {
50        $(document).ready(function () {
51            //Listener for the button on the privacy page, to edit the consent
52            $(document).on('click', '.js-showConsentModal', function (event) {
53                event.preventDefault();
54                klaro.show();
55            });
56        });
57    })();
58
59    // v2.2.1 - safari -gf20220517
60    const isSafari = navigator.vendor && 
61           navigator.vendor.indexOf('Apple') > -1 &&
62           navigator.userAgent &&
63           navigator.userAgent.indexOf('CriOS') == -1 &&
64           navigator.userAgent.indexOf('FxiOS') == -1;
65
66    $(function() {
67      setTimeout(function() {
68        // console.log("isSafari? ("+isSafari+")");
69        if (isSafari!=true) {
70          $('#klaro').removeClass('safari');
71          // $('#klaro').addClass('no-safari');
72        } else { 
73          $('#klaro').addClass('safari'); 
74          // $('#klaro').removeClass('no-safari');
75        }
76      })
77    });
78    // v2.2.1 - safari -gf20220517 END.
79};
80
81//--- Functions after window.load(): ---
82$(function() {
83		if($('iframe').length>0) {
84				var counterOfIframe = 0;
85				var attrDataSrc;
86				$('iframe').each(function() {
87						attrDataSrc=$(this).attr('src'); 
88						if (!attrDataSrc) {
89								attrDataSrc=$(this).attr('data-src'); 
90						}
91						if (attrDataSrc && ( attrDataSrc.indexOf("youtu") > -1 || attrDataSrc.indexOf("vimeo") > -1 )) {
92								/* Adjust measures for videoOverlay similar to iframe: */
93								$(this).parent().find('.klaro.cm-as-context-notice').css({'width':$(this).width()});
94								// $(this).parent().find('.klaro.cm-as-context-notice').css({'height':'100%'});  // Activate if height isn't set to 100% by css.
95								if ($(this).height() < $(this).parent().find('.klaro.cm-as-context-notice').height()) {
96										$(this).parent().find('.klaro.cm-as-context-notice .cm-buttons').css('margin-top','1em');
97								}
98						}
99						counterOfIframe++;
100				});
101		}
102
103    /**   Add class for small context-notice box  gf20211115 **/
104		$('.klaro.we_cookie_consent.cm-as-context-notice').each(function() {
105				if ($(this).width() <= 300) {
106						$(this).addClass('notice--minified');
107				}
108		});
109    
110    /** Add class to avoid Google to crawl consent info text  gf20220623 **/
111    $('.klaro.we_cookie_consent .cn-body').each(function() {
112      $(this).attr('data-nosnippet','data-nosnippet');
113    });
114});

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.