govuk_publishing_components 24.0.0 → 24.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +28 -0
  3. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +330 -4
  4. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +26 -6
  5. data/app/assets/javascripts/govuk_publishing_components/vendor/polyfills/common.js +8 -0
  6. data/app/assets/stylesheets/component_guide/application.scss +0 -8
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_accordion.scss +298 -14
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +11 -84
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +21 -5
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -13
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav.scss +4 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/print/_accordion.scss +17 -9
  13. data/app/assets/stylesheets/govuk_publishing_components/govuk_frontend_support.scss +1 -11
  14. data/app/models/govuk_publishing_components/audit_applications.rb +2 -2
  15. data/app/models/govuk_publishing_components/audit_comparer.rb +2 -2
  16. data/app/models/govuk_publishing_components/component_example.rb +4 -3
  17. data/app/views/govuk_publishing_components/audit/show.html.erb +211 -199
  18. data/app/views/govuk_publishing_components/components/_accordion.html.erb +15 -22
  19. data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -3
  20. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  22. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +50 -39
  23. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  25. data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +1 -1
  26. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  27. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +1 -1
  28. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  29. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  30. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +1 -1
  34. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_document.svg → _thumbnail_document.html.erb} +0 -0
  36. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_generic.svg → _thumbnail_generic.html.erb} +0 -0
  37. data/app/views/govuk_publishing_components/components/attachment/{_thumbnail_spreadsheet.svg → _thumbnail_spreadsheet.html.erb} +0 -0
  38. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +1 -1
  39. data/app/views/govuk_publishing_components/components/docs/accordion.yml +37 -3
  40. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +9 -0
  41. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  42. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
  43. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  45. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +2 -1
  46. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  47. data/lib/govuk_publishing_components/presenters/machine_readable/html_publication_schema.rb +1 -7
  48. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -2
  49. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  50. data/lib/govuk_publishing_components/version.rb +1 -1
  51. data/lib/tasks/govuk_publishing_components_tasks.rake +1 -1
  52. metadata +11 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aba99b9b513b88a9b3ac310bdca5299af17ff94d6c296a13e8087deb510ddf64
4
- data.tar.gz: 9238695c7fac3e53a47cda06d2de2114b7036dd805f9acba97dfc91c13151cdb
3
+ metadata.gz: cbfbb444f86b61f46e110ab8615ca02b163357d6bf3125c4f4459bed3da8b92d
4
+ data.tar.gz: 012a4752e5fd69378516db6348f18b14902714dc56e209951879f490af850f77
5
5
  SHA512:
6
- metadata.gz: 8c39fe32ea761ab5d7a4c01752430b909c96947c3e8dfc9126071392a2ec10234f1948f1a4ca8724cb379c13ed712b361cf2de68f71263d4b80010043add2ba3
7
- data.tar.gz: 53e5a2d17340534140eedd509128853c27ea1c3633110c2039f7afd9f363fcbc3f152c73829cdd32a291867b655501f58b53a8a442bcb401dc4052073c7afb23
6
+ metadata.gz: 94f375971a2803179d77d070ee86113ea6e6a17d5e547d94c7229b7fcd643b2e8636eccb1f03369e26bb074517bdf411312826a721701efd55363fab244033a2
7
+ data.tar.gz: 62c13a38b68951a6492044e29b4a7989ea2ea62e185b58c307707bdbbe9a013e4db03dc7c52b7d378f04474be5e8505751e5395d4c58f5d6cc8e8ded2a9ede83
@@ -405,6 +405,34 @@
405
405
  ],
406
406
  '/eubusiness': [
407
407
  ['Heading', 'Additional help and support']
408
+ ],
409
+ '/coronavirus': [
410
+ ['Percent', 20],
411
+ ['Percent', 40],
412
+ ['Percent', 60],
413
+ ['Percent', 80],
414
+ ['Percent', 100]
415
+ ],
416
+ '/coronavirus/education-and-childcare': [
417
+ ['Percent', 20],
418
+ ['Percent', 40],
419
+ ['Percent', 60],
420
+ ['Percent', 80],
421
+ ['Percent', 100]
422
+ ],
423
+ '/coronavirus/worker-support': [
424
+ ['Percent', 20],
425
+ ['Percent', 40],
426
+ ['Percent', 60],
427
+ ['Percent', 80],
428
+ ['Percent', 100]
429
+ ],
430
+ '/coronavirus/business-support': [
431
+ ['Percent', 20],
432
+ ['Percent', 40],
433
+ ['Percent', 60],
434
+ ['Percent', 80],
435
+ ['Percent', 100]
408
436
  ]
