govuk_publishing_components 14.0.0 → 15.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e30d0cf4decdb2a30acb643fd344d2c838e1b95dfd2de61fa50b09c6ab445af3
4
- data.tar.gz: 7b30092265431a6b3f3af79ca0dec674d84f9330025b157c92aed3e3a85e915e
3
+ metadata.gz: 23c88deb6d387134dbbd3b685859363b74ead59e037184c74a58130e36a2dff1
4
+ data.tar.gz: 8defeb9c30b3c1e5f50a39b25e2b4a59c74b119dfcfd88b342cf7c140ea81df2
5
5
  SHA512:
6
- metadata.gz: 719b37c68fce9e3975c95d7aad65d65eb2c7095f0737854fbc215e83ee6add078cc819d08d7094b04bbc1dcc9a6f5926ab390b844ba0a1d97454021a5df86845
7
- data.tar.gz: 2b0cc16fb9a17120f29f30c66e92ad5db85cb04161ead518ebe057570c76eb6401a9e42f555f31078b0a42ea01d13e9776336dc3607fd973d17d26fbe442055e
6
+ metadata.gz: 9186c00000ffd5aefd70e72229c038a8dbbfcaeec112b966c3fc50aca4e90eef3ca24f5f28cd057b8af8368819d01daa2c68cbddafecdd59a15d3bda9ab6bc22
7
+ data.tar.gz: e9194364870a3c2039dfe6e577991561c81fb1a6ab50a489579259651068267a89db9615b2882646f8f9560eb72fcf11baf54733c932000cc93051f6ee02a071
@@ -132,15 +132,53 @@
132
132
  var activeElParent = _findParent(activeEl, '[data-module="test-a11y"]')
133
133
  var wrapper = activeElParent.querySelector(resultContainerSelector)
134
134
 
135
- if (wrapper) {
136
- var resultHTML = '<h3>(' + result.id + ') ' + result.summary + ' <a href="' + result.url + '">(see guidance)</a></h3>' +
137
- '<p>' + selectorObj.reasons.join('<br />') + '</p>' +
138
- '<p>Element can be found using the selector:<br /><span class="selector">' +
139
- selectorObj.selector +
140
- '</span></p>'
141
-
142
- wrapper.insertAdjacentHTML('beforeend', resultHTML)
135
+ if (!wrapper) {
136
+ return
143
137
  }
138
+
139
+ // Section to announce the overall problem.
140
+ var headerNodeLink = document.createElement('a')
141
+ headerNodeLink.href = result.url
142
+ headerNodeLink.textContent = "(see guidance)"
143
+
144
+ var headerNode = document.createElement('h3')
145
+ headerNode.textContent = result.summary + ' (' + result.id + ') '
146
+ headerNode.appendChild(headerNodeLink)
147
+
148
+ // Section to explain the reasons
149
+ var reasonsListNode = document.createElement('ul')
150
+ selectorObj.reasons.forEach(function (reason) {
151
+ var listItemNode = document.createElement('li')
152
+ listItemNode.textContent = reason
153
+ reasonsListNode.appendChild(listItemNode)
154
+ })
155
+
156
+ var reasonsHeaderNode = document.createElement('h4')
157
+ reasonsHeaderNode.textContent = 'Possible reasons why:'
158
+
159
+ var reasonsNode = document.createElement('div')
160
+ reasonsNode.appendChild(reasonsHeaderNode)
161
+ reasonsNode.appendChild(reasonsListNode)
162
+
163
+ // Section to help find the element
164
+ var findHeader = document.createElement('h4')
165
+ findHeader.textContent = 'Element can be found using the selector:'
166
+
167
+ var findSelectorNode = document.createElement('span')
168
+ findSelectorNode.className = 'selector'
169
+ findSelectorNode.textContent = selectorObj.selector
170
+
171
+ var findNode = document.createElement('p')
172
+ findNode.appendChild(findHeader)
173
+ findNode.appendChild(findSelectorNode)
174
+
175
+ // Put all the sections together
176
+ var resultHTML = document.createElement('div')
177
+ resultHTML.appendChild(headerNode)
178
+ resultHTML.appendChild(reasonsNode)
179
+ resultHTML.appendChild(findNode)
180
+
181
+ wrapper.appendChild(resultHTML)
144
182
  })
