govuk_publishing_components 27.5.0 → 27.6.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/analytics/explicit-cross-domain-links.js +38 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/primary-links.js +32 -16
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss +8 -0
- data/app/views/govuk_publishing_components/components/layout_for_public/_account-navigation.html.erb +2 -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: 826abb0589e48d2525ea4581c2822e8c924143fd8fe1291723d8daeb9ea27aed
|
4
|
+
data.tar.gz: 3609b9bc4dd4431663e8d8a9424a366c1e62259f305eb89deea5cbd730c47459
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3b285ebf4bb142daad075031fd004e6be838ee306d4efc21e77c887f46ce8a35a91fc7d4b8a5496941e6be16b365c778b2c2a58f3e7b32c8a2863ccb1f2e92
|
7
|
+
data.tar.gz: 35d279033c32850de9356d00d89a3752203f31495b475f3810b7449ad0cb05db681d037b4f0a3b1852d635c1c9c1fb1cd5d6afb6d231341942ff742b3377e0b6
|
data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js
CHANGED
@@ -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
|
11
|
-
this
|
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
|
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
|
22
|
-
return '+' + this
|
20
|
+
if (this.extraLinks.length > 1) {
|
21
|
+
return '+' + this.extraLinks.length + ' others'
|
23
22
|
} else {
|
24
|
-
return '+' + this
|
23
|
+
return '+' + this.extraLinks.length + ' other'
|
25
24
|
}
|
26
25
|
},
|
27
26
|
addToggleLink: function () {
|
28
|
-
this
|
29
|
-
this
|
30
|
-
this
|
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
|
37
|
+
this.toggleLink.remove()
|
35
38
|
this.showExtraLinks()
|
36
39
|
},
|
37
40
|
hideExtraLinks: function () {
|
38
|
-
this
|
39
|
-
|
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
|
43
|
-
|
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
|
-
|
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
|
}
|
data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_typography.scss
CHANGED
@@ -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
|
+
}
|
data/app/views/govuk_publishing_components/components/layout_for_public/_account-navigation.html.erb
CHANGED
@@ -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>
|
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.
|
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
|
+
date: 2021-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|