409
437
  }
410
438
 
@@ -1,5 +1,331 @@
1
- // This component relies on JavaScript from GOV.UK Frontend
2
- // = require govuk/components/accordion/accordion.js
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
- window.GOVUK.Modules.Accordion = window.GOVUKFrontend
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.sectionClass = 'gem-c-accordion__section'
15
+ this.moduleId = this.$module.getAttribute('id')
16
+ this.sections = this.$module.querySelectorAll('.' + this.sectionClass)
17
+ this.openAllButton = ''
18
+ this.browserSupportsSessionStorage = helper.checkForSessionStorage()
19
+ this.controlsClass = 'gem-c-accordion__controls'
20
+ this.openAllClass = 'gem-c-accordion__open-all'
21
+ this.openAllTextClass = 'gem-c-accordion__open-all-text'
22
+ this.sectionHeaderClass = 'gem-c-accordion__section-header'
23
+ this.sectionHeadingClass = 'gem-c-accordion__section-heading'
24
+ this.sectionSummaryClass = 'gem-c-accordion__section-summary'
25
+ this.sectionButtonClass = 'gem-c-accordion__section-button'
26
+ this.sectionExpandedClass = 'gem-c-accordion__section--expanded'
27
+ this.sectionInnerContent = 'gem-c-accordion__section-content'
28
+ this.toggleLinkClass = 'js-toggle-link'
29
+ this.sectionShowHideIconClass = 'gem-c-accordion__toggle-link'
30
+ this.sectionShowHideTextClass = 'gem-c-accordion__toggle-text'
31
+ this.upChevonIconClass = 'gem-c-accordion-nav__chevron'
32
+ this.downChevonIconClass = 'gem-c-accordion-nav__chevron--down'
33
+
34
+ // Indicate that js has worked
35
+ this.$module.classList.add('gem-c-accordion--active')
36
+
37
+ this.initControls()
38
+ this.initSectionHeaders()
39
+
40
+ // Feature flag for anchor tag navigation used on manuals
41
+ if (this.$module.getAttribute('data-anchor-navigation')) {
42
+ this.openByAnchorOnLoad()
43
+ this.addEventListenersForAnchors()
44
+ }
45
+
46
+ // See if "Show all sections" button text should be updated
47
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen()
48
+ this.updateOpenAllButton(areAllSectionsOpen)
49
+ }
50
+
51
+ // Initialise controls and set attributes
52
+ GemAccordion.prototype.initControls = function () {
53
+ // Create "Show all" button and set attributes
54
+ this.openAllButton = document.createElement('button')
55
+ this.openAllButton.setAttribute('class', this.openAllClass)
56
+ this.openAllButton.setAttribute('aria-expanded', 'false')
57
+
58
+ // Create icon, add to element
59
+ var icon = document.createElement('span')
60
+ icon.classList.add(this.upChevonIconClass)
61
+ this.openAllButton.appendChild(icon)
62
+
63
+ // Create control wrapper and add controls to it
64
+ var accordionControls = document.createElement('div')
65
+ accordionControls.setAttribute('class', this.controlsClass)
66
+ accordionControls.appendChild(this.openAllButton)
67
+ this.$module.insertBefore(accordionControls, this.$module.firstChild)
68
+
69
+ // Build additional wrapper for open all toggle text, place icon after wrapped text.
70
+ var wrapperOpenAllText = document.createElement('span')
71
+ wrapperOpenAllText.classList.add(this.openAllTextClass)
72
+ this.openAllButton.insertBefore(wrapperOpenAllText, this.openAllButton.childNodes[0] || null)
73
+
74
+ // Handle events for the controls
75
+ this.openAllButton.addEventListener('click', this.onOpenOrCloseAllToggle.bind(this))
76
+ }
77
+
78
+ // Initialise section headers
79
+ GemAccordion.prototype.initSectionHeaders = function () {
80
+ // Loop through section headers
81
+ nodeListForEach(this.sections, function (section, i) {
82
+ // Set header attributes
83
+ var header = section.querySelector('.' + this.sectionHeaderClass)
84
+
85
+ this.initHeaderAttributes(header, i)
86
+ this.setExpanded(this.isExpanded(section), section)
87
+
88
+ // Handle events
89
+ header.addEventListener('click', this.onSectionToggle.bind(this, section))
90
+
91
+ // See if there is any state stored in sessionStorage and set the sections to
92
+ // open or closed.
93
+ this.setInitialState(section)
94
+ }.bind(this))
95
+ }
96
+
97
+ // Set individual header attributes
98
+ GemAccordion.prototype.initHeaderAttributes = function (headerWrapper, index) {
99
+ var span = headerWrapper.querySelector('.' + this.sectionButtonClass)
100
+ var heading = headerWrapper.querySelector('.' + this.sectionHeadingClass)
101
+ var summary = headerWrapper.querySelector('.' + this.sectionSummaryClass)
102
+
103
+ // Copy existing span element to an actual button element, for improved accessibility.
104
+ var button = document.createElement('button')
105
+ button.setAttribute('id', this.moduleId + '-heading-' + (index + 1))
106
+ button.setAttribute('aria-controls', this.moduleId + '-content-' + (index + 1))
107
+
108
+ // Create show / hide arrow icons with text.
109
+ var showIcons = document.createElement('span')
110
+ showIcons.classList.add(this.sectionShowHideIconClass, this.toggleLinkClass)
111
+
112
+ // Add pause after heading for assistive technology.
113
+ var srPause = document.createElement('span')
114
+ srPause.classList.add('govuk-visually-hidden')
115
+ srPause.innerHTML = ', '
116
+
117
+ // Build additional copy for assistive technology
118
+ var srAdditionalCopy = document.createElement('span')
119
+ srAdditionalCopy.classList.add('govuk-visually-hidden')
120
+ srAdditionalCopy.innerHTML = ' this section'
121
+
122
+ // Build additional wrapper for toggle text, place icon after wrapped text.
123
+ var wrapperShowHideIcon = document.createElement('span')
124
+ var icon = document.createElement('span')
125
+ icon.classList.add(this.upChevonIconClass)
126
+ showIcons.appendChild(icon)
127
+ wrapperShowHideIcon.classList.add(this.sectionShowHideTextClass)
128
+ showIcons.insertBefore(wrapperShowHideIcon, showIcons.childNodes[0] || null)
129
+
130
+ // Copy all attributes (https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes) from span to button
131
+ for (var i = 0; i < span.attributes.length; i++) {
132
+ var attr = span.attributes.item(i)
133
+ button.setAttribute(attr.nodeName, attr.nodeValue)
134
+ }
135
+
136
+ // span could contain HTML elements (see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content)
137
+ button.innerHTML = span.innerHTML
138
+ heading.removeChild(span)
139
+ heading.appendChild(button)
140
+ button.appendChild(srPause)
141
+
142
+ // If summary content exists add to DOM in correct order
143
+ if (typeof (summary) !== 'undefined' && summary !== null) {
144
+ button.setAttribute('aria-describedby', this.moduleId + '-summary-' + (index + 1))
145
+ button.appendChild(summary)
146
+ }
147
+
148
+ button.appendChild(showIcons)
149
+ button.appendChild(srAdditionalCopy)
150
+ }
151
+
152
+ // When section toggled, set and store state
153
+ GemAccordion.prototype.onSectionToggle = function (section) {
154
+ var expanded = this.isExpanded(section)
155
+ this.setExpanded(!expanded, section)
156
+
157
+ // Store the state in sessionStorage when a change is triggered
158
+ this.storeState(section)
159
+ }
160
+
161
+ // When Open/Close All toggled, set and store state
162
+ GemAccordion.prototype.onOpenOrCloseAllToggle = function () {
163
+ var module = this
164
+ var sections = this.sections
165
+ var nowExpanded = !this.checkIfAllSectionsOpen()
166
+
167
+ nodeListForEach(sections, function (section) {
168
+ module.setExpanded(nowExpanded, section)
169
+ // Store the state in sessionStorage when a change is triggered
170
+ module.storeState(section)
171
+ })
172
+
173
+ module.updateOpenAllButton(nowExpanded)
174
+ }
175
+
176
+ // Set section attributes when opened/closed
177
+ GemAccordion.prototype.setExpanded = function (expanded, section) {
178
+ var icon = section.querySelector('.' + this.upChevonIconClass)
179
+ var showHideText = section.querySelector('.' + this.sectionShowHideTextClass)
180
+ var button = section.querySelector('.' + this.sectionButtonClass)
181
+ var newButtonText = expanded ? 'Hide' : 'Show'
182
+
183
+ showHideText.innerHTML = newButtonText
184
+ button.setAttribute('aria-expanded', expanded)
185
+ button.classList.add(this.toggleLinkClass)
186
+
187
+ // Swap icon, change class
188
+ if (expanded) {
189
+ section.classList.add(this.sectionExpandedClass)
190
+ icon.classList.remove(this.downChevonIconClass)
191
+ } else {
192
+ section.classList.remove(this.sectionExpandedClass)
193
+ icon.classList.add(this.downChevonIconClass)
194
+ }
195
+
196
+ // See if "Show all sections" button text should be updated
197
+ var areAllSectionsOpen = this.checkIfAllSectionsOpen()
198
+ this.updateOpenAllButton(areAllSectionsOpen)
199
+ }
200
+
201
+ // Get state of section
202
+ GemAccordion.prototype.isExpanded = function (section) {
203
+ return section.classList.contains(this.sectionExpandedClass)
204
+ }
205
+
206
+ // Check if all sections are open
207
+ GemAccordion.prototype.checkIfAllSectionsOpen = function () {
208
+ // Get a count of all the Accordion sections
209
+ var sectionsCount = this.sections.length
210
+ // Get a count of all Accordion sections that are expanded
211
+ var expandedSectionCount = this.$module.querySelectorAll('.' + this.sectionExpandedClass).length
212
+ var areAllSectionsOpen = sectionsCount === expandedSectionCount
213
+
214
+ return areAllSectionsOpen
215
+ }
216
+
217
+ // Update "Show all sections" button
218
+ GemAccordion.prototype.updateOpenAllButton = function (expanded) {
219
+ var icon = this.openAllButton.querySelector('.' + this.upChevonIconClass)
220
+ var openAllCopy = this.openAllButton.querySelector('.' + this.openAllTextClass)
221
+ var newButtonText = expanded ? 'Hide all sections' : 'Show all sections'
222
+ this.openAllButton.setAttribute('aria-expanded', expanded)
223
+ openAllCopy.innerHTML = newButtonText
224
+
225
+ // Swap icon, toggle class
226
+ if (expanded) {
227
+ icon.classList.remove(this.downChevonIconClass)
228
+ } else {
229
+ icon.classList.add(this.downChevonIconClass)
230
+ }
231
+ }
232
+
233
+ var helper = {
234
+ checkForSessionStorage: function () {
235
+ var testString = 'this is the test string'
236
+ var result
237
+ try {
238
+ window.sessionStorage.setItem(testString, testString)
239
+ result = window.sessionStorage.getItem(testString) === testString.toString()
240
+ window.sessionStorage.removeItem(testString)
241
+ return result
242
+ } catch (exception) {
243
+ if ((typeof console === 'undefined' || typeof console.log === 'undefined')) {
244
+ console.log('Notice: sessionStorage not available.')
245
+ }
246
+ }
247
+ }
248
+ }
249
+
250
+ // Set the state of the accordions in sessionStorage
251
+ GemAccordion.prototype.storeState = function (section) {
252
+ if (this.browserSupportsSessionStorage) {
253
+ // We need a unique way of identifying each content in the GemAccordion. Since
254
+ // an `#id` should be unique and an `id` is required for `aria-` attributes
255
+ // `id` can be safely used.
256
+ var button = section.querySelector('.' + this.sectionButtonClass)
257
+
258
+ if (button) {
259
+ var contentId = button.getAttribute('aria-controls')
260
+ var contentState = button.getAttribute('aria-expanded')
261
+
262
+ if (typeof contentId === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
263
+ console.error(new Error('No aria controls present in accordion section heading.'))
264
+ }
265
+
266
+ if (typeof contentState === 'undefined' && (typeof console === 'undefined' || typeof console.log === 'undefined')) {
267
+ console.error(new Error('No aria expanded present in accordion section heading.'))
268
+ }
269
+
270
+ // Only set the state when both `contentId` and `contentState` are taken from the DOM.
271
+ if (contentId && contentState) {
272
+ window.sessionStorage.setItem(contentId, contentState)
273
+ }
274
+ }
275
+ }
276
+ }
277
+
278
+ // Read the state of the accordions from sessionStorage
279
+ GemAccordion.prototype.setInitialState = function (section) {
280
+ if (this.browserSupportsSessionStorage) {
281
+ var button = section.querySelector('.' + this.sectionButtonClass)
282
+
283
+ if (button) {
284
+ var contentId = button.getAttribute('aria-controls')
285
+ var contentState = contentId ? window.sessionStorage.getItem(contentId) : null
286
+
287
+ if (contentState !== null) {
288
+ this.setExpanded(contentState === 'true', section)
289
+ }
290
+ }
291
+ }
292
+ }
293
+
294
+ // Navigate to and open accordions with anchored content on page load if a hash is present
295
+ GemAccordion.prototype.openByAnchorOnLoad = function () {
296
+ if (window.location.hash && this.$module.querySelector(window.location.hash)) {
297
+ this.openForAnchor(window.location.hash)
298
+ }
299
+ }
300
+
301
+ // Add event listeners for links to open accordion sections when navigated to using said anchor links on the page
302
+ // Adding an event listener to all anchor link a tags in an accordion is risky but we circumvent this risk partially by only being a layer of accordion behaviour instead of any sort of change to link behaviour
303
+ GemAccordion.prototype.addEventListenersForAnchors = function () {
304
+ var links = this.$module.querySelectorAll('.' + this.sectionInnerContent + ' a[href*="#"]')
305
+
306
+ links.forEach(function (link) {
307
+ if (link.pathname === window.location.pathname) {
308
+ link.addEventListener('click', this.openForAnchor.bind(this, link.hash))
309
+ }
310
+ }.bind(this))
311
+ }
312
+
313
+ // Find the parent accordion section for the given id and open it
314
+ GemAccordion.prototype.openForAnchor = function (hash) {
315
+ var target = document.querySelector(hash)
316
+ var section = this.getContainingSection(target)
317
+
318
+ this.setExpanded(true, section)
319
+ }
320
+
321
+ // Loop through the given ids ancestors until the parent section class is found
322
+ GemAccordion.prototype.getContainingSection = function (target) {
323
+ while (!target.classList.contains(this.sectionClass)) {
324
+ target = target.parentElement
325
+ }
326
+
327
+ return target
328
+ }
329
+
330
+ Modules.GemAccordion = GemAccordion
331
+ })(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.$acceptCookiesLink = this.$module.querySelector('button[data-accept-cookies]')
28
- if (this.$acceptCookiesLink) {
29
- this.$acceptCookiesLink.addEventListener('click', this.$module.setCookieConsent)
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,11 +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('.gem-c-cookie-banner__wrapper')
101
+ this.$cookieBannerMainContent = document.querySelector('.js-banner-wrapper')
83
102
 
84
- this.$cookieBannerMainContent.style.display = 'none'
103
+ this.$cookieBannerMainContent.hidden = true
85
104
  this.$module.cookieBannerConfirmationMessage.style.display = 'block'
105
+ this.$module.cookieBannerConfirmationMessage.hidden = false
86
106
  }
87
107
 
88
108
  CookieBanner.prototype.isInCookiesPage = function () {