govuk_publishing_components 27.20.0 → 28.3.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/auto-scroll-tracker.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-track-event.js +22 -22
- data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +2 -20
- data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +21 -16
- data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +46 -32
- data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +20 -7
- data/app/assets/javascripts/govuk_publishing_components/analytics/mailto-link-tracker.js +22 -17
- data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +9 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics/static-analytics.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics/track-click.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -3
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +18 -18
- data/app/assets/javascripts/govuk_publishing_components/components/metadata.js +27 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/extend-object.js +22 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +5 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +8 -37
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +67 -21
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +6 -0
- data/app/views/govuk_publishing_components/components/_big_number.html.erb +19 -9
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +22 -18
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +25 -22
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +31 -25
- data/app/views/govuk_publishing_components/components/docs/big_number.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/feedback.yml +5 -0
- data/app/views/govuk_publishing_components/components/docs/input.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +2 -2
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +35 -6
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +4 -3
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +19 -11
- data/config/locales/ar.yml +0 -8
- data/config/locales/az.yml +0 -8
- data/config/locales/be.yml +0 -8
- data/config/locales/bg.yml +0 -8
- data/config/locales/bn.yml +0 -8
- data/config/locales/cs.yml +0 -8
- data/config/locales/cy.yml +0 -8
- data/config/locales/da.yml +0 -8
- data/config/locales/de.yml +0 -8
- data/config/locales/dr.yml +0 -8
- data/config/locales/el.yml +0 -8
- data/config/locales/en.yml +0 -10
- data/config/locales/es-419.yml +0 -8
- data/config/locales/es.yml +0 -8
- data/config/locales/et.yml +0 -8
- data/config/locales/fa.yml +0 -8
- data/config/locales/fi.yml +0 -8
- data/config/locales/fr.yml +0 -8
- data/config/locales/gd.yml +0 -8
- data/config/locales/gu.yml +0 -8
- data/config/locales/he.yml +0 -8
- data/config/locales/hi.yml +0 -8
- data/config/locales/hr.yml +0 -8
- data/config/locales/hu.yml +0 -8
- data/config/locales/hy.yml +0 -8
- data/config/locales/id.yml +0 -8
- data/config/locales/is.yml +0 -8
- data/config/locales/it.yml +0 -8
- data/config/locales/ja.yml +0 -8
- data/config/locales/ka.yml +0 -8
- data/config/locales/kk.yml +0 -8
- data/config/locales/ko.yml +0 -8
- data/config/locales/lt.yml +0 -8
- data/config/locales/lv.yml +0 -8
- data/config/locales/ms.yml +0 -8
- data/config/locales/mt.yml +0 -8
- data/config/locales/nl.yml +0 -8
- data/config/locales/no.yml +0 -8
- data/config/locales/pa-pk.yml +0 -8
- data/config/locales/pa.yml +0 -8
- data/config/locales/pl.yml +0 -8
- data/config/locales/ps.yml +0 -8
- data/config/locales/pt.yml +0 -8
- data/config/locales/ro.yml +0 -8
- data/config/locales/ru.yml +0 -8
- data/config/locales/si.yml +0 -8
- data/config/locales/sk.yml +0 -8
- data/config/locales/sl.yml +0 -8
- data/config/locales/so.yml +0 -8
- data/config/locales/sq.yml +0 -8
- data/config/locales/sr.yml +0 -8
- data/config/locales/sv.yml +0 -8
- data/config/locales/sw.yml +0 -8
- data/config/locales/ta.yml +0 -8
- data/config/locales/th.yml +0 -8
- data/config/locales/tk.yml +0 -8
- data/config/locales/tr.yml +0 -8
- data/config/locales/uk.yml +0 -8
- data/config/locales/ur.yml +0 -8
- data/config/locales/uz.yml +0 -8
- data/config/locales/vi.yml +0 -8
- data/config/locales/zh-hk.yml +0 -8
- data/config/locales/zh-tw.yml +0 -8
- data/config/locales/zh.yml +0 -8
- data/lib/govuk_publishing_components/presenters/big_number_helper.rb +30 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -2
- metadata +5 -15
- data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +0 -237
- data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +0 -84
- data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +0 -21
- data/app/views/govuk_publishing_components/components/_admin_analytics.html.erb +0 -20
- data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +0 -86
- data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +0 -47
- data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +0 -30
- data/app/views/govuk_publishing_components/components/docs/admin_analytics.yml +0 -10
- data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +0 -20
- data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +0 -171
- data/app/views/govuk_publishing_components/components/docs/taxonomy_list.yml +0 -112
- data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +0 -13
- data/lib/govuk_publishing_components/presenters/taxonomy_list_helper.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cdf4c30d55a0c5ec9b7708ecc5866d5f554ed0be27ffe9f23df9ae3a8862ac9
|
|
4
|
+
data.tar.gz: a2183c0f935738d9bedafae81ce3f1e5b0715ceeebe3b8eb301b7c7a79d0f56b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa3b9eeccbbfe40a2c2a304bd28bce06e4f52d2154ef5ea2affb22792d90a3964da0f6d542be541ee04bef5818a5c62e50220f69b626827ba5066192cd78a7b7
|
|
7
|
+
data.tar.gz: 2eaca61cd01cc1a788c5f6ac3668c60a36ebb1fe82befecc56fa90f7181b3a1142b7559c07bd9d809bb176e1969de6c820582d4ac5f0a05ab3304e9df3e91caa
|
|
@@ -199,7 +199,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
199
199
|
|
|
200
200
|
for (var i = 0; i < this.config.percentages.length; i++) {
|
|
201
201
|
var percent = this.config.percentages[i]
|
|
202
|
-
|
|
202
|
+
// subtract 1 pixel to solve a bug where 100% can't be reached in some cases
|
|
203
|
+
var pos = ((pageHeight / 100) * percent) - 1
|
|
203
204
|
var alreadySeen = false
|
|
204
205
|
if (trackedNodes.length) {
|
|
205
206
|
alreadySeen = trackedNodes[i].alreadySeen
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
(function (Modules) {
|
|
5
|
+
function AutoTrackEvent ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var value = element.data('track-value')
|
|
9
|
+
AutoTrackEvent.prototype.init = function () {
|
|
10
|
+
var options = { nonInteraction: 1 } // automatic events shouldn't affect bounce rate
|
|
11
|
+
var category = this.$module.getAttribute('data-track-category')
|
|
12
|
+
var action = this.$module.getAttribute('data-track-action')
|
|
13
|
+
var label = this.$module.getAttribute('data-track-label')
|
|
14
|
+
var value = parseInt(this.$module.getAttribute('data-track-value'))
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (typeof label === 'string') {
|
|
17
|
+
options.label = label
|
|
18
|
+
}
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (value || value === 0) {
|
|
21
|
+
options.value = value
|
|
22
|
+
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
|
|
25
|
+
window.GOVUK.analytics.trackEvent(category, action, options)
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
})(window)
|
|
29
|
+
Modules.AutoTrackEvent = AutoTrackEvent
|
|
30
|
+
})(window.GOVUK.Modules)
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
CustomDimensions.getAndExtendDefaultTrackingOptions = function (extraOptions) {
|
|
9
9
|
var trackingOptions = this.customDimensions()
|
|
10
|
-
return
|
|
10
|
+
return GOVUK.extendObject(trackingOptions, extraOptions)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
CustomDimensions.customDimensions = function () {
|
|
14
|
-
var dimensions =
|
|
14
|
+
var dimensions = GOVUK.extendObject(
|
|
15
15
|
{},
|
|
16
16
|
customDimensionsFromBrowser(),
|
|
17
17
|
customDimensionsFromMetaTags(),
|
|
@@ -25,24 +25,6 @@
|
|
|
25
25
|
return dimensions
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
CustomDimensions.extend = function (out) {
|
|
29
|
-
out = out || {}
|
|
30
|
-
|
|
31
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
32
|
-
if (!arguments[i]) {
|
|
33
|
-
continue
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
for (var key in arguments[i]) {
|
|
37
|
-
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
|
38
|
-
out[key] = arguments[i][key]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return out
|
|
44
|
-
}
|
|
45
|
-
|
|
46
28
|
function customDimensionsFromBrowser () {
|
|
47
29
|
var customDimensions = {
|
|
48
30
|
dimension15: window.httpStatusCode || 200,
|
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
;(function (global) {
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
var $ = global.jQuery
|
|
5
4
|
var GOVUK = global.GOVUK || {}
|
|
6
5
|
|
|
7
6
|
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
7
|
GOVUK.analyticsPlugins.downloadLinkTracker = function (options) {
|
|
9
8
|
options = options || {}
|
|
10
9
|
var downloadLinkSelector = options.selector
|
|
10
|
+
var selectors = downloadLinkSelector.split(',')
|
|
11
11
|
|
|
12
12
|
if (downloadLinkSelector) {
|
|
13
|
-
|
|
13
|
+
document.querySelector('body').addEventListener('click', function (event) {
|
|
14
|
+
var element = event.target
|
|
15
|
+
if (element.tagName !== 'A') {
|
|
16
|
+
element = element.closest('a')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!element) {
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (var i = 0; i < selectors.length; i++) {
|
|
24
|
+
if (element.matches(selectors[i].trim())) {
|
|
25
|
+
trackDownload(element)
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
})
|
|
14
30
|
}
|
|
15
31
|
|
|
16
|
-
function trackDownload (
|
|
17
|
-
var
|
|
18
|
-
var href = $link.attr('href')
|
|
32
|
+
function trackDownload (element) {
|
|
33
|
+
var href = element.getAttribute('href')
|
|
19
34
|
var evtOptions = { transport: 'beacon' }
|
|
20
|
-
var linkText =
|
|
35
|
+
var linkText = element.textContent.trim()
|
|
21
36
|
|
|
22
37
|
if (linkText) {
|
|
23
38
|
evtOptions.label = linkText
|
|
@@ -25,16 +40,6 @@
|
|
|
25
40
|
|
|
26
41
|
GOVUK.analytics.trackEvent('Download Link Clicked', href, evtOptions)
|
|
27
42
|
}
|
|
28
|
-
|
|
29
|
-
function getLinkFromEvent (evt) {
|
|
30
|
-
var $target = $(evt.target)
|
|
31
|
-
|
|
32
|
-
if (!$target.is('a')) {
|
|
33
|
-
$target = $target.parents('a')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return $target
|
|
37
|
-
}
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
global.GOVUK = GOVUK
|
|
@@ -1,49 +1,63 @@
|
|
|
1
|
+
// = require govuk/vendor/polyfills/Element/prototype/closest.js
|
|
1
2
|
;(function (global) {
|
|
2
3
|
'use strict'
|
|
3
4
|
|
|
4
|
-
var $ = global.jQuery
|
|
5
5
|
var GOVUK = global.GOVUK || {}
|
|
6
6
|
|
|
7
7
|
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
8
|
GOVUK.analyticsPlugins.externalLinkTracker = function (options) {
|
|
9
9
|
options = options || {}
|
|
10
|
-
|
|
10
|
+
GOVUK.analyticsPlugins.externalLinkTracker.options = options
|
|
11
|
+
document.querySelector('body').addEventListener('click', GOVUK.analyticsPlugins.externalLinkTracker.handleClick)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
GOVUK.analyticsPlugins.externalLinkTracker.handleClick = function (event) {
|
|
15
|
+
var element = event.target
|
|
16
|
+
if (element.tagName !== 'A') {
|
|
17
|
+
element = element.closest('a')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (!element) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink(element.getAttribute('href'))) {
|
|
25
|
+
GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent(element)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink = function (href) {
|
|
30
|
+
if (!href) {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
|
|
11
34
|
var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function trackClickEvent (evt) {
|
|
16
|
-
var $link = getLinkFromEvent(evt)
|
|
17
|
-
var options = { transport: 'beacon' }
|
|
18
|
-
var href = $link.attr('href')
|
|
19
|
-
var linkText = $.trim($link.text())
|
|
20
|
-
|
|
21
|
-
if (linkText) {
|
|
22
|
-
options.label = linkText
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (externalLinkUploadCustomDimension !== undefined) {
|
|
26
|
-
// This custom dimension will be used to duplicate the url information
|
|
27
|
-
// that we normally send in an "event action". This will be used to join
|
|
28
|
-
// up with a scheduled custom upload called "External Link Status".
|
|
29
|
-
// We can only join uploads on custom dimensions, not on `event actions`
|
|
30
|
-
// where we normally add the url info.
|
|
31
|
-
var externalLinkToJoinUploadOn = href
|
|
32
|
-
|
|
33
|
-
GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
|
|
34
|
-
}
|
|
35
|
-
GOVUK.analytics.trackEvent('External Link Clicked', href, options)
|
|
35
|
+
if (href.substring(0, 4) === 'http' && href.indexOf(currentHost) === -1) {
|
|
36
|
+
return true
|
|
36
37
|
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent = function (element) {
|
|
41
|
+
var options = { transport: 'beacon' }
|
|
42
|
+
var href = element.getAttribute('href')
|
|
43
|
+
var linkText = element.textContent.trim()
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
if (linkText) {
|
|
46
|
+
options.label = linkText
|
|
47
|
+
}
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
var externalLinkUploadCustomDimension = GOVUK.analyticsPlugins.externalLinkTracker.options.externalLinkUploadCustomDimension
|
|
50
|
+
if (externalLinkUploadCustomDimension !== undefined) {
|
|
51
|
+
// This custom dimension will be used to duplicate the url information
|
|
52
|
+
// that we normally send in an "event action". This will be used to join
|
|
53
|
+
// up with a scheduled custom upload called "External Link Status".
|
|
54
|
+
// We can only join uploads on custom dimensions, not on `event actions`
|
|
55
|
+
// where we normally add the url info.
|
|
56
|
+
var externalLinkToJoinUploadOn = href
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
|
|
46
59
|
}
|
|
60
|
+
GOVUK.analytics.trackEvent('External Link Clicked', href, options)
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
GOVUK.analyticsPlugins.externalLinkTracker.getHostname = function () {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
;(function (global) {
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
var $ = global.jQuery
|
|
5
4
|
var GOVUK = global.GOVUK || {}
|
|
6
5
|
var pii
|
|
7
6
|
|
|
@@ -78,7 +77,7 @@
|
|
|
78
77
|
// Set an options object for the pageview (e.g. transport, sessionControl)
|
|
79
78
|
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#transport
|
|
80
79
|
if (typeof options === 'object') {
|
|
81
|
-
pageviewObject =
|
|
80
|
+
pageviewObject = GOVUK.extendObject(pageviewObject || {}, options)
|
|
82
81
|
|
|
83
82
|
// trackerName is optional
|
|
84
83
|
if (typeof options.trackerName === 'string') {
|
|
@@ -87,10 +86,24 @@
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
function isEmptyObject (obj) {
|
|
90
|
+
if (typeof obj === 'undefined') {
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (var prop in obj) {
|
|
95
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return JSON.stringify(obj) === JSON.stringify({})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (isEmptyObject(pageviewObject)) {
|
|
93
104
|
sendToGa(trackerName + 'send', 'pageview')
|
|
105
|
+
} else {
|
|
106
|
+
sendToGa(trackerName + 'send', 'pageview', pageviewObject)
|
|
94
107
|
}
|
|
95
108
|
}
|
|
96
109
|
|
|
@@ -135,7 +148,7 @@
|
|
|
135
148
|
}
|
|
136
149
|
|
|
137
150
|
if (typeof options === 'object') {
|
|
138
|
-
|
|
151
|
+
evt = GOVUK.extendObject(evt, options)
|
|
139
152
|
}
|
|
140
153
|
|
|
141
154
|
sendToGa(trackerName + 'send', evt)
|
|
@@ -156,7 +169,7 @@
|
|
|
156
169
|
socialTarget: target
|
|
157
170
|
}
|
|
158
171
|
|
|
159
|
-
|
|
172
|
+
trackingOptions = GOVUK.extendObject(trackingOptions, options)
|
|
160
173
|
|
|
161
174
|
sendToGa('send', trackingOptions)
|
|
162
175
|
}
|
|
@@ -1,36 +1,41 @@
|
|
|
1
|
+
//= require ../vendor/polyfills/closest.js
|
|
1
2
|
;(function (global) {
|
|
2
3
|
'use strict'
|
|
3
4
|
|
|
4
|
-
var $ = global.jQuery
|
|
5
5
|
var GOVUK = global.GOVUK || {}
|
|
6
6
|
|
|
7
7
|
GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
|
|
8
8
|
GOVUK.analyticsPlugins.mailtoLinkTracker = function () {
|
|
9
|
-
|
|
9
|
+
document.querySelector('body').addEventListener('click', function (event) {
|
|
10
|
+
var element = event.target
|
|
11
|
+
if (element.tagName !== 'A') {
|
|
12
|
+
element = element.closest('a')
|
|
13
|
+
}
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
if (!element) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
var $link = getLinkFromEvent(evt)
|
|
15
|
-
var options = { transport: 'beacon' }
|
|
16
|
-
var href = $link.attr('href')
|
|
17
|
-
var linkText = $.trim($link.text())
|
|
19
|
+
var href = element.getAttribute('href')
|
|
18
20
|
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
+
if (!href) {
|
|
22
|
+
return
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
if (href.substring(0, 7) === 'mailto:') {
|
|
26
|
+
trackClickEvent(element, href)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
25
29
|
|
|
26
|
-
function
|
|
27
|
-
var
|
|
30
|
+
function trackClickEvent (element, href) {
|
|
31
|
+
var options = { transport: 'beacon' }
|
|
32
|
+
var linkText = element.textContent
|
|
28
33
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
34
|
+
if (linkText) {
|
|
35
|
+
options.label = linkText.trim()
|
|
31
36
|
}
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
GOVUK.analytics.trackEvent('Mailto Link Clicked', href, options)
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* global $ */
|
|
2
|
-
|
|
3
1
|
;(function (global) {
|
|
4
2
|
'use strict'
|
|
5
3
|
|
|
@@ -15,15 +13,21 @@
|
|
|
15
13
|
var STATE_PATTERN = /state=.[^&]+/g
|
|
16
14
|
|
|
17
15
|
function shouldStripDates () {
|
|
18
|
-
|
|
16
|
+
var metas = document.querySelectorAll('meta[name="govuk:static-analytics:strip-dates"]')
|
|
17
|
+
return metas.length > 0
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
function shouldStripPostcodes () {
|
|
22
|
-
|
|
21
|
+
var metas = document.querySelectorAll('meta[name="govuk:static-analytics:strip-postcodes"]')
|
|
22
|
+
return metas.length > 0
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function queryStringParametersToStrip () {
|
|
26
|
-
var
|
|
26
|
+
var meta = document.querySelector('meta[name="govuk:static-analytics:strip-query-string-parameters"]')
|
|
27
|
+
var value = false
|
|
28
|
+
if (meta) {
|
|
29
|
+
value = meta.getAttribute('content')
|
|
30
|
+
}
|
|
27
31
|
var parameters = []
|
|
28
32
|
|
|
29
33
|
if (value) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* global GOVUK,
|
|
1
|
+
/* global GOVUK, ga */
|
|
2
2
|
|
|
3
3
|
(function () {
|
|
4
4
|
'use strict'
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
ga(function (tracker) {
|
|
21
21
|
this.gaClientId = tracker.get('clientId')
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
GOVUK.triggerEvent(window, 'gaClientSet')
|
|
24
24
|
|
|
25
25
|
// Start up ecommerce tracking
|
|
26
26
|
GOVUK.Ecommerce.start()
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
// Add the cookie banner status as a custom dimension
|
|
50
50
|
var cookieBannerShown = !this.getCookie('seen_cookie_message')
|
|
51
51
|
var cookieBannerDimension = { dimension100: cookieBannerShown ? cookieBannerShown.toString() : 'false' }
|
|
52
|
-
|
|
52
|
+
options = GOVUK.extendObject(options, cookieBannerDimension)
|
|
53
53
|
|
|
54
54
|
var trackingOptions = GOVUK.CustomDimensions.getAndExtendDefaultTrackingOptions(options)
|
|
55
55
|
this.analytics.trackPageview(path, title, trackingOptions)
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
|
|
84
84
|
var cookieOptions = getOptionsFromCookie()
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
cookieOptions = GOVUK.extendObject(cookieOptions, options)
|
|
87
87
|
|
|
88
88
|
this.setCookie('analytics_next_page_call', cookieOptions)
|
|
89
89
|
}
|
|
@@ -4,10 +4,11 @@ window.GOVUK = window.GOVUK || {}
|
|
|
4
4
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
5
5
|
|
|
6
6
|
(function (Modules) {
|
|
7
|
-
function GemTrackClick () {
|
|
7
|
+
function GemTrackClick ($module) {
|
|
8
|
+
this.$module = $module
|
|
9
|
+
}
|
|
8
10
|
|
|
9
|
-
GemTrackClick.prototype.
|
|
10
|
-
this.$module = $module[0]
|
|
11
|
+
GemTrackClick.prototype.init = function () {
|
|
11
12
|
this.$module.handleClick = this.handleClick.bind(this)
|
|
12
13
|
var trackLinksOnly = this.$module.hasAttribute('data-track-links-only')
|
|
13
14
|
var limitToElementClass = this.$module.getAttribute('data-limit-to-element-class')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//= require govuk_publishing_components/lib/cookie-functions
|
|
2
|
+
//= require govuk_publishing_components/lib/extend-object
|
|
2
3
|
//= require ./analytics/pii
|
|
3
4
|
//= require ./analytics/google-analytics-universal-tracker
|
|
4
5
|
//= require ./analytics/analytics
|
|
@@ -13,7 +14,6 @@
|
|
|
13
14
|
//= require ./analytics/static-analytics
|
|
14
15
|
//= require ./analytics/ecommerce
|
|
15
16
|
//= require ./analytics/init
|
|
16
|
-
//= require ./analytics/scroll-tracker
|
|
17
17
|
//= require ./analytics/auto-scroll-tracker
|
|
18
18
|
//= require ./analytics/explicit-cross-domain-links
|
|
19
19
|
//= require ./analytics/track-click
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-env jquery */
|
|
2
1
|
// = require govuk/components/details/details.js
|
|
3
2
|
window.GOVUK = window.GOVUK || {}
|
|
4
3
|
window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
@@ -15,8 +14,8 @@ window.GOVUK.Modules.GovukDetails = window.GOVUKFrontend;
|
|
|
15
14
|
|
|
16
15
|
GemDetails.prototype.init = function () {
|
|
17
16
|
if (this.customTrackLabel) { // If a custom label has been provided, we can simply call the tracking module
|
|
18
|
-
var trackDetails = new window.GOVUK.Modules.GemTrackClick()
|
|
19
|
-
trackDetails.
|
|
17
|
+
var trackDetails = new window.GOVUK.Modules.GemTrackClick(this.$summary)
|
|
18
|
+
trackDetails.init()
|
|
20
19
|
} else if (this.detailsClick) { // If no custom label is set, we use the open/close status as the label
|
|
21
20
|
this.detailsClick.addEventListener('click', function (event) {
|
|
22
21
|
this.trackDefault(this.$summary)
|
|
@@ -25,10 +25,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
25
25
|
this.setInitialAriaAttributes()
|
|
26
26
|
this.setHiddenValues()
|
|
27
27
|
|
|
28
|
+
this.prompt.hidden = false
|
|
29
|
+
for (var k = 0; k < this.promptQuestions.length; k++) {
|
|
30
|
+
this.promptQuestions[k].hidden = false
|
|
31
|
+
}
|
|
32
|
+
this.surveyForm.hidden = true
|
|
33
|
+
|
|
28
34
|
for (var j = 0; j < this.toggleForms.length; j++) {
|
|
29
35
|
this.toggleForms[j].addEventListener('click', function (e) {
|
|
30
36
|
e.preventDefault()
|
|
31
|
-
var el = e.target
|
|
37
|
+
var el = e.target.closest('button')
|
|
32
38
|
this.toggleForm(el.getAttribute('aria-controls'))
|
|
33
39
|
this.trackEvent(this.getTrackEventParams(el))
|
|
34
40
|
this.updateAriaAttributes(el)
|
|
@@ -36,6 +42,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
for (var i = 0; i < this.closeForms.length; i++) {
|
|
45
|
+
this.closeForms[i].hidden = false
|
|
39
46
|
this.closeForms[i].addEventListener('click', function (e) {
|
|
40
47
|
e.preventDefault()
|
|
41
48
|
var el = e.target
|
|
@@ -89,7 +96,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
89
96
|
this.showFormSuccess(xhr.message)
|
|
90
97
|
this.revealInitialPrompt()
|
|
91
98
|
this.setInitialAriaAttributes()
|
|
92
|
-
this.activeForm.
|
|
99
|
+
this.activeForm.hidden ? this.activeForm.hidden = false : this.activeForm.hidden = true
|
|
93
100
|
} else {
|
|
94
101
|
this.showError(xhr)
|
|
95
102
|
this.enableSubmitFormButton($form)
|
|
@@ -114,9 +121,6 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
Feedback.prototype.setInitialAriaAttributes = function () {
|
|
117
|
-
for (var i = 0; i < this.forms.length; i++) {
|
|
118
|
-
this.forms[i].setAttribute('aria-hidden', true)
|
|
119
|
-
}
|
|
120
124
|
this.pageIsNotUsefulButton.setAttribute('aria-expanded', false)
|
|
121
125
|
this.somethingIsWrongButton.setAttribute('aria-expanded', false)
|
|
122
126
|
}
|
|
@@ -168,20 +172,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
168
172
|
|
|
169
173
|
Feedback.prototype.updateAriaAttributes = function (linkClicked) {
|
|
170
174
|
linkClicked.setAttribute('aria-expanded', true)
|
|
171
|
-
var controls = linkClicked.getAttribute('aria-controls')
|
|
172
|
-
var ariaControls = document.querySelector('#' + controls)
|
|
173
|
-
ariaControls.setAttribute('aria-hidden', false)
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
Feedback.prototype.toggleForm = function (formId) {
|
|
177
178
|
this.activeForm = this.$module.querySelector('#' + formId)
|
|
178
|
-
this.activeForm.
|
|
179
|
-
this.prompt.
|
|
180
|
-
|
|
181
|
-
var formIsVisible = !this.activeForm.classList.contains(this.jshiddenClass)
|
|
179
|
+
this.activeForm.hidden ? this.activeForm.hidden = false : this.activeForm.hidden = true
|
|
180
|
+
this.prompt.hidden ? this.prompt.hidden = false : this.prompt.hidden = true
|
|
182
181
|
|
|
183
|
-
if (
|
|
184
|
-
this.activeForm.
|
|
182
|
+
if (!this.activeForm.hidden) {
|
|
183
|
+
this.activeForm.querySelectorAll('.gem-c-textarea .govuk-textarea, .gem-c-input.govuk-input')[0]
|
|
184
|
+
.focus()
|
|
185
185
|
} else {
|
|
186
186
|
this.activeForm = false
|
|
187
187
|
}
|
|
@@ -223,20 +223,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
223
223
|
}
|
|
224
224
|
var $errors = this.activeForm.querySelector('.js-errors')
|
|
225
225
|
$errors.innerHTML = error
|
|
226
|
-
$errors.
|
|
226
|
+
$errors.hidden = false
|
|
227
227
|
$errors.focus()
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
Feedback.prototype.showFormSuccess = function () {
|
|
231
231
|
for (var i = 0; i < this.promptQuestions.length; i++) {
|
|
232
|
-
this.promptQuestions[i].
|
|
232
|
+
this.promptQuestions[i].hidden = true
|
|
233
233
|
}
|
|
234
|
-
this.promptSuccessMessage.
|
|
234
|
+
this.promptSuccessMessage.hidden = false
|
|
235
235
|
this.promptSuccessMessage.focus()
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
Feedback.prototype.revealInitialPrompt = function () {
|
|
239
|
-
this.prompt.
|
|
239
|
+
this.prompt.hidden = false
|
|
240
240
|
this.prompt.focus()
|
|
241
241
|
}
|
|
242
242
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
|
+
|
|
4
|
+
(function (Modules) {
|
|
5
|
+
function Metadata ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
Metadata.prototype.init = function () {
|
|
10
|
+
var seeAllUpdates = this.$module.querySelector('.js-see-all-updates-link')
|
|
11
|
+
|
|
12
|
+
if (seeAllUpdates) {
|
|
13
|
+
var target = document.querySelector(seeAllUpdates.getAttribute('href'))
|
|
14
|
+
|
|
15
|
+
if (target) {
|
|
16
|
+
seeAllUpdates.addEventListener('click', function () {
|
|
17
|
+
var targetToggleTrigger = target.querySelector('[aria-expanded]')
|
|
18
|
+
if (targetToggleTrigger && targetToggleTrigger.getAttribute('aria-expanded') !== 'true') {
|
|
19
|
+
targetToggleTrigger.click()
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Modules.Metadata = Metadata
|
|
27
|
+
})(window.GOVUK.Modules)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function (root) {
|
|
2
|
+
'use strict'
|
|
3
|
+
window.GOVUK = window.GOVUK || {}
|
|
4
|
+
|
|
5
|
+
window.GOVUK.extendObject = function (obj) {
|
|
6
|
+
obj = obj || {}
|
|
7
|
+
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
if (!arguments[i]) {
|
|
10
|
+
continue
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
for (var key in arguments[i]) {
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(arguments[i], key)) {
|
|
15
|
+
obj[key] = arguments[i][key]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return obj
|
|
21
|
+
}
|
|
22
|
+
}(window))
|