govuk_publishing_components 24.13.4 → 24.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +6 -5
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js +6 -7
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +7 -7
- data/app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js +13 -12
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +12 -18
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +213 -215
- data/app/assets/javascripts/govuk_publishing_components/components/govspeak.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/modal-dialogue.js +6 -4
- data/app/assets/javascripts/govuk_publishing_components/components/print-link.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +5 -4
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +4 -4
- data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +1 -1
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +25 -10
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +1 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e717864c0f9538183da995c95a88d67af2e5e4d5666122052c7840884aaf705
|
|
4
|
+
data.tar.gz: 465c33e805ec4d1567f9fc3447e001a553ba4cd542d83a28cf4dc52889824976
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c34d794a8ff619c8ea5e64e94e894fa13a0605787c1c77df151b6954fbe0347e02232b67ca0d9e87a18dd6057bf4814b0e35b32093f44db39256b3de6f9be20c
|
|
7
|
+
data.tar.gz: 5030ea6f258797c43aca3c6b7e0028b748ec38886d28fe6893d6c9dc09866c2387e12c27f7109d46bec2713babc4f04a626e5028b3f8a87b3bc0e817d8d071a7
|
|
@@ -7,15 +7,12 @@ window.GOVUK = window.GOVUK || {}
|
|
|
7
7
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
8
8
|
|
|
9
9
|
(function (Modules) {
|
|
10
|
-
function GemAccordion () {
|
|
11
|
-
|
|
12
|
-
GemAccordion.prototype.start = function ($module) {
|
|
13
|
-
this.$module = $module[0]
|
|
10
|
+
function GemAccordion ($module) {
|
|
11
|
+
this.$module = $module
|
|
14
12
|
this.sectionClass = 'gem-c-accordion__section'
|
|
15
13
|
this.moduleId = this.$module.getAttribute('id')
|
|
16
14
|
this.sections = this.$module.querySelectorAll('.' + this.sectionClass)
|
|
17
15
|
this.openAllButton = ''
|
|
18
|
-
this.browserSupportsSessionStorage = helper.checkForSessionStorage()
|
|
19
16
|
this.controlsClass = 'gem-c-accordion__controls'
|
|
20
17
|
this.openAllClass = 'gem-c-accordion__open-all'
|
|
21
18
|
this.openAllTextClass = 'gem-c-accordion__open-all-text'
|
|
@@ -39,6 +36,10 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
39
36
|
this.$module.actions.showAllText = this.$module.getAttribute('data-show-all-text')
|
|
40
37
|
this.$module.actions.hideAllText = this.$module.getAttribute('data-hide-all-text')
|
|
41
38
|
this.$module.actions.thisSectionVisuallyHidden = this.$module.getAttribute('data-this-section-visually-hidden')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
GemAccordion.prototype.init = function () {
|
|
42
|
+
this.browserSupportsSessionStorage = helper.checkForSessionStorage()
|
|
42
43
|
|
|
43
44
|
// Indicate that JavaScript has worked
|
|
44
45
|
this.$module.classList.add('gem-c-accordion--active')
|
|
@@ -6,14 +6,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
|
6
6
|
window.GOVUK.Modules.Checkboxes = window.GOVUKFrontend;
|
|
7
7
|
|
|
8
8
|
(function (Modules) {
|
|
9
|
-
function GovukCheckboxes () {
|
|
10
|
-
|
|
11
|
-
GovukCheckboxes.prototype.start = function ($module) {
|
|
12
|
-
this.$module = $module[0]
|
|
9
|
+
function GovukCheckboxes ($module) {
|
|
10
|
+
this.$module = $module
|
|
13
11
|
this.$checkboxes = this.$module.querySelectorAll('input[type=checkbox]')
|
|
14
12
|
this.$nestedCheckboxes = this.$module.querySelectorAll('[data-nested=true] input[type=checkbox]')
|
|
15
13
|
this.$exclusiveCheckboxes = this.$module.querySelectorAll('[data-exclusive=true] input[type=checkbox]')
|
|
14
|
+
}
|
|
16
15
|
|
|
16
|
+
GovukCheckboxes.prototype.init = function () {
|
|
17
17
|
this.applyAriaControlsAttributes(this.$module)
|
|
18
18
|
|
|
19
19
|
for (var i = 0; i < this.$checkboxes.length; i++) {
|
|
@@ -2,22 +2,21 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function ContextualGuidance () {
|
|
6
|
-
|
|
7
|
-
ContextualGuidance.prototype.start = function ($module) {
|
|
8
|
-
this.$module = $module[0]
|
|
5
|
+
function ContextualGuidance ($module) {
|
|
6
|
+
this.$module = $module
|
|
9
7
|
this.$guidance = this.$module.querySelector('.gem-c-contextual-guidance__wrapper')
|
|
10
8
|
this.$inputId = this.$guidance.getAttribute('for')
|
|
11
9
|
this.$input = this.$module.querySelector('#' + this.$inputId)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
ContextualGuidance.prototype.init = function () {
|
|
12
13
|
if (!this.$input) return
|
|
13
14
|
this.$input.addEventListener('focus', this.handleFocus.bind(this))
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
ContextualGuidance.prototype.handleFocus = function (event) {
|
|
17
18
|
this.hideAllGuidance()
|
|
18
|
-
|
|
19
|
-
this.$guidance.style.display = 'block'
|
|
20
|
-
}
|
|
19
|
+
this.$guidance.style.display = 'block'
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
ContextualGuidance.prototype.hideAllGuidance = function () {
|
|
@@ -2,18 +2,18 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function CookieBanner () {
|
|
5
|
+
function CookieBanner ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
|
|
8
|
+
this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
|
|
9
|
+
this.$module.cookieBannerConfirmationMessageText = this.$module.querySelector('.gem-c-cookie-banner__confirmation-message')
|
|
10
|
+
}
|
|
6
11
|
|
|
7
|
-
CookieBanner.prototype.
|
|
8
|
-
this.$module = $module[0]
|
|
12
|
+
CookieBanner.prototype.init = function () {
|
|
9
13
|
this.$module.hideCookieMessage = this.hideCookieMessage.bind(this)
|
|
10
14
|
this.$module.showConfirmationMessage = this.showConfirmationMessage.bind(this)
|
|
11
15
|
this.$module.setCookieConsent = this.setCookieConsent.bind(this)
|
|
12
16
|
this.$module.rejectCookieConsent = this.rejectCookieConsent.bind(this)
|
|
13
|
-
|
|
14
|
-
this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
|
|
15
|
-
this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
|
|
16
|
-
this.$module.cookieBannerConfirmationMessageText = this.$module.querySelector('.gem-c-cookie-banner__confirmation-message')
|
|
17
17
|
this.setupCookieMessage()
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -2,23 +2,24 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function CopyToClipboard () {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.$
|
|
5
|
+
function CopyToClipboard ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
this.$input = this.$module.querySelector('.gem-c-input')
|
|
8
|
+
this.$copyButton = this.$module.querySelector('.gem-c-button')
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
CopyToClipboard.prototype.init = function () {
|
|
12
|
+
if (!this.$input || !this.$copyButton) return
|
|
12
13
|
|
|
13
|
-
input.addEventListener('click', function () {
|
|
14
|
-
input.select()
|
|
15
|
-
})
|
|
14
|
+
this.$input.addEventListener('click', function () {
|
|
15
|
+
this.$input.select()
|
|
16
|
+
}.bind(this))
|
|
16
17
|
|
|
17
|
-
copyButton.addEventListener('click', function (event) {
|
|
18
|
+
this.$copyButton.addEventListener('click', function (event) {
|
|
18
19
|
event.preventDefault()
|
|
19
|
-
input.select()
|
|
20
|
+
this.$input.select()
|
|
20
21
|
document.execCommand('copy')
|
|
21
|
-
})
|
|
22
|
+
}.bind(this))
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
Modules.CopyToClipboard = CopyToClipboard
|
|
@@ -5,26 +5,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}
|
|
|
5
5
|
window.GOVUK.Modules.Details = window.GOVUKFrontend;
|
|
6
6
|
|
|
7
7
|
(function (Modules) {
|
|
8
|
-
function GovukDetails () {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this
|
|
12
|
-
|
|
13
|
-
var customTrackLabel = this.$module.getAttribute('data-track-label')
|
|
8
|
+
function GovukDetails ($module) {
|
|
9
|
+
this.$module = $module
|
|
10
|
+
this.customTrackLabel = this.$module.getAttribute('data-track-label')
|
|
11
|
+
this.detailsClick = this.$module.querySelector('[data-details-track-click]')
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
if (customTrackLabel) {
|
|
14
|
+
GovukDetails.prototype.init = function () {
|
|
15
|
+
if (this.customTrackLabel) { // If a custom label has been provided, we can simply call the tracking module
|
|
17
16
|
var trackDetails = new window.GOVUK.Modules.GemTrackClick()
|
|
18
|
-
trackDetails.start($module)
|
|
19
|
-
} else {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (detailsClick) {
|
|
24
|
-
detailsClick.addEventListener('click', function (event) {
|
|
25
|
-
this.trackDefault(this.$module)
|
|
26
|
-
}.bind(this))
|
|
27
|
-
}
|
|
17
|
+
trackDetails.start($(this.$module))
|
|
18
|
+
} else if (this.detailsClick) { // If no custom label is set, we use the open/close status as the label
|
|
19
|
+
this.detailsClick.addEventListener('click', function (event) {
|
|
20
|
+
this.trackDefault(this.$module)
|
|
21
|
+
}.bind(this))
|
|
28
22
|
}
|
|
29
23
|
}
|
|
30
24
|
|
|
@@ -3,244 +3,242 @@ window.GOVUK = window.GOVUK || {}
|
|
|
3
3
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
4
4
|
|
|
5
5
|
(function (Modules) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.surveyWrapper = this.element.querySelector('#survey-wrapper')
|
|
6
|
+
function Feedback ($module) {
|
|
7
|
+
this.$module = $module
|
|
8
|
+
this.somethingIsWrongForm = this.$module.querySelector('#something-is-wrong')
|
|
9
|
+
this.surveyForm = this.$module.querySelector('#page-is-not-useful')
|
|
10
|
+
this.prompt = this.$module.querySelector('.js-prompt')
|
|
11
|
+
this.forms = this.$module.querySelectorAll('.js-feedback-form')
|
|
12
|
+
this.toggleForms = this.$module.querySelectorAll('.js-toggle-form')
|
|
13
|
+
this.closeForms = this.$module.querySelectorAll('.js-close-form')
|
|
14
|
+
this.activeForm = false
|
|
15
|
+
this.pageIsUsefulButton = this.$module.querySelector('.js-page-is-useful')
|
|
16
|
+
this.pageIsNotUsefulButton = this.$module.querySelector('.js-page-is-not-useful')
|
|
17
|
+
this.somethingIsWrongButton = this.$module.querySelector('.js-something-is-wrong')
|
|
18
|
+
this.promptQuestions = this.$module.querySelectorAll('.js-prompt-questions')
|
|
19
|
+
this.promptSuccessMessage = this.$module.querySelector('.js-prompt-success')
|
|
20
|
+
this.surveyWrapper = this.$module.querySelector('#survey-wrapper')
|
|
21
|
+
this.jshiddenClass = 'js-hidden'
|
|
22
|
+
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
Feedback.prototype.init = function () {
|
|
25
|
+
this.setInitialAriaAttributes()
|
|
26
|
+
this.setHiddenValues()
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
for (var j = 0; j < this.toggleForms.length; j++) {
|
|
29
|
+
this.toggleForms[j].addEventListener('click', function (e) {
|
|
30
|
+
e.preventDefault()
|
|
31
|
+
var el = e.target
|
|
32
|
+
this.toggleForm(el.getAttribute('aria-controls'))
|
|
33
|
+
this.trackEvent(this.getTrackEventParams(el))
|
|
34
|
+
this.updateAriaAttributes(el)
|
|
35
|
+
}.bind(this))
|
|
36
|
+
}
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
for (var i = 0; i < this.closeForms.length; i++) {
|
|
39
|
+
this.closeForms[i].addEventListener('click', function (e) {
|
|
40
|
+
e.preventDefault()
|
|
41
|
+
var el = e.target
|
|
42
|
+
var formToToggle = el.getAttribute('aria-controls')
|
|
43
|
+
this.toggleForm(formToToggle)
|
|
44
|
+
this.trackEvent(this.getTrackEventParams(el))
|
|
45
|
+
this.setInitialAriaAttributes()
|
|
46
|
+
this.revealInitialPrompt()
|
|
47
|
+
var refocusClass = '.js-' + formToToggle
|
|
48
|
+
this.$module.querySelector(refocusClass).focus()
|
|
49
|
+
}.bind(this))
|
|
50
|
+
}
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
this.pageIsUsefulButton.addEventListener('click', function (e) {
|
|
53
|
+
e.preventDefault()
|
|
54
|
+
this.trackEvent(this.getTrackEventParams(this.pageIsUsefulButton))
|
|
55
|
+
this.showFormSuccess()
|
|
56
|
+
this.revealInitialPrompt()
|
|
57
|
+
}.bind(this))
|
|
58
|
+
|
|
59
|
+
this.pageIsNotUsefulButton.addEventListener('click', function (e) {
|
|
60
|
+
var gaClientId
|
|
61
|
+
var dummyGaClientId = '111111111.1111111111'
|
|
62
|
+
if (window.GOVUK.cookie('_ga') === null || window.GOVUK.cookie('_ga') === '') {
|
|
63
|
+
gaClientId = dummyGaClientId
|
|
64
|
+
} else {
|
|
65
|
+
gaClientId = window.GOVUK.cookie('_ga').split('.').slice(-2).join('.')
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
}
|
|
67
|
+
this.setHiddenValuesNotUsefulForm(gaClientId)
|
|
68
|
+
}.bind(this))
|
|
69
|
+
|
|
70
|
+
// much of the JS needed to support sending the form contents via this script is
|
|
71
|
+
// unsupported by IE, even IE11. This check causes IE to not intercept form submits
|
|
72
|
+
// and let them happen normally, which is handled already by the backend
|
|
73
|
+
if (typeof window.URLSearchParams === 'function') {
|
|
74
|
+
for (var f = 0; f < this.forms.length; f++) {
|
|
75
|
+
this.forms[f].addEventListener('submit', function (e) {
|
|
76
|
+
e.preventDefault()
|
|
77
|
+
var $form = e.target
|
|
78
|
+
var xhr = new XMLHttpRequest()
|
|
79
|
+
var url = $form.getAttribute('action')
|
|
80
|
+
var params = new FormData($form)
|
|
81
|
+
params = new URLSearchParams(params).toString()
|
|
82
|
+
|
|
83
|
+
xhr.open('POST', url, true)
|
|
84
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded')
|
|
85
|
+
|
|
86
|
+
xhr.onreadystatechange = function () {
|
|
87
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
88
|
+
this.trackEvent(this.getTrackEventParams($form))
|
|
89
|
+
this.showFormSuccess(xhr.message)
|
|
90
|
+
this.revealInitialPrompt()
|
|
91
|
+
this.setInitialAriaAttributes()
|
|
92
|
+
this.activeForm.classList.toggle(this.jshiddenClass)
|
|
93
|
+
} else {
|
|
94
|
+
this.showError(xhr)
|
|
95
|
+
this.enableSubmitFormButton($form)
|
|
100
96
|
}
|
|
97
|
+
}.bind(this)
|
|
101
98
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
99
|
+
this.disableSubmitFormButton($form)
|
|
100
|
+
xhr.send(params)
|
|
101
|
+
}.bind(this))
|
|
106
102
|
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
Feedback.prototype.disableSubmitFormButton = function ($form) {
|
|
107
|
+
var formButton = $form.querySelector('[type="submit"]')
|
|
108
|
+
formButton.setAttribute('disabled', true)
|
|
109
|
+
}
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
Feedback.prototype.enableSubmitFormButton = function ($form) {
|
|
112
|
+
var formButton = $form.querySelector('[type="submit"]')
|
|
113
|
+
formButton.removeAttribute('disabled')
|
|
114
|
+
}
|
|
117
115
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
Feedback.prototype.setInitialAriaAttributes = function () {
|
|
117
|
+
for (var i = 0; i < this.forms.length; i++) {
|
|
118
|
+
this.forms[i].setAttribute('aria-hidden', true)
|
|
119
|
+
}
|
|
120
|
+
this.pageIsNotUsefulButton.setAttribute('aria-expanded', false)
|
|
121
|
+
this.somethingIsWrongButton.setAttribute('aria-expanded', false)
|
|
122
|
+
}
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
124
|
+
Feedback.prototype.setHiddenValues = function () {
|
|
125
|
+
var javascriptEnabled = document.createElement('input')
|
|
126
|
+
javascriptEnabled.setAttribute('type', 'hidden')
|
|
127
|
+
javascriptEnabled.setAttribute('name', 'javascript_enabled')
|
|
128
|
+
javascriptEnabled.setAttribute('value', true)
|
|
129
|
+
this.somethingIsWrongForm.appendChild(javascriptEnabled)
|
|
130
|
+
|
|
131
|
+
var referrer = document.createElement('input')
|
|
132
|
+
referrer.setAttribute('type', 'hidden')
|
|
133
|
+
referrer.setAttribute('name', 'referrer')
|
|
134
|
+
referrer.setAttribute('value', document.referrer || 'unknown')
|
|
135
|
+
this.somethingIsWrongForm.appendChild(referrer)
|
|
136
|
+
this.somethingIsWrongForm.invalidInfoError = [
|
|
137
|
+
'<h2>Sorry, we’re unable to send your message as you haven’t given us any information.</h2>',
|
|
138
|
+
' <p>Please tell us what you were doing or what went wrong</p>'
|
|
139
|
+
].join('')
|
|
140
|
+
}
|
|
143
141
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (document.querySelectorAll('.gem-c-feedback__email-link#take-survey').length === 0) {
|
|
160
|
-
var takeSurvey = document.createElement('a')
|
|
161
|
-
takeSurvey.setAttribute('href', 'https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=' + finalPathName + '&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)
|
|
168
|
-
}
|
|
169
|
-
}
|
|
142
|
+
Feedback.prototype.setHiddenValuesNotUsefulForm = function (gaClientId) {
|
|
143
|
+
var currentPathName = window.location.pathname.replace(/[^\s=?&]+(?:@|%40)[^\s=?&]+/, '[email]')
|
|
144
|
+
var finalPathName = encodeURI(currentPathName)
|
|
145
|
+
this.surveyForm.invalidInfoError = [
|
|
146
|
+
'<h2>Sorry, we’re unable to send your message as you haven’t given us a valid email address.</h2>',
|
|
147
|
+
' <p>Enter an email address in the correct format, like name@example.com</p>'
|
|
148
|
+
].join('')
|
|
149
|
+
if (document.querySelectorAll('[name="email_survey_signup[ga_client_id]"]').length === 0) {
|
|
150
|
+
var hiddenInput = document.createElement('input')
|
|
151
|
+
hiddenInput.setAttribute('type', 'hidden')
|
|
152
|
+
hiddenInput.setAttribute('name', 'email_survey_signup[ga_client_id]')
|
|
153
|
+
hiddenInput.setAttribute('value', gaClientId || '0')
|
|
154
|
+
this.surveyForm.appendChild(hiddenInput)
|
|
155
|
+
}
|
|
170
156
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
157
|
+
if (document.querySelectorAll('.gem-c-feedback__email-link#take-survey').length === 0) {
|
|
158
|
+
var takeSurvey = document.createElement('a')
|
|
159
|
+
takeSurvey.setAttribute('href', 'https://www.smartsurvey.co.uk/s/gov-uk-banner/?c=' + finalPathName + '&gcl=' + gaClientId)
|
|
160
|
+
takeSurvey.setAttribute('class', 'gem-c-feedback__email-link govuk-link')
|
|
161
|
+
takeSurvey.setAttribute('id', 'take-survey')
|
|
162
|
+
takeSurvey.setAttribute('target', '_blank')
|
|
163
|
+
takeSurvey.setAttribute('rel', 'noopener noreferrer')
|
|
164
|
+
takeSurvey.innerHTML = 'Don’t have an email address?'
|
|
165
|
+
this.surveyWrapper.appendChild(takeSurvey)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
177
168
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
169
|
+
Feedback.prototype.updateAriaAttributes = function (linkClicked) {
|
|
170
|
+
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
|
+
}
|
|
182
175
|
|
|
183
|
-
|
|
176
|
+
Feedback.prototype.toggleForm = function (formId) {
|
|
177
|
+
this.activeForm = this.$module.querySelector('#' + formId)
|
|
178
|
+
this.activeForm.classList.toggle(this.jshiddenClass)
|
|
179
|
+
this.prompt.classList.toggle(this.jshiddenClass)
|
|
184
180
|
|
|
185
|
-
|
|
186
|
-
thisModule.activeForm.querySelector('.gem-c-input').focus()
|
|
187
|
-
} else {
|
|
188
|
-
thisModule.activeForm = false
|
|
189
|
-
}
|
|
190
|
-
}
|
|
181
|
+
var formIsVisible = !this.activeForm.classList.contains(this.jshiddenClass)
|
|
191
182
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
183
|
+
if (formIsVisible) {
|
|
184
|
+
this.activeForm.querySelector('.gem-c-input').focus()
|
|
185
|
+
} else {
|
|
186
|
+
this.activeForm = false
|
|
187
|
+
}
|
|
188
|
+
}
|
|
198
189
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
190
|
+
Feedback.prototype.getTrackEventParams = function ($node) {
|
|
191
|
+
return {
|
|
192
|
+
category: $node.getAttribute('data-track-category'),
|
|
193
|
+
action: $node.getAttribute('data-track-action')
|
|
194
|
+
}
|
|
195
|
+
}
|
|
204
196
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
].join('')
|
|
211
|
-
// if the response is not a 404 or 500, show the error message if it exists
|
|
212
|
-
// otherwise show the generic message
|
|
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 {
|
|
217
|
-
error = genericError
|
|
218
|
-
}
|
|
219
|
-
} else if (error.status === 422) {
|
|
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
|
|
221
|
-
// this is a temporary workaround to ensure that we are displaying relevant error messages to the users
|
|
222
|
-
error = thisModule.activeForm.invalidInfoError || genericError
|
|
223
|
-
} else {
|
|
224
|
-
error = genericError
|
|
225
|
-
}
|
|
226
|
-
var $errors = thisModule.activeForm.querySelector('.js-errors')
|
|
227
|
-
$errors.innerHTML = error
|
|
228
|
-
$errors.classList.remove(jshiddenClass)
|
|
229
|
-
$errors.focus()
|
|
230
|
-
}
|
|
197
|
+
Feedback.prototype.trackEvent = function (trackEventParams) {
|
|
198
|
+
if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
|
|
199
|
+
window.GOVUK.analytics.trackEvent(trackEventParams.category, trackEventParams.action)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
231
202
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
203
|
+
Feedback.prototype.showError = function (error) {
|
|
204
|
+
var genericError = [
|
|
205
|
+
'<h2>Sorry, we’re unable to receive your message right now.</h2>',
|
|
206
|
+
' <p>If the problem persists, we have other ways for you to provide',
|
|
207
|
+
' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
|
|
208
|
+
].join('')
|
|
209
|
+
// if the response is not a 404 or 500, show the error message if it exists
|
|
210
|
+
// otherwise show the generic message
|
|
211
|
+
if ('response' in error) {
|
|
212
|
+
if (typeof error.response === 'object' && error.response !== null) {
|
|
213
|
+
error = error.response.message === 'email survey sign up failure' ? genericError : error.response.message
|
|
214
|
+
} else {
|
|
215
|
+
error = genericError
|
|
238
216
|
}
|
|
217
|
+
} else if (error.status === 422) {
|
|
218
|
+
// there's clobbering by nginx on all 422 requests, which is why the response returns a rendered html page instead of the expected JSON
|
|
219
|
+
// this is a temporary workaround to ensure that we are displaying relevant error messages to the users
|
|
220
|
+
error = this.activeForm.invalidInfoError || genericError
|
|
221
|
+
} else {
|
|
222
|
+
error = genericError
|
|
223
|
+
}
|
|
224
|
+
var $errors = this.activeForm.querySelector('.js-errors')
|
|
225
|
+
$errors.innerHTML = error
|
|
226
|
+
$errors.classList.remove(this.jshiddenClass)
|
|
227
|
+
$errors.focus()
|
|
228
|
+
}
|
|
239
229
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
230
|
+
Feedback.prototype.showFormSuccess = function () {
|
|
231
|
+
for (var i = 0; i < this.promptQuestions.length; i++) {
|
|
232
|
+
this.promptQuestions[i].classList.add(this.jshiddenClass)
|
|
244
233
|
}
|
|
234
|
+
this.promptSuccessMessage.classList.remove(this.jshiddenClass)
|
|
235
|
+
this.promptSuccessMessage.focus()
|
|
245
236
|
}
|
|
237
|
+
|
|
238
|
+
Feedback.prototype.revealInitialPrompt = function () {
|
|
239
|
+
this.prompt.classList.remove(this.jshiddenClass)
|
|
240
|
+
this.prompt.focus()
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
Modules.Feedback = Feedback
|
|
246
244
|
})(window.GOVUK.Modules)
|
|
@@ -2,11 +2,11 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function Govspeak () {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.$module = $module[0]
|
|
5
|
+
function Govspeak ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
}
|
|
9
8
|
|
|
9
|
+
Govspeak.prototype.init = function () {
|
|
10
10
|
if (this.$module.className.indexOf('disable-youtube') === -1) {
|
|
11
11
|
this.embedYoutube()
|
|
12
12
|
}
|
|
@@ -2,14 +2,16 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function ModalDialogue () {
|
|
6
|
-
|
|
7
|
-
ModalDialogue.prototype.start = function ($module) {
|
|
8
|
-
this.$module = $module[0]
|
|
5
|
+
function ModalDialogue ($module) {
|
|
6
|
+
this.$module = $module
|
|
9
7
|
this.$dialogBox = this.$module.querySelector('.gem-c-modal-dialogue__box')
|
|
10
8
|
this.$closeButton = this.$module.querySelector('.gem-c-modal-dialogue__close-button')
|
|
11
9
|
this.$html = document.querySelector('html')
|
|
12
10
|
this.$body = document.querySelector('body')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ModalDialogue.prototype.init = function () {
|
|
14
|
+
if (!this.$dialogBox || !this.$closeButton) return
|
|
13
15
|
|
|
14
16
|
this.$module.resize = this.handleResize.bind(this)
|
|
15
17
|
this.$module.open = this.handleOpen.bind(this)
|
|
@@ -2,10 +2,11 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function PrintLink () {
|
|
5
|
+
function PrintLink ($module) {
|
|
6
|
+
this.$module = $module
|
|
7
|
+
}
|
|
6
8
|
|
|
7
|
-
PrintLink.prototype.
|
|
8
|
-
this.$module = $module[0]
|
|
9
|
+
PrintLink.prototype.init = function () {
|
|
9
10
|
this.$module.addEventListener('click', function () {
|
|
10
11
|
window.print()
|
|
11
12
|
})
|
|
@@ -3,13 +3,13 @@ window.GOVUK = window.GOVUK || {}
|
|
|
3
3
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
4
4
|
|
|
5
5
|
(function (Modules) {
|
|
6
|
-
function ReorderableList () {
|
|
7
|
-
|
|
8
|
-
ReorderableList.prototype.start = function ($module) {
|
|
9
|
-
this.$module = $module[0]
|
|
6
|
+
function ReorderableList ($module) {
|
|
7
|
+
this.$module = $module
|
|
10
8
|
this.$upButtons = this.$module.querySelectorAll('.js-reorderable-list-up')
|
|
11
9
|
this.$downButtons = this.$module.querySelectorAll('.js-reorderable-list-down')
|
|
10
|
+
}
|
|
12
11
|
|
|
12
|
+
ReorderableList.prototype.init = function () {
|
|
13
13
|
this.sortable = window.Sortable.create(this.$module, { // eslint-disable-line new-cap
|
|
14
14
|
chosenClass: 'gem-c-reorderable-list__item--chosen',
|
|
15
15
|
dragClass: 'gem-c-reorderable-list__item--drag',
|
|
@@ -2,11 +2,12 @@ window.GOVUK = window.GOVUK || {}
|
|
|
2
2
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
3
3
|
|
|
4
4
|
(function (Modules) {
|
|
5
|
-
function ShowPassword () {
|
|
6
|
-
|
|
7
|
-
ShowPassword.prototype.start = function ($module) {
|
|
8
|
-
this.$module = $module[0]
|
|
5
|
+
function ShowPassword ($module) {
|
|
6
|
+
this.$module = $module
|
|
9
7
|
this.input = this.$module.querySelector('.gem-c-input')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
ShowPassword.prototype.init = function () {
|
|
10
11
|
this.$module.togglePassword = this.togglePassword.bind(this)
|
|
11
12
|
this.$module.revertToPasswordOnFormSubmit = this.revertToPasswordOnFormSubmit.bind(this)
|
|
12
13
|
this.input.classList.add('gem-c-input--with-password')
|
|
@@ -6,10 +6,8 @@ window.GOVUK = window.GOVUK || {}
|
|
|
6
6
|
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
7
7
|
|
|
8
8
|
(function (Modules) {
|
|
9
|
-
function Gemstepnav () {
|
|
10
|
-
|
|
11
|
-
Gemstepnav.prototype.start = function ($module) {
|
|
12
|
-
this.$module = $module[0]
|
|
9
|
+
function Gemstepnav ($module) {
|
|
10
|
+
this.$module = $module
|
|
13
11
|
this.$module.actions = {} // stores text for JS appended elements 'show' and 'hide' on steps, and 'show/hide all' button
|
|
14
12
|
this.$module.rememberShownStep = false
|
|
15
13
|
this.$module.stepNavSize = false
|
|
@@ -18,7 +16,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
|
18
16
|
this.$module.activeStepClass = 'gem-c-step-nav__step--active'
|
|
19
17
|
this.$module.activeLinkHref = '#content'
|
|
20
18
|
this.$module.uniqueId = false
|
|
19
|
+
}
|
|
21
20
|
|
|
21
|
+
Gemstepnav.prototype.init = function () {
|
|
22
22
|
// Indicate that js has worked
|
|
23
23
|
this.$module.classList.add('gem-c-step-nav--active')
|
|
24
24
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
%>
|
|
4
4
|
|
|
5
5
|
<nav id="proposition-menu" class="no-proposition-name gem-c-government-navigation" aria-label="Departments and policy navigation">
|
|
6
|
-
<ul id="proposition-links">
|
|
6
|
+
<ul id="proposition-links" data-module="gem-track-click">
|
|
7
7
|
<li>
|
|
8
8
|
<a class="<%= 'active' if active == 'departments' %> govuk-link govuk-link--no-underline govuk-link--inverse"
|
|
9
9
|
data-track-category="headerClicked"
|
|
@@ -8,13 +8,9 @@ module GovukPublishingComponents
|
|
|
8
8
|
education_coronavirus: "272308f4-05c8-4d0d-abc7-b7c2e3ccd249",
|
|
9
9
|
worker_coronavirus: "b7f57213-4b16-446d-8ded-81955d782680",
|
|
10
10
|
business_coronavirus: "65666cdf-b177-4d79-9687-b9c32805e450",
|
|
11
|
-
transition_period: "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
|
|
12
|
-
}.freeze
|
|
13
|
-
|
|
14
|
-
BREXIT_TAXONS = {
|
|
15
|
-
brexit: "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
|
|
16
11
|
brexit_business: "634fd193-8039-4a70-a059-919c34ff4bfc",
|
|
17
|
-
|
|
12
|
+
brexit_individuals: "614b2e65-56ac-4f8d-bb9c-d1a14167ba25",
|
|
13
|
+
brexit_taxon: "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
|
|
18
14
|
}.freeze
|
|
19
15
|
|
|
20
16
|
# Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
|
|
@@ -39,7 +35,7 @@ module GovukPublishingComponents
|
|
|
39
35
|
def breadcrumbs
|
|
40
36
|
taxon && {
|
|
41
37
|
title: taxon["title"],
|
|
42
|
-
path:
|
|
38
|
+
path: breadcrumb_path,
|
|
43
39
|
tracking_category: "breadcrumbClicked",
|
|
44
40
|
tracking_action: tracking_action,
|
|
45
41
|
tracking_label: content_item["base_path"],
|
|
@@ -52,6 +48,8 @@ module GovukPublishingComponents
|
|
|
52
48
|
def preferred_taxon
|
|
53
49
|
if preferred_priority_taxon
|
|
54
50
|
priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
|
|
51
|
+
elsif tagged_to_both_brexit_child_taxons?
|
|
52
|
+
priority_taxons.find { |t| t["content_id"] == PRIORITY_TAXONS[:brexit_taxon] }
|
|
55
53
|
end
|
|
56
54
|
end
|
|
57
55
|
|
|
@@ -74,17 +72,34 @@ module GovukPublishingComponents
|
|
|
74
72
|
PRIORITY_TAXONS.values.include?(taxon["content_id"])
|
|
75
73
|
end
|
|
76
74
|
|
|
75
|
+
def brexit_child_taxon?(taxon)
|
|
76
|
+
brexit_child_taxons.include?(taxon["content_id"])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def brexit_child_taxons
|
|
80
|
+
[PRIORITY_TAXONS[:brexit_business], PRIORITY_TAXONS[:brexit_individuals]]
|
|
81
|
+
end
|
|
82
|
+
|
|
77
83
|
def preferred_priority_taxon
|
|
78
84
|
query_parameters["priority-taxon"] if query_parameters
|
|
79
85
|
end
|
|
80
86
|
|
|
81
87
|
def tracking_action
|
|
82
88
|
action = %w[superBreadcrumb]
|
|
83
|
-
action << "Brexitbusiness" if taxon["content_id"] ==
|
|
84
|
-
action << "Brexitcitizen" if taxon["content_id"] ==
|
|
85
|
-
action << "Brexitbusinessandcitizen" if taxon["content_id"] ==
|
|
89
|
+
action << "Brexitbusiness" if taxon["content_id"] == PRIORITY_TAXONS[:brexit_business]
|
|
90
|
+
action << "Brexitcitizen" if taxon["content_id"] == PRIORITY_TAXONS[:brexit_individuals]
|
|
91
|
+
action << "Brexitbusinessandcitizen" if taxon["content_id"] == PRIORITY_TAXONS[:brexit_taxon]
|
|
86
92
|
action.join(" ")
|
|
87
93
|
end
|
|
94
|
+
|
|
95
|
+
def tagged_to_both_brexit_child_taxons?
|
|
96
|
+
t = priority_taxons.select { |taxon| brexit_child_taxon?(taxon) }
|
|
97
|
+
t.uniq.count > 1
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def breadcrumb_path
|
|
101
|
+
taxon.dig("details", "url_override").present? ? taxon.dig("details", "url_override") : taxon["base_path"]
|
|
102
|
+
end
|
|
88
103
|
end
|
|
89
104
|
end
|
|
90
105
|
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: 24.13.
|
|
4
|
+
version: 24.13.5
|
|
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: 2021-06-
|
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: govuk_app_config
|