govuk_publishing_components 30.2.1 → 30.3.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/page-content.js +8 -0
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-link-tracker.js +6 -2
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +0 -22
- data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +2 -3
- data/app/views/govuk_publishing_components/components/docs/textarea.yml +7 -0
- data/lib/govuk_publishing_components/presenters/checkboxes_helper.rb +2 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3e967d80364c5bc79a3d6ae1338e28e4713dfbb9d4e07a6b6fda984e177e8db
|
4
|
+
data.tar.gz: 80a99542db952464b49e1b1468fb320ae5c5a997d62bd2fad49d1dd880591568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 973d005a28142f232b29ed9cb4669e57a39bbfe45403ae69ff56a94bfe8f263571ee1e51143f4dcdf75fb9fd0dc4d978fe5b957853c046ec6c1450cf0d2dd174
|
7
|
+
data.tar.gz: 1cbdfbba36fa2a140c33fb4aadbd5797d9dd4fff255b8f2d3d77ade1962dae343d322f34ff4b55001d79b914b7d1a954d800f2697e01c02fd6700d74648c0dc2
|
@@ -17,6 +17,8 @@
|
|
17
17
|
// if there are no accordion sections on the browse level 2 page
|
18
18
|
// then it is a default page with one or two lists
|
19
19
|
return document.querySelectorAll('[data-track-count="accordionSection"]').length || document.querySelectorAll('main .govuk-list').length
|
20
|
+
case isCostOfLivingHub():
|
21
|
+
return document.querySelectorAll('[data-track-count="accordionSection"]').length
|
20
22
|
case isNewBrowsePage():
|
21
23
|
return document.querySelectorAll('[data-track-count="cardList"]').length
|
22
24
|
case isMainstreamBrowsePage():
|
@@ -51,6 +53,7 @@
|
|
51
53
|
case isDocumentCollectionPage():
|
52
54
|
return document.querySelectorAll('.document-collection .group-document-list li a').length
|
53
55
|
case isNewBrowsePageLevelTwo():
|
56
|
+
case isCostOfLivingHub():
|
54
57
|
return document.querySelectorAll('[data-track-count="contentLink"]').length
|
55
58
|
case isNewBrowsePage():
|
56
59
|
return document.querySelectorAll('[data-track-count="cardLink"]').length
|
@@ -108,6 +111,11 @@
|
|
108
111
|
getMetaAttribute(metaNavigationTypeSelector) === 'browse level 2'
|
109
112
|
}
|
110
113
|
|
114
|
+
function isCostOfLivingHub () {
|
115
|
+
return getMetaAttribute(metaApplicationSelector) === 'collections' &&
|
116
|
+
getMetaAttribute(metaNavigationTypeSelector) === 'cost of living hub'
|
117
|
+
}
|
118
|
+
|
111
119
|
function isNewBrowsePage () {
|
112
120
|
return getMetaAttribute(metaApplicationSelector) === 'collections' &&
|
113
121
|
(getMetaAttribute(metaNavigationTypeSelector) === 'browse level 0' ||
|
@@ -61,7 +61,7 @@
|
|
61
61
|
clickData.link_method = this.getClickType(event)
|
62
62
|
|
63
63
|
var schema = new window.GOVUK.analyticsGA4.Schemas().eventSchema()
|
64
|
-
schema.event = '
|
64
|
+
schema.event = 'event_data'
|
65
65
|
|
66
66
|
// get attributes from the clickData object to send to GA
|
67
67
|
// only allow it if it already exists in the schema
|
@@ -124,7 +124,7 @@
|
|
124
124
|
|
125
125
|
isExternalLink: function (href) {
|
126
126
|
var isInternalLink = this.hrefPointsToDomain(href, this.internalLinksDomain) || this.hrefPointsToDomain(href, this.internalLinksDomainWithoutWww)
|
127
|
-
if (!isInternalLink && !this.hrefIsRelative(href)) {
|
127
|
+
if (!isInternalLink && !this.hrefIsRelative(href) && !this.hrefIsAnchor(href)) {
|
128
128
|
return true
|
129
129
|
}
|
130
130
|
},
|
@@ -146,6 +146,10 @@
|
|
146
146
|
hrefIsRelative: function (href) {
|
147
147
|
// Checks that a link is relative, but is not a protocol relative url
|
148
148
|
return href[0] === '/' && href[1] !== '/'
|
149
|
+
},
|
150
|
+
|
151
|
+
hrefIsAnchor: function (href) {
|
152
|
+
return href[0] === '#'
|
149
153
|
}
|
150
154
|
}
|
151
155
|
|
@@ -9,7 +9,6 @@ window.GOVUK.Modules.GovukCheckboxes = window.GOVUKFrontend.Checkboxes;
|
|
9
9
|
this.$module = $module
|
10
10
|
this.$checkboxes = this.$module.querySelectorAll('input[type=checkbox]')
|
11
11
|
this.$nestedCheckboxes = this.$module.querySelectorAll('[data-nested=true] input[type=checkbox]')
|
12
|
-
this.$exclusiveCheckboxes = this.$module.querySelectorAll('[data-exclusive=true] input[type=checkbox]')
|
13
12
|
}
|
14
13
|
|
15
14
|
GemCheckboxes.prototype.init = function () {
|
@@ -22,10 +21,6 @@ window.GOVUK.Modules.GovukCheckboxes = window.GOVUKFrontend.Checkboxes;
|
|
22
21
|
for (i = 0; i < this.$nestedCheckboxes.length; i++) {
|
23
22
|
this.$nestedCheckboxes[i].addEventListener('change', this.handleNestedCheckboxChange.bind(this))
|
24
23
|
}
|
25
|
-
|
26
|
-
for (i = 0; i < this.$exclusiveCheckboxes.length; i++) {
|
27
|
-
this.$exclusiveCheckboxes[i].addEventListener('change', this.handleExclusiveCheckboxChange)
|
28
|
-
}
|
29
24
|
}
|
30
25
|
|
31
26
|
GemCheckboxes.prototype.handleCheckboxChange = function (event) {
|
@@ -95,23 +90,6 @@ window.GOVUK.Modules.GovukCheckboxes = window.GOVUKFrontend.Checkboxes;
|
|
95
90
|
}
|
96
91
|
}
|
97
92
|
|
98
|
-
GemCheckboxes.prototype.handleExclusiveCheckboxChange = function (event) {
|
99
|
-
var $currentCheckbox = event.target
|
100
|
-
var $checkboxes = $currentCheckbox.closest('.govuk-checkboxes')
|
101
|
-
var $exclusiveOption = $checkboxes.querySelector('input[type=checkbox][data-exclusive]')
|
102
|
-
var $nonExclusiveOptions = $checkboxes.querySelectorAll('input[type=checkbox]:not([data-exclusive])')
|
103
|
-
|
104
|
-
if ($currentCheckbox.getAttribute('data-exclusive') === 'true' && $currentCheckbox.checked === true) {
|
105
|
-
for (var i = 0; i < $nonExclusiveOptions.length; i++) {
|
106
|
-
$nonExclusiveOptions[i].checked = false
|
107
|
-
}
|
108
|
-
} else if ($currentCheckbox.getAttribute('data-exclusive') !== 'true' && $currentCheckbox.checked === true) {
|
109
|
-
if ($exclusiveOption) {
|
110
|
-
$exclusiveOption.checked = false
|
111
|
-
}
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
93
|
GemCheckboxes.prototype.applyAriaControlsAttributes = function ($scope) {
|
116
94
|
var $inputs = $scope.querySelectorAll('[data-controls]')
|
117
95
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
id = cb_helper.id
|
5
5
|
%>
|
6
6
|
|
7
|
-
<%= tag.div id: id, class: cb_helper.css_classes, data: { module: "gem-checkboxes" } do %>
|
7
|
+
<%= tag.div id: id, class: cb_helper.css_classes, data: { module: "gem-checkboxes govuk-checkboxes" } do %>
|
8
8
|
<% if cb_helper.should_have_fieldset %>
|
9
9
|
<% if cb_helper.heading_markup %>
|
10
10
|
<%= tag.fieldset class: "govuk-fieldset", "aria-describedby": cb_helper.fieldset_describedby do %>
|
@@ -24,8 +24,7 @@
|
|
24
24
|
|
25
25
|
<%= tag.ul class: cb_helper.list_classes, data: {
|
26
26
|
module: ('govuk-checkboxes' if cb_helper.has_conditional),
|
27
|
-
nested: ('true' if cb_helper.has_nested)
|
28
|
-
exclusive: ('true' if cb_helper.has_exclusive)
|
27
|
+
nested: ('true' if cb_helper.has_nested)
|
29
28
|
} do %>
|
30
29
|
<% cb_helper.items.each_with_index do |item, index| %>
|
31
30
|
<% if item === :or %>
|
@@ -103,3 +103,10 @@ examples:
|
|
103
103
|
name: "described"
|
104
104
|
rows: 2
|
105
105
|
describedby: "contextual-guidance"
|
106
|
+
with_data_attributes:
|
107
|
+
data:
|
108
|
+
label:
|
109
|
+
text: "This textarea has a data attribute"
|
110
|
+
name: "with_data_attrbutes"
|
111
|
+
data:
|
112
|
+
module: "some-awesome-module-here"
|
@@ -14,8 +14,7 @@ module GovukPublishingComponents
|
|
14
14
|
:id,
|
15
15
|
:hint_text,
|
16
16
|
:description,
|
17
|
-
:heading_caption
|
18
|
-
:has_exclusive
|
17
|
+
:heading_caption
|
19
18
|
|
20
19
|
def initialize(options)
|
21
20
|
@items = options[:items] || []
|
@@ -29,7 +28,6 @@ module GovukPublishingComponents
|
|
29
28
|
|
30
29
|
# check if any item is set as being conditional
|
31
30
|
@has_conditional = options[:items].any? { |item| item.is_a?(Hash) && item[:conditional] }
|
32
|
-
@has_exclusive = options[:items].any? { |item| item.is_a?(Hash) && item[:exclusive] }
|
33
31
|
@has_nested = options[:items].any? { |item| item.is_a?(Hash) && item[:items] }
|
34
32
|
|
35
33
|
@id = options[:id] || "checkboxes-#{SecureRandom.hex(4)}"
|
@@ -97,7 +95,7 @@ module GovukPublishingComponents
|
|
97
95
|
data = checkbox[:data_attributes] || {}
|
98
96
|
data[:controls] = controls
|
99
97
|
data["aria-controls"] = aria_controls
|
100
|
-
data[:
|
98
|
+
data[:behaviour] = "exclusive" if checkbox[:exclusive]
|
101
99
|
|
102
100
|
capture do
|
103
101
|
concat check_box_tag checkbox_name, checkbox[:value], checked, class: "govuk-checkboxes__input", id: checkbox_id, data: data
|
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: 30.
|
4
|
+
version: 30.3.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: 2022-08-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|
@@ -1937,7 +1937,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1937
1937
|
- !ruby/object:Gem::Version
|
1938
1938
|
version: '0'
|
1939
1939
|
requirements: []
|
1940
|
-
rubygems_version: 3.3.
|
1940
|
+
rubygems_version: 3.3.21
|
1941
1941
|
signing_key:
|
1942
1942
|
specification_version: 4
|
1943
1943
|
summary: A gem to document components in GOV.UK frontend applications
|