govuk_publishing_components 21.39.0 → 21.40.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: ff2fe73b82ef71aeb0ce329e0fb6ab6bb3df3fa73fd537fb0e536d957bb87092
4
- data.tar.gz: 5340063122d7e758adf2d00c68812b79857aa5964b31d22d44ff584da4358018
3
+ metadata.gz: 63dfbf28131b9d02a6fe9cc587901cc54bc4bf7ecdf473d04824732a1c03eee5
4
+ data.tar.gz: 8415012a0eefb26a1f54ef8e1d2310fc61d02bdec7f43ff9e3041c91dd98ec0b
5
5
  SHA512:
6
- metadata.gz: 8c04af35d200c2d4b9c0c62f478e0e412972213fc2d68ba5419903bfc822cea426c5e77f4ddf88c58685c38493cffbf222ec80007978108e7045030d684715ff
7
- data.tar.gz: 47ece57365deebe9c156b22564477c982d5733414ecbfba42923eff8c7aed42dc38d0c6ddaa5279bf956170ad92266acd2a8751a05888716c1967751c425f7bc
6
+ metadata.gz: 9e1d62f88bf158b77955d8de348da26f8e409907942f9b2d288134dc39395aa93078d7c39a0b71a432968b73cc74e85fc0198bb134e70da16afcf827dc132688
7
+ data.tar.gz: 849e4796616742e246dd230e50805c6ad3e7d6d03395c03d10a1a7c5f4fc6e9b2aa2b6ed6381e9a843bdf41e3a28cddd8c702beb66758351a286060d99799783
@@ -17,9 +17,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
17
17
  }
18
18
 
19
19
  CookieBanner.prototype.setupCookieMessage = function () {
20
- this.$hideLink = this.$module.querySelector('button[data-hide-cookie-banner]')
21
- if (this.$hideLink) {
22
- this.$hideLink.addEventListener('click', this.$module.hideCookieMessage)
20
+ this.$hideLinks = this.$module.querySelectorAll('button[data-hide-cookie-banner]')
21
+ if (this.$hideLinks && this.$hideLinks.length) {
22
+ for (var i = 0; i < this.$hideLinks.length; i++) {
23
+ this.$hideLinks[i].addEventListener('click', this.$module.hideCookieMessage)
24
+ }
23
25
  }
24
26
 
25
27
  this.$acceptCookiesLink = this.$module.querySelector('button[data-accept-cookies]')
@@ -21,17 +21,30 @@
21
21
  for (var i = 0; i < $youtubeLinks.length; ++i) {
22
22
  var $link = $youtubeLinks[i]
23
23
  var href = $link.getAttribute('href')
24
+ var hasTracking = $link.getAttribute('data-youtube-player-analytics') == "true"
25
+ var options = {
26
+ link: $link
27
+ }
28
+
29
+ if (hasTracking) {
30
+ options.tracking = {
31
+ hasTracking: hasTracking,
32
+ category: $link.getAttribute('data-youtube-player-analytics-category')
33
+ }
34
+ }
24
35
 
25
36
  if (href.includes("/live_stream")) {
26
37
  var channelId = YoutubeLinkEnhancement.parseLivestream(href)
27
38
 
28
39
  if (!this.hasDisabledEmbed($link) && channelId) {
29
- this.setupVideo({link: $link, channel: channelId})
40
+ options.channelId = channelId
41
+ this.setupVideo(options)
30
42
  }
31
43
  } else {
32
44
  var videoId = YoutubeLinkEnhancement.parseVideoId(href)
33
45
  if (!this.hasDisabledEmbed($link) && videoId) {
34
- this.setupVideo({link: $link, videoId: videoId})
46
+ options.videoId = videoId
47
+ this.setupVideo(options)
35
48
  }
36
49
  }
37
50
  }
@@ -94,6 +107,28 @@
94
107
  // update iframe title attribute once video is ready
95
108
  var videoTitle = options.title
96
109
  event.target.f.title = videoTitle + ' (video)'
110
+ },
111
+ onStateChange: function (event) {
112
+ var states = {
113
+ "-1": "VideoUnstarted",
114
+ "0": "VideoEnded",
115
+ "1": "VideoPlaying",
116
+ "2": "VideoPaused",
117
+ "3": "VideoBuffering",
118
+ "5": "VideoCued"
119
+ }
120
+
121
+ if (states[event.data] && options.tracking && options.tracking.hasTracking
122
+ && window.GOVUK.analytics && window.GOVUK.analytics.trackEvent)
123
+ {
124
+ var tracking = {
125
+ category: options.tracking.category,
126
+ action: states[event.data],
127
+ label: { transport: 'beacon', label: event.target.getVideoUrl() }
128
+ }
129
+
130
+ window.GOVUK.analytics.trackEvent(tracking.category, tracking.action, tracking.label)
131
+ }
97
132
  }
98
133
  }
99
134
  })
@@ -33,7 +33,6 @@
33
33
  <%= link_to(attachment.title, attachment.url,
34
34
  class: "govuk-link",
35
35
  target: target,
36
- data: data_attributes) %>
37
-
38
- <%= raw("(#{attributes.join(', ')})") if attributes.any? %>
36
+ data: data_attributes) -%>
37
+ <%= raw("(#{attributes.join(', ')})") if attributes.any? -%>
39
38
  <% end %>
@@ -290,6 +290,17 @@ examples:
290
290
  block: |
291
291
  <p>This content has a YouTube livestream link, converted to an accessible embedded player by component JavaScript.</p>
292
292
  <p><a href="https://www.youtube.com/embed/live_stream?channel=UCoMdktPbSTixAyNGwb-UYkQ">Livestream video</a></p>
293
+ with_youtube_analytics:
294
+ data:
295
+ block: |
296
+ <p>This content has a YouTube link with analytics, converted to an accessible embedded player by component JavaScript.</p>
297
+ <p>
298
+ <a href="https://www.youtube.com/watch?v=ucjmWjJ25Ho"
299
+ data-youtube-player-analytics="true"
300
+ data-youtube-player-analytics-category="demo-for-components">
301
+ Youtube video with tracking
302
+ </a>
303
+ </p>
293
304
  with_youtube_embed_disabled:
294
305
  data:
295
306
  disable_youtube_expansions: true
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "21.39.0".freeze
2
+ VERSION = "21.40.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.39.0
4
+ version: 21.40.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-04-08 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters