govuk_publishing_components 27.20.0 → 28.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +21 -16
  3. data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +46 -32
  4. data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +20 -7
  5. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +1 -126
  6. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +18 -18
  7. data/app/assets/javascripts/govuk_publishing_components/lib/extend-object.js +22 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -2
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +6 -35
  10. data/app/views/govuk_publishing_components/components/docs/feedback.yml +5 -0
  11. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +9 -6
  12. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +4 -3
  13. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +4 -4
  14. data/config/locales/ar.yml +0 -8
  15. data/config/locales/az.yml +0 -8
  16. data/config/locales/be.yml +0 -8
  17. data/config/locales/bg.yml +0 -8
  18. data/config/locales/bn.yml +0 -8
  19. data/config/locales/cs.yml +0 -8
  20. data/config/locales/cy.yml +0 -8
  21. data/config/locales/da.yml +0 -8
  22. data/config/locales/de.yml +0 -8
  23. data/config/locales/dr.yml +0 -8
  24. data/config/locales/el.yml +0 -8
  25. data/config/locales/en.yml +0 -10
  26. data/config/locales/es-419.yml +0 -8
  27. data/config/locales/es.yml +0 -8
  28. data/config/locales/et.yml +0 -8
  29. data/config/locales/fa.yml +0 -8
  30. data/config/locales/fi.yml +0 -8
  31. data/config/locales/fr.yml +0 -8
  32. data/config/locales/gd.yml +0 -8
  33. data/config/locales/gu.yml +0 -8
  34. data/config/locales/he.yml +0 -8
  35. data/config/locales/hi.yml +0 -8
  36. data/config/locales/hr.yml +0 -8
  37. data/config/locales/hu.yml +0 -8
  38. data/config/locales/hy.yml +0 -8
  39. data/config/locales/id.yml +0 -8
  40. data/config/locales/is.yml +0 -8
  41. data/config/locales/it.yml +0 -8
  42. data/config/locales/ja.yml +0 -8
  43. data/config/locales/ka.yml +0 -8
  44. data/config/locales/kk.yml +0 -8
  45. data/config/locales/ko.yml +0 -8
  46. data/config/locales/lt.yml +0 -8
  47. data/config/locales/lv.yml +0 -8
  48. data/config/locales/ms.yml +0 -8
  49. data/config/locales/mt.yml +0 -8
  50. data/config/locales/nl.yml +0 -8
  51. data/config/locales/no.yml +0 -8
  52. data/config/locales/pa-pk.yml +0 -8
  53. data/config/locales/pa.yml +0 -8
  54. data/config/locales/pl.yml +0 -8
  55. data/config/locales/ps.yml +0 -8
  56. data/config/locales/pt.yml +0 -8
  57. data/config/locales/ro.yml +0 -8
  58. data/config/locales/ru.yml +0 -8
  59. data/config/locales/si.yml +0 -8
  60. data/config/locales/sk.yml +0 -8
  61. data/config/locales/sl.yml +0 -8
  62. data/config/locales/so.yml +0 -8
  63. data/config/locales/sq.yml +0 -8
  64. data/config/locales/sr.yml +0 -8
  65. data/config/locales/sv.yml +0 -8
  66. data/config/locales/sw.yml +0 -8
  67. data/config/locales/ta.yml +0 -8
  68. data/config/locales/th.yml +0 -8
  69. data/config/locales/tk.yml +0 -8
  70. data/config/locales/tr.yml +0 -8
  71. data/config/locales/uk.yml +0 -8
  72. data/config/locales/ur.yml +0 -8
  73. data/config/locales/uz.yml +0 -8
  74. data/config/locales/vi.yml +0 -8
  75. data/config/locales/zh-hk.yml +0 -8
  76. data/config/locales/zh-tw.yml +0 -8
  77. data/config/locales/zh.yml +0 -8
  78. data/lib/govuk_publishing_components/version.rb +1 -1
  79. data/lib/govuk_publishing_components.rb +0 -2
  80. metadata +3 -14
  81. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +0 -84
  82. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +0 -21
  83. data/app/views/govuk_publishing_components/components/_admin_analytics.html.erb +0 -20
  84. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +0 -86
  85. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +0 -47
  86. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +0 -30
  87. data/app/views/govuk_publishing_components/components/docs/admin_analytics.yml +0 -10
  88. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +0 -20
  89. data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +0 -171
  90. data/app/views/govuk_publishing_components/components/docs/taxonomy_list.yml +0 -112
  91. data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +0 -13
  92. 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: 52ec5aa91a7d5060c6b29671f2206a967ab5af8a3891cb800c95d6b28eb09d15