145
183
  })
146
184
  }
@@ -23,6 +23,28 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
23
23
  }
24
24
  });
25
25
 
26
+ $(scope).find('input[type=checkbox]').on('change', function(e) {
27
+ if (GOVUK.analytics && GOVUK.analytics.trackEvent) {
28
+ var $checkbox = $(e.target);
29
+ var category = $checkbox.data("track-category");
30
+ if (typeof category !== "undefined") {
31
+ var isChecked = $checkbox.is(":checked");
32
+ var uncheckTrackCategory = $checkbox.data("uncheck-track-category");
33
+ if (!isChecked && typeof uncheckTrackCategory !== "undefined") {
34
+ category = uncheckTrackCategory;
35
+ }
36
+ var action = $checkbox.data("track-action");
37
+ var options = $checkbox.data("track-options");
38
+ if (typeof options !== 'object' || options === null) {
39
+ options = {};
40
+ }
41
+ options['value'] = $checkbox.data("track-value");
42
+ options['label'] = $checkbox.data("track-label");
43
+ GOVUK.analytics.trackEvent(category, action, options);
44
+ }
45
+ }
46
+ });
47
+
26
48
  };
27
49
 
28
50
  this.toggleNestedCheckboxes = function(scope, checkbox) {
@@ -172,12 +172,9 @@
172
172
  display: none;
173
173
  }
174
174
 
175
- h3 {
176
- @include govuk-font($size: 19, $weight: bold);
177
- }
178
-
179
175
  p,
180
- h3 {
176
+ h3,
177
+ h4 {
181
178
  margin-top: 0;
182
179
  margin-bottom: $govuk-gutter / 2;
183
180
  }
@@ -190,6 +187,13 @@
190
187
  margin-top: $govuk-gutter;
191
188
  }
192
189
 
190
+ ul {
191
+ margin: 0;
192
+ padding: 0;
193
+ padding-left: 1em;
194
+ margin-bottom: 1em;
195
+ }
196
+
193
197
  .selector {
194
198
  font-style: italic;
195
199
  }
@@ -114,7 +114,7 @@ examples:
114
114
  - label: "Blue"
115
115
  value: "blue"
116
116
  checkboxes_with_data_attributes:
117
- description: Data attributes such as tracking can be applied if required. Note that for a checkbox this will not fire tracking events automatically, so if you want your tracking to work you'll need to write some tracking Javascript in the app around the component to detect it.
117
+ description: Data attributes such as tracking can be applied if required. This will fire tracking identical tracking events on check and uncheck. See below to send different events on uncheck.
118
118
  data:
119
119
  name: "With tracking"
120
120
  items:
@@ -129,6 +129,23 @@ examples:
129
129
  dimension29: "Tracked"
130
130
  }
131
131
  }
132
+ checkboxes_with_data_attributes_and_custom_uncheck_event_category:
133
+ description: It can send a different tracking event category for an uncheck. This is handled automatically
134
+ data:
135
+ name: "With tracking and a custom uncheck category"
136
+ items:
137
+ - label: "Tracked"
138
+ value: "tracked"
139
+ data_attributes: {
140
+ track_category: "checkboxClicked",
141
+ untrack_category: "checkboxUnchecked",
142
+ track_label: "/news-and-communications",
143
+ track_action: "news",
144
+ track_options: {
145
+ dimension28: 2,
146
+ dimension29: "Tracked"
147
+ }
148
+ }
132
149
  with_aria_controls_attributes:
133
150
  description: Aria controls attributes are applied to the checkboxes only if Javascript is enabled.
134
151
  data:
@@ -279,10 +279,6 @@ examples:
279
279
  <li>تابعنا باللغة العربية عبر</li>
280
280
  <li>تابعنا باللغة العربية عبر تويتر </li>
281
281
  </ul>
282
- with_bold_unstyled:
283
- data:
284
- block: |
285
- <p>This content has <strong>text in strong tags</strong>, but they are not styled as bold</p>
286
282
  with_youtube_embed:
287
283
  data:
288
284
  block: |
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '14.0.0'.freeze
2
+ VERSION = '15.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.0
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev