Skip to content

Commit

Permalink
Merge pull request #4 from punkave/hotfix/defaults
Browse files Browse the repository at this point in the history
Hotfix/defaults
  • Loading branch information
Brian Gantick authored Jun 19, 2019
2 parents 559b32f + dcfba33 commit aac17d3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/modules/pk-cookie-alert-global/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ module.exports = {
value: 'top',
label: 'Top'
}
]
],
def: 'bottom'
}
];

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pk-cookie-alert",
"version": "1.1.0",
"version": "1.1.1",
"description": "A module that provides a persistent alert for users to acknowledge the use of cookies.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/js/always.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions src/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@ import { helpers, classes } from 'pk-utilities';
function init () {
const alert = '[data-component="pk-alert"]';
const confirm = '[data-role="dismiss-pk-alert"]';
const cookiename = document.querySelector(alert).dataset.name;
let cookiename = 'pk-alert';
if (document.querySelector(alert)) {
cookiename = document.querySelector(alert).dataset.name;
}
const confirmed = hasCookie(document.cookie, cookiename);
let i;
if (!confirmed) {
for (i = 0; i < document.querySelectorAll(alert).length; ++i) {
helpers.addClass(document.querySelectorAll(alert)[i], classes.active);
for (i = 0; i < document.querySelectorAll(alert).length; ++i) {
const scopedAlert = document.querySelectorAll(alert)[i];
if (!confirmed) {
scopedAlert.setAttribute('aria-hidden', 'false');
helpers.addClass(scopedAlert, classes.active);
} else {
scopedAlert.setAttribute('aria-hidden', 'true');
helpers.removeClass(scopedAlert, classes.active);
}
}
for (i = 0; i < document.querySelectorAll(confirm).length; ++i) {
const button = document.querySelectorAll(confirm)[i];
const scopedAlert = helpers.closest(button, alert);
button.addEventListener('click', function () {
createCookie(cookiename, true);
scopedAlert.setAttribute('aria-hidden', 'true');
helpers.removeClass(scopedAlert, classes.active);
});
}
Expand Down
12 changes: 5 additions & 7 deletions views/alert.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{% if not data.global.pkAlertDisable %}
<div class="{{ data.options.baseClass }} {{ data.options.baseClass }}--{{ data.global.pkAlertAlignment }}" role="alert" data-component="pk-alert" aria-hidden="true" data-name="{{ data.options.cookieName }}">
<div class="{{ data.options.baseClass }}__inner">
{% if data.global.pkAlertText %}
{% if data.global.pkAlertText and data.global.pkAlertButton %}
<div class="{{ data.options.baseClass }} {{ data.options.baseClass }}--{{ data.global.pkAlertAlignment }}" role="alert" data-component="pk-alert" aria-hidden="true" data-name="{{ data.options.cookieName }}">
<div class="{{ data.options.baseClass }}__inner">
<div class="{{ data.options.baseClass }}__text">
{{ apos.areas.richText(data.global.pkAlertText) }}
</div>
{% endif %}
{% if data.global.pkAlertButton %}
<button type="button" class="{{ data.options.baseClass }}__button" data-role="dismiss-pk-alert">
{{ data.global.pkAlertButton }}
</button>
{% endif %}
</div>
</div>
</div>
{% endif %}
{% endif %}

0 comments on commit aac17d3

Please sign in to comment.