4
+ data.tar.gz: 0bbf50f1bb6f0cd64af2986e72a612fe28a65df3987caf523939fcf87e3341ad
5
5
  SHA512:
6
- metadata.gz: 92c367ffdd7fc084e3b68fac798c1e1e51f3c37b361e6003c877b4c8839c40eaecb98ecbf20e5d65de3fe1aa8926167c557d6ef767516d3d9deacc64f32113c4
7
- data.tar.gz: 971c347b11fdb3d12302e44deaa3bb77406b6b76d15c78e4af44c415b950aabfa688a1e9708de04eea09bf274b0484c30c27c2917392d862a1af10b013549380
6
+ metadata.gz: a144e7583969b1767bb25e64f64772d4c4e632814ba3863f6335570a3a83936eea4aa76daeb1b006f39910b5b6086f1f9f65ea63b3068f929bc167f2f5237ea2
7
+ data.tar.gz: 78e13b419fba7b1eac89947ca9891e87f4939ed27456e093c474fbeca3afb291c6c86b002fbed478630b78671bd061637a208cf5f043656631b5d12e7b5af72c
@@ -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
  }
@@ -5,132 +5,7 @@
5
5
 
6
6
  window.GOVUK = window.GOVUK || {}
7
7
 
8
- var percentages = [
9
- ['Percent', 20],
10
- ['Percent', 40],
11
- ['Percent', 60],
12
- ['Percent', 80],
13
- ['Percent', 100]
14
- ]
15
-
16
- var CONFIG = {
17
- '/brexit': percentages,
18
- '/government/publications/the-essential-trustee-what-you-need-to-know-cc3/the-essential-trustee-what-you-need-to-know-what-you-need-to-do': [
19
- ['Heading', '1. About this guidance'],
20
- ['Heading', '2. Trustees’ duties at a glance'],
21
- ['Heading', '3. Who can be a trustee and how trustees are appointed'],
22
- ['Heading', '4. Ensure your charity is carrying out its purposes for the public benefit'],
23
- ['Heading', '5. Comply with your charity’s governing document and the law'],
24
- ['Heading', '6. Act in your charity’s best interests'],
25
- ['Heading', '7. Manage your charity’s resources responsibly'],
26
- ['Heading', '8. Act with reasonable care and skill'],
27
- ['Heading', '9. Ensure your charity is accountable'],
28
- ['Heading', '10. Reduce the risk of liability'],
29
- ['Heading', '11. Your charity’s legal structure and what it means'],
30
- ['Heading', '12. Charity officers - the chair and treasurer'],
31
- ['Heading', '13. Technical terms used in this guidance']
32
- ],
33
- '/guidance/universal-credit-how-it-helps-you-into-work': [
34
- ['Heading', 'Support from your work coach'],
35
- ['Heading', 'Help available for parents'],
36
- ['Heading', 'When you can claim Universal Credit'],
37
- ['Heading', 'More detailed advice']
38
- ],
39
- '/government/publications/spring-budget-2017-documents/spring-budget-2017': [
40
- ['Heading', '1. Executive summary'],
41
- ['Heading', '2. Economic context and public finances'],
42
- ['Heading', '3. Policy decisions'],
43
- ['Heading', '4. Tax'],
44
- ['Heading', '5. Productivity'],
45
- ['Heading', '6. Public services and markets'],
46
- ['Heading', '7. Annex A: Financing'],
47
- ['Heading', '8. Annex B: Office for Budget Responsibility\'s Economic and fiscal outlook']
48
- ],
49
- '/settled-status-eu-citizens-families': [
50
- ['Heading', 'When you can apply']
51
- ],
52
- '/guidance/returning-to-the-uk': [
53
- ['Heading', 'Ending your time living abroad']
54
- ],
55
- '/council-housing': [
56
- ['Heading', 'Choice-based lettings']
57
- ],
58
- '/guidance/foreign-travel-insurance': [
59
- ['Heading', 'What your travel insurance policy should cover']
60
- ],
61
- '/guidance/living-in-france': [
62
- ['Heading', 'Passports and travel']
63
- ],
64
- '/family-permit': [
65
- ['Heading', 'EEA family permit']
66
- ],
67
- '/guidance/healthcare-for-eu-and-efta-citizens-visiting-the-uk': [
68
- ['Heading', 'Travel insurance']
69
- ],
70
- '/driving-abroad': [
71
- ['Heading', 'Check your insurance if you’re taking your own vehicle']
72
- ],
73
- '/get-a-passport-urgently': [
74
- ['Heading', 'Ways to apply']
75
- ],
76
- '/driving-abroad/international-driving-permit': [
77
- ['Heading', 'Check which IDP you need']
78
- ],
79
- '/guidance/guidance-for-suppliers-of-cattle-sheep-and-goat-ear-tags': [
80
- ['Heading', 'Tagging information for livestock keepers']
81
- ],
82
- '/guidance/how-to-move-goods-between-or-through-common-transit-countries-including-the-eu': [
83
- ['Heading', 'Start moving your goods']
84
- ],
85
- '/guidance/ecmt-international-road-haulage-permits': [
86
- ['Heading', 'Apply for permits']
87
- ],
88
- '/taking-goods-out-uk-temporarily/get-an-ata-carnet': [
89
- ['Heading', 'Using an ATA Carnet']
90
- ],
91
- '/wood-packaging-import-export': [
92
- ['Heading', 'Export solid wood packaging']
93
- ],
94
- '/coronavirus': percentages,
95
- '/coronavirus/education-and-childcare': percentages,
96
- '/coronavirus/worker-support': percentages,
97
- '/coronavirus/business-support': percentages,
98
- '/get-coronavirus-test': percentages,
99
- '/next-steps-for-your-business/results': [
100
- ['Heading', 'Things you need to do next'],
101
- ['Heading', 'Rules to follow'],
102
- ['Heading', 'Good to know'],
103
- ['Heading', 'Change your answers']
104
- ],
105
- '/guidance/brexit-guidance-for-businesses': percentages,
106
- '/guidance/brexit-guidance-for-businesses.cy': percentages,
107
- '/guidance/brexit-guidance-for-individuals-and-families': percentages,
108
- '/guidance/brexit-guidance-for-individuals-and-families.cy': percentages,
109
- '/guidance/import-and-export-goods-using-preference-agreements': percentages,
110
- '/guidance/travel-abroad-from-england-during-coronavirus-covid-19': [
111
- ['Heading', 'Before you travel abroad'],
112
- ['Heading', '1. Check the rules for the country you’re going to'],
113
- ['Heading', '2. Find out what you need to do when you return'],
114
- ['Heading', '3. Book any COVID-19 tests or quarantine hotel packages you need for your return'],
115
- ['Heading', 'Before you return'],
116
- ['Heading', 'After you return'],
117
- ['Heading', 'Travelling with children'],
118
- ['Heading', 'Ireland, the UK, the Channel Islands and the Isle of Man'],
119
- ['Heading', 'Exemptions for work, medical or compassionate reasons']
120
- ],
121
- '/guidance/travel-to-england-from-another-country-during-coronavirus-covid-19': [
122
- ['Heading', 'Before you travel'],
123
- ['Heading', '1. Check the rules for the country you’re coming from or have travelled through'],
124
- ['Heading', '2. Book any COVID-19 tests or quarantine hotel packages you need for your arrival'],
125
- ['Heading', '3. Get tested and complete documents'],
126
- ['Heading', 'When you arrive in England'],
127
- ['Heading', 'Leaving England'],
128
- ['Heading', 'Travelling with children'],
129
- ['Heading', 'Ireland, the UK, the Channel Islands and the Isle of Man'],
130
- ['Heading', 'Exemptions for work, medical or compassionate reasons']
131
- ],
132
- '/find-travel-test-provider': percentages
133
- }
8
+ var CONFIG = {}
134
9
 
