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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/auto-scroll-tracker.js +2 -1
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/auto-track-event.js +22 -22
  4. data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +2 -20
  5. data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +21 -16
  6. data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +46 -32
  7. data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +20 -7
  8. data/app/assets/javascripts/govuk_publishing_components/analytics/mailto-link-tracker.js +22 -17
  9. data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +9 -5
  10. data/app/assets/javascripts/govuk_publishing_components/analytics/static-analytics.js +4 -4
  11. data/app/assets/javascripts/govuk_publishing_components/analytics/track-click.js +4 -3
  12. data/app/assets/javascripts/govuk_publishing_components/analytics.js +1 -1
  13. data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +0 -1
  14. data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -3
  15. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +18 -18
  16. data/app/assets/javascripts/govuk_publishing_components/components/metadata.js +27 -0
  17. data/app/assets/javascripts/govuk_publishing_components/lib/extend-object.js +22 -0
  18. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -2
  19. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -2
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +5 -2
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +8 -37
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +67 -21
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -2
  24. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +6 -0
  25. data/app/views/govuk_publishing_components/components/_big_number.html.erb +19 -9
  26. data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +22 -18
  27. data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -2
  28. data/app/views/govuk_publishing_components/components/_share_links.html.erb +25 -22
  29. data/app/views/govuk_publishing_components/components/docs/accordion.yml +31 -25
  30. data/app/views/govuk_publishing_components/components/docs/big_number.yml +6 -0
  31. data/app/views/govuk_publishing_components/components/docs/feedback.yml +5 -0
  32. data/app/views/govuk_publishing_components/components/docs/input.yml +1 -1
  33. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
  34. data/app/views/govuk_publishing_components/components/docs/tabs.yml +2 -2
  35. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +35 -6
  36. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +4 -3
  37. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +19 -11
  38. data/config/locales/ar.yml +0 -8
  39. data/config/locales/az.yml +0 -8
  40. data/config/locales/be.yml +0 -8
  41. data/config/locales/bg.yml +0 -8
  42. data/config/locales/bn.yml +0 -8
  43. data/config/locales/cs.yml +0 -8
  44. data/config/locales/cy.yml +0 -8
  45. data/config/locales/da.yml +0 -8
  46. data/config/locales/de.yml +0 -8
  47. data/config/locales/dr.yml +0 -8
  48. data/config/locales/el.yml +0 -8
  49. data/config/locales/en.yml +0 -10
  50. data/config/locales/es-419.yml +0 -8
  51. data/config/locales/es.yml +0 -8
  52. data/config/locales/et.yml +0 -8
  53. data/config/locales/fa.yml +0 -8
  54. data/config/locales/fi.yml +0 -8
  55. data/config/locales/fr.yml +0 -8
  56. data/config/locales/gd.yml +0 -8
  57. data/config/locales/gu.yml +0 -8
  58. data/config/locales/he.yml +0 -8
  59. data/config/locales/hi.yml +0 -8
  60. data/config/locales/hr.yml +0 -8
  61. data/config/locales/hu.yml +0 -8
  62. data/config/locales/hy.yml +0 -8
  63. data/config/locales/id.yml +0 -8
  64. data/config/locales/is.yml +0 -8
  65. data/config/locales/it.yml +0 -8
  66. data/config/locales/ja.yml +0 -8
  67. data/config/locales/ka.yml +0 -8
  68. data/config/locales/kk.yml +0 -8
  69. data/config/locales/ko.yml +0 -8
  70. data/config/locales/lt.yml +0 -8
  71. data/config/locales/lv.yml +0 -8
  72. data/config/locales/ms.yml +0 -8
  73. data/config/locales/mt.yml +0 -8
  74. data/config/locales/nl.yml +0 -8
  75. data/config/locales/no.yml +0 -8
  76. data/config/locales/pa-pk.yml +0 -8
  77. data/config/locales/pa.yml +0 -8
  78. data/config/locales/pl.yml +0 -8
  79. data/config/locales/ps.yml +0 -8
  80. data/config/locales/pt.yml +0 -8
  81. data/config/locales/ro.yml +0 -8
  82. data/config/locales/ru.yml +0 -8
  83. data/config/locales/si.yml +0 -8
  84. data/config/locales/sk.yml +0 -8
  85. data/config/locales/sl.yml +0 -8
  86. data/config/locales/so.yml +0 -8
  87. data/config/locales/sq.yml +0 -8
  88. data/config/locales/sr.yml +0 -8
  89. data/config/locales/sv.yml +0 -8
  90. data/config/locales/sw.yml +0 -8
  91. data/config/locales/ta.yml +0 -8
  92. data/config/locales/th.yml +0 -8
  93. data/config/locales/tk.yml +0 -8
  94. data/config/locales/tr.yml +0 -8
  95. data/config/locales/uk.yml +0 -8
  96. data/config/locales/ur.yml +0 -8
  97. data/config/locales/uz.yml +0 -8
  98. data/config/locales/vi.yml +0 -8
  99. data/config/locales/zh-hk.yml +0 -8
  100. data/config/locales/zh-tw.yml +0 -8
  101. data/config/locales/zh.yml +0 -8
  102. data/lib/govuk_publishing_components/presenters/big_number_helper.rb +30 -0
  103. data/lib/govuk_publishing_components/version.rb +1 -1
  104. data/lib/govuk_publishing_components.rb +1 -2
  105. metadata +5 -15
  106. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +0 -237
  107. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +0 -84
  108. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +0 -21
  109. data/app/views/govuk_publishing_components/components/_admin_analytics.html.erb +0 -20
  110. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +0 -86
  111. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +0 -47
  112. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +0 -30
  113. data/app/views/govuk_publishing_components/components/docs/admin_analytics.yml +0 -10
  114. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +0 -20
  115. data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +0 -171
  116. data/app/views/govuk_publishing_components/components/docs/taxonomy_list.yml +0 -112
  117. data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +0 -13
  118. 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: abe5f80412062a42d0581b1137f85d3c6932cb23e20d840d08a345b642133e65
