diff --git a/cookieconsent.js b/cookieconsent.js
index 3b9c655..af59be4 100644
--- a/cookieconsent.js
+++ b/cookieconsent.js
@@ -20,8 +20,8 @@
var THEME_BUCKET_PATH = '//s3.amazonaws.com/cc.silktide.com/';
// No point going further if they've already dismissed.
- if (document.cookie.indexOf(DISMISSED_COOKIE) > -1) {
- return;
+ if (document.cookie.indexOf(DISMISSED_COOKIE) > -1 || (window.navigator && window.navigator.CookiesOK)) {
+ return;
}
// IE8...
@@ -91,11 +91,25 @@
return null;
},
- setCookie: function (name, value, expirydays) {
+ setCookie: function (name, value, expiryDays, domain, path) {
+ expiryDays = expiryDays || 365;
+
var exdate = new Date();
- expirydays = expirydays || 365;
- exdate.setDate(exdate.getDate() + expirydays);
- document.cookie = name + '=' + value + '; expires=' + exdate.toUTCString() + '; path=/'
+ exdate.setDate(exdate.getDate() + expiryDays);
+
+ var cookie = [
+ name + '=' + value,
+ 'expires=' + exdate.toUTCString(),
+ 'path=' + path || '/'
+ ];
+
+ if (domain) {
+ cookie.push(
+ 'domain=' + domain
+ );
+ }
+
+ document.cookie = cookie.join(';');
},
addEventListener: function (el, event, eventListener) {
@@ -139,7 +153,7 @@
var insertReplacements = function (htmlStr, scope) {
return htmlStr.replace(/\{\{(.*?)\}\}/g, function (_match, sub) {
var tokens = sub.split('||');
- var value;
+ var value, token;
while (token = tokens.shift()) {
token = token.trim();
@@ -217,14 +231,18 @@
dismiss: 'Got it!',
learnMore: 'More info',
link: null,
+ target: '_self',
container: null, // selector
theme: 'light-floating',
+ domain: null, // default to current domain.
+ path: '/',
+ expiryDays: 365,
markup: [
'
',
'
',
@@ -309,14 +327,14 @@
},
dismiss: function (evt) {
- evt.preventDefault() && evt.preventDefault();
+ evt.preventDefault && evt.preventDefault();
evt.returnValue = false;
this.setDismissedCookie();
this.container.removeChild(this.element);
},
setDismissedCookie: function () {
- Util.setCookie(DISMISSED_COOKIE, 'yes');
+ Util.setCookie(DISMISSED_COOKIE, 'yes', this.options.expiryDays, this.options.domain, this.options.path);
}
};
diff --git a/plugin.json b/plugin.json
index 89ca1f9..c2a91f3 100644
--- a/plugin.json
+++ b/plugin.json
@@ -1,13 +1,12 @@
{
"name": "Cookie Consent",
- "version": "1.0.7",
+ "version": "1.0.8",
"description": "Inform your users that you are using cookies",
"demo": "http://varoystrand.se/sidor/cookie-consent-for-koken/",
"author": {
"name": "Bjarne Varoystrand",
"link": "http://varoystrand.se/"
},
-
"data": {
"cookie_consent_message": {
"label": "The message shown",
@@ -62,6 +61,37 @@
{ "value": "dark-bottom", "label": "Dark bottom" },
{ "value": "false", "label": "Use your own theme" }
]
+ },
+ "cookie_consent_path": {
+ "label": "Cookie Path",
+ "info": "The path for the consent cookie that Cookie Consent uses, to remember that users have consented to cookies. Use to limit consent to a specific path within your website.",
+ "type": "string",
+ "value": "/"
+ "validation": {
+ "type": "not_empty",
+ "error_message": "You need to set a valid path for the cookie."
+ }
+ },
+ "cookie_consent_domain": {
+ "label": "Cookie Domain",
+ "info": "The domain for the consent cookie that Cookie Consent uses, to remember that users have consented to cookies. Useful if your website uses multiple subdomains, e.g. if your script is hosted at www.example.com you might override this to example.com, thereby allowing the same consent cookie to be read by subdomains like foo.example.com.",
+ "type": "string",
+ "placeholder": "example.com"
+ },
+ "cookie_consent_expirydays": {
+ "label": "Expiry days",
+ "info": "The number of days Cookie Consent should store the users consent information for. Defaults to 365 days (1 year).",
+ "type": "number",
+ "value": "365"
+ },
+ "cookie_consent_target": {
+ "label": "Target",
+ "info": "The target of the link to your cookie policy. Use to open a link in a new window.",
+ "type": "select",
+ "options": [
+ { "value": "self", "label": "Same window" },
+ { "value": "blank", "label": "Opens in new window" }
+ ]
}
}
-}
+}
\ No newline at end of file
diff --git a/plugin.php b/plugin.php
index c073fd7..3e302d2 100644
--- a/plugin.php
+++ b/plugin.php
@@ -11,12 +11,16 @@ function __construct()
function render()
{
- $message = $this->data->cookie_consent_message;
- $dismiss = $this->data->cookie_consent_dismiss;
- $learnMore = $this->data->cookie_consent_learnmore;
- $link = $this->data->cookie_consent_link;
- $theme = $this->data->cookie_consent_theme;
- $path = $this->get_path();
+ $message = $this->data->cookie_consent_message;
+ $dismiss = $this->data->cookie_consent_dismiss;
+ $learnMore = $this->data->cookie_consent_learnmore;
+ $link = $this->data->cookie_consent_link;
+ $theme = $this->data->cookie_consent_theme;
+ $target = $this->data->cookie_consent_target;
+ $cookiedomain = $this->data->cookie_consent_domain;
+ $cookiepath = $this->data->cookie_consent_path;
+ $cookieexp = $this->data->cookie_consent_expirydays;
+ $path = $this->get_path();
echo <<
@@ -25,7 +29,11 @@ function render()
dismiss: '{$dismiss}',
learnMore: '{$learnMore}',
link: '{$link}',
- theme: '{$path}/styles/{$theme}.css'
+ target: '_{$target}',
+ theme: '{$path}/styles/{$theme}.css',
+ domain: '{$cookiedomain}',
+ path: '{$cookiepath}',
+ expiryDays: '{$cookieexp}'
}