135
10
  function ScrollTracker (sitewideConfig) {
136
11
  this.config = this.getConfigForCurrentPath(sitewideConfig)
@@ -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,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))
@@ -39,7 +39,6 @@ $govuk-new-link-styles: true;
39
39
  @import "components/govspeak-html-publication";
40
40
  @import "components/govspeak";
41
41
  @import "components/heading";
42
- @import "components/highlight-boxes";
43
42
  @import "components/hint";
44
43
  @import "components/image-card";
45
44
  @import "components/input";
@@ -79,7 +78,6 @@ $govuk-new-link-styles: true;
79
78
  @import "components/summary-list";
80
79
  @import "components/tabs";
81
80
  @import "components/table";
82
- @import "components/taxonomy-list";
83
81
  @import "components/textarea";
84
82
  @import "components/title";
85
83
  @import "components/translation-nav";
@@ -6,6 +6,12 @@
6
6
  margin-top: govuk-spacing(9);
7
7
  border-bottom: 1px solid govuk-colour("white");
8
8
  }
9
+
10
+ // Scoped to the feedback component temporarily
11
+ [hidden] {
12
+ // stylelint-disable-next-line declaration-no-important
13
+ display: none !important;
14
+ }
9
15
  }
10
16
 
11
17
  .gem-c-feedback__prompt-questions {
@@ -238,38 +244,3 @@
238
244
  outline: $govuk-focus-width solid $govuk-focus-colour;
239
245
  }
