@ons/design-system 44.0.2 → 45.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/components/access-code/uac.scss +5 -5
  2. package/components/address-input/_macro.njk +1 -0
  3. package/components/address-input/autosuggest.address.js +0 -1
  4. package/components/autosuggest/_macro.njk +1 -0
  5. package/components/autosuggest/autosuggest.ui.js +3 -3
  6. package/components/autosuggest/{code.list.searcher.js → fuse-config.js} +1 -3
  7. package/components/checkboxes/_checkbox-macro.njk +1 -1
  8. package/components/checkboxes/_macro.njk +1 -1
  9. package/components/fieldset/_macro.njk +1 -1
  10. package/components/header/_header.scss +3 -4
  11. package/components/header/_macro.njk +2 -2
  12. package/components/highlight/_highlight.scss +5 -0
  13. package/components/input/_input.scss +2 -2
  14. package/components/metadata/_macro.njk +1 -1
  15. package/components/metadata/_metadata.scss +1 -1
  16. package/components/modal/_macro.njk +23 -0
  17. package/components/modal/_modal.scss +32 -0
  18. package/components/modal/modal.dom.js +14 -0
  19. package/components/modal/modal.js +104 -0
  20. package/components/radios/_macro.njk +2 -2
  21. package/components/table-of-contents/_macro.njk +7 -7
  22. package/components/textarea/_macro.njk +2 -2
  23. package/components/timeout-modal/_macro.njk +26 -0
  24. package/components/timeout-modal/timeout.dom.js +16 -0
  25. package/components/timeout-modal/timeout.js +289 -0
  26. package/css/census.css +1 -1
  27. package/css/main.css +1 -1
  28. package/favicons/census/cy/android-chrome-192x192.png +0 -0
  29. package/favicons/census/cy/android-chrome-512x512.png +0 -0
  30. package/favicons/census/cy/apple-touch-icon.png +0 -0
  31. package/favicons/census/cy/browserconfig.xml +12 -0
  32. package/favicons/census/cy/favicon-16x16.png +0 -0
  33. package/favicons/census/cy/favicon-32x32.png +0 -0
  34. package/favicons/census/cy/favicon.ico +0 -0
  35. package/favicons/census/cy/manifest.json +20 -0
  36. package/favicons/census/cy/mstitle-150x150.png +0 -0
  37. package/favicons/census/cy/mstitle-310x150.png +0 -0
  38. package/favicons/census/cy/mstitle-310x310.png +0 -0
  39. package/favicons/census/cy/mstitle-70x70.png +0 -0
  40. package/favicons/census/cy/opengraph.png +0 -0
  41. package/favicons/census/cy/safari-pinned-tab.svg +3 -0
  42. package/favicons/census/cy/site.webmanifest +19 -0
  43. package/favicons/census/cy/twitter.png +0 -0
  44. package/favicons/census/en/android-chrome-192x192.png +0 -0
  45. package/favicons/census/en/android-chrome-512x512.png +0 -0
  46. package/favicons/census/en/apple-touch-icon.png +0 -0
  47. package/favicons/census/en/browserconfig.xml +12 -0
  48. package/favicons/census/en/favicon-16x16.png +0 -0
  49. package/favicons/census/en/favicon-32x32.png +0 -0
  50. package/favicons/census/en/favicon.ico +0 -0
  51. package/favicons/census/en/manifest.json +20 -0
  52. package/favicons/census/en/mstitle-150x150.png +0 -0
  53. package/favicons/census/en/mstitle-310x150.png +0 -0
  54. package/favicons/census/en/mstitle-310x310.png +0 -0
  55. package/favicons/census/en/mstitle-70x70.png +0 -0
  56. package/favicons/census/en/opengraph.png +0 -0
  57. package/favicons/census/en/safari-pinned-tab.svg +3 -0
  58. package/favicons/census/en/site.webmanifest +19 -0
  59. package/favicons/census/en/twitter.png +0 -0
  60. package/favicons/census/ni/favicon.ico +0 -0
  61. package/js/abortable-fetch.js +55 -0
  62. package/js/analytics.js +70 -0
  63. package/js/cookies-functions.js +182 -0
  64. package/js/cookies-settings.dom.js +13 -0
  65. package/js/cookies-settings.js +105 -0
  66. package/js/domready.js +17 -0
  67. package/js/fetch.js +19 -0
  68. package/js/inpagelink.dom.js +13 -0
  69. package/js/inpagelink.js +31 -0
  70. package/js/main.js +27 -0
  71. package/js/polyfills.js +9 -0
  72. package/js/print-button.js +16 -0
  73. package/{page-templates → layout}/_template.njk +0 -0
  74. package/package.json +4 -4
  75. package/scripts/main.es5.js +2 -2
  76. package/scripts/main.js +1 -1
  77. package/scss/main.scss +2 -5
  78. package/scss/patternlib.scss +3 -0
  79. package/scss/vars/_vars.scss +1 -1
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <browserconfig>
3
+ <msapplication>
4
+ <tile>
5
+ <square70x70logo src="mstile-70x70.png"/>
6
+ <square150x150logo src="mstile-150x150.png"/>
7
+ <square310x310logo src="mstile-310x310.png"/>
8
+ <wide310x150logo src="mstile-310x150.png"/>
9
+ <TileColor>#902082</TileColor>
10
+ </tile>
11
+ </msapplication>
12
+ </browserconfig>
Binary file
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "Cyfrifiad2021",
3
+ "short_name": "Cyfrifiad2021",
4
+ "icons": [
5
+ {
6
+ "src": "android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "android-chrome-512x512.png",
12
+ "sizes": "512x512",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "content_security_policy": "script-src 'self' https://cdn.ons.gov.uk; object-src 'self' https://cdn.ons.gov.uk;",
17
+ "theme_color": "#902082",
18
+ "background_color": "#902082",
19
+ "display": "standalone"
20
+ }
Binary file
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24">
2
+ <path d="M13,24C6.4,24,1,18.6,1,12C1,5.4,6.4,0,13,0c3.3,0,6.5,1.4,8.8,3.8c1,1.1,1,2.8-0.1,3.9c-1.1,1-2.8,1-3.9-0.1c-1.3-1.3-3-2.1-4.8-2.1c-3.6,0-6.5,2.9-6.5,6.5c0,3.6,2.9,6.5,6.5,6.5c1.8,0,3.5-0.7,4.8-2.1c1-1.1,2.8-1.2,3.9-0.1c1.1,1,1.2,2.8,0.1,3.9C19.5,22.6,16.3,24,13,24" fill-rule="nonzero"></path>
3
+ </svg>
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "Cyfrifiad2021",
3
+ "short_name": "Cyfrifiad2021",
4
+ "icons": [
5
+ {
6
+ "src": "android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "android-chrome-512x512.png",
12
+ "sizes": "512x512",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "theme_color": "#902082",
17
+ "background_color": "#902082",
18
+ "display": "standalone"
19
+ }
Binary file
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <browserconfig>
3
+ <msapplication>
4
+ <tile>
5
+ <square70x70logo src="mstile-70x70.png"/>
6
+ <square150x150logo src="mstile-150x150.png"/>
7
+ <square310x310logo src="mstile-310x310.png"/>
8
+ <wide310x150logo src="mstile-310x150.png"/>
9
+ <TileColor>#902082</TileColor>
10
+ </tile>
11
+ </msapplication>
12
+ </browserconfig>
Binary file
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "Census2021",
3
+ "short_name": "Census2021",
4
+ "icons": [
5
+ {
6
+ "src": "android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "android-chrome-512x512.png",
12
+ "sizes": "512x512",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "content_security_policy": "script-src 'self' https://cdn.ons.gov.uk; object-src 'self' https://cdn.ons.gov.uk;",
17
+ "theme_color": "#902082",
18
+ "background_color": "#902082",
19
+ "display": "standalone"
20
+ }
Binary file
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24">
2
+ <path d="M13,24C6.4,24,1,18.6,1,12C1,5.4,6.4,0,13,0c3.3,0,6.5,1.4,8.8,3.8c1,1.1,1,2.8-0.1,3.9c-1.1,1-2.8,1-3.9-0.1c-1.3-1.3-3-2.1-4.8-2.1c-3.6,0-6.5,2.9-6.5,6.5c0,3.6,2.9,6.5,6.5,6.5c1.8,0,3.5-0.7,4.8-2.1c1-1.1,2.8-1.2,3.9-0.1c1.1,1,1.2,2.8,0.1,3.9C19.5,22.6,16.3,24,13,24" fill-rule="nonzero"></path>
3
+ </svg>
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "Census2021",
3
+ "short_name": "Census2021",
4
+ "icons": [
5
+ {
6
+ "src": "android-chrome-192x192.png",
7
+ "sizes": "192x192",
8
+ "type": "image/png"
9
+ },
10
+ {
11
+ "src": "android-chrome-512x512.png",
12
+ "sizes": "512x512",
13
+ "type": "image/png"
14
+ }
15
+ ],
16
+ "theme_color": "#902082",
17
+ "background_color": "#902082",
18
+ "display": "standalone"
19
+ }
Binary file
Binary file
@@ -0,0 +1,55 @@
1
+ class AbortableFetch {
2
+ constructor(url, options) {
3
+ this.url = url;
4
+ this.options = options;
5
+ this.controller = new window.AbortController();
6
+ this.status = 'UNSENT';
7
+ }
8
+
9
+ send() {
10
+ this.status = 'LOADING';
11
+
12
+ return new Promise((resolve, reject) => {
13
+ abortableFetch(this.url, { signal: this.controller.signal, ...this.options })
14
+ .then(response => {
15
+ if (response.status >= 200 && response.status < 300) {
16
+ this.status = 'DONE';
17
+ resolve(response);
18
+ } else if (response.status >= 400) {
19
+ this.status = 'DONE';
20
+ resolve(response);
21
+ } else {
22
+ this.status = 'DONE';
23
+ reject(response);
24
+ }
25
+ })
26
+ .catch(error => {
27
+ this.status = 'undefined';
28
+ reject(error);
29
+ });
30
+ });
31
+ }
32
+
33
+ abort() {
34
+ this.controller.abort();
35
+ }
36
+ }
37
+
38
+ function abortableFetch(url, options) {
39
+ return window
40
+ .fetch(url, options)
41
+ .then(response => {
42
+ if (response) {
43
+ return response;
44
+ } else {
45
+ const error = new Error(response.status);
46
+ error.response = response;
47
+ throw error;
48
+ }
49
+ })
50
+ .catch(error => {
51
+ throw error;
52
+ });
53
+ }
54
+
55
+ export default (url, options) => new AbortableFetch(url, options);
@@ -0,0 +1,70 @@
1
+ import domready from './domready';
2
+
3
+ export let trackEvent = (event, data) => {
4
+ console.log(`[Analytics disabled] Event: ${event}`); // eslint-disable-line no-console
5
+ console.log(data); // eslint-disable-line no-console
6
+ };
7
+
8
+ if (typeof window.ga !== 'undefined') {
9
+ trackEvent = (evt, data) => {
10
+ window.ga(evt, data);
11
+ };
12
+ }
13
+
14
+ export const trackElement = el => {
15
+ return trackEvent('send', {
16
+ hitType: 'event',
17
+ eventCategory: el.getAttribute('data-ga-category') || '',
18
+ eventAction: el.getAttribute('data-ga-action') || '',
19
+ eventLabel: el.getAttribute('data-ga-label') || '',
20
+ });
21
+ };
22
+
23
+ const isVisible = el => {
24
+ return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
25
+ };
26
+
27
+ export default function initAnalytics() {
28
+ let trackVisibleElements = [...document.querySelectorAll('[data-ga=visible]')];
29
+
30
+ const interval = window.setInterval(() => {
31
+ trackVisibleElements = trackVisibleElements.filter(element => {
32
+ return isVisible(element) ? trackElement(element) && false : true;
33
+ });
34
+ if (trackVisibleElements.length === 0) {
35
+ window.clearInterval(interval);
36
+ }
37
+ }, 200);
38
+
39
+ [...document.querySelectorAll('[data-ga=error]')].map(trackElement);
40
+
41
+ document.body.addEventListener('click', ({ target }) => {
42
+ if (target.getAttribute('data-ga') === 'click') {
43
+ trackElement(target);
44
+ }
45
+ });
46
+
47
+ const afterPrint = () => {
48
+ return trackEvent('send', {
49
+ hitType: 'event',
50
+ eventCategory: 'Print Intent',
51
+ eventAction: 'Print Intent',
52
+ eventLabel: window.location.pathname
53
+ .split('/')
54
+ .slice(-3)
55
+ .join('/'),
56
+ });
57
+ };
58
+
59
+ if (window.matchMedia) {
60
+ const mediaQueryList = window.matchMedia('print');
61
+ mediaQueryList.addListener(function(mql) {
62
+ if (!mql.matches) {
63
+ afterPrint();
64
+ }
65
+ });
66
+ }
67
+ window.onafterprint = afterPrint;
68
+ }
69
+
70
+ domready(initAnalytics);
@@ -0,0 +1,182 @@
1
+ export const DEFAULT_COOKIE_CONSENT = {
2
+ essential: true,
3
+ settings: false,
4
+ usage: false,
5
+ campaigns: false,
6
+ };
7
+
8
+ export const COOKIE_CATEGORIES = {
9
+ RH_SESSION: 'essential',
10
+ session: 'essential',
11
+ ons_cookie_policy: 'essential',
12
+ ons_cookie_message_displayed: 'essential',
13
+ _ga: 'usage',
14
+ _gid: 'usage',
15
+ _gat: 'usage',
16
+ _use_hitbox: 'campaigns',
17
+ VISITOR_INFO1_LIVE: 'campaigns',
18
+ _fbp: 'campaigns',
19
+ COOKIE_SUPPORT: 'essential',
20
+ GUEST_LANGUAGE_ID: 'essential',
21
+ JSESSIONID: 'essential',
22
+ ID: 'essential',
23
+ COMPANY_ID: 'essential',
24
+ USER_UUID: 'essential',
25
+ LFR_SESSION_STATE_: 'essential',
26
+ csfcfc: 'essential',
27
+ };
28
+
29
+ export function cookie(name, value, options) {
30
+ if (typeof value !== 'undefined') {
31
+ if (value === false || value === null) {
32
+ return setCookie(name, '', { days: -1 });
33
+ } else {
34
+ if (typeof options === 'undefined') {
35
+ options = { days: 30 };
36
+ }
37
+ return setCookie(name, value, options);
38
+ }
39
+ } else {
40
+ return getCookie(name);
41
+ }
42
+ }
43
+
44
+ export function setDefaultConsentCookie() {
45
+ const defaultConsentCookie = JSON.stringify(DEFAULT_COOKIE_CONSENT).replace(/"/g, "'");
46
+ setCookie('ons_cookie_policy', defaultConsentCookie, { days: 365 });
47
+ }
48
+
49
+ export function approveAllCookieTypes() {
50
+ let approvedConsent = {
51
+ essential: true,
52
+ settings: true,
53
+ usage: true,
54
+ campaigns: true,
55
+ };
56
+
57
+ setCookie('ons_cookie_policy', JSON.stringify(approvedConsent).replace(/"/g, "'"), { days: 365 });
58
+ }
59
+
60
+ export function getConsentCookie() {
61
+ const consentCookie = cookie('ons_cookie_policy');
62
+ let consentCookieObj;
63
+
64
+ if (consentCookie) {
65
+ consentCookieObj = JSON.parse(consentCookie.replace(/'/g, '"'));
66
+
67
+ if (typeof consentCookieObj !== 'object' && consentCookieObj !== null) {
68
+ consentCookieObj = JSON.parse(consentCookieObj.replace(/'/g, '"'));
69
+ }
70
+ } else {
71
+ return null;
72
+ }
73
+ return consentCookieObj;
74
+ }
75
+
76
+ export function setConsentCookie(options) {
77
+ const domain = getDomain(document.domain);
78
+
79
+ let cookieConsent = getConsentCookie();
80
+ if (!cookieConsent) {
81
+ cookieConsent = JSON.parse(JSON.stringify(DEFAULT_COOKIE_CONSENT).replace(/'/g, '"'));
82
+ }
83
+ for (let cookieType in options) {
84
+ cookieConsent[cookieType] = options[cookieType];
85
+ if (!options[cookieType]) {
86
+ for (let cookies in COOKIE_CATEGORIES) {
87
+ if (COOKIE_CATEGORIES[cookies] === cookieType) {
88
+ cookie(cookies, null);
89
+ if (cookie(cookies)) {
90
+ const cookieString = cookies + '=; expires=' + new Date() + '; domain=' + domain + '; path=/';
91
+ document.cookie = cookieString;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ setCookie('ons_cookie_policy', JSON.stringify(cookieConsent).replace(/"/g, "'"), { days: 365 });
98
+ }
99
+
100
+ export function checkConsentCookieCategory(cookieName, cookieCategory) {
101
+ let currentConsentCookie = getConsentCookie();
102
+ if (!currentConsentCookie && COOKIE_CATEGORIES[cookieName]) {
103
+ return true;
104
+ }
105
+
106
+ currentConsentCookie = getConsentCookie();
107
+ try {
108
+ return currentConsentCookie[cookieCategory];
109
+ } catch (e) {
110
+ console.error(e);
111
+ return false;
112
+ }
113
+ }
114
+
115
+ export function checkConsentCookie(cookieName, cookieValue) {
116
+ // If we're setting the consent, session or RH_SESSION cookie OR deleting a cookie, allow by default
117
+ if (cookieName === 'ons_cookie_policy' || cookieValue === null || cookieValue === false) {
118
+ return true;
119
+ }
120
+
121
+ if (COOKIE_CATEGORIES[cookieName]) {
122
+ const cookieCategory = COOKIE_CATEGORIES[cookieName];
123
+ return checkConsentCookieCategory(cookieName, cookieCategory);
124
+ } else {
125
+ // Deny the cookie if it is not known to us
126
+ return false;
127
+ }
128
+ }
129
+
130
+ export function setCookie(name, value, options) {
131
+ const domain = getDomain(document.domain);
132
+ let setDomain = '';
133
+
134
+ if (domain.indexOf('localhost') === -1) {
135
+ setDomain = '; domain=' + domain;
136
+ }
137
+
138
+ if (checkConsentCookie(name, value)) {
139
+ if (typeof options === 'undefined') {
140
+ options = {};
141
+ }
142
+
143
+ let cookieString = name + '=' + value + setDomain + '; path=/';
144
+ if (options.days) {
145
+ const date = new Date();
146
+ date.setTime(date.getTime() + options.days * 24 * 60 * 60 * 1000);
147
+ cookieString = cookieString + '; expires=' + date.toGMTString();
148
+ }
149
+ if (document.location.protocol === 'https:') {
150
+ cookieString = cookieString + '; Secure';
151
+ }
152
+ document.cookie = cookieString;
153
+ }
154
+ }
155
+
156
+ export function getCookie(name) {
157
+ const nameEQ = name + '=';
158
+ const cookies = document.cookie.split(';');
159
+ for (let i = 0, len = cookies.length; i < len; i++) {
160
+ let cookie = cookies[i];
161
+ while (cookie.charAt(0) === ' ') {
162
+ cookie = cookie.substring(1, cookie.length);
163
+ }
164
+ if (cookie.indexOf(nameEQ) === 0) {
165
+ return decodeURIComponent(cookie.substring(nameEQ.length));
166
+ }
167
+ }
168
+ return null;
169
+ }
170
+
171
+ export function getDomain(domain) {
172
+ let i = 0,
173
+ domainName = domain,
174
+ p = domainName.split('.'),
175
+ s = '_gd' + new Date().getTime();
176
+ while (i < p.length - 1 && document.cookie.indexOf(s + '=' + s) == -1) {
177
+ domainName = p.slice(-1 - ++i).join('.');
178
+ document.cookie = s + '=' + s + ';domain=' + domainName + ';';
179
+ }
180
+ document.cookie = s + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=' + domainName + ';';
181
+ return domainName;
182
+ }
@@ -0,0 +1,13 @@
1
+ import domready from './domready';
2
+
3
+ async function cookiesSettings() {
4
+ const cookiesSettings = [...document.querySelectorAll('[data-module=cookie-settings]')];
5
+ if (cookiesSettings.length) {
6
+ const CookiesSettings = (await import('./cookies-settings')).default;
7
+ cookiesSettings.forEach(form => {
8
+ new CookiesSettings(form);
9
+ });
10
+ }
11
+ }
12
+
13
+ domready(cookiesSettings);
@@ -0,0 +1,105 @@
1
+ import { unset } from 'lodash';
2
+
3
+ import { cookie, setConsentCookie, setCookie, setDefaultConsentCookie } from './cookies-functions';
4
+
5
+ export default class CookiesSettings {
6
+ constructor(component) {
7
+ this.component = component;
8
+ this.returnLink = document.querySelector('.ons-js-return-link');
9
+ this.confirmationMessage = document.querySelector('.ons-cookies-confirmation-message');
10
+ this.cookiesBanner = document.querySelector('.ons-cookies-banner');
11
+
12
+ this.component.addEventListener('submit', this.submitSettingsForm.bind(this));
13
+ this.returnLink.addEventListener('click', this.goBackToPrevPage.bind(this));
14
+
15
+ this.setInitialFormValues();
16
+ }
17
+
18
+ setInitialFormValues() {
19
+ if (!cookie('ons_cookie_policy')) {
20
+ setDefaultConsentCookie();
21
+ }
22
+
23
+ const currentConsentCookie = cookie('ons_cookie_policy');
24
+ let currentConsentCookieJSON = JSON.parse(currentConsentCookie.replace(/'/g, '"'));
25
+
26
+ try {
27
+ unset(currentConsentCookieJSON, 'essential');
28
+ } catch (e) {
29
+ console.error(e);
30
+ }
31
+
32
+ for (let cookieType in currentConsentCookieJSON) {
33
+ let radioButton;
34
+
35
+ if (currentConsentCookieJSON[cookieType]) {
36
+ radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=on]');
37
+ } else {
38
+ radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=off]');
39
+ }
40
+
41
+ radioButton.checked = true;
42
+ }
43
+ }
44
+
45
+ submitSettingsForm(event) {
46
+ event.preventDefault();
47
+
48
+ if (!cookie('ons_cookie_message_displayed')) {
49
+ setCookie('ons_cookie_message_displayed', true, { days: 365 });
50
+ }
51
+
52
+ const formInputs = event.target.getElementsByTagName('input');
53
+ let options = {};
54
+
55
+ for (let i = 0; i < formInputs.length; i++) {
56
+ const input = formInputs[i];
57
+ if (input.checked) {
58
+ const name = input.name.replace('cookies-', '');
59
+ const value = input.value === 'on' ? true : false;
60
+
61
+ options[name] = value;
62
+
63
+ if (name === 'usage' && value === true) {
64
+ if (typeof loadGTM != 'undefined') {
65
+ loadGTM();
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ setConsentCookie(options);
72
+
73
+ this.showConfirmationMessage();
74
+ this.hideCookiesBanner();
75
+
76
+ return false;
77
+ }
78
+
79
+ showConfirmationMessage() {
80
+ this.confirmationMessage.classList.remove('ons-u-d-no');
81
+ document.body.scrollTop = document.documentElement.scrollTop = 0;
82
+ this.setConfirmationMessageAttributes();
83
+ }
84
+
85
+ hideCookiesBanner() {
86
+ if (this.cookiesBanner) {
87
+ this.cookiesBanner.style.display = 'none';
88
+ }
89
+ }
90
+
91
+ setConfirmationMessageAttributes() {
92
+ this.confirmationMessage.setAttribute('role', 'alert');
93
+ if (document.referrer != '') {
94
+ this.confirmationMessage.setAttribute('autofocus', 'autofocus');
95
+ this.confirmationMessage.setAttribute('tabindex', '-1');
96
+ this.confirmationMessage.focus();
97
+ } else {
98
+ this.returnLink.style.display = 'none';
99
+ }
100
+ }
101
+
102
+ goBackToPrevPage() {
103
+ window.history.back();
104
+ }
105
+ }
package/js/domready.js ADDED
@@ -0,0 +1,17 @@
1
+ let callbacks = [];
2
+
3
+ const onReady = () => {
4
+ callbacks.forEach(fn => fn.call());
5
+ callbacks = [];
6
+ window.onsDOMReady = true;
7
+ };
8
+
9
+ export default function ready(fn) {
10
+ if (document.readyState === 'loading') {
11
+ callbacks.push(fn);
12
+ } else {
13
+ fn.call();
14
+ }
15
+ }
16
+
17
+ document.addEventListener('DOMContentLoaded', onReady);
package/js/fetch.js ADDED
@@ -0,0 +1,19 @@
1
+ export function checkStatus(response) {
2
+ if (response.status >= 200 && response.status < 300) {
3
+ return response;
4
+ } else {
5
+ const error = new Error(response.statusText);
6
+ error.response = response;
7
+ throw error;
8
+ }
9
+ }
10
+
11
+ export default function(url, options) {
12
+ return window
13
+ .fetch(url, {
14
+ method: 'GET',
15
+ credentials: 'include',
16
+ ...options,
17
+ })
18
+ .then(checkStatus);
19
+ }
@@ -0,0 +1,13 @@
1
+ import domready from './domready';
2
+
3
+ async function initialise() {
4
+ const links = [...document.getElementsByClassName('ons-js-inpagelink')];
5
+
6
+ if (links.length) {
7
+ const inPageLinks = (await import('./inpagelink')).default;
8
+
9
+ inPageLinks(links);
10
+ }
11
+ }
12
+
13
+ domready(initialise);