-
Notifications
You must be signed in to change notification settings - Fork 26
Feature/filament cookies #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
70a5b1a
c7c4401
26247d2
4e7c9c3
a08ae66
87e044e
df26d48
4a4b86c
0154e5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,25 @@ | |
| "name": "Kristof Serré", | ||
| "email": "[email protected]", | ||
| "homepage": "https://www.statik.be" | ||
| }, | ||
| { | ||
| "name": "Seppe Van Besauw", | ||
| "email": "[email protected]", | ||
| "homepage": "https://www.statik.be" | ||
| } | ||
| ], | ||
| "homepage": "https://github.com/statikbe/laravel-cookie-consent", | ||
| "keywords": ["Laravel", "cookie", "gdpr"], | ||
| "keywords": [ | ||
| "Laravel", | ||
| "cookie", | ||
| "gdpr", | ||
| "Filament", | ||
| "cookie-banner", | ||
| "Google Tag Manager", | ||
| "privacy", | ||
| "GDPR", | ||
| "consent" | ||
| ], | ||
| "license": "MIT", | ||
| "require": { | ||
| "php": "^8.0", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "/public/js/cookie-consent.js": "/public/js/cookie-consent.js", | ||
| "/public/js/cookie-consent-filament.js": "/public/js/cookie-consent-filament.js", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kan dat kwaad dat die hier allebei staan? Misschien ook in readme zetten dat ze die verwijderen afhankelijk van de theme?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mix-manifest.json is auto-generated tijdens de build van de package. Dus niet de bedoeling dat we deze manueel gaan bewerken. That said, deze mix manifest klopt wel nog niet zie ik, vergeten een nieuwe build te maken na onze changes donderdag, so fixed that! |
||
| "/public/css/cookie-consent.css": "/public/css/cookie-consent.css" | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import { getCookie, setCookie } from './util/cookies'; | ||
|
|
||
| let onConsentChange; | ||
| window.cookieBannerConsentChange = (callback) => { | ||
| onConsentChange = callback; | ||
| }; | ||
|
|
||
| document.addEventListener('alpine:init', () => { | ||
| Alpine.data('cookieConsentModal', (props) => ({ | ||
| COOKIE_KEY: props.COOKIE_KEY, | ||
| IGNORED_PATHS: JSON.parse(props.IGNORED_PATHS), | ||
| COOKIE_VALUE_ANALYTICS: props.COOKIE_VALUE_ANALYTICS, | ||
| COOKIE_VALUE_MARKETING: props.COOKIE_VALUE_MARKETING, | ||
| COOKIE_VALUE_BOTH: props.COOKIE_VALUE_BOTH, | ||
| COOKIE_VALUE_NONE: props.COOKIE_VALUE_NONE, | ||
| COOKIE_EXPIRATION_DAYS: props.COOKIE_EXPIRATION_DAYS, | ||
| GTM_EVENT: props.GTM_EVENT, | ||
| SESSION_DOMAIN: props.SESSION_DOMAIN, | ||
| COOKIE_SECURE: props.COOKIE_SECURE, | ||
| checkboxAnalytics: false, | ||
| checkboxMarketing: false, | ||
| init() { | ||
| this.$nextTick(() => { | ||
| this.initialize(); | ||
| }); | ||
| }, | ||
| // Button listeners | ||
| acceptAll() { | ||
| this.updateCookie(this.COOKIE_VALUE_BOTH); | ||
| this.closeCookieConsentModal(); | ||
| this.closeCookieSettingsModal(); | ||
| }, | ||
| acceptEssentials() { | ||
| this.updateCookie(this.COOKIE_VALUE_NONE); | ||
| this.closeCookieConsentModal(); | ||
| this.closeCookieSettingsModal(); | ||
| }, | ||
| openSettings() { | ||
| this.openCookieSettingsModal(); | ||
| }, | ||
| saveSettings() { | ||
| let cookieValue; | ||
|
|
||
| if (this.checkboxAnalytics && this.checkboxMarketing) { | ||
| cookieValue = this.COOKIE_VALUE_BOTH; | ||
| } else if (this.checkboxAnalytics) { | ||
| cookieValue = this.COOKIE_VALUE_ANALYTICS; | ||
| } else if (this.checkboxMarketing) { | ||
| cookieValue = this.COOKIE_VALUE_MARKETING; | ||
| } else { | ||
| cookieValue = this.COOKIE_VALUE_NONE; | ||
| } | ||
|
|
||
| this.updateCookie(cookieValue); | ||
| this.closeCookieConsentModal(); | ||
| this.closeCookieSettingsModal(); | ||
| }, | ||
| // Helper functions | ||
| openCookieConsentModal() { | ||
| this.$dispatch('open-modal', { id: 'cookie-consent-modal' }); | ||
| }, | ||
| closeCookieConsentModal() { | ||
| this.$dispatch('close-modal', { id: 'cookie-consent-modal' }); | ||
| }, | ||
| openCookieSettingsModal() { | ||
| this.$dispatch('open-modal', { id: 'cookie-consent-settings-modal' }); | ||
| }, | ||
| closeCookieSettingsModal() { | ||
| this.$dispatch('close-modal', { id: 'cookie-consent-settings-modal' }); | ||
| }, | ||
| initialize() { | ||
| const ignoredPathsArray = this.IGNORED_PATHS | ||
| ? this.IGNORED_PATHS.map((ignoredPath) => ignoredPath.trim()) | ||
| : []; | ||
| const isIgnoredPage = ignoredPathsArray.indexOf(location.pathname) > -1; | ||
|
|
||
| const isRobot = /bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex/i.test(navigator.userAgent); | ||
|
|
||
| if (isRobot) return; | ||
|
|
||
| if (!getCookie(this.COOKIE_KEY) && !isIgnoredPage) { | ||
| this.openCookieConsentModal(); | ||
| } | ||
|
|
||
| this.fillFormData(); | ||
| }, | ||
| fillFormData() { | ||
| const cookieValue = getCookie(this.COOKIE_KEY); | ||
|
|
||
| this.checkboxAnalytics = | ||
| cookieValue === this.COOKIE_VALUE_BOTH || cookieValue === this.COOKIE_VALUE_ANALYTICS; | ||
| this.checkboxMarketing = | ||
| cookieValue === this.COOKIE_VALUE_BOTH || cookieValue === this.COOKIE_VALUE_MARKETING; | ||
| }, | ||
| updateCookie(cookieValue) { | ||
| setCookie( | ||
| this.COOKIE_KEY, | ||
| cookieValue, | ||
| this.COOKIE_EXPIRATION_DAYS, | ||
| this.SESSION_DOMAIN, | ||
| this.COOKIE_SECURE, | ||
| ); | ||
|
|
||
| if (onConsentChange) { | ||
| onConsentChange(cookieValue); | ||
| } | ||
|
|
||
| // Fire GTM event if dataLayer is found | ||
| if (window.dataLayer) { | ||
| window.dataLayer.push({ event: this.GTM_EVENT }); | ||
| } | ||
| }, | ||
| })); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.