Skip to content

Commit

Permalink
Replace inline style by hidden attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonsobral committed Mar 22, 2022
1 parent 39d28a7 commit 9d9c2f3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

Cookies EU banner is an MIT-licensed open source project and completely free to use.
You can support it's ongoing development by being a backer or a sponsor:

- [Become a backer or sponsor on Patreon](https://www.patreon.com/alexandredemode)
- [One-time donation via PayPal](https://www.paypal.me/demodealexandre/20eur)

Expand Down Expand Up @@ -48,7 +48,7 @@ It is a GDPR-compliant way to get cookie consent from visitors.
Insert the banner before any content at the beginning of the `<body>` element, with these IDs:

```html
<div id="cookies-eu-banner" style="display: none;">
<div id="cookies-eu-banner" hidden>
By continuing to visit this site, you accept the use of cookies by Google Analytics for statistical purposes.
<a href="./read-more.html" id="cookies-eu-more">Read more</a>
<button id="cookies-eu-reject">Reject</button>
Expand Down Expand Up @@ -124,10 +124,10 @@ The third parameter (`true` in the example below) define if Cookie EU banner use
#### waitRemove

If you want add some transition on accept/reject, and want to prevent the premature deletion of the banner, you can add
`data-wait-remove` attribute to the banner, with the time to wait in milliseconds.
`data-wait-remove` attribute to the banner, with the time to wait in milliseconds.

```html
<div id="cookies-eu-banner" style="display: none;" data-wait-remove="250">
<div id="cookies-eu-banner" hidden data-wait-remove="250">
<!-- ... -->
</div>
```
Expand Down
2 changes: 1 addition & 1 deletion docs/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</style>
</head>
<body>
<div id="cookies-eu-banner" style="display: none;">
<div id="cookies-eu-banner" hidden>
<span>By continuing to visit this site, you accept the use of cookies by Google Analytics for statistical purposes.</span>
<a href="./read-more.html" id="cookies-eu-more">Read more</a>
<button id="cookies-eu-reject">Reject</button>
Expand Down
2 changes: 1 addition & 1 deletion docs/demo/read-more.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</style>
</head>
<body>
<div id="cookies-eu-banner" style="display: none;">
<div id="cookies-eu-banner" hidden>
By continuing your visit to this site, you accept the use of cookies by Google Analytics to make visits statistics.
<a href="./read-more.html" id="cookies-eu-more">Read more</a>
<button id="cookies-eu-reject">Reject</button>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h3 class="section-subtitle">How to use?</h3>
</p>
<pre><code class="html">
&lt;body>
&lt;div id="cookies-eu-banner" style="display: none;">
&lt;div id="cookies-eu-banner" hidden>
By continuing your visit to this site, you accept the use of cookies by Google Analytics to make visits statistics.
&lt;a href="./read-more.html" id="cookies-eu-more">Read more&lt;/a>
&lt;button id="cookies-eu-reject">Reject&lt;/button>
Expand Down Expand Up @@ -207,7 +207,7 @@ <h4 class="section-part-title">Option: <code>waitRemove</code></h4>
</p>

<pre><code class="html">
&lt;div id="cookies-eu-banner" style="display: none;" <span class="highlight">data-wait-remove="250"</span>>
&lt;div id="cookies-eu-banner" hidden <span class="highlight">data-wait-remove="250"</span>>
<!-- ... -->
&lt;/div>
</code></pre>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cookies-eu-banner",
"title": "Cookies EU banner",
"description": "Manage display of banner to accept/reject cookies from tracking services like Google Analytics",
"version": "2.0.1",
"version": "2.1.0",
"main": "dist/cookies-eu-banner.js",
"homepage": "http://alex-d.github.io/Cookies-EU-banner/",
"author": {
Expand Down
6 changes: 5 additions & 1 deletion src/cookies-eu-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@
addClickListener = this.addClickListener,
removeBanner = _this.removeBanner.bind(_this, waitRemove);

banner.style.display = 'block';
if (banner.hasAttribute('hidden')) {
banner.removeAttribute('hidden');
} else {
banner.style.display = 'block';
}

if (moreLink) {
addClickListener(moreLink, function () {
Expand Down

0 comments on commit 9d9c2f3

Please sign in to comment.