1/* DOKUWIKI:include jquery.cookiebar.js */
2
3jQuery(function(){(function($) {
4    /** wrapping GA functions */
5    window.ga = function () {
6        if ('show' != JSINFO.ACT) {
7            return;
8        }
9
10        if (typeof window.gtag === 'function' && arguments[0] === 'send' && arguments[1] === 'event') {
11            window.gtag('event', arguments[3], {
12                event_category: arguments[2],
13                event_label: arguments[4],
14            });
15        }
16    };
17
18    if ('show' != JSINFO.ACT) {
19        return;
20    }
21
22    var consentGiven = function ( cookieValue ) {
23        cookieValue == 'accepted' && typeof window.gtag === 'function' && gtag('consent', 'update', {
24            ad_user_data: 'granted',
25            ad_personalization: 'granted',
26            ad_storage: 'granted',
27            analytics_storage: 'granted'
28        });
29
30        (function (w, d, s, l, i) {
31            w[l] = w[l] || []; w[l].push({'gtm.start':new Date().getTime(), event: 'gtm.js'});
32            var f = d.getElementsByTagName(s)[0],
33            j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true;
34            j.src = '//www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
35        })(window, document, 'script', 'dataLayer', window.dataLayer[0][1] );
36    };
37
38    var consentDenied = function ( cookieValue ) {
39        cookieValue != 'accepted' && typeof window.gtag === 'function' && gtag('consent', 'update', {
40            ad_user_data: 'denied',
41            ad_personalization: 'denied',
42            ad_storage: 'denied',
43            analytics_storage: 'denied'
44        });
45    };
46
47    var getTemplateOrPluginOption = function ( name ) {
48        return ( LANG.template && LANG.template[ JSINFO.plugins.googleconsent.template ] ? LANG.template[ JSINFO.plugins.googleconsent.template ][ name ] : undefined ) || JSINFO.plugins.googleconsent[name];
49    };
50
51
52    $.cookieBar({
53        fixed:              true,
54        autoEnable:         false,
55        bottom:             true,
56        forceShow:          true,
57        append:             true,
58
59        message:            getTemplateOrPluginOption('acceptBody'),
60        acceptText:         getTemplateOrPluginOption('acceptButton'),
61        acceptButton:       !!getTemplateOrPluginOption('acceptButton'),
62        declineText:        getTemplateOrPluginOption('declineButton'),
63        declineButton:      !!getTemplateOrPluginOption('declineButton'),
64        policyText:         getTemplateOrPluginOption('policyButton'),
65        policyButton:       !!getTemplateOrPluginOption('policyButton'),
66        policyURL:          getTemplateOrPluginOption('policyURL'),
67        acceptOnContinue:   !!JSINFO.plugins.googleconsent.acceptOnContinue,
68        acceptOnScroll:     !!JSINFO.plugins.googleconsent.acceptOnScroll,
69        acceptAnyClick:     !!JSINFO.plugins.googleconsent.acceptAnyClick,
70        expireDays:         !!JSINFO.plugins.googleconsent.expireDays,
71        renewOnVisit:       !!JSINFO.plugins.googleconsent.renewOnVisit,
72        forceShow:          !!JSINFO.plugins.googleconsent.forceShow,
73
74        acceptFunction:     consentGiven,
75        declineFunction:    consentDenied,
76    });
77
78    $.cookieBar( 'cookies' ) && consentGiven( 'accepted' );
79
80})(jQuery);});
81