Skip to content
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

Custom decline event #463

Open
basvandertogt opened this issue Dec 19, 2022 · 0 comments
Open

Custom decline event #463

basvandertogt opened this issue Dec 19, 2022 · 0 comments

Comments

@basvandertogt
Copy link

Hi!

Is there an event available which i can use to decline and close the modal?
I need this because i want to add the decline option in to the consentModal description.

<script>
var klaroConfig = {
    /*
    Setting 'testing' to 'true' will cause Klaro to not show the consent notice or
    modal by default, except if a special hash tag is appended to the URL (#klaro-
    testing). This makes it possible to test Klaro on your live website without
    affecting normal visitors.
    */
    testing: false,

    /*
    You can customize the ID of the DIV element that Klaro will create when starting
    up. By default, Klaro will use 'klaro'.
    */
    elementID: 'klaro',

    /*
    You can customize how Klaro persists consent information in the browser. Specify
    either cookie' (the default) or 'localStorage'.
    */
    storageMethod: 'cookie',

    /*
    You can customize the name of the cookie or localStorage entry that Klaro will
    use for storing the consent information. By default, Klaro will use 'klaro'.
    */
    storageName: 'klaro',

    /*
    If set to `true`, Klaro will render the texts given in the
    `consentModal.description` and `consentNotice.description` translations as HTML.
    This enables you to e.g. add custom links or interactive content.
    */
    htmlTexts: true,

    /*
    You can change the cookie domain for the consent manager itself. Use this if you
    want to get consent once for multiple matching domains. By default, Klaro will
    use the current domain. Only relevant if 'storageMethod' is set to 'cookie'.
    */
    // cookieDomain: '.example.com',

    /*
    You can also set a custom expiration time for the Klaro cookie. By default, it
    will expire after 30 days. Only relevant if 'storageMethod' is set to 'cookie'.
    */
    cookieExpiresAfterDays: 365,

    /*
    Defines the default state for services in the consent modal (true=enabled by
    default). You can override this setting in each service.
    */
    default: false,

    /*
    If 'mustConsent' is set to 'true', Klaro will directly display the consent
    manager modal and not allow the user to close it before having actively
    consented or declined the use of third-party services.
    */
    mustConsent: true,

    /*
    Setting 'acceptAll' to 'true' will show an "accept all" button in the notice and
    modal, which will enable all third-party services if the user clicks on it. If
    set to 'false', there will be an "accept" button that will only enable the
    services that are enabled in the consent modal.
    */
    acceptAll: true,

    /*
    Setting 'hideDeclineAll' to 'true' will hide the "decline" button in the consent
    modal and force the user to open the modal in order to change his/her consent or
    disable all third-party services. We strongly advise you to not use this
    feature, as it opposes the "privacy by default" and "privacy by design"
    principles of the GDPR (but might be acceptable in other legislations such as
    under the CCPA)
    */
    hideDeclineAll: false,

    /*
    Setting 'hideLearnMore' to 'true' will hide the "learn more / customize" link in
    the consent notice. We strongly advise against using this under most
    circumstances, as it keeps the user from customizing his/her consent choices.
    */
    hideLearnMore: false,
    translations: {
      nl: {
        acceptAll: 'Oké',
        decline: 'Weigeren',
        consentModal: {
          title: 'Cookies',
          description:
            'Met cookies en technieken die daarop lijken helpen we je beter en persoonlijker. Dankzij functionele cookies werkt de website goed. Ze hebben ook een analytische functie. Zo maken we de website elke dag een beetje beter. We laten je graag nuttige advertenties zien. Daarom gebruiken we technologie om je gedrag binnen en buiten onze website te volgen. Dat doen we op een anonieme manier. Meer weten? Lees <a href="/cookiebeleid/">hier</a> alles over onze cookie- en privacyverklaring. Klik op \'Oké\' om te accepteren. Kies je voor <a href="" id="custom-decline">weigeren</a>? Dan plaatsen we alleen functionele en analytische cookies en gebruiken we technieken die daarop lijken.'
        },
        googleAnalytics: {
          title: "Google Analytics",
          description: "",
        },
        purposes: {
          analytics: "Analytics",
          styling: "Styling",
        }
      }
    },
    apps: [
      {
        name: "googleAnalytics",
        purposes: ["analytics"],
      },
    ],
  };
  
document.addEventListener('DOMContentLoaded', customDecline, false);

function customDecline () {
 document.getElementById("custom-decline").onclick = function(e){
    e.preventDefault();
    klaro.declineAndHide();
  }; 
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant