source: main/trunk/greenstone3/web/interfaces/default/js/cookieconsent-init.js@ 36914

Last change on this file since 36914 was 36914, checked in by kjdon, 17 months ago

dynamically decide on cookie-consent path - use cookie_path if it is set (in servlets.xml) otherwise use servlet_context - set by LibraryServlet in config_params,a nd then passed in to xslt

File size: 5.3 KB
Line 
1// @ts-nocheck
2
3/**
4 * Initialisation for the cookieconsent.js script, version 2.7.2.
5 * See https://github.com/orestbida/cookieconsent for customisation options.
6 * The translation strings that are referenced in this document via 'gs.text.ccm.XXX'
7 * can be found in the 'interface_default<_LANG>.properties' files, under 'WEB-INF/classes'.
8 */
9
10// obtain plugin
11var cc = initCookieConsent();
12
13// run plugin with your configuration
14cc.run({
15 current_lang: 'en',
16 autoclear_cookies: false, // default: false
17 page_scripts: true, // default: false
18 cookie_path: gs.xsltParams.cookie_path, // default: root ( / )
19 gui_options: {
20 consent_modal: {
21 layout: 'cloud', // box/cloud/bar
22 position: 'bottom left', // bottom/middle/top + left/right/center
23 transition: 'slide', // zoom/slide
24 swap_buttons: false // enable to invert buttons
25 },
26 settings_modal: {
27 layout: 'box', // box/bar
28 // position: 'left', // left/right - only valid with 'bar' layout
29 transition: 'slide' // zoom/slide
30 }
31 },
32
33 // mode: 'opt-in' // default: 'opt-in'; value: 'opt-in' or 'opt-out'
34 // delay: 0, // default: 0
35 // auto_language: null // default: null; could also be 'browser' or 'document'
36 // autorun: true, // default: true
37 // force_consent: false, // default: false
38 // hide_from_bots: false, // default: false
39 // remove_cookie_tables: false // default: false
40 // cookie_name: 'cc_cookie', // default: 'cc_cookie'
41 // cookie_expiration: 182, // default: 182 (days)
42 // cookie_necessary_only_expiration: 182 // default: disabled
43 // cookie_domain: location.hostname, // default: current domain
44 // cookie_same_site: 'Lax', // default: 'Lax'
45 // use_rfc_cookie: false, // default: false
46 // revision: 0, // default: 0
47
48 onFirstAction: function(user_preferences, cookie){
49 // callback triggered only once
50 },
51
52 onAccept: function (cookie) {
53 // ...
54 },
55
56 onChange: function (cookie, changed_preferences) {
57 // ...
58 },
59
60 languages: {
61 'en': {
62 consent_modal: {
63 title: gs.text.ccm.Popup_Title,
64 description: gs.text.ccm.Popup_Description + ' <button type="button" data-cc="c-settings" class="cc-link">'
65 + gs.text.ccm.Popup_OpenAdvancedManager + '</button>',
66 primary_btn: {
67 text: gs.text.ccm.Popup_AcceptAllCookies,
68 role: 'accept_necessary' // 'accept_selected' or 'accept_all'
69 },
70 // secondary_btn: {
71 // text: gs.text.ccm.Popup_AcceptNecessaryCookies,
72 // role: 'accept_necessary' // 'settings' or 'accept_necessary'
73 // }
74 },
75 settings_modal: {
76 title: gs.text.ccm.Manager_Title,
77 save_settings_btn: gs.text.ccm.Manager_SaveSettingsButton,
78 accept_all_btn: gs.text.ccm.Manager_AcceptAllButton,
79 // reject_all_btn: ccm.Manager_AcceptNecessaryButton,
80 close_btn_label: gs.text.ccm.Manager_CloseButton,
81 cookie_table_headers: [
82 { name: gs.text.ccm.Manager.CookieTableHeaders_Name },
83 { provider: gs.text.ccm.Manager.CookieTableHeaders_Provider },
84 { expiration: gs.text.ccm.Manager.CookieTableHeaders_Expiration },
85 { description: gs.text.ccm.Manager.CookieTableHeaders_Description }
86 ],
87 blocks: [
88 {
89 description: gs.text.ccm.Manager_Description
90 },
91 {
92 title: gs.text.ccm.Manager.RequiredCookies_Title,
93 description: gs.text.ccm.Manager.RequiredCookies_Description,
94 toggle: {
95 value: 'required', // The cookie collection to toggle
96 enabled: true,
97 readonly: true
98 },
99 cookie_table: [
100 {
101 name: 'JSESSIONID',
102 provider: window.location.hostname,
103 expiration: gs.text.ccm.Manager.CookieTable_EndOfSessionExpiration,
104 description: gs.text.ccm.Manager.RequiredCookies.JSESSIONID_Description,
105 },
106 {
107 name: 'supportsXSLT',
108 provider: window.location.hostname,
109 expiration: gs.text.ccm.Manager.CookieTable_EndOfSessionExpiration,
110 description: gs.text.ccm.Manager.RequiredCookies.supportsXSLT_Description
111 }
112 ]
113 }
114 ]
115 }
116 }
117 }
118});
Note: See TracBrowser for help on using the repository browser.