Skip to content

Commit

Permalink
add data-cookieman-accept-none option #83
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Eberle committed Jan 17, 2020
1 parent dda0365 commit 2709859
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Documentation/Configuration/Customization/Index.rst
Expand Up @@ -63,6 +63,11 @@ These **HTML element attributes** control the functionality:

Mark all checkboxes

<* data-cookieman-accept-none>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Uncheck all checkboxes (will just leave the groups with the options preselected=1, disabled=1 checked)

They can appear multiple times and also together on the same element.

Example:
Expand Down
12 changes: 12 additions & 0 deletions Resources/Public/Js/cookieman.js
Expand Up @@ -12,6 +12,7 @@ var cookieman = (function () {
checkboxes = form.querySelectorAll('[type=checkbox][name]'),
saveButtons = document.querySelectorAll('[data-cookieman-save]'),
acceptAllButtons = document.querySelectorAll('[data-cookieman-accept-all]'),
acceptNoneButtons = document.querySelectorAll('[data-cookieman-accept-none]'),
injectedTrackingObjects = [],
loadedTrackingObjectScripts = {}

Expand Down Expand Up @@ -100,6 +101,11 @@ var cookieman = (function () {
selectAll()
}

function onAcceptNoneClick(e) {
e.preventDefault()
selectNone()
}

function setDntTextIfEnabled() {
if (window.navigator.doNotTrack === '1') {
var dnts = document.querySelectorAll('[data-cookieman-dnt]')
Expand Down Expand Up @@ -274,6 +280,12 @@ var cookieman = (function () {
onAcceptAllClick
)
}
for (i = 0; i < acceptNoneButtons.length; i++) {
acceptNoneButtons[i].addEventListener(
'click',
onAcceptNoneClick
)
}
for (i = 0; i < saveButtons.length; i++) {
saveButtons[i].addEventListener(
'click',
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/Js/cookieman.min.js

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

0 comments on commit 2709859

Please sign in to comment.