├── .DS_Store
├── README.md
├── cookiecuttr.css
└── jquery.cookiecuttr.js
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cdwharton/cookieCuttr/4dc24d962837c039f50efbf48505b44166989c39/.DS_Store
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | CookieCuttr
2 | ===========
3 |
4 | A tailorable jQuery plugin to deal with the EU Cookie Law.
5 |
6 | **We're not accepting any more pull requests, someone else is working on a new version at the moment, when its ready, we'll link it here.**
7 |
8 | Dependencies
9 | ------------
10 |
11 | * [jQuery](https://github.com/jquery/jquery)
12 | * [jQuery.cookie](https://github.com/carhartl/jquery-cookie)
13 |
14 | Useage
15 | ------
16 |
17 | Add `jquery.cookiecuttr.js`, after jQuery and jQuery.cookie, and `cookiecuttr.css` to the head of your HTML document. Then call CookieCuttr on document ready.
18 |
19 | ```javascript
20 | $(document).ready(function () {
21 | $.cookieCuttr();
22 | });
23 | ```
24 |
25 | For any JavaScript you want to disable, you need to wrap the following if statement around it.
26 |
27 | ```javascript
28 | if (jQuery.cookie('cc_cookie_accept') == "cc_cookie_accept") {
29 | // insert the code you do not want to run UNTIL cookies are accepted here
30 | }
31 | ```
32 |
33 | Example with Google Analytics
34 | -----------------------------
35 |
36 | ```javascript
37 | if (jQuery.cookie('cc_cookie_accept') == "cc_cookie_accept") {
38 | var _gaq = _gaq || [];
39 | _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
40 | _gaq.push(['_trackPageview']);
41 |
42 | (function() {
43 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
44 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
45 | var s = document. getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
46 | })();
47 | }
48 | ```
49 |
50 | Alternatively, you can do the following until cookies are declined.
51 |
52 | ```javascript
53 | if (jQuery.cookie('cc_cookie_decline') == "cc_cookie_decline") {
54 | // do nothing
55 | } else {
56 | var _gaq = _gaq || [];
57 | _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
58 | _gaq.push(['_trackPageview']);
59 |
60 | (function() {
61 | var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
62 | ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
63 | var s = document. getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
64 | })();
65 | }
66 | ```
67 |
68 | You can also do the following.
69 |
70 | ```javascript
71 | if( $.cookieAccepted() ) {
72 | // insert the code you do not want to run UNTIL cookies are accepted here
73 | }
74 | ```
75 |
76 | Read More About EU Cookie Law
77 | -----------------------------
78 |
79 | * [Is the EU's cookie law confusing you too?](http://www.123-reg.co.uk/blog/security-issues/is-the-eus-cookie-law-confusing-you-too/)
80 | * [New EU cookie law (e-Privacy Directive)](http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx)
81 | * [Cookies – Doing nothing isn't the right answer](http://chriswharton.me/2012/05/cookies-doing-nothing-isnt-the-right-answer/)
82 |
83 | Using WordPress?
84 | ----------------
85 |
86 | A Wordpress version is available [here](http://cookiecuttr.com/wordpress-plugin/).
87 |
88 | Options
89 | -------
90 |
91 | For options, see the [WIKI](/weare2ndfloor/cookieCuttr/wiki/Options).
92 |
93 | Contributing to CookieCuttr
94 | ---------------------------
95 |
96 | * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
97 | * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
98 | * Fork the project
99 | * Start a feature/bugfix branch
100 | * Commit and push until you are happy with your contribution
101 | * Initiate a [pull request](https://help.github.com/articles/using-pull-requests)
102 |
103 | Credits
104 | -------
105 |
106 | * [weare2ndfloor](https://github.com/weare2ndfloor) for the plugin
107 | * [unsymbol](https://github.com/unsymbol) for organising the implementation txt into a readme markdown file
108 |
109 | Copyright
110 | ---------
111 |
112 | Copyright (c) 2012 Chris Wharton. See LICENSE.txt for further details.
113 |
--------------------------------------------------------------------------------
/cookiecuttr.css:
--------------------------------------------------------------------------------
1 | /* To be used with cookieCuttr by Chris Wharton (http://cookiecuttr.com) */
2 |
3 | .cc-cookies { position:fixed; width: 90%; left: 0; top: 0; padding: 0.5em 5%; background: #565656; background: rgba(86,86,86,0.95); color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 -1px 0 rgba(0,0,0,0.35); z-index: 99999; text-align: center; color: #fff; }
4 | .cc-cookies a, .cc-cookies a:hover { color: #fff; text-decoration: underline; }
5 | .cc-cookies a:hover { text-decoration: none; }
6 | .cc-overlay { height: 100%; padding-top: 25%; }
7 | .cc-cookies-error { float: left; width: 90%; text-align: center; margin: 1em 0 2em 0; background: #fff; padding: 2em 5%; border: 1px solid #ccc; font-size: 18px; color: #333; }
8 | .cc-cookies a.cc-cookie-accept, .cc-cookies-error a.cc-cookie-accept, .cc-cookies a.cc-cookie-decline, .cc-cookies-error a.cc-cookie-decline, .cc-cookies a.cc-cookie-reset { display: inline-block; color: #fff; text-decoration: none; background: #7DAF3B; padding: 0.5em 0.75em; border-radius: 3px; box-shadow: 0 0 2px rgba(0,0,0,0.25); text-shadow: 0 -1px 0 rgba(0,0,0,0.35); -o-transition: background 0.5s ease-in; -webkit-transition: background 0.25s ease-in; -moz-transition: background 0.25s ease-in; }
9 | .cc-cookies a.cc-cookie-decline, .cc-cookies-error a.cc-cookie-decline { background: #af3b3b; margin-left: 0.5em; }
10 | .cc-cookies a.cc-cookie-reset { background: #f15b00; }
11 | .cc-cookies a:hover.cc-cookie-accept, .cc-cookies-error a:hover.cc-cookie-accept, .cc-cookies a:hover.cc-cookie-decline, .cc-cookies-error a:hover.cc-cookie-decline, .cc-cookies a:hover.cc-cookie-reset { background: #000; -o-transition: background 0.5s ease-in; -webkit-transition: background 0.25s ease-in; -moz-transition: background 0.25s ease-in; }
12 | .cc-cookies-error a.cc-cookie-accept, .cc-cookies-error a.cc-cookie-decline { display: block; margin-top: 1em; }
13 | .cc-cookies.cc-discreet { width: auto; padding: 0.5em 1em; left: auto; top: auto; }
14 | .cc-cookies.cc-discreet a.cc-cookie-reset { background: none; text-shadow: none; padding: 0; text-decoration: underline; }
15 | .cc-cookies.cc-discreet a:hover.cc-cookie-reset { text-decoration: none; }
16 |
17 | @media screen and (max-width: 768px) {
18 | .cc-cookies a.cc-cookie-accept, .cc-cookies a.cc-cookie-decline, .cc-cookies a.cc-cookie-reset { display: block; margin: 1em 0; }
19 | }
20 |
21 | @media screen and (max-width: 480px) {
22 | .cc-cookies { position: relative; float: left; }
23 | }
--------------------------------------------------------------------------------
/jquery.cookiecuttr.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (C) 2012 Chris Wharton (chris@weare2ndfloor.com)
3 | *
4 | * This program is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License as published by
6 | * the Free Software Foundation, either version 3 of the License, or
7 | * (at your option) any later version.
8 | *
9 | * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
10 | * HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
11 | * INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR
12 | * FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE
13 | * OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
14 | * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.COPYRIGHT HOLDERS WILL NOT
15 | * BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL
16 | * DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
17 | *
18 | * You should have received a copy of the GNU General Public License
19 | * along with this program. If not, see
To continue using this functionality, please",
38 | cookieWhatAreTheyLink: "http://www.allaboutcookies.org/",
39 | cookieDisable: '',
40 | cookieExpires: 365,
41 | cookieAcceptButtonText: "ACCEPT COOKIES",
42 | cookieDeclineButtonText: "DECLINE COOKIES",
43 | cookieResetButtonText: "RESET COOKIES FOR THIS WEBSITE",
44 | cookieWhatAreLinkText: "What are cookies?",
45 | cookieNotificationLocationBottom: false, // top or bottom - they are your only options, so true for bottom, false for top
46 | cookiePolicyPage: false,
47 | cookiePolicyPageMessage: 'Please read the information below and then choose from the following options',
48 | cookieDiscreetLink: false,
49 | cookieDiscreetReset: false,
50 | cookieDiscreetLinkText: "Cookies?",
51 | cookieDiscreetPosition: "topleft", //options: topleft, topright, bottomleft, bottomright
52 | cookieNoMessage: false, // change to true hide message from all pages apart from your policy page
53 | cookieDomain: ""
54 | };
55 | var options = $.extend(defaults, options);
56 | var message = defaults.cookieMessage.replace('{{cookiePolicyLink}}', defaults.cookiePolicyLink);
57 | defaults.cookieMessage = 'We use cookies on this website, you can read about them here. To use the website as intended please...';
58 | //convert options
59 | var cookiePolicyLinkIn = options.cookiePolicyLink;
60 | var cookieCutter = options.cookieCutter;
61 | var cookieCutterDeclineOnly = options.cookieCutterDeclineOnly;
62 | var cookieAnalytics = options.cookieAnalytics;
63 | var cookieDeclineButton = options.cookieDeclineButton;
64 | var cookieAcceptButton = options.cookieAcceptButton;
65 | var cookieResetButton = options.cookieResetButton;
66 | var cookieOverlayEnabled = options.cookieOverlayEnabled;
67 | var cookiePolicyLink = options.cookiePolicyLink;
68 | var cookieMessage = message;
69 | var cookieAnalyticsMessage = options.cookieAnalyticsMessage;
70 | var cookieErrorMessage = options.cookieErrorMessage;
71 | var cookieDisable = options.cookieDisable;
72 | var cookieWhatAreTheyLink = options.cookieWhatAreTheyLink;
73 | var cookieExpires = options.cookieExpires;
74 | var cookieAcceptButtonText = options.cookieAcceptButtonText;
75 | var cookieDeclineButtonText = options.cookieDeclineButtonText;
76 | var cookieResetButtonText = options.cookieResetButtonText;
77 | var cookieWhatAreLinkText = options.cookieWhatAreLinkText;
78 | var cookieNotificationLocationBottom = options.cookieNotificationLocationBottom;
79 | var cookiePolicyPage = options.cookiePolicyPage;
80 | var cookiePolicyPageMessage = options.cookiePolicyPageMessage;
81 | var cookieDiscreetLink = options.cookieDiscreetLink;
82 | var cookieDiscreetReset = options.cookieDiscreetReset;
83 | var cookieDiscreetLinkText = options.cookieDiscreetLinkText;
84 | var cookieDiscreetPosition = options.cookieDiscreetPosition;
85 | var cookieNoMessage = options.cookieNoMessage;
86 | // cookie identifier
87 | var $cookieAccepted = $.cookie('cc_cookie_accept') == "cc_cookie_accept";
88 | $.cookieAccepted = function () {
89 | return $cookieAccepted;
90 | };
91 | var $cookieDeclined = $.cookie('cc_cookie_decline') == "cc_cookie_decline";
92 | $.cookieDeclined = function () {
93 | return $cookieDeclined;
94 | };
95 | // write cookie accept button
96 | if (cookieAcceptButton) {
97 | var cookieAccept = ' ' + cookieAcceptButtonText + ' ';
98 | } else {
99 | var cookieAccept = "";
100 | }
101 | // write cookie decline button
102 | if (cookieDeclineButton) {
103 | var cookieDecline = ' ' + cookieDeclineButtonText + ' ';
104 | } else {
105 | var cookieDecline = "";
106 | }
107 | // write extra class for overlay
108 | if (cookieOverlayEnabled) {
109 | var cookieOverlay = 'cc-overlay';
110 | } else {
111 | var cookieOverlay = "";
112 | }
113 | // to prepend or append, that is the question?
114 | if ((cookieNotificationLocationBottom) || (cookieDiscreetPosition == "bottomright") || (cookieDiscreetPosition == "bottomleft")) {
115 | var appOrPre = true;
116 | } else {
117 | var appOrPre = false;
118 | }
119 | if (($cookieAccepted) || ($cookieDeclined)) {
120 | // write cookie reset button
121 | if ((cookieResetButton) && (cookieDiscreetReset)) {
122 | if (appOrPre) {
123 | $('body').append('