govuk_publishing_components 24.10.2 → 24.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +1 -1
  3. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +142 -104
  4. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +1 -1
  5. data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +2 -2
  6. data/app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js +1 -1
  7. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +3 -0
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +0 -11
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +50 -31
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +0 -35
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_contents-list.scss +0 -13
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +0 -6
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +0 -4
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +10 -3
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +11 -1
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_print-link.scss +1 -1
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +0 -1
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_show-password.scss +1 -0
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +8 -2
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +6 -2
  21. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -0
  22. data/app/assets/stylesheets/govuk_publishing_components/components/print/_attachment.scss +2 -3
  23. data/app/assets/stylesheets/govuk_publishing_components/components/print/_back-link.scss +2 -3
  24. data/app/assets/stylesheets/govuk_publishing_components/components/print/_button.scss +0 -4
  25. data/app/assets/stylesheets/govuk_publishing_components/components/print/_feedback.scss +2 -3
  26. data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-footer.scss +2 -6
  27. data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-header.scss +2 -3
  28. data/app/assets/stylesheets/govuk_publishing_components/components/print/_metadata.scss +2 -6
  29. data/app/assets/stylesheets/govuk_publishing_components/components/print/_search.scss +2 -3
  30. data/app/assets/stylesheets/govuk_publishing_components/components/print/_share-links.scss +2 -3
  31. data/app/assets/stylesheets/govuk_publishing_components/components/print/_skip-link.scss +2 -3
  32. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +0 -4
  33. data/app/assets/stylesheets/govuk_publishing_components/components/print/_subscription-links.scss +2 -3
  34. data/app/assets/stylesheets/govuk_publishing_components/components/print/_translation-nav.scss +2 -3
  35. data/app/views/govuk_publishing_components/components/_action_link.html.erb +2 -1
  36. data/app/views/govuk_publishing_components/components/_attachment.html.erb +4 -4
  37. data/app/views/govuk_publishing_components/components/_attachment_link.html.erb +1 -1
  38. data/app/views/govuk_publishing_components/components/_back_link.html.erb +1 -1
  39. data/app/views/govuk_publishing_components/components/_button.html.erb +1 -1
  40. data/app/views/govuk_publishing_components/components/_character_count.html.erb +1 -1
  41. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +10 -3
  42. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +1 -1
  43. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +16 -6
  44. data/app/views/govuk_publishing_components/components/_feedback.html.erb +1 -1
  45. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +14 -14
  46. data/app/views/govuk_publishing_components/components/_image_card.html.erb +15 -2
  47. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +8 -11
  48. data/app/views/govuk_publishing_components/components/_machine_readable_metadata.html.erb +1 -1
  49. data/app/views/govuk_publishing_components/components/_metadata.html.erb +7 -7
  50. data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +1 -1
  51. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +13 -13
  52. data/app/views/govuk_publishing_components/components/_phase_banner.html.erb +1 -5
  53. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +11 -7
  54. data/app/views/govuk_publishing_components/components/_print_link.html.erb +1 -1
  55. data/app/views/govuk_publishing_components/components/_search.html.erb +1 -1
  56. data/app/views/govuk_publishing_components/components/_share_links.html.erb +2 -2
  57. data/app/views/govuk_publishing_components/components/_skip_link.html.erb +1 -1
  58. data/app/views/govuk_publishing_components/components/_step_by_step_nav.html.erb +6 -6
  59. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  60. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +10 -10
  61. data/app/views/govuk_publishing_components/components/_success_alert.html.erb +1 -1
  62. data/app/views/govuk_publishing_components/components/_tabs.html.erb +1 -1
  63. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  64. data/app/views/govuk_publishing_components/components/docs/feedback.yml +2 -0
  65. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +2 -0
  66. data/app/views/govuk_publishing_components/components/docs/inset_text.yml +2 -2
  67. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +18 -15
  68. data/app/views/govuk_publishing_components/components/docs/phase_banner.yml +2 -2
  69. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +6 -6
  70. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +5 -5
  71. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +6 -6
  72. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +1 -1
  73. data/app/views/govuk_publishing_components/components/metadata/_sentence.html.erb +4 -4
  74. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +1 -1
  75. data/config/locales/ar.yml +153 -0
  76. data/config/locales/az.yml +153 -0
  77. data/config/locales/be.yml +153 -0
  78. data/config/locales/bg.yml +153 -0
  79. data/config/locales/bn.yml +153 -0
  80. data/config/locales/cs.yml +153 -0
  81. data/config/locales/cy.yml +145 -6
  82. data/config/locales/da.yml +153 -0
  83. data/config/locales/de.yml +153 -0
  84. data/config/locales/dr.yml +153 -0
  85. data/config/locales/el.yml +153 -0
  86. data/config/locales/en.yml +142 -109
  87. data/config/locales/es-419.yml +153 -0
  88. data/config/locales/es.yml +153 -0
  89. data/config/locales/et.yml +150 -0
  90. data/config/locales/fa.yml +153 -0
  91. data/config/locales/fi.yml +153 -0
  92. data/config/locales/fr.yml +150 -0
  93. data/config/locales/gd.yml +153 -0
  94. data/config/locales/gu.yml +153 -0
  95. data/config/locales/he.yml +153 -0
  96. data/config/locales/hi.yml +153 -0
  97. data/config/locales/hr.yml +153 -0
  98. data/config/locales/hu.yml +153 -0
  99. data/config/locales/hy.yml +153 -0
  100. data/config/locales/id.yml +153 -0
  101. data/config/locales/is.yml +153 -0
  102. data/config/locales/it.yml +153 -0
  103. data/config/locales/ja.yml +153 -0
  104. data/config/locales/ka.yml +153 -0
  105. data/config/locales/kk.yml +153 -0
  106. data/config/locales/ko.yml +153 -0
  107. data/config/locales/lt.yml +153 -0
  108. data/config/locales/lv.yml +153 -0
  109. data/config/locales/ms.yml +153 -0
  110. data/config/locales/mt.yml +153 -0
  111. data/config/locales/nl.yml +153 -0
  112. data/config/locales/no.yml +154 -1
  113. data/config/locales/pa-pk.yml +153 -0
  114. data/config/locales/pa.yml +153 -0
  115. data/config/locales/pl.yml +153 -0
  116. data/config/locales/ps.yml +153 -0
  117. data/config/locales/pt.yml +153 -0
  118. data/config/locales/ro.yml +153 -0
  119. data/config/locales/ru.yml +153 -0
  120. data/config/locales/si.yml +153 -0
  121. data/config/locales/sk.yml +153 -0
  122. data/config/locales/sl.yml +153 -0
  123. data/config/locales/so.yml +153 -0
  124. data/config/locales/sq.yml +153 -0
  125. data/config/locales/sr.yml +153 -0
  126. data/config/locales/sv.yml +153 -0
  127. data/config/locales/sw.yml +153 -0
  128. data/config/locales/ta.yml +153 -0
  129. data/config/locales/th.yml +153 -0
  130. data/config/locales/tk.yml +153 -0
  131. data/config/locales/tr.yml +153 -0
  132. data/config/locales/uk.yml +153 -0
  133. data/config/locales/ur.yml +153 -0
  134. data/config/locales/uz.yml +153 -0
  135. data/config/locales/vi.yml +153 -0
  136. data/config/locales/zh-hk.yml +153 -0
  137. data/config/locales/zh-tw.yml +153 -0
  138. data/config/locales/zh.yml +153 -0
  139. data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +1 -2
  140. data/lib/govuk_publishing_components/presenters/content_item.rb +5 -3
  141. data/lib/govuk_publishing_components/presenters/contents_list_helper.rb +0 -3
  142. data/lib/govuk_publishing_components/presenters/machine_readable/page.rb +4 -0
  143. data/lib/govuk_publishing_components/version.rb +1 -1
  144. data/node_modules/govuk-frontend/govuk/components/accordion/_index.scss +7 -16
  145. data/node_modules/govuk-frontend/govuk/components/back-link/_index.scss +4 -15
  146. data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +1 -1
  147. data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +3 -3
  148. data/node_modules/govuk-frontend/govuk/components/cookie-banner/README.md +15 -0
  149. data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +40 -22
  150. data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +6 -6
  151. data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +15 -5
  152. data/node_modules/govuk-frontend/govuk/components/date-input/macro-options.json +2 -2
  153. data/node_modules/govuk-frontend/govuk/components/details/_index.scss +5 -1
  154. data/node_modules/govuk-frontend/govuk/components/file-upload/_index.scss +13 -14
  155. data/node_modules/govuk-frontend/govuk/components/file-upload/macro-options.json +1 -1
  156. data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +14 -19
  157. data/node_modules/govuk-frontend/govuk/components/header/_index.scss +39 -21
  158. data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +1 -1
  159. data/node_modules/govuk-frontend/govuk/components/phase-banner/_index.scss +1 -1
  160. data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +3 -3
  161. data/node_modules/govuk-frontend/govuk/components/select/macro-options.json +1 -1
  162. data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -1
  163. data/node_modules/govuk-frontend/govuk/components/tabs/_index.scss +1 -6
  164. data/node_modules/govuk-frontend/govuk/components/textarea/macro-options.json +1 -1
  165. data/node_modules/govuk-frontend/govuk/components/warning-text/_index.scss +10 -0
  166. data/node_modules/govuk-frontend/govuk/core/_links.scss +8 -0
  167. data/node_modules/govuk-frontend/govuk/helpers/_links.scss +153 -38
  168. data/node_modules/govuk-frontend/govuk/settings/_all.scss +2 -0
  169. data/node_modules/govuk-frontend/govuk/settings/_links.scss +62 -0
  170. data/node_modules/govuk-frontend/package.json +1 -1
  171. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e7fe72e738809175f7caa96a6003eb8191b09e0f26bbc72963088d6ef20eb7d
