| 5 |
lars |
1 |
# jquery.cookieBar
|
|
|
2 |
|
|
|
3 |
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] (http://carlwoodhouse.github.com/jquery.cookieBar)
|
|
|
4 |
|
|
|
5 |
Uses: [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) - bundled, no need to reference.
|
|
|
6 |
|
|
|
7 |
## Installation
|
|
|
8 |
|
|
|
9 |
Include script *after* the jQuery library
|
|
|
10 |
|
|
|
11 |
<script src="/path/jquery.cookieBar.js"></script>
|
|
|
12 |
|
|
|
13 |
If you want the default styles also include the css, if not feel free to style it as you see wish!
|
|
|
14 |
|
|
|
15 |
<link rel="stylesheet" type="text/css" href="cookieBar.css">
|
|
|
16 |
|
|
|
17 |
## Usage
|
|
|
18 |
|
|
|
19 |
Create a cookiebar with no markup whatsoever! it's like magic ...
|
|
|
20 |
|
|
|
21 |
<script type="text/javascript">
|
|
|
22 |
$(document).ready(function() {
|
|
|
23 |
$.cookieBar();
|
|
|
24 |
});
|
|
|
25 |
</script>
|
|
|
26 |
|
|
|
27 |
Or, create your cookiebar markup from a simple container, example:
|
|
|
28 |
|
|
|
29 |
<script type="text/javascript">
|
|
|
30 |
$(document).ready(function() {
|
|
|
31 |
$('.cookie-message').cookieBar();
|
|
|
32 |
});
|
|
|
33 |
</script>
|
|
|
34 |
|
|
|
35 |
<div class="cookie-message">
|
|
|
36 |
The government says i have to tell you i use cookies, so here it is
|
|
|
37 |
</div>
|
|
|
38 |
|
|
|
39 |
Or, create your cookiebar markup from a simple container with an advanced button, example:
|
|
|
40 |
|
|
|
41 |
<script type="text/javascript">
|
|
|
42 |
$(document).ready(function() {
|
|
|
43 |
$('.cookie-message').cookieBar({ closeButton : '.my-close-button' });
|
|
|
44 |
});
|
|
|
45 |
</script>
|
|
|
46 |
|
|
|
47 |
<div class="cookie-message">
|
|
|
48 |
The government says i have to tell you i use cookies, so here it is <a class="my-close-button" href>cheers!</a>
|
|
|
49 |
</div>
|
|
|
50 |
|
|
|
51 |
Full Example
|
|
|
52 |
Check out example.html in the repository or visit our [github-page] (http://carlwoodhouse.github.com/jquery.cookieBar)
|
|
|
53 |
|
|
|
54 |
## Options
|
|
|
55 |
**closeButton** - Define a close button for the bar
|
|
|
56 |
|
|
|
57 |
closeButton: 'none'
|
|
|
58 |
|
|
|
59 |
*Default: a close button will be added automagically*
|
|
|
60 |
|
|
|
61 |
**secure** - Define if the cookie transmission requires secure protocal (https)
|
|
|
62 |
|
|
|
63 |
secure: true
|
|
|
64 |
|
|
|
65 |
*Default: false*
|
|
|
66 |
|
|
|
67 |
**path** - Define the path the cookie is valid for
|
|
|
68 |
|
|
|
69 |
path: '/path/for/cookie'
|
|
|
70 |
|
|
|
71 |
*Default: '/' (site wide)*
|
|
|
72 |
|
|
|
73 |
**domain** - Define the domain the cookie operates on
|
|
|
74 |
|
|
|
75 |
domain: 'domain.com'
|
|
|
76 |
|
|
|
77 |
*Default: domain cookie was created on*
|
|
|
78 |
|
|
|
79 |
## Authors
|
|
|
80 |
|
|
|
81 |
* [Carl Woodhouse](https://github.com/carlwoodhouse)
|
|
|
82 |
* [Craig Hamnett](https://github.com/craighamnett)
|