govuk_publishing_components 23.14.0 → 24.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +286 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +26 -10
- data/app/assets/javascripts/govuk_publishing_components/components/step-by-step-nav.js +23 -14
- data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +8 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/component_support.scss +0 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +298 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +7 -87
- data/app/assets/stylesheets/govuk_publishing_components/components/_document-list.scss +6 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_error-alert.scss +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +35 -44
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +21 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +105 -48
- data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_contact.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +17 -9
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +1 -11
- data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
- data/app/models/govuk_publishing_components/component_doc.rb +1 -1
- data/app/views/govuk_publishing_components/audit/show.html.erb +26 -26
- data/app/views/govuk_publishing_components/components/_accordion.html.erb +13 -20
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -3
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +47 -36
- data/app/views/govuk_publishing_components/components/_document_list.html.erb +11 -1
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +5 -2
- data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_document.svg → _thumbnail_document.html.erb} +0 -0
- data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_generic.svg → _thumbnail_generic.html.erb} +0 -0
- data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_spreadsheet.svg → _thumbnail_spreadsheet.html.erb} +0 -0
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +8 -3
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +5 -0
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +9 -0
- data/app/views/govuk_publishing_components/components/docs/document_list.yml +42 -7
- data/app/views/govuk_publishing_components/components/docs/govspeak.yml +3 -3
- data/app/views/govuk_publishing_components/components/docs/layout_header.yml +11 -0
- data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +9 -4
- data/config/initializers/assets.rb +0 -1
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +61 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +1 -1
- data/node_modules/govuk-frontend/govuk/components/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/fixtures.json +10 -10
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/template.njk +2 -2
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/_index.scss +1 -0
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +1 -1
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +13 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_cookie-banner.scss +2 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/_index.scss +51 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/fixtures.json +425 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro-options.json +132 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/macro.njk +3 -0
- data/node_modules/govuk-frontend/govuk/components/cookie-banner/template.njk +63 -0
- data/node_modules/govuk-frontend/govuk/components/details/fixtures.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/header/fixtures.json +18 -18
- data/node_modules/govuk-frontend/govuk/components/header/template.njk +4 -4
- data/node_modules/govuk-frontend/govuk/components/table/_index.scss +21 -0
- data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/objects/_all.scss +1 -0
- data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +94 -0
- data/node_modules/govuk-frontend/package.json +1 -1
- metadata +13 -20
- data/app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small-focus.svg +0 -4
- data/app/assets/images/govuk_publishing_components/chevron-banner/chevron-banner-small.svg +0 -4
- data/app/assets/javascripts/govuk_publishing_components/components/header.js +0 -8
- data/app/assets/javascripts/govuk_publishing_components/lib/auto-track-event.js +0 -31
- data/app/assets/stylesheets/govuk_publishing_components/components/_chevron-banner.scss +0 -138
- data/app/assets/stylesheets/govuk_publishing_components/components/_list.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_variables.scss +0 -27
- data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_back-arrow.scss +0 -13
- data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_clearfix.scss +0 -8
- data/app/views/govuk_publishing_components/components/_chevron_banner.html.erb +0 -19
- data/app/views/govuk_publishing_components/components/_subscription-links.html.erb +0 -85
- data/app/views/govuk_publishing_components/components/_translation-nav.html.erb +0 -33
- data/app/views/govuk_publishing_components/components/docs/chevron_banner.yml +0 -33
- data/app/views/govuk_publishing_components/components/docs/subscription-links.yml +0 -103
- data/app/views/govuk_publishing_components/components/docs/translation-nav.yml +0 -139
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce32a486835dfd2796501f4cf80d3403ad4074fa1a832678a221fb9b607f3d3
|
4
|
+
data.tar.gz: 3b67448789550b585b08a3aa96666ac4fdc7a18cd5c6c8621668aa8e5ed91506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a19281a025aa4f0a0c51a14c06844d4ad67b2de6217fe57cf87bef328ed42a0bc7b959d0c07672d58e68b7e7995d7b2e02a47744723854ad7e3444ee3b748f
|
7
|
+
data.tar.gz: f866b24a0aa8c7cce2dfe1f3c4bab39aa977d1e40ded6abc218563c365fba0f743efe2a4d1ce47091beb5610b98f2c0acc367b18b11a533cfbe92f9eadb5ece9
|
@@ -1,5 +1,287 @@
|
|
1
|
-
|
2
|
-
//
|
1
|
+
/* global nodeListForEach */
|
2
|
+
// = require ../vendor/polyfills/closest.js
|
3
|
+
// = require ../vendor/polyfills/indexOf.js
|
4
|
+
// = require ../vendor/polyfills/common.js
|
5
|
+
|
3
6
|
window.GOVUK = window.GOVUK || {}
|
4
|
-
window.GOVUK.Modules = window.GOVUK.Modules || {}
|
5
|
-
|
7
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
8
|
+
|
9
|
+
(function (Modules) {
|
10
|
+
function GemAccordion () { }
|
11
|
+
|
12
|
+
GemAccordion.prototype.start = function ($module) {
|
13
|
+
this.$module = $module[0]
|
14
|
+
this.moduleId = this.$module.getAttribute('id')
|
15
|
+
this.sections = this.$module.querySelectorAll('.gem-c-accordion__section')
|
16
|
+
this.openAllButton = ''
|
17
|
+
this.browserSupportsSessionStorage = helper.checkForSessionStorage()
|
18
|
+
this.controlsClass = 'gem-c-accordion__controls'
|
19
|
+
this.openAllClass = 'gem-c-accordion__open-all'
|
20
|
+
this.openAllTextClass = 'gem-c-accordion__open-all-text'
|
21
|
+
this.sectionHeaderClass = 'gem-c-accordion__section-header'
|
22
|
+
this.sectionHeadingClass = 'gem-c-accordion__section-heading'
|
23
|
+
this.sectionSummaryClass = 'gem-c-accordion__section-summary'
|
24
|
+
this.sectionButtonClass = 'gem-c-accordion__section-button'
|
25
|
+
this.sectionExpandedClass = 'gem-c-accordion__section--expanded'
|
26
|
+
this.sectionInnerContent = 'gem-c-accordion__section-content'
|
27
|
+
this.toggleLinkClass = 'js-toggle-link'
|
28
|
+
this.sectionShowHideIconClass = 'gem-c-accordion__toggle-link'
|
29
|
+
this.sectionShowHideTextClass = 'gem-c-accordion__toggle-text'
|
30
|
+
this.upChevonIconClass = 'gem-c-accordion-nav__chevron'
|
31
|
+
this.downChevonIconClass = 'gem-c-accordion-nav__chevron--down'
|
32
|
+
|
33
|
+
// Indicate that js has worked
|
34
|
+
this.$module.classList.add('gem-c-accordion--active')
|
35
|
+
|
36
|
+
this.initControls()
|
37
|
+
this.initSectionHeaders()
|
38
|
+
|
39
|
+
// See if "Show all sections" button text should be updated
|
40
|
+
var areAllSectionsOpen = this.checkIfAllSectionsOpen()
|
41
|
+
this.updateOpenAllButton(areAllSectionsOpen)
|
42
|
+
}
|
43
|
+
|
44
|
+
// Initialise controls and set attributes
|
45
|
+
GemAccordion.prototype.initControls = function () {
|
46
|
+
// Create "Show all" button and set attributes
|
47
|
+
this.openAllButton = document.createElement('button')
|
48
|
+
this.openAllButton.setAttribute('class', this.openAllClass)
|
49
|
+
this.openAllButton.setAttribute('aria-expanded', 'false')
|
50
|
+
|
51
|
+
// Create icon, add to element
|
52
|
+
var icon = document.createElement('span')
|
53
|
+
icon.classList.add(this.upChevonIconClass)
|
54
|
+
this.openAllButton.appendChild(icon)
|
55
|
+
|
56
|
+
// Create control wrapper and add controls to it
|
57
|
+
var accordionControls = document.createElement('div')
|
58
|
+
accordionControls.setAttribute('class', this.controlsClass)
|
59
|
+
accordionControls.appendChild(this.openAllButton)
|
60
|
+
this.$module.insertBefore(accordionControls, this.$module.firstChild)
|
61
|
+
|
62
|
+
// Build addtional wrapper for open all toggle text, place icon after wrapped text.
|
63
|
+
var wrapperOpenAllText = document.createElement('span')
|
64
|
+
wrapperOpenAllText.classList.add(this.openAllTextClass)
|
65
|
+
this.openAllButton.insertBefore(wrapperOpenAllText, this.openAllButton.childNodes[0] || null)
|
66
|
+
|
67
|
+
// Handle events for the controls
|
68
|
+
this.openAllButton.addEventListener('click', this.onOpenOrCloseAllToggle.bind(this))
|
69
|
+
}
|
70
|
+
|
71
|
+
// Initialise section headers
|
72
|
+
GemAccordion.prototype.initSectionHeaders = function () {
|
73
|
+
// Loop through section headers
|
74
|
+
nodeListForEach(this.sections, function (section, i) {
|
75
|
+
// Set header attributes
|
76
|
+
var header = section.querySelector('.' + this.sectionHeaderClass)
|
77
|
+
this.initHeaderAttributes(header, i)
|
78
|
+
this.setExpanded(this.isExpanded(section), section)
|
79
|
+
|
80
|
+
// Handle events
|
81
|
+
header.addEventListener('click', this.onSectionToggle.bind(this, section))
|
82
|
+
|
83
|
+
// See if there is any state stored in sessionStorage and set the sections to
|
84
|
+
// open or closed.
|
85
|
+
this.setInitialState(section)
|
86
|
+
}.bind(this))
|
87
|
+
}
|
88
|
+
|
89
|
+
// Set individual header attributes
|
90
|
+
GemAccordion.prototype.initHeaderAttributes = function (headerWrapper, index) {
|
91
|
+
var span = headerWrapper.querySelector('.' + this.sectionButtonClass)
|
92
|
+
var heading = headerWrapper.querySelector('.' + this.sectionHeadingClass)
|
93
|
+
var summary = headerWrapper.querySelector('.' + this.sectionSummaryClass)
|
94
|
+
|
95
|
+
// Copy existing span element to an actual button element, for improved accessibility.
|
96
|
+
var button = document.createElement('button')
|
97
|
+
button.setAttribute('id', this.moduleId + '-heading-' + (index + 1))
|
98
|
+
button.setAttribute('aria-controls', this.moduleId + '-content-' + (index + 1))
|
99
|
+
|
100
|
+
// Create show / hide arrow icons with text.
|
101
|
+
var showIcons = document.createElement('span')
|
102
|
+
showIcons.classList.add(this.sectionShowHideIconClass, this.toggleLinkClass)
|
103
|
+
|
104
|
+
// Add pause after heading for assistive technology.
|
105
|
+
var srPause = document.createElement('span')
|
106
|
+
srPause.classList.add('govuk-visually-hidden')
|
107
|
+
srPause.innerHTML = ', '
|
108
|
+
|
109
|
+
// Build addtional copy for assistive technology
|
110
|
+
var srAddtionalCopy = document.createElement('span')
|
111
|
+
srAddtionalCopy.classList.add('govuk-visually-hidden')
|
112
|
+
srAddtionalCopy.innerHTML = ' this section'
|
113
|
+
|
114
|
+
// Build addtional wrapper for toggle text, place icon after wrapped text.
|
115
|
+
var wrapperShowHideIcon = document.createElement('span')
|
116
|
+
var icon = document.createElement('span')
|
117
|
+
icon.classList.add(this.upChevonIconClass)
|
118
|
+
showIcons.appendChild(icon)
|
119
|
+
wrapperShowHideIcon.classList.add(this.sectionShowHideTextClass)
|
120
|
+
showIcons.insertBefore(wrapperShowHideIcon, showIcons.childNodes[0] || null)
|
121
|
+
|
122
|
+
// Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from span to button
|
123
|
+
for (var i = 0; i < span.attributes.length; i++) {
|
124
|
+
var attr = span.attributes.item(i)
|
125
|
+
button.setAttribute(attr.nodeName, attr.nodeValue)
|
126
|
+
}
|
127
|
+
|
128
|
+
// span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
|
129
|
+
button.innerHTML = span.innerHTML
|
130
|
+
heading.removeChild(span)
|
131
|
+
heading.appendChild(button)
|
132
|
+
button.appendChild(srPause)
|
133
|
+
|
134
|
+
// If summary content exists add to DOM in correct order
|
135
|
+
if (typeof (summary) !== 'undefined' && summary !== null) {
|
136
|
+
button.setAttribute('aria-describedby', this.moduleId + '-summary-' + (index + 1))
|
137
|
+
button.appendChild(summary)
|
138
|
+
}
|
139
|
+
|
140
|
+
button.appendChild(showIcons)
|
141
|
+
button.appendChild(srAddtionalCopy)
|
142
|
+
}
|
143
|
+
|
144
|
+
// When section toggled, set and store state
|
145
|
+
GemAccordion.prototype.onSectionToggle = function (section) {
|
146
|
+
var expanded = this.isExpanded(section)
|
147
|
+
this.setExpanded(!expanded, section)
|
148
|
+
|
149
|
+
// Store the state in sessionStorage when a change is triggered
|
150
|
+
this.storeState(section)
|
151
|
+
}
|
152
|
+
|
153
|
+
// When Open/Close All toggled, set and store state
|
154
|
+
GemAccordion.prototype.onOpenOrCloseAllToggle = function () {
|
155
|
+
var module = this
|
156
|
+
var sections = this.sections
|
157
|
+
var nowExpanded = !this.checkIfAllSectionsOpen()
|
158
|
+
|
159
|
+
nodeListForEach(sections, function (section) {
|
160
|
+
module.setExpanded(nowExpanded, section)
|
161
|
+
// Store the state in sessionStorage when a change is triggered
|
162
|
+
module.storeState(section)
|
163
|
+
})
|
164
|
+
|
165
|
+
module.updateOpenAllButton(nowExpanded)
|
166
|
+
}
|
167
|
+
|
168
|
+
// Set section attributes when opened/closed
|
169
|
+
GemAccordion.prototype.setExpanded = function (expanded, section) {
|
170
|
+
var icon = section.querySelector('.' + this.upChevonIconClass)
|
171
|
+
var showHideText = section.querySelector('.' + this.sectionShowHideTextClass)
|
172
|
+
var button = section.querySelector('.' + this.sectionButtonClass)
|
173
|
+
var newButtonText = expanded ? 'Hide' : 'Show'
|
174
|
+
|
175
|
+
showHideText.innerHTML = newButtonText
|
176
|
+
button.setAttribute('aria-expanded', expanded)
|
177
|
+
button.classList.add(this.toggleLinkClass)
|
178
|
+
|
179
|
+
// Swap icon, change class
|
180
|
+
if (expanded) {
|
181
|
+
section.classList.add(this.sectionExpandedClass)
|
182
|
+
icon.classList.remove(this.downChevonIconClass)
|
183
|
+
} else {
|
184
|
+
section.classList.remove(this.sectionExpandedClass)
|
185
|
+
icon.classList.add(this.downChevonIconClass)
|
186
|
+
}
|
187
|
+
|
188
|
+
// See if "Show all sections" button text should be updated
|
189
|
+
var areAllSectionsOpen = this.checkIfAllSectionsOpen()
|
190
|
+
this.updateOpenAllButton(areAllSectionsOpen)
|
191
|
+
}
|
192
|
+
|
193
|
+
// Get state of section
|
194
|
+
GemAccordion.prototype.isExpanded = function (section) {
|
195
|
+
return section.classList.contains(this.sectionExpandedClass)
|
196
|
+
}
|
197
|
+
|
198
|
+
// Check if all sections are open
|
199
|
+
GemAccordion.prototype.checkIfAllSectionsOpen = function () {
|
200
|
+
// Get a count of all the Accordion sections
|
201
|
+
var sectionsCount = this.sections.length
|
202
|
+
// Get a count of all Accordion sections that are expanded
|
203
|
+
var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length
|
204
|
+
var areAllSectionsOpen = sectionsCount === expandedSectionCount
|
205
|
+
|
206
|
+
return areAllSectionsOpen
|
207
|
+
}
|
208
|
+
|
209
|
+
// Update "Show all sections" button
|
210
|
+
GemAccordion.prototype.updateOpenAllButton = function (expanded) {
|
211
|
+
var icon = this.openAllButton.querySelector('.' + this.upChevonIconClass)
|
212
|
+
var openAllCopy = this.openAllButton.querySelector('.' + this.openAllTextClass)
|
213
|
+
var newButtonText = expanded ? 'Hide all sections' : 'Show all sections'
|
214
|
+
this.openAllButton.setAttribute('aria-expanded', expanded)
|
215
|
+
openAllCopy.innerHTML = newButtonText
|
216
|
+
|
217
|
+
// Swap icon, toggle class
|
218
|
+
if (expanded) {
|
219
|
+
icon.classList.remove(this.downChevonIconClass)
|
220
|
+
} else {
|
221
|
+
icon.classList.add(this.downChevonIconClass)
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
var helper = {
|
226
|
+
checkForSessionStorage: function () {
|
227
|
+
var testString = 'this is the test string'
|
228
|
+
var result
|
229
|
+
try {
|
230
|
+
window.sessionStorage.setItem(testString, testString)
|
231
|
+
result = window.sessionStorage.getItem(testString) === testString.toString()
|
232
|
+
window.sessionStorage.removeItem(testString)
|
233
|
+
return result
|
234
|
+
} catch (exception) {
|
235
|
+
if ((typeof console === 'undefined' || typeof console.log === 'undefined')) {
|
236
|
+
console.log('Notice: sessionStorage not available.')
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
// Set the state of the accordions in sessionStorage
|
243
|
+
GemAccordion.prototype.storeState = function (section) {
|
244
|
+
if (this.browserSupportsSessionStorage) {
|
245
|
+
// We need a unique way of identifying each content in the GemAccordion. Since
|
246
|
+
// an `#id` should be unique and an `id` is required for `aria-` attributes
|
247
|
+
// `id` can be safely used.
|
248
|
+
var button = section.querySelector('.' + this.sectionButtonClass)
|
249
|
+
|
250
|
+
if (button) {
|
251
|
+
var contentId = button.getAttribute('aria-controls')
|
252
|
+
var contentState = button.getAttribute('aria-expanded')
|
253
|
+
|
254
|
+
if (typeof contentId === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
|
255
|
+
console.error(new Error('No aria controls present in accordion section heading.'))
|
256
|
+
}
|
257
|
+
|
258
|
+
if (typeof contentState === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
|
259
|
+
console.error(new Error('No aria expanded present in accordion section heading.'))
|
260
|
+
}
|
261
|
+
|
262
|
+
// Only set the state when both `contentId` and `contentState` are taken from the DOM.
|
263
|
+
if (contentId && contentState) {
|
264
|
+
window.sessionStorage.setItem(contentId, contentState)
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
// Read the state of the accordions from sessionStorage
|
271
|
+
GemAccordion.prototype.setInitialState = function (section) {
|
272
|
+
if (this.browserSupportsSessionStorage) {
|
273
|
+
var button = section.querySelector('.' + this.sectionButtonClass)
|
274
|
+
|
275
|
+
if (button) {
|
276
|
+
var contentId = button.getAttribute('aria-controls')
|
277
|
+
var contentState = contentId ? window.sessionStorage.getItem(contentId) : null
|
278
|
+
|
279
|
+
if (contentState !== null) {
|
280
|
+
this.setExpanded(contentState === 'true', section)
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
Modules.GemAccordion = GemAccordion
|
287
|
+
})(window.GOVUK.Modules)
|
@@ -9,10 +9,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
9
9
|
this.$module.hideCookieMessage = this.hideCookieMessage.bind(this)
|
10
10
|
this.$module.showConfirmationMessage = this.showConfirmationMessage.bind(this)
|
11
11
|
this.$module.setCookieConsent = this.setCookieConsent.bind(this)
|
12
|
+
this.$module.rejectCookieConsent = this.rejectCookieConsent.bind(this)
|
12
13
|
|
13
14
|
this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
|
14
15
|
this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
|
15
|
-
|
16
|
+
this.$module.cookieBannerConfirmationMessageText = this.$module.querySelector('.gem-c-cookie-banner__confirmation-message')
|
16
17
|
this.setupCookieMessage()
|
17
18
|
}
|
18
19
|
|
@@ -24,9 +25,16 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
27
|
-
this.$
|
28
|
-
if (this.$
|
29
|
-
this.$
|
28
|
+
this.$acceptCookiesButton = this.$module.querySelector('button[data-accept-cookies]')
|
29
|
+
if (this.$acceptCookiesButton) {
|
30
|
+
this.$acceptCookiesButton.style.display = 'block'
|
31
|
+
this.$acceptCookiesButton.addEventListener('click', this.$module.setCookieConsent)
|
32
|
+
}
|
33
|
+
|
34
|
+
this.$rejectCookiesButton = this.$module.querySelector('button[data-reject-cookies]')
|
35
|
+
if (this.$rejectCookiesButton) {
|
36
|
+
this.$rejectCookiesButton.style.display = 'block'
|
37
|
+
this.$rejectCookiesButton.addEventListener('click', this.$module.rejectCookieConsent)
|
30
38
|
}
|
31
39
|
|
32
40
|
this.showCookieMessage()
|
@@ -56,6 +64,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
56
64
|
|
57
65
|
CookieBanner.prototype.hideCookieMessage = function (event) {
|
58
66
|
if (this.$module) {
|
67
|
+
this.$module.hidden = true
|
59
68
|
this.$module.style.display = 'none'
|
60
69
|
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
61
70
|
}
|
@@ -66,6 +75,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
66
75
|
}
|
67
76
|
|
68
77
|
CookieBanner.prototype.setCookieConsent = function () {
|
78
|
+
if (this.$acceptCookiesButton.getAttribute('data-cookie-types') === 'all') {
|
79
|
+
this.$module.cookieBannerConfirmationMessageText.insertAdjacentHTML('afterbegin', 'You have accepted additional cookies. ')
|
80
|
+
}
|
69
81
|
window.GOVUK.approveAllCookieTypes()
|
70
82
|
this.$module.showConfirmationMessage()
|
71
83
|
this.$module.cookieBannerConfirmationMessage.focus()
|
@@ -78,15 +90,19 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
78
90
|
}
|
79
91
|
}
|
80
92
|
|
93
|
+
CookieBanner.prototype.rejectCookieConsent = function () {
|
94
|
+
this.$module.cookieBannerConfirmationMessageText.insertAdjacentHTML('afterbegin', 'You have rejected additional cookies. ')
|
95
|
+
this.$module.showConfirmationMessage()
|
96
|
+
this.$module.cookieBannerConfirmationMessage.focus()
|
97
|
+
window.GOVUK.cookie('cookies_preferences_set', 'true', { days: 365 })
|
98
|
+
}
|
99
|
+
|
81
100
|
CookieBanner.prototype.showConfirmationMessage = function () {
|
82
|
-
this.$cookieBannerMainContent = document.querySelector('.
|
101
|
+
this.$cookieBannerMainContent = document.querySelector('.js-banner-wrapper')
|
83
102
|
|
84
|
-
this.$cookieBannerMainContent.
|
103
|
+
this.$cookieBannerMainContent.hidden = true
|
85
104
|
this.$module.cookieBannerConfirmationMessage.style.display = 'block'
|
86
|
-
|
87
|
-
|
88
|
-
CookieBanner.prototype.listenForCrossOriginMessages = function () {
|
89
|
-
window.addEventListener('message', this.receiveMessage.bind(this), false)
|
105
|
+
this.$module.cookieBannerConfirmationMessage.hidden = false
|
90
106
|
}
|
91
107
|
|
92
108
|
CookieBanner.prototype.isInCookiesPage = function () {
|
@@ -40,13 +40,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
40
40
|
this.$module.sessionStoreLink = this.$module.sessionStoreLink + '_' + this.$module.uniqueId
|
41
41
|
}
|
42
42
|
|
43
|
-
this.$module.upChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"
|
44
|
-
'<path d="M19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499998 10C0.499999 4.7533 4.7533 0.500001 10 0.500002C15.2467 0.500003 19.5 4.7533 19.5 10Z" stroke="#1D70B8"/>' +
|
45
|
-
'<path d="M6.32617 12.3262L10 8.65234L13.6738 12.3262" stroke="#1D70B8" stroke-width="2"/>' +
|
43
|
+
this.$module.upChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
|
44
|
+
'<path class="gem-c-step-nav__chevron-stroke" d="M19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499998 10C0.499999 4.7533 4.7533 0.500001 10 0.500002C15.2467 0.500003 19.5 4.7533 19.5 10Z" stroke="#1D70B8"/>' +
|
45
|
+
'<path class="gem-c-step-nav__chevron-stroke" d="M6.32617 12.3262L10 8.65234L13.6738 12.3262" stroke="#1D70B8" stroke-width="2"/>' +
|
46
46
|
'</svg>'
|
47
|
-
this.$module.downChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"
|
48
|
-
'<path d="M0.499997 10C0.499998 4.75329 4.75329 0.499999 10 0.499999C15.2467 0.5 19.5 4.75329 19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499997 10Z" stroke="#1D70B8"/>' +
|
49
|
-
'<path d="M13.6738 8.67383L10 12.3477L6.32617 8.67383" stroke="#1D70B8" stroke-width="2"/>' +
|
47
|
+
this.$module.downChevronSvg = '<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">' +
|
48
|
+
'<path class="gem-c-step-nav__chevron-stroke" d="M0.499997 10C0.499998 4.75329 4.75329 0.499999 10 0.499999C15.2467 0.5 19.5 4.75329 19.5 10C19.5 15.2467 15.2467 19.5 10 19.5C4.75329 19.5 0.499997 15.2467 0.499997 10Z" stroke="#1D70B8"/>' +
|
49
|
+
'<path class="gem-c-step-nav__chevron-stroke" d="M13.6738 8.67383L10 12.3477L6.32617 8.67383" stroke="#1D70B8" stroke-width="2"/>' +
|
50
50
|
'</svg>'
|
51
51
|
|
52
52
|
var stepNavTracker = new this.StepNavTracker(this.$module.uniqueId, this.$module.totalSteps, this.$module.totalLinks)
|
@@ -76,8 +76,8 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
76
76
|
var showall = document.createElement('div')
|
77
77
|
showall.className = 'gem-c-step-nav__controls'
|
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
|
-
this.$module.
|
80
|
-
this.$module.
|
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
|
+
'<span class="gem-c-step-nav__chevron js-step-controls-button-icon">' + this.$module.downChevronSvg + '</span>' +
|
81
81
|
'</button>'
|
82
82
|
|
83
83
|
var steps = this.$module.querySelectorAll('.gem-c-step-nav__steps')[0]
|
@@ -93,13 +93,20 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
93
93
|
if (!thisel.querySelectorAll('.js-toggle-link').length) {
|
94
94
|
var span = document.createElement('span')
|
95
95
|
var showHideSpan = document.createElement('span')
|
96
|
+
var showHideSpanText = document.createElement('span')
|
97
|
+
var showHideSpanIcon = document.createElement('span')
|
96
98
|
var commaSpan = document.createElement('span')
|
97
99
|
var thisSectionSpan = document.createElement('span')
|
98
100
|
|
99
101
|
showHideSpan.className = 'gem-c-step-nav__toggle-link js-toggle-link'
|
102
|
+
showHideSpanText.className = 'gem-c-step-nav__button-text js-toggle-link-text'
|
103
|
+
showHideSpanIcon.className = 'gem-c-step-nav__chevron js-toggle-link-icon'
|
100
104
|
commaSpan.className = 'govuk-visually-hidden'
|
101
105
|
thisSectionSpan.className = 'govuk-visually-hidden'
|
102
106
|
|
107
|
+
showHideSpan.appendChild(showHideSpanText)
|
108
|
+
showHideSpan.appendChild(showHideSpanIcon)
|
109
|
+
|
103
110
|
commaSpan.innerHTML = ', '
|
104
111
|
thisSectionSpan.innerHTML = ' this section'
|
105
112
|
|
@@ -351,12 +358,12 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
351
358
|
|
352
359
|
Gemstepnav.prototype.setShowHideAllText = function () {
|
353
360
|
var shownSteps = this.$module.querySelectorAll('.step-is-shown').length
|
361
|
+
|
354
362
|
// Find out if the number of is-opens == total number of steps
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
}
|
363
|
+
var shownStepsIsTotalSteps = shownSteps === this.$module.totalSteps
|
364
|
+
|
365
|
+
this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-text').innerHTML = shownStepsIsTotalSteps ? this.$module.actions.hideAllText : this.$module.actions.showAllText
|
366
|
+
this.$module.showOrHideAllButton.querySelector('.js-step-controls-button-icon').innerHTML = shownStepsIsTotalSteps ? this.$module.upChevronSvg : this.$module.downChevronSvg
|
360
367
|
}
|
361
368
|
|
362
369
|
Gemstepnav.prototype.StepView = function (stepElement, $module) {
|
@@ -394,7 +401,9 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
394
401
|
|
395
402
|
this.titleButton.setAttribute('aria-expanded', isShown)
|
396
403
|
var showHideText = this.stepElement.querySelectorAll('.js-toggle-link')[0]
|
397
|
-
|
404
|
+
|
405
|
+
showHideText.querySelector('.js-toggle-link-text').innerHTML = isShown ? this.hideText : this.showText
|
406
|
+
showHideText.querySelector('.js-toggle-link-icon').innerHTML = isShown ? this.upChevronSvg : this.downChevronSvg
|
398
407
|
}
|
399
408
|
|
400
409
|
this.isShown = function () {
|