4
- data.tar.gz: ca5784e8fc57b3314d60ea63733e03d636671329d5ef697d59ff82a595069200
3
+ metadata.gz: 1a7412745cae4dbe87f20efe5c2b982af372122cae8564c4f7279f17ea16f82a
4
+ data.tar.gz: 8f52c319afd75c6744c17b39719624bdda2888908d481291fc7fe34e51fb604d
5
5
  SHA512:
6
- metadata.gz: f376231a1805b60263dd404cfe9f39fa5c552ae227a3c2059a9353da6afdfa14a6a3831b68e5c4346b3ca2624a861deb89695d5b738cdb7c59c66ee02b641c52
7
- data.tar.gz: 26e0e71bad0c3b6d98e0d091b7925999fc8b0600e01c30900f1271ecb047619b0a4361ffa0f767f5f1f18539bf189f0fa3c8f7ad36f8107b0846808a8d3b9448
6
+ metadata.gz: ee916cc182125dc67fab048c61b9647434141a8a28832015d1d2f2159cf329506375fe136e8f46b8989a00f8c7f7ae7c7fabeec0e6195eae9b6eb0c9114ea644
7
+ data.tar.gz: a0bdb49b4a265e2054a05121d0d1f6c0cf0c79d5aaa3c0d0d390e90712b9935cd484cbe3cb0cc62ab2b5c2ac43ce9784b24ea4475791e32ed6b9aa2d322b6e34
@@ -47,7 +47,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
47
47
  this.initSectionHeaders()
