govuk_publishing_components 21.65.1 → 21.66.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00cb9ed2b1890ec679368a5b6565f425ab630a8c7576e36ec05572f7b82def5e
4
- data.tar.gz: c252f946b8c435ff7dcfc4a4f68453cbf653b1e3cc71d1fe85c1060c2e6a0df9
3
+ metadata.gz: 903043f0922348d52d8bd086a8450bc950b4cef41f9698981fbac4ff94e969e0
4
+ data.tar.gz: 68eec1602de4314d9072e1cc36d746f264477d07ca26ca10fa5e4b7053837694
5
5
  SHA512:
6
- metadata.gz: 88c4f14857cdab94770e04b4ca84f9733f10855b43bc6706f87960d6ff552c8de581071c1aa80da8460e34de43ded3534cbed2c76a371f4c50d62edff361f994
7
- data.tar.gz: ffad88268390f0a57eeb6eb31b77c8f88b53d21eb0cff4fa6ed399899ff32ca8519f4c1f7bccc2e2fc5e161ee95d91ff749e7356c9bc9ff25288aef71b66a85f
6
+ metadata.gz: 0e640b5131f343fac9d48ae517be2b5c5edcff7c90bd3599eabda72750c11535f9aafcf22c85e703097a547b487031f385815b6b9db427914432e4bd45aa4b3e
7
+ data.tar.gz: 6de32726b845f9a80c16bd782d9afa20d9e18f3bbe85af6823bed4d9a5b250e481d45504c3f28ab72b23de5263ea54e5a7de2a075e3b7e1efec985c7e34e2370
@@ -8,19 +8,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
8
8
 
9
9
  Modules.Feedback = function () {
10
10
  this.start = function ($element) {
11
+ this.element = $element[0]
12
+ this.somethingIsWrongForm = this.element.querySelector('#something-is-wrong')
13
+ this.surveyForm = this.element.querySelector('#page-is-not-useful')
11
14
  this.$prompt = $element.find('.js-prompt')
12
15
  this.$fields = $element.find('.gem-c-feedback__form-field')
13
16
  this.$forms = $element.find('.js-feedback-form')
14
17
  this.$toggleForms = $element.find('.js-toggle-form')
15
18
  this.$closeForms = $element.find('.js-close-form')
19
+ this.activeForm = false
16
20
  this.$activeForm = false
17
21
  this.$pageIsUsefulButton = $element.find('.js-page-is-useful')
18
22
  this.$pageIsNotUsefulButton = $element.find('.js-page-is-not-useful')
19
23
  this.$somethingIsWrongButton = $element.find('.js-something-is-wrong')
20
24
  this.$promptQuestions = $element.find('.js-prompt-questions')
21
25
  this.$promptSuccessMessage = $element.find('.js-prompt-success')
22
- this.$somethingIsWrongForm = $element.find('#something-is-wrong')
23
- this.$surveyForm = $element.find('#page-is-not-useful')
26
+ this.$somethingIsWrongForm = $(this.somethingIsWrongForm)
27
+ this.$surveyForm = $(this.surveyForm)
24
28
  this.$surveyWrapper = $element.find('#survey-wrapper')
25
29
 
26
30
  var that = this
@@ -103,12 +107,23 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
103
107
  function setHiddenValues () {
104
108
  that.$somethingIsWrongForm.append('<input type="hidden" name="javascript_enabled" value="true"/>')
105
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>'
115
+ ].join('')
106
116
  }
107
117
 
108
118
  function setHiddenValuesNotUsefulForm (gaClientId) {
109
119
  var currentPathName = window.location.pathname.replace(/[^\s=?&]+(?:@|%40)[^\s=?&]+/, '[email]')
110
120
  var finalPathName = encodeURI(currentPathName)
111
-
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>'
126
+ ].join('')
112
127
  if (document.querySelectorAll('[name="email_survey_signup[ga_client_id]"]').length === 0) {
113
128
  that.$surveyForm.append($('<input name="email_survey_signup[ga_client_id]" type="hidden">').val(gaClientId || '0'))
114
129
  }
@@ -124,7 +139,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
124
139
  }
125
140
 
