Git Product home page Git Product logo

jquery.cookiebar's Introduction

jquery.cookieBar

A simple, lightweight jQuery plugin for creating a notification bar that is dismissable and dismiss is saved by cookie. Perfect for implementing the new eu cookielaw! - example available on gh-pages

If you like jquery.cookieBar and use it commercially please consider giving a donation. Thankyou.

Installation

Include script after the jQuery library

<script src="/path/jquery.cookieBar.js"></script>

If you want the default styles also include the css, if not feel free to style it as you see wish!

<link rel="stylesheet" type="text/css" href="cookieBar.css">

Usage

Create a cookiebar with no markup whatsoever! it's like magic ...

<script type="text/javascript">
	$(document).ready(function() {
	  $.cookieBar();
	});
</script>

Or, create your cookiebar markup from a simple container, example:

<script type="text/javascript">
	$(document).ready(function() {
	  $('.cookie-message').cookieBar();
	});
</script>

<div class="cookie-message">
	The government says i have to tell you i use cookies, so here it is
</div>

Or, create your cookiebar markup from a simple container with an advanced button, example:

<script type="text/javascript">
	$(document).ready(function() {
	  $('.cookie-message').cookieBar({ closeButton : '.my-close-button' });
	});
</script>

<div class="cookie-message">
	The government says i have to tell you i use cookies, so here it is <a class="my-close-button" href>cheers!</a>
</div>

Or, create your cookiebar markup from a simple container with a super advanced button that does something custom on close instead of just hiding, example:

<script type="text/javascript">
	$(document).ready(function() {
	  $('.cookie-message').cookieBar({ closeButton : '.my-close-button', hideOnClose: false });
	  $('.cookie-message').on('cookieBar-close', function() { $(this).slideUp(); });
	});
</script>

<div class="cookie-message">
	The government says i have to tell you i use cookies, so here it is <a class="my-close-button" href>cheers!</a>
</div>

Full Example Check out example.html in the repository or visit our [github-page] (http://carlwoodhouse.github.com/jquery.cookieBar)

Options

closeButton - Define a close button for the bar

closeButton: 'none'

Default: a close button will be added automagically

hideOnClose - Hide the cookiebar when the close button is clicked

hideOnClose: false

*Use-case: you might want some different behaviour on close, eg. a slide animiation. an event will be triggered on close. Default: the cookiebar will be hidden on close

name - Define the cookie name, useful for subdomains or versioning cookies

name: 'somecookiename'

Default: 'cookiebar'

secure - Define if the cookie transmission requires secure protocal (https)

secure: true

Default: false

path - Define the path the cookie is valid for

path: '/path/for/cookie'

Default: '/' (site wide)

domain - Define the domain the cookie operates on

domain: 'domain.com'

Default: domain cookie was created on

expiresDays - Define the expiry date of the cookie in days (from time created)

expiresDays: 30

Default: 365

Special thanks to Craig Hamnett for the original CSS.

jquery.cookiebar's People

Contributors

carlwoodhouse avatar colin-r avatar craighamnett avatar marksearle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery.cookiebar's Issues

Cookie Bar flicker IE + Chrome

Hi there,

Great plugin by the way but i am having a slight issue. The plugin functions as expected but after continuing after first view the panel hides fine but on subsequent pages in both IE & Chrome there is a flicker whereby the panel is displayed momentarily before being hidden again. I don't seem to get the flicker on Firefox, Safari or Opera but i do on IE & Chrome.

Any ideas?

Container Injection

Make it possible to inject a default container for the message so no markup is required only the script initialisation!

Would be nice to be able to version the cookie

If new functionality is added to the site in which additional Cookies are created, it would be nice to be able to adjust the code to check for an updated version of the cookie and force it to show again for users who have previously accepted.

One way would be to have an option in the JS setup that allows a version number parameter. This could then check for a different cookie name (e.g. cookiebar_2) forcing users to see the cookie bar again.

Cookie bars without denial feature are not legal in Europe

I'm currently working on websites that originally use this script. Reason: Customers got pricy caution letters by a lawyer, because the visitor can't deny cookies and third party stuff is always loaded.

This is not legal by EU law and takes the existence of a cookie bar ad absurdum. No offense meant, just wanted to let you know :)

I'm replacing your script now since it doesn't offer the required denial options.

Unique cookie for subdomain

Cookie not working for checking on subdomain. I will want a situation where
example.com cookies is not the same as abc.exmple.com

I have tried using

path and domain configuration

path: '/'
domain : 'example.com'

and

path: '/'
domain : 'abc.example.com'

but the above two keeps mapping to thesame cookies, hence cookie bar only show for one of the domain and for all once enabled

When closed - showing until inline style added

Once it is closed, on reload it will show for a split second till .hide loads.

It would be best to have display:none on .cookie-message since .show is used to check status before hittings close.
So solution is simple:

.cookie-message {
  display: none;
}

Bar disappearing on window load

When I install the script and enqueue it in WordPress, the bar shows briefly and then automatically hides. This is using an Incognito window so there's no chance a cookie has been created.

Adding a CSS class on the cookie bar when accepted

I'm using your awesome plugin with a cookie bar in a div created by me.

Problem: When I click the Accept button I need to hide the cookie bar with a "slide down" effect, while now your plugin hide the bar with a display:none.

Is there a way to add a class css on the bar instead of hiding with the display:none ?

what is the license

Under what license is your code available? if MIT then you do not have the license available in the repo and mentioned in the code which means that your code can't be really used commercially.

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.