govuk_publishing_components 21.9.0 → 21.10.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: d362c075a89db5f3d1587d72e9a3d0c8070cbe2713a35b778fdb3d545b36e487
4
- data.tar.gz: 1dc4a84c352fc5b14dcbf4f56d983c6d4393dd2fbbaca7e8bebb32ebe01c4520
3
+ metadata.gz: f3b714e4ac16dcb7d35863086c6f857ef31d142bfcc7b80f3fece4a113b96bd7
4
+ data.tar.gz: 8268154d670cdcfdc51009609e2724c9695dfa5e2f8a782133917dbdf3ab26cb
5
5
  SHA512:
6
- metadata.gz: 3a824a6145852638cedcd298c05e21298a79e23c12773f1e5cf331767ecd23966981d6cfa9e698c6e3f576ddcb22ebc92485fb1328e3eba3f20430a80705172e
7
- data.tar.gz: 7531c820a83f0132b353e5a35fdba7095f0f1a49f9899cdd26a7c99212da6fcb052e030d03488da7dfc16533a28210ac3f206c38d5c9060be8c37e778371180a
6
+ metadata.gz: 98c6cc5de694a0496ff98451e8f7a56317b92747b8c0266ca4fb4f43365731d393008fd17f87a9be00e93efa7d7e53203f9c1bd639c6bf2b28e58885950a0c24
7
+ data.tar.gz: 58b9b92e675013a7c65baa7a91e7d5b9c8cd3c673fa22a13b3bfa75429fdbbe527139b2efb88874d0ab0ed7bfc52d83d4a90414a43fbe5d2d1f4004c621fd3cd
@@ -0,0 +1,48 @@
1
+ /* eslint-env jquery */
2
+ // = require govuk/components/details/details.js
3
+ window.GOVUK = window.GOVUK || {}
4
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
5
+
6
+ (function (Modules) {
7
+ 'use strict'
8
+
9
+ Modules.GovukDetails = function () {
10
+ this.start = function (element) {
11
+ var customTrackLabel = element[0].getAttribute('data-track-label')
12
+
13
+ // If a custom label has been provided, we can simply call the tracking module
14
+ if (customTrackLabel) {
15
+ var trackDetails = new window.GOVUK.Modules.TrackClick()
16
+ trackDetails.start(element)
17
+ } else {
18
+ // If no custom label is set, we use the open/close status as the label
19
+ var detailsComponent = element[0]
20
+ var detailsClick = detailsComponent.querySelector('[data-details-track-click]')
21
+ var that = this
22
+
23
+ $(detailsClick).click(function (e) {
24
+ that.trackDefault(detailsComponent)
25
+ })
26
+ }
27
+ }
28
+
29
+ this.trackDefault = function (element) {
30
+ if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
31
+ var componentStatus = (element.getAttribute('open') == null) ? 'open' : 'closed'
32
+ var trackCategory = element.getAttribute('data-track-category')
33
+ var trackAction = element.getAttribute('data-track-action')
34
+ var trackOptions = element.getAttribute('data-track-options')
35
+
36
+ if (typeof trackOptions !== 'object' || trackOptions === null) {
37
+ trackOptions = {}
38
+ }
39
+
40
+ trackOptions['label'] = componentStatus
41
+
42
+ if (trackAction && trackCategory) {
43
+ window.GOVUK.analytics.trackEvent(trackCategory, trackAction, trackOptions)
44
+ }
45
+ }
46
+ }
47
+ }
48
+ })(window.GOVUK.Modules)
@@ -10,7 +10,7 @@
10
10
  data_attributes[:module] = 'govuk-details'
11
11
  %>
12
12
  <%= tag.details class: css_classes, data: data_attributes, open: open do %>
13
- <summary class="govuk-details__summary">
13
+ <summary class="govuk-details__summary" data-details-track-click>
14
14
  <span class="govuk-details__summary-text">
15
15
  <%= title %>
16
16
  </span>
@@ -22,6 +22,18 @@ examples:
22
22
  block: |
23
23
  We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
24
24
  with_data_attributes:
25
+ description: Can be used for tracking. By default, `track-label` is set to the status ("open" or "closed") unless a track_label is passed into the component.
26
+ data:
27
+ title: Help with nationality
28
+ data_attributes:
29
+ track_category: "checker-qa"
30
+ track_action: "business-question"
31
+ track_label: "custom label here"
32
+ track_options:
33
+ dimension20: "custom dimension"
34
+ block: |
35
+ We need to know your nationality so we can work out which elections you’re entitled to vote in. If you can’t provide your nationality, you’ll have to send copies of identity documents through the post.
36
+ with_GTM_tracking:
25
37
  data:
26
38
  title: Help with nationality
27
39
  data_attributes:
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '21.9.0'.freeze
2
+ VERSION = '21.10.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: 21.9.0
4
+ version: 21.10.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: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2019-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters
@@ -405,6 +405,7 @@ files:
405
405
  - app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
406
406
  - app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js
407
407
  - app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js
408
+ - app/assets/javascripts/govuk_publishing_components/components/details.js
408
409
  - app/assets/javascripts/govuk_publishing_components/components/error-summary.js
409
410
  - app/assets/javascripts/govuk_publishing_components/components/feedback.js
410
411
  - app/assets/javascripts/govuk_publishing_components/components/govspeak.js