govuk_publishing_components 27.5.0 → 27.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5eeb1e46730d1f7b1bc3eceb3be65497a4c4f0e2d68695b21cca5ce55f617126
4
- data.tar.gz: 44aeca5c635114770a59d61dc92806bc6bb2b50c582566760fec95967fe65391
3
+ metadata.gz: 826abb0589e48d2525ea4581c2822e8c924143fd8fe1291723d8daeb9ea27aed
4
+ data.tar.gz: 3609b9bc4dd4431663e8d8a9424a366c1e62259f305eb89deea5cbd730c47459
5
5
  SHA512:
6
- metadata.gz: 548b6ce397891440ccbb4b5cce2c23f8ad5d4097d8b7fc4f4a3ff4c82f6203dcac21416e86c37321bf4c51d555bbd5eb001b5094726e47e1d36f8b0df1380c01
7
- data.tar.gz: adb5135492b5b1f4db2dcc2157ad0de43d50b367676f64c161209bb91762c4d448c7055fb04acaf6415ddf10f32db900c76629805c80be06537b99287419045d
6
+ metadata.gz: fc3b285ebf4bb142daad075031fd004e6be838ee306d4efc21e77c887f46ce8a35a91fc7d4b8a5496941e6be16b365c778b2c2a58f3e7b32c8a2863ccb1f2e92
7
+ data.tar.gz: 35d279033c32850de9356d00d89a3752203f31495b475f3810b7449ad0cb05db681d037b4f0a3b1852d635c1c9c1fb1cd5d6afb6d231341942ff742b3377e0b6
@@ -8,6 +8,24 @@
8
8
  this.start = function ($module) {
9
9
  var element = $module[0]
10
10
 
11
+ var cookieBannerEngaged = GOVUK.cookie('cookies_preferences_set')
12
+
13
+ // If not engaged, append only ?cookie-consent=not-engaged
14
+ // If engaged and rejected, append only ?cookie-consent=reject
15
+ // If engaged and accepted usage, append ?_ga=clientid if available and cookie-consent=accept
16
+
17
+ if (cookieBannerEngaged === 'false') {
18
+ this.decorate(element, 'cookie_consent=not-engaged')
19
+ return
20
+ }
21
+ var cookieConsent = GOVUK.getConsentCookie()
22
+ if (cookieConsent.usage === false) {
23
+ this.decorate(element, 'cookie_consent=reject')
24
+ return
25
+ }
26
+
27
+ this.decorate(element, 'cookie_consent=accept')
28
+
11
29
  if (!global.ga) { return }
12
30
 
13
31
  global.ga(function () {
@@ -28,6 +46,26 @@
28
46
  }
29
47
  })
30
48
  }
49
+
50
+ this.decorate = function (element, param) {
51
+ var attribute = 'href'
52
+ var attributeValue = element.getAttribute(attribute)
53
+
54
+ if (!attributeValue) {
55
+ attribute = 'action'
56
+ attributeValue = element.getAttribute(attribute)
57
+ }
58
+
59
+ if (!attributeValue) { return }
60
+
61
+ if (attributeValue.includes('?')) {
62
+ attributeValue += '&' + param
63
+ element.setAttribute(attribute, attributeValue)
64
+ } else {
65
+ attributeValue += '?' + param
66
+ element.setAttribute(attribute, attributeValue)
67
+ }
68
+ }
31
69
  }
32
70
 
33
71
  global.GOVUK = GOVUK
