@@ -32,7 +32,8 @@ The goal was to make something as small as possible and versatile enough that I
3232 - add 'data-consent' property with consent section name (e.g. analytics, functional, performance)
3333-->
3434<script data-consent =" analytics" async src =" https://www.googletagmanager.com/gtag/js?id=G-TEST" type =" text/plain" id =" js-analytics-gtm" >
35- console .log (google_tag_manager) // evaluated 'onload' of src
35+ // The contents of this script is injected when the parent script is loaded, for convenience
36+ console .log (google_tag_manager)
3637 </script >
3738<script data-consent =" analytics" type =" text/plain" id =" js-analytics-gtm-after" >
3839 console .log (' This script runs as soon as analytics section consent is granted' )
@@ -138,25 +139,24 @@ html:not(.js-bm-hidden)::after {
138139 }
139140 ```
140141 - example usage: `if (Consent && Consent.analytics) { doAnalyticsThing() }`
141- - ` bmInvalidateConsent ()` – Delete stored consent data and reinstate UI
142- - ` bmUpdateConsent ()` – Opens My Consent Settings modal
143- - example usage: `<a href="javascript:bmUpdateConsent ();"> Update my consent settings</a>`
142+ - ` bmInvalidate ()` – Delete stored consent data and reinstate UI
143+ - ` bmOpen ()` – Opens My Consent Settings modal
144+ - example usage: `<a href="javascript:bmOpen ();"> Update my consent settings</a>`
144145
145146## Events
146147
147148The easiest way to see how events work is to view the ` console.debug() ` calls in the [ demo] ( https://replete.github.io/biscuitman )
148- - ` biscuitman:openModal `
149- - ` biscuitman:closeModel `
150- - ` biscuitman:buttonPress `
151- - ` biscuitman:saveConsent `
152- - ` biscuitman:scriptInjected `
153- - ` biscuitman:scriptLoaded `
154- - ` biscuitman:invalidateConsent `
155- - ` biscuitman:updateConsent `
149+ - ` biscuitman:open ` => ` {time: 1718915128298} ` modal opened
150+ - ` biscuitman:close ` => ` {time: 1718915128298} ` modal closed
151+ - ` biscuitman:button ` => ` {id: "settings", time: 1718915128298} ` button clicked
152+ - ` biscuitman:save ` => ` {data: {consentTime: 1718914784624, advertisement:true, advertisement: fal..}, time: 1718914784624} ` consent choice saved
153+ - ` biscuitman:inject ` => ` {el: $Element, parent?: $Element, time: 1718914784624} ` script injected to DOM. if parent exists, it's a new tag inserted after a ` src ` script loaded which also had text content (a 'dependent' script = tidier convenient markup)
154+ - ` biscuitman:invalidate ` => ` {data: {..consentObjectJustDeleted}, time: 1718915128298} ` consent invalidated
155+ - ` biscuitman:update ` => ` {data: {...currentConsentObject}, time: 1718914784624} ` returns current consent object and time
156156
157157You can watch for these events like this:
158158``` js
159- document .addEventListener (' biscuitman:openModal ' , (e ) => {
159+ document .addEventListener (' biscuitman:open ' , (e ) => {
160160 console .log (' modal opened' )
161161}, true );
162162```
0 commit comments