126
141
  function toggleForm (formId) {
127
- that.$activeForm = $element.find('#' + formId)
142
+ that.activeForm = that.element.querySelector('#' + formId)
143
+ that.$activeForm = $(that.activeForm)
128
144
  that.$activeForm.toggleClass(jshiddenClass)
129
145
  that.$prompt.toggleClass(jshiddenClass)
130
146
 
@@ -158,18 +174,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
158
174
  '<p>If the problem persists, we have other ways for you to provide',
159
175
  ' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
160
176
  ].join('')
161
-
162
177
  // if the response is not a 404 or 500, show the error message if it exists
163
178
  // otherwise show the generic message
164
- // this covers the 422 status the feedback application return for empty fields
165
- // for all other, show generic error
166
179
  if (typeof (error.responseJSON) !== 'undefined') {
167
180
  error = typeof (error.responseJSON.message) === 'undefined' ? genericError : error.responseJSON.message
168
181
 
169
182
  if (error === 'email survey sign up failure') {
170
183
  error = genericError
171
184
  }
185
+ } else if (error.status === 422) {
186
+ // 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
172
189
  } else {
190
+ // for all other, show generic error
173
191
  error = genericError
174
192
  }
175
193
  var $errors = that.$activeForm.find('.js-errors')
@@ -10,7 +10,7 @@
10
10
  for (i = 0, _i = els.length; i < _i; i++) {
11
11
  els[i].addEventListener('click', function (e) {
12
12
  e.preventDefault()
13
- var target = document.getElementById(this.getAttribute('href').substr(1))
13
+ var target = this.getAttribute('href') ? document.getElementById(this.getAttribute('href').substr(1)) : document.getElementById(this.getAttribute('data-search-toggle-for'))
14
14
  var targetClass = target.getAttribute('class') || ''
15
15
  var sourceClass = this.getAttribute('class') || ''
16
16
 
@@ -21,8 +21,10 @@
21
21
  }
22
22
  if (sourceClass.indexOf('js-visible') !== -1) {
23
23
  this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''))
24
+ this.innerText = 'Show search'
24
25
  } else {
25
26
  this.setAttribute('class', sourceClass + ' js-visible')
27
+ this.innerText = 'Hide search'
26
28
  }
27
29
  this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true')
28
30
  target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === 'false')
@@ -1,36 +1,41 @@
1
+ //= require govuk/vendor/polyfills/Element/prototype/classList.js
1
2
  /*
2
3
  Toggle the class 'focus' on input boxes on element focus/blur
3
4
  Used by the search component but generic enough for reuse
4
5
  */
6
+ window.GOVUK = window.GOVUK || {}
5
7
  window.GOVUK.Modules = window.GOVUK.Modules || {};
6
8
 
