Skip to content

Commit

Permalink
feat(options): add policy and target options to NgcContentOptions
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
tinesoft committed Oct 17, 2018
1 parent 4d3fa61 commit a0849f2
Show file tree
Hide file tree
Showing 9 changed files with 1,377 additions and 24 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ Basically this involved the following steps (using ngx-translate + Anglar CLI):
"dismiss": "Got it!",
"allow": "Allow cookies",
"deny": "Decline",
"link": "Learn more"
"link": "Learn more",
"policy": "Cookie Policy"
}
}
```
Expand Down Expand Up @@ -247,7 +248,7 @@ export class AppComponent {
this.translateService.use(browserLang.match(/en|fr/) ? browserLang : 'en');

this.translateService//
.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link'])
.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link', 'cookie.policy'])
.subscribe(data => {

this.ccService.getConfig().content = this.ccService.getConfig().content || {} ;
Expand All @@ -258,6 +259,7 @@ export class AppComponent {
this.ccService.getConfig().content.allow = data['cookie.allow'];
this.ccService.getConfig().content.deny = data['cookie.deny'];
this.ccService.getConfig().content.link = data['cookie.link'];
this.ccService.getConfig().content.policy = data['cookie.policy'];

this.ccService.destroy();//remove previous cookie bar (with default messages)
this.ccService.init(this.ccService.getConfig()); // update config with translated messages
Expand Down
6 changes: 3 additions & 3 deletions demo/src/app/getting-started/getting-started.component.html

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions demo/src/app/home/playground/playground.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export class PlaygroundComponent implements OnInit {
dismiss: 'Got it!',
deny: 'Refuse cookies',
link: 'Learn more',
href: 'https://cookiesandyou.com'
href: 'https://cookiesandyou.com',
policy: 'Cookie Policy',

}
};

Expand All @@ -112,7 +114,7 @@ export class PlaygroundComponent implements OnInit {
this.translate.use(lang);
this.translate//
// See assets/i18n/**.json for the keys
.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link'])
.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link', 'cookie.policy'])
.subscribe(data => {

this.options.content.header = data['cookie.header'];
Expand All @@ -121,6 +123,7 @@ export class PlaygroundComponent implements OnInit {
this.options.content.allow = data['cookie.allow'];
this.options.content.deny = data['cookie.deny'];
this.options.content.link = data['cookie.link'];
this.options.content.policy = data['cookie.policy'];

this.updateConfig();
});
Expand Down
3 changes: 2 additions & 1 deletion demo/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dismiss": "Got it!",
"allow": "Allow cookies",
"deny": "Decline",
"link": "Learn more"
"link": "Learn more",
"policy": "Cookie Policy"
}
}
3 changes: 2 additions & 1 deletion demo/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dismiss": "OK, j'ai compris!",
"allow": "Autoriser les cookies",
"deny": "Refuser",
"link": "Plus d'information"
"link": "Plus d'information",
"policy": "Cookie Policy"
}
}
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@
"@angular/core": "6.0.0",
"@angular/common": "6.0.0",
"cookieconsent": "3.0.6"
},
},
"devDependencies": {
"@angular/compiler" : "6.0.0",
"@angular/platform-server" : "6.0.0",
"@angular/platform-browser" : "6.0.0",
"@angular/platform-browser-dynamic" : "6.0.0",
"@angular/compiler-cli" : "6.0.0",
"zone.js" : "0.8.26",
"rxjs" : "6.0.0",
"tslint" : "5.7.0",
"gulp-tslint" : "8.1.3",
"typescript" : "2.7.2",
"awesome-typescript-loader" : "5.2.0",
"codelyzer" : "4.2.1",
"@angular/animations" : "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/platform-server": "6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/compiler-cli": "6.0.0",
"zone.js": "0.8.26",
"rxjs": "6.0.0",
"tslint": "5.7.0",
"gulp-tslint": "8.1.3",
"typescript": "2.7.2",
"awesome-typescript-loader": "5.2.0",
"codelyzer": "4.2.1",
"@angular/animations": "6.0.0",
"@types/jasmine": "2.5.41",
"istanbul-instrumenter-loader": "3.0.1",
"jasmine-core": "2.8.0",
Expand Down Expand Up @@ -85,7 +85,7 @@
"gulp-hub": "0.8.0",
"ansi-colors": "2.0.1",
"fancy-log": "1.3.2",
"html-loader": "0.5.5",
"html-loader": "0.5.5",
"gulp-real-favicon": "0.3.0",
"gulp-rename": "1.2.2",
"gulp-replace": "0.6.1",
Expand Down
4 changes: 4 additions & 0 deletions src/model/content-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ export class NgcContentOptions {
href? = 'http://cookiesandyou.com';

close? = '❌';

policy? = 'Cookie Policy';

target? = '_blank';
}
2 changes: 2 additions & 0 deletions src/service/cookieconsent-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ describe('cookieconsent-config', () => {
expect(config.content.link).toEqual('Learn more');
expect(config.content.href).toEqual('http://cookiesandyou.com');
expect(config.content.close).toEqual('❌');
expect(config.content.policy).toEqual('Cookie Policy');
expect(config.content.target).toEqual('_blank');
});

it('should have sensible "cookie" default values', () => {
Expand Down
Loading

0 comments on commit a0849f2

Please sign in to comment.