cookieconsent::CookieConsent method render_js (public)
<instance of cookieconsent::CookieConsent> render_js
Defined in packages/cookie-consent/tcl/cookie-consent-procs.tcl
Perform the actual rendering of the cookie consent widget.
- Testcases:
- No testcase defined.
Source code: set static false if {${:position} eq "pushdown"} { set position top set static true } elseif {${:position} in {"left" "right"}} { set position bottom-${:position} } else { set position ${:position} } # # Set up a dictionary for the palette with common # settings: # set d {popup {text #fff} button {text #000}} # # Update the default palette based on the value of the # passed-in palette. # switch ${:palette} { oacs { dict set d popup background \#004570 dict set d button background \#f1d600 } honeybee { dict set d popup background \#000 dict set d button background \#f1d600 } mono { dict set d popup background \#237afc dict set d button background transparent dict set d button text \#fff dict set d button border \#fff } neon { dict set d popup background \#1d8a8a dict set d button background \#62ffaa } corporate { dict set d popup background \#edeff5 dict set d popup text \#838391 dict set d button background \#4b81e8 } default { set d ${:default-palette} } } # # We have to juggle the colors depending on the layout # set buttonBackground [dict get $d button background] set buttonTextColor [dict get $d button text] if {[dict exists $d button border]} { set buttonBorder [dict get $d button border] } else { set buttonBorder $buttonBackground } switch ${:layout} { block - classic - edgeless {set theme ${:layout}} wire { set theme block set buttonBackground transparent set buttonTextColor [dict get $d button background] } } # # Use different cookies dependent on the subsite # set cookie_name "cookieconsent_status-${:subsite_id}" set js [subst { window.addEventListener("load", function(){ window.cookieconsent.initialise({ "palette": { "popup": { "background": "[dict get $d popup background]", "text": "[dict get $d popup text]", }, "button": { "background": "$buttonBackground", "border": "$buttonBorder", "text": "$buttonTextColor" } }, "cookie": { "name": "$cookie_name", "path": "/", "domain": "", "samesite": "lax", "expiryDays": "${:expiryDays}" }, "theme": "$theme", "position": "$position", "static": $static, "content": { "message": "[lang::util::localize ${:message-text}]", "dismiss": "[lang::util::localize ${:dismiss-button-text}]", "link": "[lang::util::localize ${:policy-link-text}]", "href": "${:learn-more-link}", "header": "Cookies used on the website!", "deny": "Decline", "allow": "Allow cookies" } })}); }] return $jsXQL Not present: Generic, PostgreSQL, Oracle