7
9
  (function (Modules) {
8
- 'use strict'
10
+ function GemToggleInputClassOnFocus () { }
9
11
 
10
- Modules.GemToggleInputClassOnFocus = function () {
11
- this.start = function ($el) {
12
- var $toggleTarget = $el.find('.js-class-toggle')
12
+ GemToggleInputClassOnFocus.prototype.start = function ($module) {
13
+ this.$module = $module[0]
14
+ this.toggleTarget = this.$module.querySelector('.js-class-toggle')
15
+ this.$module.addFocusClass = this.addFocusClass.bind(this)
16
+ this.$module.removeFocusClassFromEmptyInput = this.removeFocusClassFromEmptyInput.bind(this)
13
17
 
14
- if (!inputIsEmpty()) {
15
- addFocusClass()
16
- }
18
+ if (!this.inputIsEmpty()) {
19
+ this.addFocusClass()
20
+ }
17
21
 
18
- $toggleTarget.on('focus', addFocusClass)
19
- $toggleTarget.on('blur', removeFocusClassFromEmptyInput)
22
+ this.toggleTarget.addEventListener('focus', this.$module.addFocusClass)
23
+ this.toggleTarget.addEventListener('blur', this.$module.removeFocusClassFromEmptyInput)
24
+ }
20
25
 
21
- function inputIsEmpty () {
22
- return $toggleTarget.val() === ''
23
- }
26
+ GemToggleInputClassOnFocus.prototype.inputIsEmpty = function () {
27
+ return this.toggleTarget.value === ''
28
+ }
24
29
 
25
- function addFocusClass () {
26
- $toggleTarget.addClass('focus')
27
- }
30
+ GemToggleInputClassOnFocus.prototype.addFocusClass = function () {
31
+ this.toggleTarget.classList.add('focus')
32
+ }
28
33
 
29
- function removeFocusClassFromEmptyInput () {
30
- if (inputIsEmpty()) {
31
- $toggleTarget.removeClass('focus')
32
- }
33
- }
34
+ GemToggleInputClassOnFocus.prototype.removeFocusClassFromEmptyInput = function () {
35
+ if (this.inputIsEmpty()) {
36
+ this.toggleTarget.classList.remove('focus')
34
37
  }
35
38
  }
39
+
40
+ Modules.GemToggleInputClassOnFocus = GemToggleInputClassOnFocus
36
41
  })(window.GOVUK.Modules)
@@ -213,11 +213,11 @@ $large-input-size: 50px;
213
213
  }
214
214
 
215
215
  .search-toggle {
216
+ display: none;
216
217
  background-color: govuk-colour("blue");
217
218
  background-image: image-url("govuk_publishing_components/search-button.png");
218
219
  background-position: 0 50%;
219
220
  background-repeat: no-repeat;
220
- display: block;
221
221
  float: right;
222
222
  height: 30px;
223
223
  margin: -46px 0;
@@ -225,6 +225,7 @@ $large-input-size: 50px;
225
225
  padding: 0;
226
226
  text-indent: -5000px;
227
227
  width: 36px;
228
+ border: 0;
228
229
 
229
230
  &:focus {
230
231
  border-width: 0;
@@ -250,4 +251,10 @@ $large-input-size: 50px;
250
251
  @include govuk-media-query($from: tablet) {
251
252
  display: none;
252
253
  }
254
+
255
+ @include govuk-media-query($until: tablet) {
256
+ .js-enabled & {
257
+ display: block;
258
+ }
259
+ }
253
260
  }
@@ -4,6 +4,7 @@
4
4
  description_govspeak ||= false
5
5
  description ||= yield || false
6
6
  aria_live ||= false
7
+ lang = local_assigns[:lang].presence
7
8
  local_assigns[:margin_bottom] ||= 8
8
9
  local_assigns[:margin_bottom] = 8 if local_assigns[:margin_bottom] > 9
9
10
 
@@ -17,7 +18,7 @@
17
18
  description_present = description.present? || description_text.present? || description_govspeak.present?
18
19
  %>
19
20
  <% if title || description_present %>
20
- <%= tag.section class: css_classes, aria: aria_attributes, role: "region" do %>
21
+ <%= tag.section class: css_classes, aria: aria_attributes, lang: lang, role: "region" do %>
21
22
  <% if title %>
22
23
  <% if description_present %>
23
24
  <%= tag.h2 title, class: "gem-c-notice__title" %>
@@ -42,3 +42,11 @@ examples:
42
42
  title: 'Your settings have been saved'
43
43
  description_govspeak: <p>This is a confirmation message to tell you your settings have been saved</p>
44
44
  aria_live: true
45
+ with_locale:
46
+ description: |
47
+ Passing a lang value allows the content of the notice to be labelled as being a different language from surrounding content.
48
+ The lang attribute must be set to a [valid BCP47 string](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang#Language_tag_syntax). A valid code can be the two or three letter language code - for example, English is en or eng, Korean is ko or kor - but if in doubt please check.
49
+ data:
50
+ title: 'This publication was withdrawn on 30 September 2015'
51
+ description_govspeak: <p>This document is no longer current. We published a new version on 30 September 2015.</p>
52
+ lang: 'en'
@@ -26,7 +26,6 @@
26
26
  'track-category' => 'yesNoFeedbackForm',
27
27
  'track-action' => 'ffYesClick'
28
28
  },
29
- 'aria-expanded': false,
30
29
  role: 'button',
31
30
  } do %>
32
31
  <%= t("components.feedback.yes", default: "Yes") %> <span class="govuk-visually-hidden"><%= t("components.feedback.is_useful", default: "this page is useful") %></span>
@@ -1,4 +1,4 @@
1
- <a href="#search" class="search-toggle js-header-toggle">Search</a>
1
+ <button class="search-toggle js-header-toggle" data-search-toggle-for="search">Show search</button>
2
2
  <form id="search" class="gem-c-layout-header__search-form govuk-clearfix" action="/search" method="get" role="search">
3
3
  <%= render "govuk_publishing_components/components/search", {
4
4
  id: "site-search-text",
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.65.1".freeze
2
+ VERSION = "21.66.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 21.65.1
4
+ version: 21.66.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2020-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config