240
246
  }
241
-
242
- // hide without js
243
- // show with js, unless also has the js-hidden class
244
- .gem-c-feedback__js-show,
245
- .gem-c-feedback__prompt-success,
246
- .gem-c-feedback__prompt-questions,
247
- .gem-c-feedback__error-summary {
248
- display: none;
249
-
250
- .js-enabled & {
251
- display: block;
252
-
253
- &.js-hidden {
254
- display: none;
255
- }
256
- }
257
- }
258
-
259
- // maintain table display for prompt and prompt-questions
260
- .js-enabled .gem-c-feedback__prompt {
261
- @include govuk-media-query($from: tablet) {
262
- display: table;
263
- }
264
- }
265
-
266
- .js-enabled .gem-c-feedback__prompt-questions {
267
- @include govuk-media-query($from: tablet) {
268
- display: table-cell;
269
- }
270
- }
271
-
272
- // show the default feedback form without js
273
- .js-enabled .gem-c-feedback__form.js-hidden {
274
- display: none;
275
- }
@@ -5,6 +5,11 @@ body: |
5
5
 
6
6
  This component uses JavaScript for expanding and collapsing and also for submitting form responses. This code is not compatible with Internet Explorer, so IE11 and down do not use JavaScript to submit the forms, instead falling back to a normal form submission.
7
7
  accessibility_criteria: |
8
+ The form must:
9
+
10
+ * be functional and accessible with JavaScript disabled
11
+ * be usable and accessible with stylesheets disabled
12
+
8
13
  Form elements in the component must:
9
14
 
10
15
  * accept focus
@@ -1,9 +1,10 @@
1
1
  <form action="/contact/govuk/problem_reports"
2
2
  id="something-is-wrong"
3
- class="gem-c-feedback__form js-feedback-form js-hidden"
3
+ class="gem-c-feedback__form js-feedback-form"
4
4
  data-track-category="Onsite Feedback"
5
5
  data-track-action="GOV.UK Send Form"
6
- method="post">
6
+ method="post"
7
+ hidden>
7
8
  <button
8
9
  class="govuk-button govuk-button--secondary gem-c-feedback__close gem-c-feedback__js-show js-close-form"
9
10
  data-track-category="Onsite Feedback"
@@ -15,26 +16,28 @@
15
16
 
16
17
  <div class="govuk-grid-row">
17
18
  <div class="govuk-grid-column-two-thirds">
18
- <div class="gem-c-feedback__error-summary gem-c-feedback__js-show js-hidden js-errors" tabindex="-1"></div>
19
+ <div class="gem-c-feedback__error-summary gem-c-feedback__js-show js-errors" tabindex="-1" hidden></div>
19
20
 
20
21
  <input type="hidden" name="url" value="<%= url_without_pii %>">
21
22
 
22
23
  <h3 class="gem-c-feedback__form-heading"><%= t("components.feedback.help_us_improve_govuk") %></h3>
23
24
  <p id="feedback_explanation" class="gem-c-feedback__form-paragraph"><%= t("components.feedback.dont_include_personal_info") %></p>
