|
1 | | -/*! biscuitman.js 0.3.11 */ |
| 1 | +/*! biscuitman.js 0.3.12 */ |
2 | 2 | ((d, w, Object1, h, bm)=>{ |
3 | 3 | const defaults = { |
4 | 4 | key: 'myconsent', |
|
16 | 16 | save: 'Save My Settings', |
17 | 17 | settingsTitle: 'My Consent Settings', |
18 | 18 | info: ``, |
19 | | - more: '(Show more)', |
| 19 | + more: 'Show more', |
20 | 20 | noCookies: 'No cookies to display', |
21 | 21 | acceptNonEU: false |
22 | 22 | }; |
|
46 | 46 | <div class="bm-sections"> |
47 | 47 | <p><span>${o.message}</span></p> |
48 | 48 | <p>${o.info.split('\n').map((line, i, arr)=>{ |
49 | | - let more = arr.length > 1 && o.enableMore && i == 0 ? `<a class="more" href="javascript:void(0)">${o.more}</a>` : ''; |
50 | | - return `<span>${line}${more}</span>`; |
| 49 | + return `<span>${line}</span> |
| 50 | + ${arr.length > 1 && o.enableMore && i == 0 ? `<a class="more" href="javascript:void(0)">${o.more}</a>` : ''}`; |
51 | 51 | }).join('')} |
52 | 52 | </p> |
53 | 53 | ${o.sections.map((section)=>{ |
54 | 54 | let hasConsent = getConsents()[section]; |
55 | 55 | let isEssential = section === 'essential'; |
56 | | - let isDisabled = isEssential ? 'disabled' : ''; |
57 | | - let isChecked = isEssential ? 'checked' : ''; |
58 | | - if (hasConsent !== undefined) isChecked = hasConsent ? 'checked' : ''; |
| 56 | + let disabledProp = isEssential ? 'disabled' : ''; |
| 57 | + let checkedProp = isEssential ? 'checked' : ''; |
| 58 | + if (hasConsent !== undefined) checkedProp = hasConsent ? 'checked' : ''; |
59 | 59 | let cookies = o[`${section}Cookies`]; |
60 | 60 | return ` |
61 | 61 | <section> |
62 | 62 | <details> |
63 | 63 | <summary> |
64 | 64 | <b>${o[`${section}Title`]}</b> |
65 | | - <label for="${bm}_${section}"> |
66 | | - <input type="checkbox" id="${bm}_${section}" ${isDisabled} ${isChecked} data-s="${section}"/> |
| 65 | + <label for="${bm}_${section}" class="${disabledProp} ${checkedProp}"> |
| 66 | + <input type="checkbox" id="${bm}_${section}" ${disabledProp} ${checkedProp} data-s="${section}"/> |
67 | 67 | </label> |
68 | 68 | <p>${o[`${section}Message`]}</p> |
69 | 69 | </summary> |
|
88 | 88 | dialog.addEventListener('cancel', cancelModalHandler); |
89 | 89 | const moreLink = ui.querySelector('.more'); |
90 | 90 | if (moreLink) moreLink.addEventListener('click', moreLink.remove); |
| 91 | + ui.querySelectorAll('[data-s]').forEach((checkbox)=>checkbox.addEventListener('change', (e)=>{ |
| 92 | + checkbox.parentElement.classList.toggle('checked', e.target.checked); |
| 93 | + })); |
91 | 94 | d.body.appendChild(ui); |
92 | 95 | } |
93 | 96 | const displayUI = (show)=>ui.classList.toggle('bm-hide', !show); |
|
288 | 291 | dispatch('invalidate', { |
289 | 292 | data: getConsents() |
290 | 293 | }); |
| 294 | + checkConsents({}); |
291 | 295 | saveConsents(false); |
292 | 296 | setConsents({}); |
293 | 297 | localStorage.removeItem(o.key); |
|
0 commit comments