Skip to content

Commit

Permalink
Merge pull request #131 from orestbida/v2.7
Browse files Browse the repository at this point in the history
release v2.7.0
  • Loading branch information
orestbida authored Dec 6, 2021
2 parents d44622f + 4d44fce commit 02224c2
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 144 deletions.
26 changes: 20 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ A __lightweight__ & __gdpr compliant__ cookie consent plugin written in plain ja

```bash
# CDN links
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.6.2/dist/cookieconsent.js
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.6.2/dist/cookieconsent.css
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.7.0/dist/cookieconsent.js
https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@v2.7.0/dist/cookieconsent.css
```

Thanks to [Till Sanders](https://github.com/tillsanders) for bringing the plugin on npm.
Expand Down Expand Up @@ -349,8 +349,7 @@ cookieconsent.run({
```
<i>Default layout is `box` and default transition is `zoom`.</i>

#### Note: if `force_consent` option is not enabled, the `middle` position will be ignored

#### ~~Note: if `force_consent` option is not enabled, the `middle` position will be ignored~~. As of v2.7.0 the `middle` position is allowed regardless of `force_consent`.
<br>

## Manage third party scripts
Expand Down Expand Up @@ -543,14 +542,27 @@ Additional methods for an easier management of your scripts and cookie settings
- <details><summary>cookieconsent<code>.getConfig(&lt;field&gt;)</code> [v2.7.0+]</summary>
<p>

The `.getConfig()` method allows you to read configuration options from the current instance:
The `.getConfig()` method allows you to read configuration options from the current instance:
```javascript
cookieconsent.getConfig('current_lang'); // get currently used language
cookieconsent.getConfig('cookie_expiration'); // get configured cookie expiration
// ...
```
</p>
</details>
- <details><summary>cookieconsent<code>.getUserPreferences()</code> [v2.7.0+]</summary>
<p>

The `.getUserPreferences()` returns the following object (for analytics/logging purposes):
```javascript
{
accept_type: string, // 'all', 'necessary', 'custom'
accepted_categories: string[], // e.g. ['necessary', 'analytics']
rejected_categories: string[] // e.g. ['ads']
}
```
</p>
</details>


### All available options
Expand All @@ -560,6 +572,7 @@ Below a table which sums up all of the available options (must be passed to the
| `autorun` | boolean | true | If enabled, show the cookie consent as soon as possible (otherwise you need to manually call the `.show()` method) |
| `delay` | number | 0 | Number of `milliseconds` before showing the consent-modal |
| `cookie_expiration` | number | 182 | Number of days before the cookie expires (182 days = 6 months) |
| `cookie_necessary_only_expiration` | number | - | Specify if you want to set a different number of days - before the cookie expires - when the user accepts only the necessary categories |
| `cookie_path` | string | "/" | Path where the cookie will be set |
| `cookie_domain` | string | location.hostname | Specify your domain (will be grabbed by default) or a subdomain |
| `cookie_same_site` | string | "Lax" | SameSite attribute |
Expand All @@ -574,8 +587,9 @@ Below a table which sums up all of the available options (must be passed to the
| `remove_cookie_tables`| boolean | false | Enable if you want to remove the html cookie tables (but still want to make use of `autoclear_cookies`) |
| `hide_from_bots` | boolean | false | Enable if you don't want the plugin to run when a bot/crawler/webdriver is detected |
| `gui_options` | object | - | Customization option which allows to choose layout, position and transition. Check [layout options & customization](#layout-options--customization) |
| __`onAccept`__ | function | - | Method run `once` either when: <br> 1. The moment the cookie consent is accepted <br> 2. After each page load (if cookie consent has already been accepted) |
| __`onAccept`__ | function | - | Method run on: <br> 1. the moment the cookie consent is accepted <br> 2. after each page load (if cookie consent has already been accepted) |
| __`onChange`__ | function | - | Method run `whenever preferences are modified` (and only if cookie consent has already been accepted) |
| __`onFirstAction`__ | function | - | Method run only `once` when the user makes the initial choice (accept/reject) |
| `languages` | object | - | [Check below](#how-to-configure-languages--cookie-settings) for configuration
## Full example configurations
Expand Down
Loading

0 comments on commit 02224c2

Please sign in to comment.