24
25
 
25
- <%= render "govuk_publishing_components/components/input", {
26
+ <%= render "govuk_publishing_components/components/textarea", {
26
27
  label: {
27
28
  text: t("components.feedback.what_doing")
28
29
  },
29
30
  name: "what_doing",
31
+ rows: 3,
30
32
  describedby: "feedback_explanation"
31
33
  } %>
32
34
 
33
- <%= render "govuk_publishing_components/components/input", {
35
+ <%= render "govuk_publishing_components/components/textarea", {
34
36
  label: {
35
37
  text: t("components.feedback.what_wrong")
36
38
  },
37
- name: "what_wrong"
39
+ name: "what_wrong",
40
+ rows: 3
38
41
  } %>
39
42
 
40
43
  <%= render "govuk_publishing_components/components/button", {
@@ -1,6 +1,6 @@
1
1
  <form action="/contact/govuk/email-survey-signup"
2
2
  id="page-is-not-useful"
3
- class="gem-c-feedback__form gem-c-feedback__form--email gem-c-feedback__js-show js-feedback-form js-hidden"
3
+ class="gem-c-feedback__form gem-c-feedback__form--email gem-c-feedback__js-show js-feedback-form"
4
4
  data-track-category="yesNoFeedbackForm"
5
5
  data-track-action="Send Form"
6
6
  method="post">
@@ -9,13 +9,14 @@
9
9
  data-track-category="yesNoFeedbackForm"
10
10
  data-track-action="ffFormClose"
11
11
  aria-controls="page-is-not-useful"
12
- aria-expanded="true">
12
+ aria-expanded="true"
13
+ hidden>
13
14
  <%= t("components.feedback.close") %>
14
15
  </button>
15
16
 
16
17
  <div class="govuk-grid-row">
17
18
  <div class="govuk-grid-column-two-thirds" id="survey-wrapper">
18
- <div class="gem-c-feedback__error-summary js-hidden js-errors" tabindex="-1"></div>
19
+ <div class="gem-c-feedback__error-summary js-errors" tabindex="-1" hidden></div>
19
20
 
20
21
  <input name="email_survey_signup[survey_id]" type="hidden" value="footer_satisfaction_survey">
21
22
  <input name="email_survey_signup[survey_source]" type="hidden" value="<%= path_without_pii %>">
@@ -3,10 +3,10 @@
3
3
  %>
4
4
 
5
5
  <div class="gem-c-feedback__prompt gem-c-feedback__js-show js-prompt" tabindex="-1">
6
- <div class="gem-c-feedback__prompt-questions js-prompt-questions">
6
+ <div class="gem-c-feedback__prompt-questions js-prompt-questions" hidden>
7
7
  <h2 class="gem-c-feedback__prompt-question"><%= t("components.feedback.is_this_page_useful") %></h2>
8
8
  <!-- Maybe button exists only to try and capture clicks by bots -->
9
- <button data-track-category="yesNoFeedbackForm" data-track-action="ffMaybeClick" aria-expanded="false" style="display: none" hidden="hidden" aria-hidden="true">
9
+ <button data-track-category="yesNoFeedbackForm" data-track-action="ffMaybeClick" aria-expanded="false" hidden>
10
10
  <%= t("components.feedback.maybe") %>
11
11
  </button>
12
12
 
@@ -23,10 +23,10 @@
23
23
  </li>
24
24
  </ul>
25
25
  </div>
26
- <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-success js-prompt-success js-hidden" role="alert">
26
+ <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-success js-prompt-success" role="alert" hidden>
27
27
  <%= t("components.feedback.thank_you_for_feedback") %>
28
28
  </div>
29
- <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-questions--something-is-wrong js-prompt-questions">
29
+ <div class="gem-c-feedback__prompt-questions gem-c-feedback__prompt-questions--something-is-wrong js-prompt-questions" hidden>
30
30
  <button class="govuk-button gem-c-feedback__prompt-link js-toggle-form js-something-is-wrong" data-track-category="Onsite Feedback" data-track-action="GOV-UK Open Form" aria-controls="something-is-wrong" aria-expanded="false">
31
31
  <%= t("components.feedback.something_wrong") %>
32
32
  </button>