govuk_publishing_components 37.5.0 → 37.6.0
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics/analytics.js +10 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-core.js +5 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-scroll-tracker.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +35 -8
- data/app/assets/javascripts/govuk_publishing_components/domain-config.js +73 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-settings.js +40 -19
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/lib/single-consent-functions.js +59 -0
- data/app/assets/javascripts/govuk_publishing_components/load-analytics.js +9 -75
- data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +8 -15
- data/app/controllers/govuk_publishing_components/audit_controller.rb +0 -1
- data/app/models/govuk_publishing_components/audit_comparer.rb +0 -1
- data/app/views/govuk_publishing_components/components/_govspeak.html.erb +0 -11
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +0 -9
- data/config/locales/en.yml +2 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- data/node_modules/axe-core/README.md +4 -2
- data/node_modules/axe-core/axe.d.ts +21 -8
- data/node_modules/axe-core/axe.js +13 -11
- data/node_modules/axe-core/axe.min.js +3 -3
- data/node_modules/axe-core/package.json +3 -2
- data/node_modules/axe-core/sri-history.json +4 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5059f8b24e5d099520ca6f53061525153ddf6e7e31a5d4d1401516cb3856fc4
|
|
4
|
+
data.tar.gz: 6565eeaa1b13939dbb5295327aa5d9862bd568b8af022d803419d22bc6890f5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 828d20c4426cad1bce861a0f4eef8f9aa46947fa0f381ca54f8408ef9675d828b3d9c7be18d513bf5c9f4b9c34197cb30cefa030f33134cac24ae1cdead608ab
|
|
7
|
+
data.tar.gz: 53515ff838f233ab6b5bf5d3db5fe4d78e4c360faf4368cdfff7d9ef1ebbcebb8959637728348c74acd2e7003b94c4fa127c9dfe83c0a0b608263bcfdb17ce1f
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
Analytics.PIISafe = PIISafe
|
|
22
22
|
|
|
23
23
|
Analytics.prototype.sendToTrackers = function (method, args) {
|
|
24
|
+
// Allows us to stop sending tracking at the moment a user sets their usage cookies to "false" on the cookie settings page.
|
|
25
|
+
if (window.GOVUK.stopSendingAnalytics) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
24
29
|
for (var i = 0, l = this.trackers.length; i < l; i++) {
|
|
25
30
|
var tracker = this.trackers[i]
|
|
26
31
|
var fn = tracker[method]
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
Analytics.prototype.trackPageview = function (path, title, options) {
|
|
50
55
|
arguments[0] = arguments[0] || this.defaultPathForTrackPageview(window.location)
|
|
51
56
|
if (arguments.length === 0) { arguments.length = 1 }
|
|
52
|
-
this.sendToTrackers('trackPageview', this.pii.stripPII(arguments))
|
|
57
|
+
return this.sendToTrackers('trackPageview', this.pii.stripPII(arguments))
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
/*
|
|
@@ -59,11 +64,11 @@
|
|
|
59
64
|
options.nonInteraction – Prevent event from impacting bounce rate
|
|
60
65
|
*/
|
|
61
66
|
Analytics.prototype.trackEvent = function (category, action, options) {
|
|
62
|
-
this.sendToTrackers('trackEvent', this.pii.stripPII(arguments))
|
|
67
|
+
return this.sendToTrackers('trackEvent', this.pii.stripPII(arguments))
|
|
63
68
|
}
|
|
64
69
|
|
|
65
70
|
Analytics.prototype.trackShare = function (network, options) {
|
|
66
|
-
this.sendToTrackers('trackSocial', this.pii.stripPII([network, 'share', global.location.pathname, options]))
|
|
71
|
+
return this.sendToTrackers('trackSocial', this.pii.stripPII([network, 'share', global.location.pathname, options]))
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
/*
|
|
@@ -71,14 +76,14 @@
|
|
|
71
76
|
Universal Analytics profile
|
|
72
77
|
*/
|
|
73
78
|
Analytics.prototype.setDimension = function (index, value) {
|
|
74
|
-
this.sendToTrackers('setDimension', this.pii.stripPII(arguments))
|
|
79
|
+
return this.sendToTrackers('setDimension', this.pii.stripPII(arguments))
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
/*
|
|
78
83
|
Add a beacon to track a page in another GA account on another domain.
|
|
79
84
|
*/
|
|
80
85
|
Analytics.prototype.addLinkedTrackerDomain = function (trackerId, name, domain) {
|
|
81
|
-
this.sendToTrackers('addLinkedTrackerDomain', arguments)
|
|
86
|
+
return this.sendToTrackers('addLinkedTrackerDomain', arguments)
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
GOVUK.Analytics = Analytics
|
|
@@ -39,6 +39,11 @@ window.GOVUK.analyticsGa4 = window.GOVUK.analyticsGa4 || {};
|
|
|
39
39
|
},
|
|
40
40
|
|
|
41
41
|
sendData: function (data) {
|
|
42
|
+
// Allows us to stop sending tracking at the moment a user sets their usage cookies to "false" on the cookie settings page.
|
|
43
|
+
if (window.GOVUK.stopSendingAnalytics) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
data.govuk_gem_version = this.getGemVersion()
|
|
43
48
|
data.timestamp = this.getTimestamp()
|
|
44
49
|
|
|
@@ -164,7 +164,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
164
164
|
bottom: pos.bottom + document.documentElement.scrollTop,
|
|
165
165
|
eventData: {
|
|
166
166
|
type: type,
|
|
167
|
-
text: heading.textContent.replace(/\s+/g, ' ').trim(),
|
|
167
|
+
text: heading.getAttribute('data-ga4-text') || heading.textContent.replace(/\s+/g, ' ').trim(),
|
|
168
168
|
index_section: i + 1,
|
|
169
169
|
index_section_count: totalHeadings
|
|
170
170
|
}
|
|
@@ -10,10 +10,17 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
10
10
|
|
|
11
11
|
CookieBanner.prototype.init = function () {
|
|
12
12
|
this.$module.hideCookieMessage = this.hideCookieMessage.bind(this)
|
|
13
|
+
this.$module.showCookieMessage = this.showCookieMessage.bind(this)
|
|
13
14
|
this.$module.showConfirmationMessage = this.showConfirmationMessage.bind(this)
|
|
14
15
|
this.$module.setCookieConsent = this.setCookieConsent.bind(this)
|
|
15
16
|
this.$module.rejectCookieConsent = this.rejectCookieConsent.bind(this)
|
|
16
17
|
this.setupCookieMessage()
|
|
18
|
+
|
|
19
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
20
|
+
window.addEventListener('hide-cookie-banner', this.$module.hideCookieMessage)
|
|
21
|
+
window.addEventListener('show-cookie-banner', this.$module.showCookieMessage)
|
|
22
|
+
window.GOVUK.singleConsent.init()
|
|
23
|
+
}
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
CookieBanner.prototype.setupCookieMessage = function () {
|
|
@@ -34,10 +41,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
34
41
|
this.$rejectCookiesButton.addEventListener('click', this.$module.rejectCookieConsent)
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
45
|
+
this.showCookieMessage()
|
|
46
|
+
}
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
CookieBanner.prototype.showCookieMessage = function () {
|
|
50
|
+
window.removeEventListener('show-cookie-banner', this.$module.showCookieMessage)
|
|
41
51
|
// Show the cookie banner if not in the cookie settings page or in an iframe
|
|
42
52
|
if (!this.isInCookiesPage() && !this.isInIframe()) {
|
|
43
53
|
var shouldHaveCookieMessage = (this.$module && window.GOVUK.cookie('cookies_preferences_set') !== 'true')
|
|
@@ -47,7 +57,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
47
57
|
|
|
48
58
|
// Set the default consent cookie if it isn't already present
|
|
49
59
|
if (!window.GOVUK.cookie('cookies_policy')) {
|
|
50
|
-
window.GOVUK.
|
|
60
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
61
|
+
window.GOVUK.setDefaultConsentCookie()
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
window.GOVUK.deleteUnconsentedCookies()
|
|
@@ -56,9 +68,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
CookieBanner.prototype.hideCookieMessage = function (event) {
|
|
71
|
+
window.removeEventListener('hide-cookie-banner', this.$module.hideCookieMessage)
|
|
59
72
|
if (this.$module) {
|
|
60
73
|
this.$module.hidden = true
|
|
61
|
-
window.GOVUK.
|
|
74
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
75
|
+
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
|
76
|
+
}
|
|
62
77
|
}
|
|
63
78
|
|
|
64
79
|
if (event.target) {
|
|
@@ -70,25 +85,37 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
70
85
|
if (this.$acceptCookiesButton.getAttribute('data-cookie-types') === 'all') {
|
|
71
86
|
this.$module.querySelector('.gem-c-cookie-banner__confirmation-message--accepted').hidden = false
|
|
72
87
|
}
|
|
73
|
-
window.GOVUK.
|
|
88
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
89
|
+
window.GOVUK.singleConsent.setPreferences('accept')
|
|
90
|
+
} else {
|
|
91
|
+
window.GOVUK.approveAllCookieTypes()
|
|
92
|
+
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
this.$module.showConfirmationMessage()
|
|
75
96
|
this.$module.cookieBannerConfirmationMessage.focus()
|
|
76
|
-
|
|
97
|
+
|
|
77
98
|
if (window.GOVUK.analyticsInit) {
|
|
78
99
|
window.GOVUK.analyticsInit()
|
|
79
100
|
}
|
|
80
101
|
if (window.GOVUK.globalBarInit) {
|
|
81
102
|
window.GOVUK.globalBarInit.init()
|
|
82
103
|
}
|
|
83
|
-
window.GOVUK.
|
|
104
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
105
|
+
window.GOVUK.triggerEvent(window, 'cookie-consent')
|
|
106
|
+
}
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
CookieBanner.prototype.rejectCookieConsent = function () {
|
|
87
110
|
this.$module.querySelector('.gem-c-cookie-banner__confirmation-message--rejected').hidden = false
|
|
88
111
|
this.$module.showConfirmationMessage()
|
|
89
112
|
this.$module.cookieBannerConfirmationMessage.focus()
|
|
90
|
-
window.GOVUK.
|
|
91
|
-
|
|
113
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
114
|
+
window.GOVUK.singleConsent.setPreferences('reject')
|
|
115
|
+
} else {
|
|
116
|
+
window.GOVUK.setDefaultConsentCookie()
|
|
117
|
+
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
|
118
|
+
}
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
CookieBanner.prototype.showConfirmationMessage = function () {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
|
2
|
+
window.GOVUK.vars = window.GOVUK.vars || {}
|
|
3
|
+
window.GOVUK.vars.domains = [
|
|
4
|
+
{
|
|
5
|
+
// need to have this one at the start, see loadGa4 function
|
|
6
|
+
name: 'development',
|
|
7
|
+
domains: [
|
|
8
|
+
'localhost',
|
|
9
|
+
'127.0.0.1',
|
|
10
|
+
'0.0.0.0',
|
|
11
|
+
'dev.gov.uk'
|
|
12
|
+
],
|
|
13
|
+
initialiseGA4: true,
|
|
14
|
+
id: 'GTM-MG7HG5W',
|
|
15
|
+
auth: 'bRiZ-jiEHtw6hHpGd6dF9w',
|
|
16
|
+
preview: 'env-3',
|
|
17
|
+
gaProperty: 'UA-UNSET',
|
|
18
|
+
gaPropertyCrossDomain: 'UA-UNSET',
|
|
19
|
+
consentApiUrl: 'staging'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'production',
|
|
23
|
+
domains: [
|
|
24
|
+
'www.gov.uk',
|
|
25
|
+
'www-origin.publishing.service.gov.uk',
|
|
26
|
+
'assets.publishing.service.gov.uk'
|
|
27
|
+
],
|
|
28
|
+
initialiseGA4: true,
|
|
29
|
+
id: 'GTM-MG7HG5W',
|
|
30
|
+
gaProperty: 'UA-26179049-1',
|
|
31
|
+
gaPropertyCrossDomain: 'UA-145652997-1',
|
|
32
|
+
consentApiUrl: 'production'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'staging',
|
|
36
|
+
domains: [
|
|
37
|
+
'www.staging.publishing.service.gov.uk',
|
|
38
|
+
'www-origin.staging.publishing.service.gov.uk',
|
|
39
|
+
'assets.staging.publishing.service.gov.uk'
|
|
40
|
+
],
|
|
41
|
+
initialiseGA4: true,
|
|
42
|
+
id: 'GTM-MG7HG5W',
|
|
43
|
+
auth: 'oJWs562CxSIjZKn_GlB5Bw',
|
|
44
|
+
preview: 'env-5',
|
|
45
|
+
gaProperty: 'UA-26179049-20',
|
|
46
|
+
gaPropertyCrossDomain: 'UA-145652997-1',
|
|
47
|
+
consentApiUrl: 'staging'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'integration',
|
|
51
|
+
domains: [
|
|
52
|
+
'www.integration.publishing.service.gov.uk',
|
|
53
|
+
'www-origin.integration.publishing.service.gov.uk',
|
|
54
|
+
'assets.integration.publishing.service.gov.uk'
|
|
55
|
+
],
|
|
56
|
+
initialiseGA4: true,
|
|
57
|
+
id: 'GTM-MG7HG5W',
|
|
58
|
+
auth: 'C7iYdcsOlYgGmiUJjZKrHQ',
|
|
59
|
+
preview: 'env-4',
|
|
60
|
+
gaProperty: 'UA-26179049-22',
|
|
61
|
+
gaPropertyCrossDomain: 'UA-145652997-1',
|
|
62
|
+
consentApiUrl: 'staging'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'devdocs',
|
|
66
|
+
domains: [
|
|
67
|
+
'docs.publishing.service.gov.uk'
|
|
68
|
+
],
|
|
69
|
+
initialiseGA4: true,
|
|
70
|
+
id: 'GTM-TNKCK97',
|
|
71
|
+
consentApiUrl: 'production'
|
|
72
|
+
}
|
|
73
|
+
]
|
|
@@ -12,31 +12,39 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
12
12
|
document.querySelector('form[data-module=cookie-settings]')
|
|
13
13
|
.addEventListener('submit', this.$module.submitSettingsForm)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
16
|
+
window.GOVUK.singleConsent.init(this.setInitialFormValues.bind(this))
|
|
17
|
+
} else {
|
|
18
|
+
this.setInitialFormValues()
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
CookieSettings.prototype.setInitialFormValues = function () {
|
|
19
23
|
if (!window.GOVUK.cookie('cookies_policy')) {
|
|
20
|
-
window.GOVUK.
|
|
24
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
25
|
+
window.GOVUK.setDefaultConsentCookie()
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
var currentConsentCookie = window.GOVUK.cookie('cookies_policy')
|
|
24
|
-
|
|
30
|
+
if (currentConsentCookie) {
|
|
31
|
+
var currentConsentCookieJSON = JSON.parse(currentConsentCookie)
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
// We don't need the essential value as this cannot be changed by the user
|
|
34
|
+
delete currentConsentCookieJSON.essential
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
for (var cookieType in currentConsentCookieJSON) {
|
|
37
|
+
var radioButton
|
|
31
38
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (currentConsentCookieJSON[cookieType]) {
|
|
40
|
+
radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=on]')
|
|
41
|
+
} else {
|
|
42
|
+
radioButton = document.querySelector('input[name=cookies-' + cookieType + '][value=off]')
|
|
43
|
+
}
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
if (radioButton) {
|
|
46
|
+
radioButton.checked = true
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
}
|
|
@@ -54,16 +62,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
54
62
|
var value = input.value === 'on'
|
|
55
63
|
|
|
56
64
|
options[name] = value
|
|
65
|
+
|
|
66
|
+
if (name === 'usage' && !value) {
|
|
67
|
+
window.GOVUK.stopSendingAnalytics = true
|
|
68
|
+
window.GOVUK.LUX = {}
|
|
69
|
+
}
|
|
57
70
|
}
|
|
58
71
|
}
|
|
59
72
|
|
|
60
|
-
window.GOVUK.
|
|
61
|
-
|
|
73
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
74
|
+
window.GOVUK.singleConsent.setPreferences(null, options)
|
|
75
|
+
} else {
|
|
76
|
+
window.GOVUK.setConsentCookie(options)
|
|
77
|
+
window.GOVUK.setCookie('cookies_preferences_set', true, { days: 365 })
|
|
78
|
+
}
|
|
62
79
|
|
|
63
80
|
this.fireAnalyticsEvent(options)
|
|
64
|
-
|
|
65
81
|
this.showConfirmationMessage()
|
|
66
|
-
|
|
67
82
|
return false
|
|
68
83
|
}
|
|
69
84
|
|
|
@@ -102,7 +117,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
CookieSettings.prototype.getReferrerLink = function () {
|
|
105
|
-
|
|
120
|
+
var documentReferrer = false
|
|
121
|
+
try {
|
|
122
|
+
documentReferrer = document.referrer || new URL(document.referrer).pathname
|
|
123
|
+
} catch (e) {
|
|
124
|
+
console.error('Error grabbing referrer for cookie settings', window.location, e)
|
|
125
|
+
}
|
|
126
|
+
return documentReferrer
|
|
106
127
|
}
|
|
107
128
|
|
|
108
129
|
Modules.CookieSettings = CookieSettings
|
data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
CHANGED
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
|
|
164
164
|
YoutubeLinkEnhancement.prototype.campaignCookiesAllowed = function () {
|
|
165
165
|
var cookiePolicy = window.GOVUK.getConsentCookie()
|
|
166
|
-
return cookiePolicy !== null ? cookiePolicy.campaigns :
|
|
166
|
+
return cookiePolicy !== null ? cookiePolicy.campaigns : false
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
YoutubeLinkEnhancement.nextId = function () {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* global GovSingleConsent */
|
|
2
|
+
// = require govuk-single-consent/dist/singleconsent.iife.js
|
|
3
|
+
|
|
4
|
+
(function (root) {
|
|
5
|
+
'use strict'
|
|
6
|
+
window.GOVUK = window.GOVUK || {}
|
|
7
|
+
|
|
8
|
+
window.GOVUK.singleConsent = {
|
|
9
|
+
init: function (callback) {
|
|
10
|
+
if (!window.GOVUK.useSingleConsentApi) {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
callback = callback || this.apiCallback
|
|
14
|
+
// determine where we are and set the consent api URL accordingly
|
|
15
|
+
if (!this.url) {
|
|
16
|
+
this.url = 'staging'
|
|
17
|
+
var environment = window.GOVUK.loadAnalytics.getEnvironment(window.GOVUK.analyticsGa4.core.trackFunctions.getHostname())
|
|
18
|
+
if (environment) {
|
|
19
|
+
this.url = environment.consentApiUrl
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// create the consent API object
|
|
23
|
+
this.consentApiObj = new GovSingleConsent(callback, this.url)
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
apiCallback: function (consents, consentsPreferencesSet, error) {
|
|
27
|
+
if (error) {
|
|
28
|
+
console.error('Single consent error: ', error, window.location)
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
if (consentsPreferencesSet) {
|
|
32
|
+
if (consents && consents.usage) {
|
|
33
|
+
window.GOVUK.triggerEvent(window, 'cookie-consent')
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
window.GOVUK.triggerEvent(window, 'show-cookie-banner')
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
setPreferences: function (type, options) {
|
|
41
|
+
if (window.GOVUK.useSingleConsentApi) {
|
|
42
|
+
try {
|
|
43
|
+
switch (type) {
|
|
44
|
+
case 'accept':
|
|
45
|
+
this.consentApiObj.setConsents(GovSingleConsent.ACCEPT_ALL)
|
|
46
|
+
break
|
|
47
|
+
case 'reject':
|
|
48
|
+
this.consentApiObj.setConsents(GovSingleConsent.REJECT_ALL)
|
|
49
|
+
break
|
|
50
|
+
default:
|
|
51
|
+
this.consentApiObj.setConsents(options)
|
|
52
|
+
}
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error('Single consent ' + type + ' error: ', e, window.location)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}(window))
|
|
@@ -1,78 +1,12 @@
|
|
|
1
1
|
//= require govuk_publishing_components/analytics
|
|
2
2
|
//= require govuk_publishing_components/analytics-ga4
|
|
3
3
|
//= require govuk_publishing_components/analytics/linked-domains
|
|
4
|
+
//= require govuk_publishing_components/domain-config
|
|
4
5
|
|
|
5
6
|
window.GOVUK.loadAnalytics = {
|
|
6
|
-
domains: [
|
|
7
|
-
{
|
|
8
|
-
// need to have this one at the start, see loadGa4 function
|
|
9
|
-
name: 'development',
|
|
10
|
-
domains: [
|
|
11
|
-
'localhost',
|
|
12
|
-
'127.0.0.1',
|
|
13
|
-
'0.0.0.0',
|
|
14
|
-
'dev.gov.uk'
|
|
15
|
-
],
|
|
16
|
-
initialiseGA4: true,
|
|
17
|
-
id: 'GTM-MG7HG5W',
|
|
18
|
-
auth: 'bRiZ-jiEHtw6hHpGd6dF9w',
|
|
19
|
-
preview: 'env-3',
|
|
20
|
-
gaProperty: 'UA-UNSET',
|
|
21
|
-
gaPropertyCrossDomain: 'UA-UNSET'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'production',
|
|
25
|
-
domains: [
|
|
26
|
-
'www.gov.uk',
|
|
27
|
-
'www-origin.publishing.service.gov.uk',
|
|
28
|
-
'assets.publishing.service.gov.uk'
|
|
29
|
-
],
|
|
30
|
-
initialiseGA4: true,
|
|
31
|
-
id: 'GTM-MG7HG5W',
|
|
32
|
-
gaProperty: 'UA-26179049-1',
|
|
33
|
-
gaPropertyCrossDomain: 'UA-145652997-1'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'staging',
|
|
37
|
-
domains: [
|
|
38
|
-
'www.staging.publishing.service.gov.uk',
|
|
39
|
-
'www-origin.staging.publishing.service.gov.uk',
|
|
40
|
-
'assets.staging.publishing.service.gov.uk'
|
|
41
|
-
],
|
|
42
|
-
initialiseGA4: true,
|
|
43
|
-
id: 'GTM-MG7HG5W',
|
|
44
|
-
auth: 'oJWs562CxSIjZKn_GlB5Bw',
|
|
45
|
-
preview: 'env-5',
|
|
46
|
-
gaProperty: 'UA-26179049-20',
|
|
47
|
-
gaPropertyCrossDomain: 'UA-145652997-1'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'integration',
|
|
51
|
-
domains: [
|
|
52
|
-
'www.integration.publishing.service.gov.uk',
|
|
53
|
-
'www-origin.integration.publishing.service.gov.uk',
|
|
54
|
-
'assets.integration.publishing.service.gov.uk'
|
|
55
|
-
],
|
|
56
|
-
initialiseGA4: true,
|
|
57
|
-
id: 'GTM-MG7HG5W',
|
|
58
|
-
auth: 'C7iYdcsOlYgGmiUJjZKrHQ',
|
|
59
|
-
preview: 'env-4',
|
|
60
|
-
gaProperty: 'UA-26179049-22',
|
|
61
|
-
gaPropertyCrossDomain: 'UA-145652997-1'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'devdocs',
|
|
65
|
-
domains: [
|
|
66
|
-
'docs.publishing.service.gov.uk'
|
|
67
|
-
],
|
|
68
|
-
initialiseGA4: true,
|
|
69
|
-
id: 'GTM-TNKCK97'
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
|
|
73
7
|
loadExtraDomains: function () {
|
|
74
|
-
if (Array.isArray(window.GOVUK.
|
|
75
|
-
|
|
8
|
+
if (Array.isArray(window.GOVUK.vars.extraDomains)) {
|
|
9
|
+
window.GOVUK.vars.domains = window.GOVUK.vars.domains.concat(window.GOVUK.vars.extraDomains)
|
|
76
10
|
}
|
|
77
11
|
},
|
|
78
12
|
|
|
@@ -89,8 +23,8 @@ window.GOVUK.loadAnalytics = {
|
|
|
89
23
|
window.GOVUK.analyticsVars.gaProperty = 'UA-UNSET'
|
|
90
24
|
window.GOVUK.analyticsVars.gaPropertyCrossDomain = 'UA-UNSET'
|
|
91
25
|
|
|
92
|
-
for (var i = 0; i <
|
|
93
|
-
var current =
|
|
26
|
+
for (var i = 0; i < window.GOVUK.vars.domains.length; i++) {
|
|
27
|
+
var current = window.GOVUK.vars.domains[i]
|
|
94
28
|
if (this.arrayContains(currentDomain, current.domains)) {
|
|
95
29
|
window.GOVUK.analyticsVars.gaProperty = current.gaProperty
|
|
96
30
|
window.GOVUK.analyticsVars.gaPropertyCrossDomain = current.gaPropertyCrossDomain
|
|
@@ -135,11 +69,11 @@ window.GOVUK.loadAnalytics = {
|
|
|
135
69
|
getEnvironment: function (currentDomain) {
|
|
136
70
|
// lots of dev domains, so simplify the matching process
|
|
137
71
|
if (currentDomain.match(/[a-zA-Z0-9.-]+dev\.gov\.uk/)) {
|
|
138
|
-
return
|
|
72
|
+
return window.GOVUK.vars.domains[0]
|
|
139
73
|
} else {
|
|
140
|
-
for (var i = 0; i <
|
|
141
|
-
if (this.arrayContains(currentDomain,
|
|
142
|
-
return
|
|
74
|
+
for (var i = 0; i < window.GOVUK.vars.domains.length; i++) {
|
|
75
|
+
if (this.arrayContains(currentDomain, window.GOVUK.vars.domains[i].domains)) {
|
|
76
|
+
return window.GOVUK.vars.domains[i]
|
|
143
77
|
}
|
|
144
78
|
}
|
|
145
79
|
}
|
|
@@ -17,7 +17,7 @@ $large-input-size: 50px;
|
|
|
17
17
|
height: $large-input-size;
|
|
18
18
|
|
|
19
19
|
.gem-c-search__icon {
|
|
20
|
-
|
|
20
|
+
transform: scale(.4);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -106,19 +106,6 @@ $large-input-size: 50px;
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
@mixin icon-positioning($container-size) {
|
|
110
|
-
$icon-dimension: 20px;
|
|
111
|
-
$icon-position: calc(($container-size - $icon-dimension) / 2);
|
|
112
|
-
|
|
113
|
-
display: block;
|
|
114
|
-
pointer-events: none;
|
|
115
|
-
position: absolute;
|
|
116
|
-
height: $icon-dimension;
|
|
117
|
-
width: $icon-dimension;
|
|
118
|
-
top: $icon-position;
|
|
119
|
-
left: $icon-position;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
109
|
.gem-c-search__submit {
|
|
123
110
|
border: 0;
|
|
124
111
|
cursor: pointer;
|
|
@@ -135,7 +122,13 @@ $large-input-size: 50px;
|
|
|
135
122
|
overflow: hidden;
|
|
136
123
|
|
|
137
124
|
.gem-c-search__icon {
|
|
138
|
-
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
position: absolute;
|
|
127
|
+
height: 100%;
|
|
128
|
+
width: 100%;
|
|
129
|
+
top: 0;
|
|
130
|
+
left: 0;
|
|
131
|
+
transform: scale(.5);
|
|
139
132
|
}
|
|
140
133
|
|
|
141
134
|
&:focus {
|
|
@@ -10,20 +10,9 @@
|
|
|
10
10
|
classes << "disable-youtube" if disable_youtube_expansions
|
|
11
11
|
classes << "gem-c-govspeak--inverse" if inverse
|
|
12
12
|
|
|
13
|
-
disable_ga4 ||= false
|
|
14
|
-
|
|
15
13
|
data_modules = "govspeak"
|
|
16
|
-
data_modules << " ga4-link-tracker" unless disable_ga4
|
|
17
14
|
data_attributes = { module: data_modules }
|
|
18
15
|
|
|
19
|
-
unless disable_ga4
|
|
20
|
-
data_attributes.merge!({
|
|
21
|
-
ga4_track_links_only: "",
|
|
22
|
-
ga4_limit_to_element_class: "call-to-action, info-notice, help-notice, advisory",
|
|
23
|
-
ga4_link: { "event_name": "navigation", "type": "callout" }.to_json,
|
|
24
|
-
})
|
|
25
|
-
end
|
|
26
|
-
|
|
27
16
|
%>
|
|
28
17
|
|
|
29
18
|
<%= tag.div(class: "gem-c-govspeak govuk-govspeak " + classes.join(" "), data: data_attributes) do %>
|
|
@@ -914,12 +914,3 @@ examples:
|
|
|
914
914
|
<p>Deforested area. Credit: Blue Ventures-Garth Cripps</p>
|
|
915
915
|
</figcaption>
|
|
916
916
|
</figure>
|
|
917
|
-
without_ga4_tracking:
|
|
918
|
-
description: |
|
|
919
|
-
Disables GA4 tracking on the component. Tracking is enabled by default. This adds a data module and data-attributes with JSON data. See the [ga4-link-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
|
|
920
|
-
data:
|
|
921
|
-
block: |
|
|
922
|
-
<p>
|
|
923
|
-
<a href='https://www.gov.uk'>Hello World</a>
|
|
924
|
-
</p>
|
|
925
|
-
disable_ga4: true
|
data/config/locales/en.yml
CHANGED
|
@@ -234,8 +234,8 @@ en:
|
|
|
234
234
|
popular_links:
|
|
235
235
|
- label: Get support with the cost of living
|
|
236
236
|
href: "/cost-of-living"
|
|
237
|
-
- label: Find out about
|
|
238
|
-
href: "/
|
|
237
|
+
- label: Find out about help you can get with your energy bills
|
|
238
|
+
href: "/get-help-energy-bills"
|
|
239
239
|
- label: Find a job
|
|
240
240
|
href: "/find-a-job"
|
|
241
241
|
- label: 'Universal Credit account: sign in'
|