GithubHelp home page GithubHelp logo

nfreear / cookie-notice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aoepeople/cookie-notice

0.0 3.0 0.0 111 KB

CookieNotice — a very simple and small vanilla JavaScript cookie notice for GDPR/DSGVO‎ information purposes. Multi language support and detection buillt in.

License: MIT License

JavaScript 92.15% HTML 7.85%
npm-package cookie gdpr vanilla-javascript

cookie-notice's Introduction

Build status — Travis-CI cookie-notice on Npmjs License Total downloads ~ Npmjs Size of Javascript

CookieNotice

CookieNoticeJS is a very simple and small (→ 2 kB gzip) vanilla JS script with multi language support for GDPR/DSGVO‎ transparency and notification purposes that provides an easy way to show a cookie notice on your website.

FetchBot

Available via npm

npm install cookie-notice
npm test

To use in your project There are plenty ways for integration:

When installed via npm, include in any project by using path below:

<script src="node-modules/cookie-notice/dist/cookie.notice.min.js"></script>

For usage undeled with Angular2+ add line below in "scripts" section in angular-cli.json:

{
    "scripts": [
        "../node_modules/cookie-notice/dist/cookie.notice.js",
        "../optional/path/to/custom/cookie-notice-config.js"
    ]
}

When cloned directly from gitHub use path below:

<script src="cookie-notice/dist/cookie.notice.min.js"></script>

Behavior

You will get a dismissable banner on the bottom of your pages showing a default cookie audit like the following:

We use cookies to make sure you can have the best experience on our website. If you continue to use this site we assume that you will be happy with it.

Check my website for a DEMO. Depending on the visitor browser language one of the preloaded translations will be shown. At the moment CookieNoticeJS supports EN, IT, DE and FR. If you want to contribute with an extra language do not hesitate to open an issue or a PR.

CookieNoticeJS has been successfully tested on IE9+, Chrome, Firefox and Safari.

Customize CookieNoticeJS

For the most of you including the script should be enough but CookieNoticeJS comes with many customization options. Let's see an example:

<script src="js/cookie.notice.min.js"></script>
<script>
    new cookieNoticeJS({

       // Localizations of the notice message
       'messageLocales': {
         'it': 'Custom localized message'
       },

       // Localizations of the dismiss button text
       'buttonLocales': {
         'it': 'Chiudi'
       },

       // Position for the cookie-notifier (default=bottom)
       'cookieNoticePosition': 'top',

       // Shows the "learn more button (default=false)
       'learnMoreLinkEnabled': false,

       // The href of the learn more link must be applied if (learnMoreLinkEnabled=true)
       'learnMoreLinkHref': '/learn/more/index.html',

       // Text for optional learn more button
       'learnMoreLinkText':{
           'en':'learn more'
       },

       // The message will be shown again in X days
       'expiresIn': 30,

       // Dismiss button background color
       'buttonBgColor': '#d35400',  

       // Dismiss button text color
       'buttonTextColor': '#fff',

       // Notice background color
       'noticeBgColor': '#000',

       // Notice text color
       'noticeTextColor': '#fff',

       // the learnMoreLink color (default='#009fdd')
       'linkColor': '#f00',

       // The target of the learn more link (default='', or '_blank')
       'linkTarget': '',

       // Print debug output to the console (default=false)
       'debug': false
    });
</script>

Configuration via data- attribute

Configuration options can be put in a data-cookie-notice HTML attribute in JSON format. Note, you can include the Javascript from the unpkg CDN (browse). For example:

<script
  data-cookie-notice='{ "learnMoreLinkEnabled": true, "learnMoreLinkHref": "/privacy.html" }'
  src="https://unpkg.com/cookie-notice@^1/dist/cookie.notice.min.js"
></script>

Author

Alessandro Benoit

Contributors

Bernhard Behrendt @AOEpeople, Nick Freear IET at the OU

License

License: MIT

cookie-notice's People

Contributors

bernhardbehrendt avatar micc83 avatar nfreear avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.