Giter Site home page Giter Site logo

skdhruv / simple-cookie-choices Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caiojhonny/simple-cookie-choices

0.0 1.0 0.0 32 KB

A simple cookie choices thought to the GDPR rules ๐Ÿ”’๐Ÿช

Home Page: https://simple-cookie-choices.caiojhonny.com/

HTML 61.10% CSS 2.14% JavaScript 36.76%

simple-cookie-choices's Introduction

Simple Cookie Choices

Javascript only. Just 3.3kb gzipped.

This plugin helps you to create a banner or dialog box for accepting or denying the terms based on the GDPR rules.

Demo

Consent Bar

Consent Dialog

Setup

Include the script into your site

<script src="simple-cookie-choices.min.js"></script>

Usage

To use a Consent Bar

SimpleCookieChoices.showCookieConsentBar('This site uses cookies to offer you a better browsing expirience.', 'Find out more on how we use cookies and how you can change your settings', '/cookie-policy.html', 'I accept cookies', 'I refuse cookies');

To use a Dialog Bar

SimpleCookieChoices.showCookieConsentDialog('This site uses cookies to offer you a better browsing expirience.', 'Find out more on how we use cookies and how you can change your settings', '/cookie-policy.html', 'I accept cookies', 'I refuse cookies');

Parameters

Necessary parameters for the initialization of the plugin:

cookieText Brief descriptive text about your privacy policy

linkText(optional) Short text with link. It can be linked to your privacy page.

linkHref(optional) Link to your linkText

acceptBtnTitle Title from your accept button

rejectBtnTitle Title from your reject button

Functions

SimpleCookieChoices.consentAccepted() Returns a boolean value if consensus was accepted

SimpleCookieChoices.setAccept() Action to accept the terms

SimpleCookieChoices.setReject() Action to reject the terms

SimpleCookieChoices.eraseCookies() Clear the plugin cookies

SimpleCookieChoices.showCookieConsentBar() To init a Consent Bar (params required)

SimpleCookieChoices.showCookieConsentDialog() To init a Dialog Bar (params required)

Events

cookiechoicestatechanged You can see if the user has changed option

window.addEventListener('cookiechoicestatechanged', function (e) {
  console.log('Choice state changed', e.detail.state);
});

License

MIT

[top]

simple-cookie-choices's People

Contributors

caiojhonny avatar

Watchers

James Cloos 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.