All Projects → ketanmistry → Ihavecookies

ketanmistry / Ihavecookies

Licence: mit
jQuery plugin to display cookie consent message (EU regulation)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ihavecookies

Ax5ui Grid
Javascript UI Component - GRID ( Excel Grid, jqGrid, angularjs grid, jquery grid, SlickGrid, ag-grid gridify)
Stars: ✭ 102 (-3.77%)
Mutual labels:  jquery-plugin, jquery
Dropdown
a lightweight dropdown of jQuery plugins
Stars: ✭ 105 (-0.94%)
Mutual labels:  jquery-plugin, jquery
Jquery Mosaic
A jQuery plugin to build responsive mosaics of images or any other content fitted to match heights in multiple rows while maintaining aspect ratios. http://jquery-mosaic.tin.cat
Stars: ✭ 80 (-24.53%)
Mutual labels:  jquery-plugin, jquery
Imgnotes
Extension of the jQuery imgViewer plugin to add markers and notes to the image
Stars: ✭ 98 (-7.55%)
Mutual labels:  jquery-plugin, jquery
Translucent
Translucent plastic card theme.
Stars: ✭ 93 (-12.26%)
Mutual labels:  jquery-plugin, jquery
Swiftype Search Jquery
Elastic Site Search jQuery search plugin
Stars: ✭ 74 (-30.19%)
Mutual labels:  jquery-plugin, jquery
Jquery Sortablejs
A jQuery binding for SortableJS
Stars: ✭ 94 (-11.32%)
Mutual labels:  jquery-plugin, jquery
Jtap
Tap Event for jQuery
Stars: ✭ 65 (-38.68%)
Mutual labels:  jquery-plugin, jquery
Gdb
Generic Data Binder (GDB) for jQuery is a framework agnostic and extremely easy to use 2 way data binder. GDB binds views and models in realtime with live two-way binding and no hefty framework necessary.
Stars: ✭ 90 (-15.09%)
Mutual labels:  jquery-plugin, jquery
Multipicker
Form styling plugin for jQuery
Stars: ✭ 90 (-15.09%)
Mutual labels:  jquery-plugin, jquery
Jquery.toaster
jQuery plugin for displaying customizable toast notifications via Bootstrap alerts
Stars: ✭ 74 (-30.19%)
Mutual labels:  jquery-plugin, jquery
Pretty Dropdowns
A simple, lightweight jQuery plugin to create stylized drop-down menus.
Stars: ✭ 96 (-9.43%)
Mutual labels:  jquery-plugin, jquery
Jalert
jQuery alert/modal/lightbox plugin
Stars: ✭ 73 (-31.13%)
Mutual labels:  jquery-plugin, jquery
Applozic Web Plugin
Javascript (jQuery) Real Time Chat & Messaging plugin
Stars: ✭ 76 (-28.3%)
Mutual labels:  jquery-plugin, jquery
Jquery Lockfixed
jQuery lockfixed plugin
Stars: ✭ 69 (-34.91%)
Mutual labels:  jquery-plugin, jquery
Tui.calendar
🍞📅A JavaScript calendar that has everything you need.
Stars: ✭ 9,537 (+8897.17%)
Mutual labels:  jquery-plugin, jquery
Jquery.balloon.js
A jQuery plugin to add balloon tips to elements User-friendly, fine-tunable and without css and images
Stars: ✭ 54 (-49.06%)
Mutual labels:  jquery-plugin, jquery
Cmd Resume
Web-based Command Line Resume
Stars: ✭ 55 (-48.11%)
Mutual labels:  jquery-plugin, jquery
Popup Maker
Popup Maker plugin for WordPress
Stars: ✭ 87 (-17.92%)
Mutual labels:  jquery-plugin, jquery
Basictable
Basic Table jQuery or Vanilla JS plugin for simple responsive tables.
Stars: ✭ 94 (-11.32%)
Mutual labels:  jquery-plugin, jquery

jQuery Cookie Consent Plugin (WIP)

