From 4968fed20cbd63e2af197995679b0933d731b43e Mon Sep 17 00:00:00 2001 From: Melvin Reijnoudt Date: Tue, 24 Jul 2018 14:09:01 +0200 Subject: [PATCH] If daysHidden and/or daysReminder are 0, we do not want to set a cookie, if you do there may be a problem due to time difference, so the banner will not be shown on refresh --- index.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 95f9f0b..af4ef92 100644 --- a/index.js +++ b/index.js @@ -170,20 +170,24 @@ SmartBanner.prototype = { }, close: function () { this.hide(); - cookie.set(this.appId + '-smartbanner-closed', 'true', { - path: '/', - expires: new Date(Number(new Date()) + (this.options.daysHidden * 1000 * 60 * 60 * 24)) - }); + if(this.options.daysHidden > 0) { + cookie.set(this.appId + '-smartbanner-closed', 'true', { + path: '/', + expires: new Date(Number(new Date()) + (this.options.daysHidden * 1000 * 60 * 60 * 24)) + }); + } if (typeof this.options.close === 'function') { return this.options.close(); } }, install: function () { this.hide(); - cookie.set(this.appId + '-smartbanner-installed', 'true', { - path: '/', - expires: new Date(Number(new Date()) + (this.options.daysReminder * 1000 * 60 * 60 * 24)) - }); + if(this.options.daysReminder > 0) { + cookie.set(this.appId + '-smartbanner-installed', 'true', { + path: '/', + expires: new Date(Number(new Date()) + (this.options.daysReminder * 1000 * 60 * 60 * 24)) + }); + } if (typeof this.options.close === 'function') { return this.options.close(); }