/example.html
HTML | 120 lines | 107 code | 13 blank | 0 comment | 0 complexity | 68f4844c0b5846c0b7c7dbdf8a3a2c89 MD5 | raw file
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>Cookiebar test</title>
- <link rel="stylesheet" href="cookiebar.css" />
- <style type="text/css">
- body{
- margin: 0;
- padding: 0;
- font-family: sans-serif;
- }
- #areCookiesEnabled{
- margin: 30px;
- }
- </style>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
- <script type="text/javascript" src="cookiebar.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- /**
- * Simple example 1
- */
- //Cookiebar.load($("#cookiebar_holder"));
- /**
- * Simple example 2
- */
- /*
- Cookiebar.init({
- text: "This website uses cookies.",
- confirmText: "ok",
- confirmButton: true,
- closeButton: false
- });
- Cookiebar.load($("#cookiebar_holder"));
- */
- /**
- * Full example with all available options
- */
- Cookiebar.init({
- //cookiebar message
- text: 'Please enable <a href="more.html" target="_blank">cookes</a>.',
- //confirm button text
- confirmText: "ok",
- //close button text
- closeText: "close",
- //show confirm button
- confirmButton: true,
- //show close button
- closeButton: true,
- //refresh page after close/confirm button click
- refresh: false,
- //keep showing cookiebar until user enables cookies
- preserve: false,
- //cookiebar cookie expiration date (if "usePhp" is true, also change constant EXPIRE_DAYS in cookiebar.php)
- expireDays: 365,
- //cookie name for cookiebar (you can leave these at the default value)
- cookieName: "cookiebar_enabled",
- //set and get cookies using php (you probability wont need this)
- usePhp: false,
- //link to php script (useful only if "usePhp" is true)
- phpUrl: "http://localhost/cookiebar.php",
- //on load callback
- onLoad: function(){
- Cookiebar.slideDown();
- console.log("Cookiebar onLoad!");
- },
- //on confirm clallback
- onConfirm: function(){
- Cookiebar.slideUp();
- console.log("Cookiebar onConfirm!");
- },
- //on close callback
- onClose: function(){
- Cookiebar.slideUp();
- console.log("Cookiebar onClose!");
- }
- });
- Cookiebar.load($("#cookiebar_holder"));
- /**
- * Check if cookies are enabled
- */
- $("#areCookiesEnabled").click(function () {
- if(Cookiebar.areCookiesEnabled()){
- alert("Cookies are enabled.");
- }else {
- alert("Cookies are not enabled.");
- }
- //if "usePhp" is true you need to use callback to check if cookies are enabled
- /*
- Cookiebar.areCookiesEnabled(function (enabled) {
- alert(enabled);
- });
- */
- });
- /**
- * Set cookies enabled
- */
- //Cookiebar.setCookiesEnabled(true);
- });
- </script>
- </head>
- <body>
- <div id="cookiebar_holder"></div>
- <input type="button" value="Are cookies enabled?" id="areCookiesEnabled" />
- </body>
- </html>