@@ -2,15 +2,14 @@
2
2
  ;(function (global) {
3
3
  'use strict'
4
4
 
5
- var $ = global.jQuery
6
5
  var GOVUK = global.GOVUK || {}
7
6
 
8
7
  // Only show the first {n} items in a list, documentation is in the README.md
9
8
  var PrimaryList = function (el, selector) {
10
- this.$el = $(el)
11
- this.$extraLinks = this.$el.find('li:not(' + selector + ')')
9
+ this.el = el
10
+ this.extraLinks = this.el.querySelectorAll('li:not(' + selector + ')')
12
11
  // only hide more than one extra link
13
- if (this.$extraLinks.length > 1) {
12
+ if (this.extraLinks.length > 1) {
14
13
  this.addToggleLink()
15
14
  this.hideExtraLinks()
16
15
  }
@@ -18,29 +17,35 @@
18
17
 
19
18
  PrimaryList.prototype = {
20
19
  toggleText: function () {
21
- if (this.$extraLinks.length > 1) {
22
- return '+' + this.$extraLinks.length + ' others'
20
+ if (this.extraLinks.length > 1) {
21
+ return '+' + this.extraLinks.length + ' others'
23
22
  } else {
24
- return '+' + this.$extraLinks.length + ' other'
23
+ return '+' + this.extraLinks.length + ' other'
25
24
  }
26
25
  },
27
26
  addToggleLink: function () {
28
- this.$toggleLink = $('<a href="#">' + this.toggleText() + '</a>')
29
- this.$toggleLink.click($.proxy(this.toggleLinks, this))
30
- this.$toggleLink.insertAfter(this.$el)
27
+ this.toggleLink = document.createElement('a')
28
+ this.toggleLink.href = '#'
29
+ this.toggleLink.setAttribute('aria-expanded', 'false')
30
+ this.toggleLink.innerText = this.toggleText()
31
+
32
+ this.el.parentNode.insertBefore(this.toggleLink, this.el.nextSibling)
33
+ this.toggleLink.addEventListener('click', this.toggleLinks.bind(this))
31
34
  },
32
35
  toggleLinks: function (e) {
33
36
  e.preventDefault()
34
- this.$toggleLink.remove()
37
+ this.toggleLink.remove()
35
38
  this.showExtraLinks()
36
39
  },
37
40
  hideExtraLinks: function () {
38
- this.$extraLinks.addClass('visuallyhidden')
39
- $(window).trigger('govuk.pageSizeChanged')
41
+ for (var i = 0; i < this.extraLinks.length; i++) {
42
+ this.extraLinks[i].className = 'primary-links--display-none'
43
+ }
40
44
  },
41
45
  showExtraLinks: function () {
42
- this.$extraLinks.removeClass('visuallyhidden')
43
- $(window).trigger('govuk.pageSizeChanged')
46
+ for (var i = 0; i < this.extraLinks.length; i++) {
47
+ this.extraLinks[i].className = ''
48
+ }
44
49
  }
45
50
  }
46
51
 
@@ -48,7 +53,18 @@
48
53
 
49
54
  GOVUK.primaryLinks = {
50
55
  init: function (selector) {
51
- $(selector).parent().each(function (i, el) {
56
+ var allListItems = document.querySelectorAll(selector)
57
+ var AllLists = []
58
+
59
+ for (var i = 0; i < allListItems.length; i++) {
60
+ var parent = allListItems[i].parentNode
61
+
62
+ if (AllLists.indexOf(parent) < 0) {
63
+ AllLists.push(parent)
64
+ }
65
+ }
66
+
67
+ AllLists.forEach(function (el, i) {
52
68
  new GOVUK.PrimaryList(el, selector) // eslint-disable-line no-new
53
69
  })
54
70
  }
@@ -108,3 +108,11 @@
108
108
  @include govuk-link-style-inverse;
109
109
  }
110
110
  }
111
+
112
+ // This helper class is for use by the primary links js module
113
+ // We have this custom helper here with a single rule over using the design system helper class govuk-!-display-none
114
+ // because jasmine tests don't like the "!" in the distributed helper class
115
+
116
+ .primary-links--display-none {
117
+ display: none;
118
+ }
@@ -16,6 +16,7 @@
16
16
  GovukPersonalisation::Urls.manage,
17
17
  class: 'gem-c-layout-for-public-account-menu__link govuk-link govuk-link--no-visited-state',
18
18
  'aria-current': page_is == "manage" ? "page" : nil,
19
+ data: { module: "explicit-cross-domain-links" },
19
20
  ) %>
20
21
  </li>
21
22
  <li class="gem-c-layout-for-public-account-menu__item <%= "gem-c-layout-for-public-account-menu__item--current" if page_is == "security" %>">
@@ -24,6 +25,7 @@
24
25
  GovukPersonalisation::Urls.security,
25
26
  class: 'gem-c-layout-for-public-account-menu__link govuk-link govuk-link--no-visited-state',
26
27
  'aria-current': page_is == "security" ? "page" : nil,
28
+ data: { module: "explicit-cross-domain-links" },
27
29
  ) %>
28
30
  </li>
29
31
  </ul>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "27.5.0".freeze
2
+ VERSION = "27.6.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: 27.5.0
4
+ version: 27.6.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: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2021-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config