4
- data.tar.gz: 6b46ff356ab253ec47fb4ed7d67f4cd8b40c0024bedf4511e03e4416b2ee519d
3
+ metadata.gz: 1cdf4c30d55a0c5ec9b7708ecc5866d5f554ed0be27ffe9f23df9ae3a8862ac9
4
+ data.tar.gz: a2183c0f935738d9bedafae81ce3f1e5b0715ceeebe3b8eb301b7c7a79d0f56b
5
5
  SHA512:
6
- metadata.gz: 92c367ffdd7fc084e3b68fac798c1e1e51f3c37b361e6003c877b4c8839c40eaecb98ecbf20e5d65de3fe1aa8926167c557d6ef767516d3d9deacc64f32113c4
7
- data.tar.gz: 971c347b11fdb3d12302e44deaa3bb77406b6b76d15c78e4af44c415b950aabfa688a1e9708de04eea09bf274b0484c30c27c2917392d862a1af10b013549380
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
- var pos = (pageHeight / 100) * percent
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
- ;(function (global) {
2
- 'use strict'
1
+ window.GOVUK = window.GOVUK || {}
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
3
 
4
- var GOVUK = global.GOVUK || {}
5
- GOVUK.Modules = GOVUK.Modules || {}
4
+ (function (Modules) {
5
+ function AutoTrackEvent ($module) {
6
+ this.$module = $module
7
+ }
6
8
 
7
- GOVUK.Modules.AutoTrackEvent = function () {
8
- this.start = function (element) {
9
- var options = { nonInteraction: 1 } // automatic events shouldn't affect bounce rate
10
- var category = element.data('track-category')
11
- var action = element.data('track-action')
12
- var label = element.data('track-label')
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
- if (typeof label === 'string') {
16
- options.label = label
17
- }
16
+ if (typeof label === 'string') {
17
+ options.label = label
18
+ }
18
19
 
19
- if (value || value === 0) {
20
- options.value = value
21
- }
20
+ if (value || value === 0) {
21
+ options.value = value
22
+ }
22
23
 
23
- if (GOVUK.analytics && GOVUK.analytics.trackEvent) {
24
- GOVUK.analytics.trackEvent(category, action, options)
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
- global.GOVUK = GOVUK
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 this.extend(trackingOptions, extraOptions)
10
+ return GOVUK.extendObject(trackingOptions, extraOptions)
11
11
  }
12
12
 
13
13
  CustomDimensions.customDimensions = function () {
14
- var dimensions = this.extend(
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
- $('body').on('click', downloadLinkSelector, trackDownload)
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 (evt) {
17
- var $link = getLinkFromEvent(evt)
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 = $.trim($link.text())
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
- var externalLinkUploadCustomDimension = options.externalLinkUploadCustomDimension
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
- var externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'
13
- $('body').on('click', externalLinkSelector, trackClickEvent)
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
- function getLinkFromEvent (evt) {
39
- var $target = $(evt.target)
45
+ if (linkText) {
46
+ options.label = linkText
47
+ }
40
48
 
41
- if (!$target.is('a')) {
42
- $target = $target.parents('a')
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
- return $target
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 = $.extend(pageviewObject || {}, options)
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
- if (!$.isEmptyObject(pageviewObject)) {
91
- sendToGa(trackerName + 'send', 'pageview', pageviewObject)
92
- } else {
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
- $.extend(evt, options)
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
- $.extend(trackingOptions, options)
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
- var mailtoLinkSelector = 'a[href^="mailto:"]'
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
- $('body').on('click', mailtoLinkSelector, trackClickEvent)
15
+ if (!element) {
16
+ return
17
+ }
12
18
 
13
- function trackClickEvent (evt) {
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 (linkText) {
20
- options.label = linkText
21
+ if (!href) {
22
+ return
21
23
  }
22
24
 
23
- GOVUK.analytics.trackEvent('Mailto Link Clicked', href, options)
24
- }
25
+ if (href.substring(0, 7) === 'mailto:') {
26
+ trackClickEvent(element, href)
27
+ }
28
+ })
25
29
 
26
- function getLinkFromEvent (evt) {
27
- var $target = $(evt.target)
30
+ function trackClickEvent (element, href) {
31
+ var options = { transport: 'beacon' }
32
+ var linkText = element.textContent
28
33
 
29
- if (!$target.is('a')) {
30
- $target = $target.parents('a')
34
+ if (linkText) {
35
+ options.label = linkText.trim()
31
36
  }
32
37
 
33
- return $target
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
- return ($('meta[name="govuk:static-analytics:strip-dates"]').length > 0)
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
- return ($('meta[name="govuk:static-analytics:strip-postcodes"]').length > 0)
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 value = $('meta[name="govuk:static-analytics:strip-query-string-parameters"]').attr('content')
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, $, ga */
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
- $(window).trigger('gaClientSet')
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
- $.extend(options, cookieBannerDimension)
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
- $.extend(cookieOptions, options)
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.start = function ($module) {
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/vendor/polyfills/Element/prototype/closest.js
3
2
  // = require govuk/components/checkboxes/checkboxes.js
4
3
  window.GOVUK = window.GOVUK || {}
@@ -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.start($(this.$summary))
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.classList.toggle(this.jshiddenClass)
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.classList.toggle(this.jshiddenClass)
179
- this.prompt.classList.toggle(this.jshiddenClass)
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 (formIsVisible) {
184
- this.activeForm.querySelector('.gem-c-input').focus()
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.classList.remove(this.jshiddenClass)
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].classList.add(this.jshiddenClass)
232
+ this.promptQuestions[i].hidden = true
233
233
  }
234
- this.promptSuccessMessage.classList.remove(this.jshiddenClass)
234
+ this.promptSuccessMessage.hidden = false
235
235
  this.promptSuccessMessage.focus()
236
236
  }
237
237
 
238
238
  Feedback.prototype.revealInitialPrompt = function () {
239
- this.prompt.classList.remove(this.jshiddenClass)
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))