govuk_publishing_components 23.4.0 → 23.5.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: c709998b8885c2971dd9a8748371d99a0153037f2d39e7776eadcad3dfc9870b
4
- data.tar.gz: 6e71541e40cc1c636639c8b09650a526d29745161db15b1f99a821375395f07b
3
+ metadata.gz: ccb3ff988da8eed7ce14013d8f0a0f054661b7ee9322a2caa75ab49a5b064162
4
+ data.tar.gz: b115615020b7694cab625d98ee0abe11e98306d8776c7afb3ffd400d642fe32c
5
5
  SHA512:
6
- metadata.gz: 865a9b6d06c7bb7cbae057bb37e289e784a3ffec53352e491e1492a0d71bd774d2f5596d78379b6c4da1ffab046a01b7de597669e9606c5410caffe5c2a2df6b
7
- data.tar.gz: e91cd02916c1bb0c8f25687c481b7ce61890f51c404ea5625b64411ef38e2347c978c833916103465acfea5e31560dfa81209e619576bbb507538e85649342f8
6
+ metadata.gz: cfb2771a84017aca9fc781ea5d650a1402cbf1a88770993e222e42cfe0aa946e14569c14add10ae41dd5ee7619ce028dcfaf501049b7738e56d71afe65f7d2d0
7
+ data.tar.gz: 571a20b867d372fefc21d4dcf451fd59c56530146fb7c7e258a878320c905ff408f60ce793675a2fba6fbbdedc94fea17adc310eff84529d34b0529193a7f58c
@@ -2,22 +2,24 @@ window.GOVUK = window.GOVUK || {}
2
2
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
3
 
4
4
  (function (Modules) {
5
- 'use strict'
5
+ function CopyToClipboard () { }
6
6
 
7
- Modules.CopyToClipboard = function () {
8
- this.start = function (element) {
9
- var input = element[0].querySelector('.gem-c-input')
10
- var copyButton = element[0].querySelector('.gem-c-button')
7
+ CopyToClipboard.prototype.start = function ($module) {
8
+ this.$module = $module[0]
11
9
 
12
- input.addEventListener('click', function () {
13
- input.select()
14
- })
10
+ var input = this.$module.querySelector('.gem-c-input')
11
+ var copyButton = this.$module.querySelector('.gem-c-button')
15
12
 
16
- copyButton.addEventListener('click', function (event) {
17
- event.preventDefault()
18
- input.select()
19
- document.execCommand('copy')
20
- })
21
- }
13
+ input.addEventListener('click', function () {
14
+ input.select()
15
+ })
16
+
17
+ copyButton.addEventListener('click', function (event) {
18
+ event.preventDefault()
19
+ input.select()
20
+ document.execCommand('copy')
21
+ })
22
22
  }
23
+
24
+ Modules.CopyToClipboard = CopyToClipboard
23
25
  })(window.GOVUK.Modules)
@@ -4,47 +4,51 @@ window.GOVUK = window.GOVUK || {}
4
4
  window.GOVUK.Modules = window.GOVUK.Modules || {};
5
5
 
6
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
- if (detailsClick) {
24
- detailsClick.addEventListener('click', function (event) {
25
- that.trackDefault(detailsComponent)
26
- })
27
- }
7
+ function GovukDetails () { }
8
+
9
+ GovukDetails.prototype.start = function ($module) {
10
+ this.$module = $module[0]
11
+
12
+ var customTrackLabel = this.$module.getAttribute('data-track-label')
13
+
14
+ // If a custom label has been provided, we can simply call the tracking module
15
+ if (customTrackLabel) {
16
+ var trackDetails = new window.GOVUK.Modules.TrackClick()
17
+ trackDetails.start($module)
18
+ } else {
19
+ // If no custom label is set, we use the open/close status as the label
20
+ var detailsClick = this.$module.querySelector('[data-details-track-click]')
21
+
22
+ if (detailsClick) {
23
+ detailsClick.addEventListener('click', function (event) {
24
+ this.trackDefault(this.$module)
25
+ }.bind(this))
28
26
  }
29
27
  }
28
+ }
30
29
 
31
- this.trackDefault = function (element) {
32
- if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
33
- var componentStatus = (element.getAttribute('open') == null) ? 'open' : 'closed'
34
- var trackCategory = element.getAttribute('data-track-category')
35
- var trackAction = element.getAttribute('data-track-action')
36
- var trackOptions = element.getAttribute('data-track-options')
30
+ GovukDetails.prototype.trackDefault = function (element) {
31
+ if (window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
32
+ var componentStatus = (element.getAttribute('open') == null) ? 'open' : 'closed'
33
+ var trackCategory = element.getAttribute('data-track-category')
34
+ var trackAction = element.getAttribute('data-track-action')
35
+ var trackOptions = element.getAttribute('data-track-options')
37
36
 
38
- if (typeof trackOptions !== 'object' || trackOptions === null) {
39
- trackOptions = {}
40
- }
37
+ if (trackOptions) {
38
+ trackOptions = JSON.parse(trackOptions)
39
+ }
40
+
41
+ if (typeof trackOptions !== 'object' || trackOptions === null) {
42
+ trackOptions = {}
43
+ }
41
44
 
42
- trackOptions.label = componentStatus
45
+ trackOptions.label = componentStatus
43
46
 
44
- if (trackAction && trackCategory) {
45
- window.GOVUK.analytics.trackEvent(trackCategory, trackAction, trackOptions)
46
- }
47
+ if (trackAction && trackCategory) {
48
+ window.GOVUK.analytics.trackEvent(trackCategory, trackAction, trackOptions)
47
49
  }
48
50
  }
49
51
  }
52
+
53
+ Modules.GovukDetails = GovukDetails
50
54
  })(window.GOVUK.Modules)
