govuk_publishing_components 28.0.0 → 28.4.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/auto-scroll-tracker.js +2 -1
- data/app/assets/javascripts/govuk_publishing_components/analytics/auto-track-event.js +22 -22
- data/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js +2 -20
- data/app/assets/javascripts/govuk_publishing_components/analytics/mailto-link-tracker.js +22 -17
- data/app/assets/javascripts/govuk_publishing_components/analytics/pii.js +9 -5
- data/app/assets/javascripts/govuk_publishing_components/analytics/static-analytics.js +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics/track-click.js +4 -3
- data/app/assets/javascripts/govuk_publishing_components/analytics.js +1 -1
- data/app/assets/javascripts/govuk_publishing_components/components/checkboxes.js +0 -1
- data/app/assets/javascripts/govuk_publishing_components/components/details.js +2 -3
- data/app/assets/javascripts/govuk_publishing_components/components/metadata.js +27 -0
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/barchart-enhancement.js +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_big-number.scss +5 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +0 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +67 -21
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +6 -0
- data/app/views/govuk_publishing_components/components/_big_number.html.erb +19 -9
- data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +0 -4
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +22 -18
- data/app/views/govuk_publishing_components/components/_metadata.html.erb +2 -2
- data/app/views/govuk_publishing_components/components/_share_links.html.erb +25 -22
- data/app/views/govuk_publishing_components/components/docs/accordion.yml +31 -25
- data/app/views/govuk_publishing_components/components/docs/big_number.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +0 -47
- data/app/views/govuk_publishing_components/components/docs/input.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
- data/app/views/govuk_publishing_components/components/docs/tabs.yml +2 -2
- data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +26 -0
- data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +16 -8
- data/config/locales/en.yml +0 -4
- data/lib/govuk_publishing_components/presenters/big_number_helper.rb +30 -0
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +0 -38
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/lib/govuk_publishing_components.rb +1 -0
- metadata +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +0 -112
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_covid_cta.html.erb +0 -27
@@ -1,112 +0,0 @@
|
|
1
|
-
/* global GOVUK, $ */
|
2
|
-
|
3
|
-
(function () {
|
4
|
-
'use strict'
|
5
|
-
|
6
|
-
window.GOVUK = window.GOVUK || {}
|
7
|
-
|
8
|
-
var CONFIG = {}
|
9
|
-
|
10
|
-
function ScrollTracker (sitewideConfig) {
|
11
|
-
this.config = this.getConfigForCurrentPath(sitewideConfig)
|
12
|
-
this.SCROLL_TIMEOUT_DELAY = 10
|
13
|
-
|
14
|
-
if (!this.config) {
|
15
|
-
this.enabled = false
|
16
|
-
return
|
17
|
-
}
|
18
|
-
this.enabled = true
|
19
|
-
|
20
|
-
this.trackedNodes = this.buildNodes(this.config)
|
21
|
-
|
22
|
-
$(window).scroll($.proxy(this.onScroll, this))
|
23
|
-
this.trackVisibleNodes()
|
24
|
-
};
|
25
|
-
|
26
|
-
ScrollTracker.prototype.getConfigForCurrentPath = function (sitewideConfig) {
|
27
|
-
for (var path in sitewideConfig) {
|
28
|
-
if (this.normalisePath(window.location.pathname) === this.normalisePath(path)) {
|
29
|
-
return sitewideConfig[path]
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
|
34
|
-
ScrollTracker.prototype.buildNodes = function (config) {
|
35
|
-
var nodes = []
|
36
|
-
var NodeConstructor, nodeData
|
37
|
-
|
38
|
-
for (var i = 0; i < config.length; i++) {
|
39
|
-
NodeConstructor = ScrollTracker[config[i][0] + 'Node']
|
40
|
-
nodeData = config[i][1]
|
41
|
-
nodes.push(new NodeConstructor(nodeData))
|
42
|
-
}
|
43
|
-
|
44
|
-
return nodes
|
45
|
-
}
|
46
|
-
|
47
|
-
ScrollTracker.prototype.normalisePath = function (path) {
|
48
|
-
return path.split('/').join('')
|
49
|
-
}
|
50
|
-
|
51
|
-
ScrollTracker.prototype.onScroll = function () {
|
52
|
-
clearTimeout(this.scrollTimeout)
|
53
|
-
this.scrollTimeout = setTimeout($.proxy(this.trackVisibleNodes, this), this.SCROLL_TIMEOUT_DELAY)
|
54
|
-
}
|
55
|
-
|
56
|
-
ScrollTracker.prototype.trackVisibleNodes = function () {
|
57
|
-
for (var i = 0; i < this.trackedNodes.length; i++) {
|
58
|
-
if (this.trackedNodes[i].isVisible() && !this.trackedNodes[i].alreadySeen) {
|
59
|
-
this.trackedNodes[i].alreadySeen = true
|
60
|
-
|
61
|
-
var action = this.trackedNodes[i].eventData.action
|
62
|
-
var label = this.trackedNodes[i].eventData.label
|
63
|
-
|
64
|
-
GOVUK.analytics.trackEvent('ScrollTo', action, { label: label, nonInteraction: true })
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
ScrollTracker.PercentNode = function (percentage) {
|
70
|
-
this.percentage = percentage
|
71
|
-
this.eventData = { action: 'Percent', label: String(percentage) }
|
72
|
-
}
|
73
|
-
|
74
|
-
ScrollTracker.PercentNode.prototype.isVisible = function () {
|
75
|
-
return this.currentScrollPercent() >= this.percentage
|
76
|
-
}
|
77
|
-
|
78
|
-
ScrollTracker.PercentNode.prototype.currentScrollPercent = function () {
|
79
|
-
var $document = $(document)
|
80
|
-
var $window = $(window)
|
81
|
-
return (($window.scrollTop() / ($document.height() - $window.height())) * 100.0)
|
82
|
-
}
|
83
|
-
|
84
|
-
ScrollTracker.HeadingNode = function (headingText) {
|
85
|
-
this.$element = getHeadingElement(headingText)
|
86
|
-
this.eventData = { action: 'Heading', label: headingText }
|
87
|
-
|
88
|
-
function getHeadingElement (headingText) {
|
89
|
-
var $headings = $('h1, h2, h3, h4, h5, h6')
|
90
|
-
for (var i = 0; i < $headings.length; i++) {
|
91
|
-
if ($.trim($headings.eq(i).text()).replace(/\s/g, ' ') === headingText) return $headings.eq(i)
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
ScrollTracker.HeadingNode.prototype.isVisible = function () {
|
97
|
-
if (!this.$element) return false
|
98
|
-
return this.elementIsVisible(this.$element)
|
99
|
-
}
|
100
|
-
|
101
|
-
ScrollTracker.HeadingNode.prototype.elementIsVisible = function ($element) {
|
102
|
-
var $window = $(window)
|
103
|
-
var positionTop = $element.offset().top
|
104
|
-
return (positionTop > $window.scrollTop() && positionTop < ($window.scrollTop() + $window.height()))
|
105
|
-
}
|
106
|
-
|
107
|
-
$().ready(function () {
|
108
|
-
window.GOVUK.scrollTracker = new ScrollTracker(CONFIG)
|
109
|
-
})
|
110
|
-
|
111
|
-
window.GOVUK.ScrollTracker = ScrollTracker
|
112
|
-
}())
|
data/app/views/govuk_publishing_components/components/contextual_sidebar/_covid_cta.html.erb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
<% shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) %>
|
2
|
-
<%
|
3
|
-
title = t("components.related_navigation.covid_booster.title")
|
4
|
-
link_text = t("components.related_navigation.covid_booster.link_text")
|
5
|
-
link_path = t("components.related_navigation.covid_booster.link_path")
|
6
|
-
lang = shared_helper.t_locale("components.related_navigation.covid_booster.title")
|
7
|
-
%>
|
8
|
-
|
9
|
-
<% data_attributes = {
|
10
|
-
"module": "gem-track-click",
|
11
|
-
"track-category": "relatedLinkClicked",
|
12
|
-
"track-action": "1.0 Coronavirus",
|
13
|
-
"track-label": link_path,
|
14
|
-
"track-dimension": link_text,
|
15
|
-
"track-dimension-index": "29",
|
16
|
-
} %>
|
17
|
-
|
18
|
-
<%= tag.div class: "gem-c-contextual-sidebar__cta gem-c-contextual-sidebar__cta--covid" do %>
|
19
|
-
<%= tag.h2 title, class: "gem-c-contextual-sidebar__heading govuk-heading-s" %>
|
20
|
-
<%= tag.p class: "gem-c-contextual-sidebar__text govuk-body" do %>
|
21
|
-
<%= link_to link_text,
|
22
|
-
link_path,
|
23
|
-
class: "govuk-link",
|
24
|
-
data: data_attributes,
|
25
|
-
lang: lang %>
|
26
|
-
<% end %>
|
27
|
-
<% end %>
|