-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f8a340
Showing
127 changed files
with
4,850 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!-- | ||
IF YOU DON'T FILL OUT THE FOLLOWING INFORMATION YOUR ISSUE MIGHT BE CLOSED WITHOUT INVESTIGATING | ||
--> | ||
### Bug Report or Feature Request (mark with an `x`) | ||
``` | ||
- [ ] bug report -> please search issues before submitting | ||
- [ ] feature request | ||
``` | ||
|
||
### OS and Version? | ||
<!-- | ||
> Windows 7, 8 or 10. Linux (which distribution).macOS(Yosemite ? El Capitan? Sierra ?) | ||
--> | ||
|
||
### Versions. | ||
<!-- | ||
Output from: `ng --version`, in case you are using Angular CLI. | ||
Otherwise, output from: `node --version` , `npm --version` and Angular version. | ||
--> | ||
|
||
|
||
### Repro steps. | ||
<!-- | ||
Simple steps to reproduce this bug. | ||
Please include: commands run, packages added, related code changes. | ||
A link to a sample repo would help too. | ||
--> | ||
|
||
|
||
### The log given by the failure. | ||
<!-- Normally this include a stack trace and some more information. --> | ||
|
||
|
||
### Desired functionality. | ||
<!-- | ||
What would like to see implemented? | ||
What is the usecase? | ||
--> | ||
|
||
|
||
### Mention any other details that might be useful. | ||
<!-- Please include a link to the repo if this is related to an OSS project. --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# IDEs and editors | ||
/.idea | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
testem.log | ||
/typings | ||
/config/gulp-tasks/README.md | ||
|
||
# e2e | ||
/e2e/*.js | ||
/e2e/*.map | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
sudo: required | ||
dist: trusty | ||
|
||
#install google chrome, using addons | ||
addons: | ||
apt: | ||
sources: | ||
- google-chrome | ||
packages: | ||
- google-chrome-stable | ||
|
||
language: node_js | ||
node_js: | ||
- "6" | ||
|
||
before_script: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
- npm install --quiet -g gulp-cli | ||
|
||
script: gulp test:ci | ||
|
||
after_success: gulp coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"generator-ngx-library": { | ||
"authorName": "Tine Kondo", | ||
"authorEmail": "[email protected]", | ||
"githubUsername": "tinesoft", | ||
"projectName": "ngx-cookieconsent", | ||
"projectVersion": "0.0.1", | ||
"projectDescription": "Cookie Consent module for Angular.", | ||
"projectKeywords": [ | ||
"angular", | ||
"ng", | ||
"cookie", | ||
"law", | ||
"eu" | ||
], | ||
"moduleName": "cookieconsent", | ||
"ngVersion": "2.0.0", | ||
"ngPrefix": "ngc", | ||
"ngModules": [ | ||
"core", | ||
"common" | ||
], | ||
"useGreenkeeper": true, | ||
"useCompodoc": true | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Tine Kondo | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
# ngx-cookieconsent - [Cookie Consent](https://cookieconsent.insites.com/) module for Angular. | ||
|
||
[![npm version](https://badge.fury.io/js/ngx-cookieconsent.svg)](https://badge.fury.io/js/ngx-cookieconsent) | ||
[![Build Status](https://travis-ci.org/tinesoft/ngx-cookieconsent.svg?branch=master)](https://travis-ci.org/tinesoft/ngx-cookieconsent) | ||
[![Coverage Status](https://coveralls.io/repos/github/tinesoft/ngx-cookieconsent/badge.svg?branch=master)](https://coveralls.io/github/tinesoft/ngx-cookieconsent?branch=master) | ||
[![dependency Status](https://david-dm.org/tinesoft/ngx-cookieconsent/status.svg)](https://david-dm.org/tinesoft/ngx-cookieconsent) | ||
[![devDependency Status](https://david-dm.org/tinesoft/ngx-cookieconsent/dev-status.svg?branch=master)](https://david-dm.org/tinesoft/ngx-cookieconsent#info=devDependencies) | ||
[![Greenkeeper Badge](https://badges.greenkeeper.io/tinesoft/ngx-cookieconsent.svg)](https://greenkeeper.io/) | ||
|
||
## Demo | ||
|
||
View the module in action at https://tinesoft.github.io/ngx-cookieconsent | ||
|
||
## Dependencies | ||
* [Angular](https://angular.io) (*requires* Angular 2 or higher, tested with 2.0.0 and 4.0.0) | ||
* [Cookie Consent](https://cookieconsent.insites.com/) (*requires* Cookie Consent 3 or higher, tested with 3.0.4) | ||
|
||
|
||
## Installation | ||
Install above dependencies via *npm*. In particular for `Cookie Consent`: | ||
```shell | ||
npm install --save cookieconsent | ||
``` | ||
|
||
Now install `ngx-cookieconsent` via: | ||
```shell | ||
npm install --save ngx-cookieconsent | ||
``` | ||
|
||
--- | ||
##### Angular-CLI | ||
>**Note**: If you are using `angular-cli` to build your app, make sure that `cookieconsent` is properly listed as a [global library](https://github.com/angular/angular-cli/wiki/stories-global-scripts), and as [global style](https://github.com/angular/angular-cli/wiki/stories-global-styles). | ||
To do so, edit your `.angular-cli.json` as such: | ||
``` | ||
"scripts": [ | ||
"../node_modules/cookieconsent/build/cookieconsent.min.js" | ||
], | ||
"styles": [ | ||
"../node_modules/cookieconsent/build/cookieconsent.min.css" | ||
], | ||
``` | ||
|
||
##### SystemJS | ||
>**Note**:If you are using `SystemJS`, you should adjust your configuration to point to the UMD bundle. | ||
In your systemjs config file, `map` needs to tell the System loader where to look for `ngx-cookieconsent`: | ||
```js | ||
map: { | ||
'ngx-cookieconsent': 'node_modules/ngx-cookieconsent/bundles/ngx-cookieconsent.umd.js', | ||
} | ||
``` | ||
In your systemjs config file, `meta` needs to tell the System loader how to load `cookieconsent`: | ||
```js | ||
meta: { | ||
'./node_modules/cookieconsent/build/cookieconsent.min.js': { | ||
format: 'amd' | ||
} | ||
} | ||
``` | ||
In your index.html file, add script and link tags to load `cookieconsent` globally: | ||
```html | ||
<!-- 1. Configure SystemJS --> | ||
<script src="system.config.js"></script> | ||
<!-- 2. Add cookieconsent dependency--> | ||
<link rel="stylesheet" type="text/css" href="node_modules/cookieconsent/build/cookieconsent.min.css"/> | ||
<script src="node_modules/cookieconsent/build/cookieconsent.min.js"></script> | ||
``` | ||
|
||
--- | ||
|
||
Once installed you need to import the main module: | ||
```ts | ||
import {NgcCookieConsentModule} from 'ngx-cookieconsent'; | ||
``` | ||
The only remaining part is to list the imported module in your application module. The exact method will be slightly | ||
different for the root (top-level) module for which you should end up with the code similar to (notice `NgcCookieConsentModule.forRoot()`): | ||
```ts | ||
import {NgcCookieConsentModule, NgcCookieConsentConfig} from 'ngx-cookieconsent'; | ||
|
||
const cookieConfig:NgcCookieConsentConfig = { | ||
cookie: { | ||
domain: 'your.domain.com' // it is recommended to set your domain, for cookies to work properly | ||
}, | ||
palette: { | ||
popup: { | ||
background: '#000' | ||
}, | ||
button: { | ||
background: '#f1d600' | ||
} | ||
}, | ||
theme: 'edgeless', | ||
type: 'opt-out' | ||
}; | ||
|
||
|
||
@NgModule({ | ||
declarations: [AppComponent, ...], | ||
imports: [NgcCookieConsentModule.forRoot(cookieConfig), ...], | ||
bootstrap: [AppComponent] | ||
}) | ||
export class AppModule { | ||
} | ||
``` | ||
|
||
> Note: The configuration object passed to the `NgcCookieConsentModule.forRoot()` is optional, but it is recommended to provided one, with at least the 'cookie.domain' property set to your domain. | ||
Other modules in your application can simply import `NgcCookieConsentModule`: | ||
|
||
```ts | ||
import {NgcCookieConsentModule} from 'ngx-cookieconsent'; | ||
|
||
@NgModule({ | ||
declarations: [OtherComponent, ...], | ||
imports: [NgcCookieConsentModule, ...], | ||
}) | ||
export class OtherModule { | ||
} | ||
``` | ||
|
||
## Usage | ||
|
||
Once the module is imported, you can use the `NgcCookieContentService` in your component (i.e. `AppComponent`) to subscribe to main events fired by Cookie Consent and do stuff like disabling cookies or other. | ||
|
||
Here is how it works: | ||
|
||
```ts | ||
import { Component, OnInit, OnDestroy } from '@angular/core'; | ||
import { NgcCookieConsentService } from 'ngx-cookieconsent'; | ||
import { Subscription } from 'rxjs/Subscription'; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
}) | ||
export class AppComponent implements OnInit, OnDestroy { | ||
|
||
//keep refs to subscriptions to be able to unsubscribe later | ||
private popupOpenSubscription: Subscription; | ||
private popupCloseSubscription: Subscription; | ||
private initializeSubscription: Subscription; | ||
private statusChangeSubscription: Subscription; | ||
private revokeChoiceSubscription: Subscription; | ||
|
||
constructor(private ccService: NgcCookieConsentService){} | ||
|
||
ngOnInit() { | ||
// subscribe to cookieconsent observables to react to main events | ||
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe( | ||
() => { | ||
// you can use this.ccService.getConfig() to do stuff... | ||
}); | ||
|
||
this.popupCloseSubscription = this.ccService.popupClose$.subscribe( | ||
() => { | ||
// you can use this.ccService.getConfig() to do stuff... | ||
}); | ||
|
||
this.initializeSubscription = this.ccService.initialize$.subscribe( | ||
(event: NgcInitializeEvent) => { | ||
// you can use this.ccService.getConfig() to do stuff... | ||
}); | ||
|
||
this.statusChangeSubscription = this.ccService.statusChange$.subscribe( | ||
(event: NgcStatusChangeEvent) => { | ||
// you can use this.ccService.getConfig() to do stuff... | ||
}); | ||
|
||
this.revokeChoiceSubscription = this.ccService.revokeChoice$.subscribe( | ||
() => { | ||
// you can use this.ccService.getConfig() to do stuff... | ||
}); | ||
} | ||
|
||
ngOnDestroy() { | ||
// unsubscribe to cookieconsent observables to prevent memory leaks | ||
this.popupOpenSubscription.unsubscribe(); | ||
this.popupCloseSubscription.unsubscribe(); | ||
this.initializeSubscription.unsubscribe(); | ||
this.statusChangeSubscription.unsubscribe(); | ||
this.revokeChoiceSubscription.unsubscribe(); | ||
} | ||
} | ||
|
||
``` | ||
|
||
See [Cookie Consent Documentation](https://cookieconsent.insites.com/documentation/about-cookie-consent/) to see more about how to customize the UI or interact with user interactions. | ||
|
||
## Credits | ||
|
||
`ngx-cookieconsent` is built upon [Cookie Consent](https://cookieconsent.insites.com/), created by [Insites](https://insites.com) | ||
|
||
## License | ||
|
||
Copyright (c) 2017 Tine Kondo. Licensed under the MIT License (MIT) | ||
|
Oops, something went wrong.