A lightweight jQuery plugin that displays a cookie 🍪 consent message as required by EU regulation. The plugin displays a message on the user's first visit to your website and, by default, again 30 days after their last visit.

The visitor must click the accept button within the popup for the cookie to be set thus granting their consent (GDPR).

Usage

Download the latest version and include it within your page along with jQuery (1.7.4 or later).

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/2.x.x/jquery.min.js"></script>
<script type="text/javascript" src="jquery.ihavecookies.min.js"></script>

Then initialise the plugin using:

// With the default options
$('body').ihavecookies();

// Or with customised options
var options = {
    title: ...
}
$('body').ihavecookies(options);

This will append the cookie popup to the <body> tag with the default settings and message.

Options

There are a number of options available to help with customisation:

Option Default Value Description
title "Cookies & Privacy" A custom title for the popup
message "Cookies enable you to use shopping carts and to personalize your experience on our sites, tell us which parts of our websites people have visited, help us measure the effectiveness of ads and web searches, and give us insights into user behavior so we can improve our communications and products." Add your own cookie message here, if you prefer not to use the default one. HTML can be included within this message.
link "/privacy-policy" Link to your privacy policy for more information
delay 2000 Time before the popup is displayed after page load (in milliseconds)
expires 30 Days for the cookie to expire
onAccept function(){} Optional callback function when 'Accept' button is clicked
uncheckBoxes false Unchecks all checkboxes on page load that have class .ihavecookies applied to them. Set to true to turn this option on
moreInfoLabel 'More information' Label for link to privacy policy
acceptBtnLabel 'Accept All Cookies' Label for accept cookies button
advancedBtnLabel 'Customise Cookies' Label for customise cookies button
cookieTypesTitle 'Select cookies to accept' Title for customise cookies section
fixedCookieTypeLabel 'Necessary' Label for the "necessary" cookie type
fixedCookieTypeDesc 'These are cookies that are essential for the website to work correctly.' Description for the "necessary" cookie type
cookieTypes Array Array of cookie types for which to show checkboxes for - See code example below.

Events

Reopening the message

Use reinit to reopen ihavecookies when clicking on an element. This opens the message with the previously selected checkboxes ticked.

$('button').click(function(){
    $('body').ihavecookies(options, 'reinit');
});

Example Code

The code below shows an example of the cookie types options.

$('body').ihavecookies({
    // Optional callback function when 'Accept' button is clicked
    onAccept: function() {
        // Do whatever you need to here...
    },

    // Array of cookie types for which to show checkboxes.
    // - type: Type of cookie. This is also the label that is displayed.
    // - value: Value of the checkbox so it can be easily identified in
    //          your application.
    // - description: Description for this cookie type. Displayed in
    //                title attribute.
    cookieTypes: [
        {
            type: 'Site Preferences',
            value: 'preferences',
            description: 'These are cookies that are related to your site preferences, e.g. remembering your username, site colours, etc.'
        },
        {
            type: 'Analytics',
            value: 'analytics',
            description: 'Cookies related to site visits, browser types, etc.'
        },
        {
            type: 'Marketing',
            value: 'marketing',
            description: 'Cookies related to marketing, e.g. newsletters, social media, etc'
        }
    ],
});

Methods

$.fn.ihavecookies.cookie() returns the value of the cookieControlPrefs cookie.

$.fn.ihavecookies.preference(cookieTypeValue) returns true if the the cookie type has been accepted, otherwise false.

Styling

The plugin doesn't include any CSS so it can be styled to fit in with your websites look and feel. The cookie message has an ID of #gdpr-cookie-message. Sample CSS can be viewed in the accompanying example.css file.

Cookie

When the visitor accepts the message, the cookie cookieControl with value true is set along with cookie cookieControlPrefs which contains an array of accepted cookie types e.g. ["preferences","analytics"]. This will enable you to perform additional checks where necessary within your application (with regard to GDPR regulations).

Example

An example of the cookie consent message can be viewed at https://iamketan.com.au or in the accompanying example.html file.

Author

Ketan Mistry (@ketanumistry)

License

This plugin is available under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].