@@ -2,13 +2,14 @@ window.GOVUK = window.GOVUK || {}
2
2
  window.GOVUK.Modules = window.GOVUK.Modules || {};
3
3
 
4
4
  (function (Modules) {
5
- 'use strict'
5
+ function PrintLink () { }
6
6
 
7
- Modules.PrintLink = function () {
8
- this.start = function (element) {
9
- element[0].addEventListener('click', function () {
10
- window.print()
11
- })
12
- }
7
+ PrintLink.prototype.start = function ($module) {
8
+ this.$module = $module[0]
9
+ this.$module.addEventListener('click', function () {
10
+ window.print()
11
+ })
13
12
  }
13
+
14
+ Modules.PrintLink = PrintLink
14
15
  })(window.GOVUK.Modules)
@@ -0,0 +1,13 @@
1
+ window.GOVUK = window.GOVUK || {}
2
+ window.GOVUK.Modules = window.GOVUK.Modules || {};
3
+
4
+ (function (Modules) {
5
+ function InitialFocus () { }
6
+
7
+ InitialFocus.prototype.start = function ($module) {
8
+ this.$module = $module[0]
9
+ this.$module.focus()
10
+ }
11
+
12
+ Modules.InitialFocus = InitialFocus
13
+ })(window.GOVUK.Modules)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "23.4.0".freeze
2
+ VERSION = "23.5.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: 23.4.0
4
+ version: 23.5.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: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -425,7 +425,6 @@ files:
425
425
  - app/assets/javascripts/govuk_publishing_components/components/feedback.js
426
426
  - app/assets/javascripts/govuk_publishing_components/components/govspeak.js
427
427
  - app/assets/javascripts/govuk_publishing_components/components/header.js
428
- - app/assets/javascripts/govuk_publishing_components/components/initial-focus.js
429
428
  - app/assets/javascripts/govuk_publishing_components/components/modal-dialogue.js
430
429
  - app/assets/javascripts/govuk_publishing_components/components/print-link.js
431
430
  - app/assets/javascripts/govuk_publishing_components/components/radio.js
@@ -441,6 +440,7 @@ files:
441
440
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/magna-charta.js
442
441
  - app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
443
442
  - app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
443
+ - app/assets/javascripts/govuk_publishing_components/lib/initial-focus.js
444
444
  - app/assets/javascripts/govuk_publishing_components/lib/primary-links.js
445
445
  - app/assets/javascripts/govuk_publishing_components/lib/select.js
446
446
  - app/assets/javascripts/govuk_publishing_components/lib/toggle-input-class-on-focus.js
@@ -1,12 +0,0 @@
1
- window.GOVUK = window.GOVUK || {}
2
- window.GOVUK.Modules = window.GOVUK.Modules || {};
3
-
4
- (function (Modules) {
5
- 'use strict'
6
-
7
- Modules.InitialFocus = function () {
8
- this.start = function (element) {
9
- element.focus()
10
- }
11
- }
12
- })(window.GOVUK.Modules)