48
48
 
49
49
  // Feature flag for anchor tag navigation used on manuals
50
- if (this.$module.getAttribute('data-anchor-navigation')) {
50
+ if (this.$module.getAttribute('data-anchor-navigation') === 'true') {
51
51
  this.openByAnchorOnLoad()
52
52
  this.addEventListenersForAnchors()
53
53
  }
@@ -1,5 +1,4 @@
1
- /* eslint-env jquery */
2
-
1
+ /* global XMLHttpRequest, FormData */
3
2
  window.GOVUK = window.GOVUK || {}
4
3
  window.GOVUK.Modules = window.GOVUK.Modules || {};
5
4
 
@@ -11,53 +10,56 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
11
10
  this.element = $element[0]
12
11
  this.somethingIsWrongForm = this.element.querySelector('#something-is-wrong')
13
12
  this.surveyForm = this.element.querySelector('#page-is-not-useful')
14
- this.$prompt = $element.find('.js-prompt')
15
- this.$fields = $element.find('.gem-c-feedback__form-field')
16
- this.$forms = $element.find('.js-feedback-form')
17
- this.$toggleForms = $element.find('.js-toggle-form')
18
- this.$closeForms = $element.find('.js-close-form')
13
+ this.prompt = this.element.querySelector('.js-prompt')
14
+ this.forms = this.element.querySelectorAll('.js-feedback-form')
15
+ this.toggleForms = this.element.querySelectorAll('.js-toggle-form')
16
+ this.closeForms = this.element.querySelectorAll('.js-close-form')
19
17
  this.activeForm = false
20
- this.$activeForm = false
21
- this.$pageIsUsefulButton = $element.find('.js-page-is-useful')
22
- this.$pageIsNotUsefulButton = $element.find('.js-page-is-not-useful')
23
- this.$somethingIsWrongButton = $element.find('.js-something-is-wrong')
24
- this.$promptQuestions = $element.find('.js-prompt-questions')
25
- this.$promptSuccessMessage = $element.find('.js-prompt-success')
26
- this.$somethingIsWrongForm = $(this.somethingIsWrongForm)
27
- this.$surveyForm = $(this.surveyForm)
28
- this.$surveyWrapper = $element.find('#survey-wrapper')
29
-
30
- var that = this
18
+ this.pageIsUsefulButton = this.element.querySelector('.js-page-is-useful')
19
+ this.pageIsNotUsefulButton = this.element.querySelector('.js-page-is-not-useful')
20
+ this.somethingIsWrongButton = this.element.querySelector('.js-something-is-wrong')
21
+ this.promptQuestions = this.element.querySelectorAll('.js-prompt-questions')
22
+ this.promptSuccessMessage = this.element.querySelector('.js-prompt-success')
23
+ this.surveyWrapper = this.element.querySelector('#survey-wrapper')
24
+
25
+ var thisModule = this
31
26
  var jshiddenClass = 'js-hidden'
32
27
 
33
28
  setInitialAriaAttributes()
34
29
  setHiddenValues()
35
30
 
36
- this.$toggleForms.on('click', function (e) {
37
- e.preventDefault()
38
- toggleForm($(e.target).attr('aria-controls'))
39
- trackEvent(getTrackEventParams($(this)))
40
- updateAriaAttributes($(this))
41
- })
31
+ for (var j = 0; j < this.toggleForms.length; j++) {
32
+ this.toggleForms[j].addEventListener('click', function (e) {
33
+ e.preventDefault()
34
+ var el = e.target
35
+ toggleForm(el.getAttribute('aria-controls'))
36
+ trackEvent(getTrackEventParams(el))
37
+ updateAriaAttributes(el)
38
+ })
39
+ }
42
40
 
43
- this.$closeForms.on('click', function (e) {
44
- e.preventDefault()
45
- toggleForm($(e.target).attr('aria-controls'))
46
- trackEvent(getTrackEventParams($(this)))
47
- setInitialAriaAttributes()
48
- revealInitialPrompt()
49
- var refocusClass = '.js-' + $(e.target).attr('aria-controls')
50
- $element.find(refocusClass).focus()
51
- })
41
+ for (var i = 0; i < this.closeForms.length; i++) {
42
+ this.closeForms[i].addEventListener('click', function (e) {
43
+ e.preventDefault()
44
+ var el = e.target
45
+ var formToToggle = el.getAttribute('aria-controls')
46
+ toggleForm(formToToggle)
47
+ trackEvent(getTrackEventParams(el))
48
+ setInitialAriaAttributes()
49
+ revealInitialPrompt()
50
+ var refocusClass = '.js-' + formToToggle
51
+ thisModule.element.querySelector(refocusClass).focus()
52
+ })
53
+ }
52
54
 
53
- this.$pageIsUsefulButton.on('click', function (e) {
55
+ this.pageIsUsefulButton.addEventListener('click', function (e) {
54
56
  e.preventDefault()
55
- trackEvent(getTrackEventParams(that.$pageIsUsefulButton))
57
+ trackEvent(getTrackEventParams(thisModule.pageIsUsefulButton))
56
58
  showFormSuccess()
57
59
  revealInitialPrompt()
58
60
  })
59
61
 
60
- this.$pageIsNotUsefulButton.on('click', function (e) {
62
+ this.pageIsNotUsefulButton.addEventListener('click', function (e) {
61
63
  var gaClientId
62
64
  var dummyGaClientId = '111111111.1111111111'
63
65
  if (window.GOVUK.cookie('_ga') === null || window.GOVUK.cookie('_ga') === '') {
@@ -68,95 +70,129 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
68
70
  setHiddenValuesNotUsefulForm(gaClientId)
69
71
  })
70
72
 
71
- $element.find('form').on('submit', function (e) {
72
- e.preventDefault()
73
- var $form = $(this)
74
- $.ajax({
75
- type: 'POST',
76
- url: $form.attr('action'),
77
- dataType: 'json',
78
- data: $form.serialize(),
79
- beforeSend: disableSubmitFormButton($form),
80
- timeout: 6000
81
- }).done(function (xhr) {
82
- trackEvent(getTrackEventParams($form))
83
- showFormSuccess(xhr.message)
84
- revealInitialPrompt()
85
- setInitialAriaAttributes()
86
- that.$activeForm.toggleClass(jshiddenClass)
87
- }).fail(function (xhr) {
88
- showError(xhr)
89
- enableSubmitFormButton($form)
90
- })
91
- })
73
+ // much of the JS needed to support sending the form contents via this script is
74
+ // unsupported by IE, even IE11. This check causes IE to not intercept form submits
75
+ // and let them happen normally, which is handled already by the backend
76
+ if (typeof window.URLSearchParams === 'function') {
77
+ for (var f = 0; f < this.forms.length; f++) {
78
+ this.forms[f].addEventListener('submit', function (e) {
79
+ e.preventDefault()
80
+ var $form = e.target
81
+ var xhr = new XMLHttpRequest()
82
+ var url = $form.getAttribute('action')
83
+ var params = new FormData($form)
84
+ params = new URLSearchParams(params).toString()
85
+
86
+ xhr.open('POST', url, true)
87
+ xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
88
+
89
+ xhr.onreadystatechange = function () {
90
+ if (xhr.readyState === 4 && xhr.status === 200) {
91
+ trackEvent(getTrackEventParams($form))
92
+ showFormSuccess(xhr.message)
93
+ revealInitialPrompt()
94
+ setInitialAriaAttributes()
95
+ thisModule.activeForm.classList.toggle(jshiddenClass)
96
+ } else {
97
+ showError(xhr)
98
+ enableSubmitFormButton($form)
99
+ }
100
+ }
101
+
102
+ disableSubmitFormButton($form)
103
+ xhr.send(params)
104
+ })
105
+ }
106
+ }
92
107
 
93
108
  function disableSubmitFormButton ($form) {
94
- $form.find('input[type="submit"]').prop('disabled', true)
109
+ var formButton = $form.querySelector('[type="submit"]')
110
+ formButton.setAttribute('disabled', true)
95
111
  }
96
112
 
97
113
  function enableSubmitFormButton ($form) {
98
- $form.find('input[type="submit"]').removeAttr('disabled')
114
+ var formButton = $form.querySelector('[type="submit"]')
115
+ formButton.removeAttribute('disabled')
99
116
  }
100
117
 
101
118
  function setInitialAriaAttributes () {
102
- that.$forms.attr('aria-hidden', true)
103
- that.$pageIsNotUsefulButton.attr('aria-expanded', false)
104
- that.$somethingIsWrongButton.attr('aria-expanded', false)
119
+ for (var i = 0; i < thisModule.forms.length; i++) {
120
+ thisModule.forms[i].setAttribute('aria-hidden', true)
121
+ }
122
+ thisModule.pageIsNotUsefulButton.setAttribute('aria-expanded', false)
123
+ thisModule.somethingIsWrongButton.setAttribute('aria-expanded', false)
105
124
  }
106
125
 
107
126
  function setHiddenValues () {
108
- that.$somethingIsWrongForm.append('<input type="hidden" name="javascript_enabled" value="true"/>')
109
- that.$somethingIsWrongForm.append($('<input type="hidden" name="referrer">').val(document.referrer || 'unknown'))
110
- that.somethingIsWrongForm.invalidInfoError = [
111
- '<h2>',
112
- ' Sorry, we’re unable to send your message as you haven’t given us any information.',
113
- '</h2>',
114
- '<p>Please tell us what you were doing or what went wrong</p>'
127
+ var javascriptEnabled = document.createElement('input')
128
+ javascriptEnabled.setAttribute('type', 'hidden')
129
+ javascriptEnabled.setAttribute('name', 'javascript_enabled')
130
+ javascriptEnabled.setAttribute('value', true)
131
+ thisModule.somethingIsWrongForm.appendChild(javascriptEnabled)
132
+
133
+ var referrer = document.createElement('input')
134
+ referrer.setAttribute('type', 'hidden')
135
+ referrer.setAttribute('name', 'referrer')
136
+ referrer.setAttribute('value', document.referrer || 'unknown')
137
+ thisModule.somethingIsWrongForm.appendChild(referrer)
138
+ thisModule.somethingIsWrongForm.invalidInfoError = [
139
+ '<h2>Sorry, we’re unable to send your message as you haven’t given us any information.</h2>',
140
+ ' <p>Please tell us what you were doing or what went wrong</p>'
115
141
  ].join('')
116
142
  }
117
143
 
118
144
  function setHiddenValuesNotUsefulForm (gaClientId) {
119
145
  var currentPathName = window.location.pathname.replace(/[^\s=?&]+(?:@|%40)[^\s=?&]+/, '[email]')
120
146
  var finalPathName = encodeURI(currentPathName)
121
- that.surveyForm.invalidInfoError = [
122
- '<h2>',
123
- ' Sorry, we’re unable to send your message as you haven’t given us a valid email address. ',
124
- '</h2>',
125
- '<p>Enter an email address in the correct format, like name@example.com</p>'
147
+ thisModule.surveyForm.invalidInfoError = [
148
+ '<h2>Sorry, we’re unable to send your message as you haven’t given us a valid email address.</h2>',
149
+ ' <p>Enter an email address in the correct format, like name@example.com</p>'
126
150
  ].join('')
127
151
  if (document.querySelectorAll('[name="email_survey_signup[ga_client_id]"]').length === 0) {
128
- that.$surveyForm.append($('<input name="email_survey_signup[ga_client_id]" type="hidden">').val(gaClientId || '0'))
152
+ var hiddenInput = document.createElement('input')
153
+ hiddenInput.setAttribute('type', 'hidden')
154
+ hiddenInput.setAttribute('name', 'email_survey_signup[ga_client_id]')
155
+ hiddenInput.setAttribute('value', gaClientId || '0')
156
+ thisModule.surveyForm.appendChild(hiddenInput)
129
157
  }
130
158
 
131
159
  if (document.querySelectorAll('.gem-c-feedback__email-link#take-survey').length === 0) {
132
- that.$surveyWrapper.append('<a href="https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=' + finalPathName + '&amp;gcl=' + gaClientId + '" class="gem-c-feedback__email-link govuk-link" id="take-survey" target="_blank" rel="noopener noreferrer">Don’t have an email address?</a>')
160
+ var takeSurvey = document.createElement('a')
161
+ takeSurvey.setAttribute('href', 'https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=' + finalPathName + '&amp;gcl=' + gaClientId)
162
+ takeSurvey.setAttribute('class', 'gem-c-feedback__email-link govuk-link')
163
+ takeSurvey.setAttribute('id', 'take-survey')
164
+ takeSurvey.setAttribute('target', '_blank')
165
+ takeSurvey.setAttribute('rel', 'noopener noreferrer')
166
+ takeSurvey.innerHTML = 'Don’t have an email address?'
167
+ thisModule.surveyWrapper.appendChild(takeSurvey)
133
168
  }
134
169
  }
135
170
 
136
171
  function updateAriaAttributes (linkClicked) {
137
- linkClicked.attr('aria-expanded', true)
138
- $('#' + linkClicked.attr('aria-controls')).attr('aria-hidden', false)
172
+ linkClicked.setAttribute('aria-expanded', true)
173
+ var controls = linkClicked.getAttribute('aria-controls')
174
+ var ariaControls = document.querySelector('#' + controls)
175
+ ariaControls.setAttribute('aria-hidden', false)
139
176
  }
140
177
 
141
178
  function toggleForm (formId) {
142
- that.activeForm = that.element.querySelector('#' + formId)
143
- that.$activeForm = $(that.activeForm)
144
- that.$activeForm.toggleClass(jshiddenClass)
145
- that.$prompt.toggleClass(jshiddenClass)
179
+ thisModule.activeForm = thisModule.element.querySelector('#' + formId)
180
+ thisModule.activeForm.classList.toggle(jshiddenClass)
181
+ thisModule.prompt.classList.toggle(jshiddenClass)
146
182
 
147
- var formIsVisible = !that.$activeForm.hasClass(jshiddenClass)
183
+ var formIsVisible = !thisModule.activeForm.classList.contains(jshiddenClass)
148
184
 
149
185
  if (formIsVisible) {
150
- that.$activeForm.find('.gem-c-input').first().focus()
186
+ thisModule.activeForm.querySelector('.gem-c-input').focus()
151
187
  } else {
152
- that.$activeForm = false
188
+ thisModule.activeForm = false
153
189
  }
154
190
  }
155
191
 
156
192
  function getTrackEventParams ($node) {
157
193
  return {
158
- category: $node.data('track-category'),
159
- action: $node.data('track-action')
194
+ category: $node.getAttribute('data-track-category'),
195
+ action: $node.getAttribute('data-track-action')
160
196
  }
161
197
  }
162
198
 
@@ -168,40 +204,42 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
168
204
 
169
205
  function showError (error) {
170
206
  var genericError = [
171
- '<h2>',
172
- ' Sorry, we’re unable to receive your message right now. ',
173
- '</h2>',
174
- '<p>If the problem persists, we have other ways for you to provide',
207
+ '<h2>Sorry, we’re unable to receive your message right now.</h2>',
208
+ ' <p>If the problem persists, we have other ways for you to provide',
175
209
  ' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
176
210
  ].join('')
177
211
  // if the response is not a 404 or 500, show the error message if it exists
178
212
  // otherwise show the generic message
179
- if (typeof (error.responseJSON) !== 'undefined') {
180
- error = typeof (error.responseJSON.message) === 'undefined' ? genericError : error.responseJSON.message
181
-
182
- if (error === 'email survey sign up failure') {
213
+ if ('response' in error) {
214
+ if (typeof error.response === 'object' && error.response !== null) {
215
+ error = error.response.message === 'email survey sign up failure' ? genericError : error.response.message
216
+ } else {
183
217
  error = genericError
184
218
  }
185
219
  } else if (error.status === 422) {
186
220
  // there's clobbering by nginx on all 422 requests, which is why the response returns a rendered html page instead of the expected JSON
187
- // this is a temporary workaround to ensure that are are displaying relevant error messages to the users
188
- error = that.activeForm.invalidInfoError || genericError
221
+ // this is a temporary workaround to ensure that we are displaying relevant error messages to the users
222
+ error = thisModule.activeForm.invalidInfoError || genericError
189
223
  } else {
190
- // for all other, show generic error
191
224
  error = genericError
192
225
  }
193
- var $errors = that.$activeForm.find('.js-errors')
194
- $errors.html(error).removeClass(jshiddenClass).focus()
226
+ var $errors = thisModule.activeForm.querySelector('.js-errors')
227
+ $errors.innerHTML = error
228
+ $errors.classList.remove(jshiddenClass)
229
+ $errors.focus()
195
230
  }
196
231
 
197
232
  function showFormSuccess () {
198
- that.$promptQuestions.addClass(jshiddenClass)
199
- that.$promptSuccessMessage.removeClass(jshiddenClass).focus()
233
+ for (var i = 0; i < thisModule.promptQuestions.length; i++) {
234
+ thisModule.promptQuestions[i].classList.add(jshiddenClass)
235
+ }
236
+ thisModule.promptSuccessMessage.classList.remove(jshiddenClass)
237
+ thisModule.promptSuccessMessage.focus()
200
238
  }
201
239
 
202
240
  function revealInitialPrompt () {
203
- that.$prompt.removeClass(jshiddenClass)
204
- that.$prompt.focus()
241
+ thisModule.prompt.classList.remove(jshiddenClass)
242
+ thisModule.prompt.focus()
205
243
  }
206
244
  }
207
245
  }
@@ -98,7 +98,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
98
98
  event = new window.CustomEvent(eventName, params)
99
99
  } else {
100
100
  event = document.createEvent('CustomEvent')
101
- event.initCustomEvent(eventName, params.bubbles, params.cancelable)
101
+ event.initCustomEvent(eventName, params.bubbles, params.cancelable, null)
102
102
  }
103
103
 
104
104
  element.dispatchEvent(event)
@@ -74,7 +74,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
74
74
 
75
75
  Gemstepnav.prototype.addShowHideAllButton = function () {
76
76
  var showall = document.createElement('div')
77
- showall.className = 'gem-c-step-nav__controls'
77
+ showall.className = 'gem-c-step-nav__controls govuk-!-display-none-print'
78
78
  showall.innerHTML = '<button aria-expanded="false" class="gem-c-step-nav__button gem-c-step-nav__button--controls js-step-controls-button">' +
79
79
  '<span class="gem-c-step-nav__button-text gem-c-step-nav__button-text--all js-step-controls-button-text">' + this.$module.actions.showAllText + '</span>' +
80
80
  '<span class="gem-c-step-nav__chevron js-step-controls-button-icon">' + this.$module.downChevronSvg + '</span>' +
@@ -98,7 +98,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
98
98
  var commaSpan = document.createElement('span')
99
99
  var thisSectionSpan = document.createElement('span')
100
100
 
101
- showHideSpan.className = 'gem-c-step-nav__toggle-link js-toggle-link'
101
+ showHideSpan.className = 'gem-c-step-nav__toggle-link js-toggle-link govuk-!-display-none-print'
102
102
  showHideSpanText.className = 'gem-c-step-nav__button-text js-toggle-link-text'
103
103
  showHideSpanIcon.className = 'gem-c-step-nav__chevron js-toggle-link-icon'
104
104
  commaSpan.className = 'govuk-visually-hidden'
@@ -10,7 +10,7 @@
10
10
  event = new window.CustomEvent(eventName, params)
11
11
  } else {
12
12
  event = document.createEvent('CustomEvent')
13
- event.initCustomEvent(eventName, params.bubbles, params.cancelable)
13
+ event.initCustomEvent(eventName, params.bubbles, params.cancelable, null)
14
14
  }
15
15
 
16
16
  element.dispatchEvent(event)
@@ -1,6 +1,9 @@
1
1
  // This is the file that the application needs to include in order to use
2
2
  // the components.
3
3
 
4
+ // feature flag for accessible link styles
5
+ $govuk-new-link-styles: true;
6
+
4
7
  @import "govuk_publishing_components/govuk_frontend_support";
5
8
  @import "govuk_publishing_components/component_support";
6
9
 
@@ -4,22 +4,11 @@
4
4
  @import "govuk_frontend_support";
5
5
 
6
6
  @import "components/print/accordion";
7
- @import "components/print/attachment";
8
- @import "components/print/back-link";
9
7
  @import "components/print/button";
10
8
  @import "components/print/contents-list";
11
- @import "components/print/feedback";
12
9
  @import "components/print/govspeak-html-publication";
13
10
  @import "components/print/govspeak";
14
- @import "components/print/layout-header";
15
- @import "components/print/layout-footer";
16
- @import "components/print/metadata";
17
- @import "components/print/search";
18
- @import "components/print/share-links";
19
- @import "components/print/skip-link";
20
11
  @import "components/print/step-by-step-nav-header";
21
12
  @import "components/print/step-by-step-nav";
22
- @import "components/print/subscription-links";
23
13
  @import "components/print/textarea";
24
14
  @import "components/print/title";
25
- @import "components/print/translation-nav";
@@ -40,6 +40,7 @@ $gem-c-accordion-bottom-border-width: 1px;
40
40
  @include govuk-font($size: 16);
41
41
  @include govuk-link-common;
42
42
  @include govuk-link-style-default;
43
+
43
44
  // Remove default button focus outline in Firefox
44
45
  &::-moz-focus-inner {
45
46
  padding: 0;
@@ -47,21 +48,6 @@ $gem-c-accordion-bottom-border-width: 1px;
47
48
  }
48
49
  }
49
50
 
50
- .gem-c-accordion__open-all:hover,
51
- .gem-c-accordion__open-all-text:hover {
52
- text-decoration: underline;
53
- color: $govuk-link-colour;
54
- }
55
-
56
- // Focus state, also to change chervon icon to black
57
- .gem-c-accordion__open-all:focus {
58
- .gem-c-accordion__open-all-text,
59
- .gem-c-accordion-nav__chevron {
60
- color: $govuk-focus-text-colour;
61
- text-decoration: none;
62
- }
63
- }
64
-
65
51
  // Create Chervon icon align with text
66
52
  .gem-c-accordion-nav__chevron {
67
53
  vertical-align: text-top;
@@ -73,6 +59,7 @@ $gem-c-accordion-bottom-border-width: 1px;
73
59
  margin-left: govuk-em(5, 14);
74
60
  border: govuk-em(1, 14) solid;
75
61
  border-radius: govuk-em(100, 14);
62
+
76
63
  // Main icon size across views, yet keep responsive for zoom
77
64
  @include govuk-media-query($from: tablet) {
78
65
  width: govuk-em(20, 16);
@@ -94,6 +81,7 @@ $gem-c-accordion-bottom-border-width: 1px;
94
81
  transform: rotate(-45deg);
95
82
  left: govuk-em(6, 14);
96
83
  bottom: govuk-em(5, 14);
84
+
97
85
  @include govuk-media-query($from: tablet) {
98
86
  width: govuk-em(6, 16);
99
87
  height: govuk-em(6, 16);
@@ -105,6 +93,22 @@ $gem-c-accordion-bottom-border-width: 1px;
105
93
  }
106
94
  }
107
95
 
96
+ .gem-c-accordion__open-all:hover,
97
+ .gem-c-accordion__section-button:hover {
98
+ .gem-c-accordion-nav__chevron {
99
+ color: $govuk-link-hover-colour;
100
+ text-decoration: none;
101
+ }
102
+ }
103
+
104
+ // Focus state, also to change chervon icon to black
105
+ .gem-c-accordion__open-all:focus {
106
+ .gem-c-accordion-nav__chevron {
107
+ color: $govuk-focus-text-colour;
108
+ text-decoration: none;
109
+ }
110
+ }
111
+
108
112
  // Rotate icon to create "Down" version
109
113
  .gem-c-accordion-nav__chevron--down {
110
114
  transform: rotate(180deg);
@@ -150,6 +154,10 @@ $gem-c-accordion-bottom-border-width: 1px;
150
154
  @include govuk-typography-common;
151
155
  width: 100%;
152
156
 
157
+ &:hover {
158
+ color: $govuk-link-hover-colour;
159
+ }
160
+
153
161
  &:active {
154
162
  z-index: 1;
155
163
  color: $govuk-link-active-colour;
@@ -163,26 +171,12 @@ $gem-c-accordion-bottom-border-width: 1px;
163
171
  }
164
172
  }
165
173
 
166
- .gem-c-accordion__section-button:hover {
167
- color: $govuk-link-colour;
168
- // On hover, add underline to toggle link
169
- .gem-c-accordion__toggle-text {
170
- text-decoration: underline;
171
- color: $govuk-link-colour;
172
- }
173
- }
174
-
175
174
  .gem-c-accordion__section-button:focus {
176
175
  @include govuk-focused-text;
177
176
  // Overwrite focus border to top
178
177
  box-shadow: 0 0, 0 -4px;
179
178
  border-top: 1px solid transparent;
180
179
 
181
- // Focus state to change the toggle link within individual sections
182
- .gem-c-accordion__toggle-text {
183
- color: $govuk-focus-text-colour;
184
- text-decoration: none;
185
- }
186
180
  // Focus state to change chervon icon colour within individual sections
187
181
  .gem-c-accordion-nav__chevron {
188
182
  color: $govuk-text-colour;
@@ -225,10 +219,24 @@ $gem-c-accordion-bottom-border-width: 1px;
225
219
  }
226
220
  }
227
221
 
228
- // Setting width of the text, so the icon doesn't shift (left / right) when toggled
229
222
  .gem-c-accordion__toggle-text {
230
- min-width: govuk-em(40, 16);
231
223
  display: inline-block;
224
+ // Setting width of the text so the icon doesn't shift left or right when
225
+ // toggled:
226
+ min-width: govuk-em(40, 16);
227
+ }
228
+
229
+ // On hover add underline to toggle link only:
230
+ .gem-c-accordion__section-button:hover .gem-c-accordion__toggle-text {
231
+ color: $govuk-link-hover-colour;
232
+ @include govuk-link-decoration;
233
+ @include govuk-link-hover-decoration;
234
+ }
235
+
236
+ // Ensure the correct focus sstate text colour and no underline:
237
+ .gem-c-accordion__section-button:focus .gem-c-accordion__toggle-text {
238
+ color: $govuk-focus-text-colour;
239
+ text-decoration: none;
232
240
  }
233
241
 
234
242
  .gem-c-accordion__open-all-text {
@@ -237,6 +245,17 @@ $gem-c-accordion-bottom-border-width: 1px;
237
245
  text-align: left;
238
246
  }
239
247
 
248
+ .gem-c-accordion__open-all:hover {
249
+ .gem-c-accordion__open-all-text {
250
+ @include govuk-link-decoration;
251
+ @include govuk-link-hover-decoration;
252
+ }
253
+ }
254
+
255
+ .gem-c-accordion__open-all:focus .gem-c-accordion__open-all-text {
256
+ text-decoration: none;
257
+ }
258
+
240
259
  // Change the summary subheading size.
241
260
  .gem-c-accordion__section-summary {
242
261
  @include govuk-responsive-margin(1, "top");