orestbida / cookieconsent

:cookie: Simple cross-browser cookie-consent plugin written in vanilla js
https://playground.cookieconsent.orestbida.com/
MIT License
4.08k stars 416 forks source link

Expose the event that triggered onModalShow/onModalHide callback function #706

Closed peaemaye closed 3 months ago

peaemaye commented 4 months ago

When using the onModalShow() callback function it can be useful to know what triggered it. An easy way to achieve this is to expose the event that triggered the callback allowing us to check the event.target or other info.

In my case I wanted to auto-expand a third party services section if it was opened from a static button using: data-cc='show-preferencesModal', but not if it was opened from the button in the standard consent modal. I've put together a quick StackBlitz to show this in action: https://stackblitz.com/edit/stackblitz-starters-9caf9y?file=index.js

Hopefully you agree that this would be a useful addition.

vercel[bot] commented 4 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **cookieconsent-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/orest-bidas-projects/cookieconsent-docs/FtBLLiBCHx3iWnZUFs8QtpVVqBDE)) | [Visit Preview](https://cookieconsent-docs-git-fork-peaemay-08dbb3-orest-bidas-projects.vercel.app) | | Jul 15, 2024 2:33pm |
netlify[bot] commented 4 months ago

Deploy Preview for cookieconsentv3-playground canceled.

Name Link
Latest commit 46ff940b79c78e2b7c68468c47945bcf4d9bbfdf
Latest deploy log https://app.netlify.com/sites/cookieconsentv3-playground/deploys/66953337456fee0008056513
stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.