Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #202 from Wikia/XW-4110-sb-cookies-redefined
Browse files Browse the repository at this point in the history
XW-4110 | Cookie for all subdomains, cleanups, cookie setting logic
  • Loading branch information
Aga Serowiec authored Oct 20, 2017
2 parents 19432d3 + 8e50ecb commit da40c2a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions app/components/fandom-app-smart-banner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Ember from 'ember';
import {track, trackActions} from '../utils/track';
import {standalone, system} from '../utils/browser';
import config from '../config/environment';

const {
$,
Expand All @@ -15,12 +16,13 @@ export default Component.extend({

options: {
// Duration to hide the banner after close button is clicked (0 = always show banner)
daysHiddenAfterClose: 15,
daysHiddenAfterClose: 30,

// Duration to hide the banner after it is clicked (0 = always show banner)
daysHiddenAfterView: 30,
daysHiddenAfterView: 90,
},
dayInSeconds: 86400000,
dayInMiliseconds: 86400000,
closeButtonSelector: '.fandom-app-smart-banner__close',

i18n: inject.service(),

Expand Down Expand Up @@ -48,10 +50,14 @@ export default Component.extend({
}
},

click() {
this.setSmartBannerCookie(this.get('options.daysHiddenAfterView'));
click(event) {
if (event.target === this.$(this.get('closeButtonSelector'))[0]) {
return;
}

this.track(trackActions.install);
this.sendAction('toggleVisibility', false);
this.setSmartBannerCookie(this.get('options.daysHiddenAfterView'));
},

/**
Expand All @@ -74,18 +80,19 @@ export default Component.extend({
},

/**
* Sets fandom-sb-closed1 cookie for given number of days
* Sets fandom-sb-closed=1 cookie for given number of days
*
* @param {number} days
* @returns {void}
*/
setSmartBannerCookie(days) {
const date = new Date();

date.setTime(date.getTime() + (days * this.get('dayInSeconds')));
date.setTime(date.getTime() + (days * this.get('dayInMiliseconds')));
$.cookie('fandom-sb-closed', 1, {
expires: date,
path: '/'
path: '/',
domain: config.cookieDomain
});
},

Expand Down

0 comments on commit da40c2a

Please sign in to comment.