-
Notifications
You must be signed in to change notification settings - Fork 62
/
example.html
62 lines (54 loc) · 2.9 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<html>
<head>
<meta charset="UTF-8">
<title>I have 🍪s</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.ihavecookies.js"></script>
<script type="text/javascript">
var options = {
title: '🍪 Accept Cookies & Privacy Policy?',
message: 'There are no cookies used on this site, but if there were this message could be customised to provide more details. Click the <strong>accept</strong> button below to see the optional callback in action...',
delay: 600,
expires: 1,
link: '#privacy',
onAccept: function(){
var myPreferences = $.fn.ihavecookies.cookie();
console.log('Yay! The following preferences were saved...');
console.log(myPreferences);
},
uncheckBoxes: true,
acceptBtnLabel: 'Accept Cookies',
moreInfoLabel: 'More information',
cookieTypesTitle: 'Select which cookies you want to accept',
fixedCookieTypeLabel: 'Essential',
fixedCookieTypeDesc: 'These are essential for the website to work correctly.'
}
$(document).ready(function() {
$('body').ihavecookies(options);
if ($.fn.ihavecookies.preference('marketing') === true) {
console.log('This should run because marketing is accepted.');
}
$('#ihavecookiesBtn').on('click', function(){
$('body').ihavecookies(options, 'reinit');
});
});
</script>
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab|Quicksand:400,500" rel="stylesheet">
<link href="example.css" rel="stylesheet">
</head>
<body>
<div class="container">
<h1>ihavecookies jQuery Plugin in action</h1>
<p>When you load this page you will see an example of the cookie message popup in the bottom right corner.</p>
<p>If you don't see it then you've probably already accepted it. Click the button below to reopen it.</p>
<p><button id="ihavecookiesBtn">Open Settings</button></p>
<h3>Checkboxes</h3>
<p>With the recent EU regulations, visitors now must be able to opt-in to marketing, preferences, etc themselves. The plugin has an option that enables checkboxes to be unchecked automatically on page load.</p>
<ul>
<li><input type="checkbox" id="opt1" value="Y" checked> <label for="opt1">Checked by default ‐ remains checked</label>
<li><input type="checkbox" id="opt2" value="Y"> <label for="opt2">Unchecked by default ‐ remains unchecked</label>
<li><input type="checkbox" id="opt3" value="Y" class="ihavecookies" checked> <label for="opt3">Checked by default ‐ <em>ihavecookies</em> automatically unchecks this on page load because is has the class <code>ihavecookies</code> applied to it.</label>
</ul>
</div>
</body>
</html>