govuk_publishing_components 27.17.0 → 28.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/govuk_publishing_components/image-card-srcset/cop26-170.jpg +0 -0
  3. data/app/assets/images/govuk_publishing_components/image-card-srcset/cop26-240.jpg +0 -0
  4. data/app/assets/images/govuk_publishing_components/image-card-srcset/cop26-320.jpg +0 -0
  5. data/app/assets/images/govuk_publishing_components/image-card-srcset/cop26-480.jpg +0 -0
  6. data/app/assets/images/govuk_publishing_components/image-card-srcset/cop26.jpg +0 -0
  7. data/app/assets/javascripts/govuk_publishing_components/analytics/download-link-tracker.js +21 -16
  8. data/app/assets/javascripts/govuk_publishing_components/analytics/explicit-cross-domain-links.js +1 -1
  9. data/app/assets/javascripts/govuk_publishing_components/analytics/external-link-tracker.js +46 -32
  10. data/app/assets/javascripts/govuk_publishing_components/analytics/google-analytics-universal-tracker.js +20 -7
  11. data/app/assets/javascripts/govuk_publishing_components/analytics/page-content.js +74 -65
  12. data/app/assets/javascripts/govuk_publishing_components/analytics/scroll-tracker.js +1 -126
  13. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +18 -18
  14. data/app/assets/javascripts/govuk_publishing_components/components/single-page-notification-button.js +25 -11
  15. data/app/assets/javascripts/govuk_publishing_components/lib/extend-object.js +22 -0
  16. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -2
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +19 -14
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +6 -35
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_image-card.scss +17 -7
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +5 -104
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +24 -14
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_signup-link.scss +34 -0
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_single-page-notification-button.scss +8 -0
  24. data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_warning-callout.scss +7 -0
  25. data/app/assets/stylesheets/govuk_publishing_components/components/mixins/_grid-helper.scss +141 -0
  26. data/app/views/govuk_publishing_components/components/_contextual_sidebar.html.erb +5 -1
  27. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -0
  28. data/app/views/govuk_publishing_components/components/_intervention.html.erb +10 -1
  29. data/app/views/govuk_publishing_components/components/_search.html.erb +1 -0
  30. data/app/views/govuk_publishing_components/components/_signup_link.html.erb +30 -0
  31. data/app/views/govuk_publishing_components/components/_single_page_notification_button.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +3 -3
  33. data/app/views/govuk_publishing_components/components/contextual_sidebar/_covid_cta.html.erb +27 -0
  34. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +15 -87
  35. data/app/views/govuk_publishing_components/components/docs/feedback.yml +5 -0
  36. data/app/views/govuk_publishing_components/components/docs/image_card.yml +29 -0
  37. data/app/views/govuk_publishing_components/components/docs/intervention.yml +9 -0
  38. data/app/views/govuk_publishing_components/components/docs/search.yml +3 -0
  39. data/app/views/govuk_publishing_components/components/docs/signup_link.yml +39 -0
  40. data/app/views/govuk_publishing_components/components/feedback/_problem_form.html.erb +9 -6
  41. data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +4 -3
  42. data/app/views/govuk_publishing_components/components/feedback/_yes_no_banner.html.erb +4 -4
  43. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +1 -1
  44. data/config/locales/ar.yml +0 -8
  45. data/config/locales/az.yml +0 -8
  46. data/config/locales/be.yml +0 -8
  47. data/config/locales/bg.yml +0 -8
  48. data/config/locales/bn.yml +0 -8
  49. data/config/locales/cs.yml +0 -8
  50. data/config/locales/cy.yml +0 -8
  51. data/config/locales/da.yml +0 -8
  52. data/config/locales/de.yml +0 -8
  53. data/config/locales/dr.yml +0 -8
  54. data/config/locales/el.yml +0 -8
  55. data/config/locales/en.yml +9 -13
  56. data/config/locales/es-419.yml +0 -8
  57. data/config/locales/es.yml +0 -8
  58. data/config/locales/et.yml +0 -8
  59. data/config/locales/fa.yml +0 -8
  60. data/config/locales/fi.yml +0 -8
  61. data/config/locales/fr.yml +0 -8
  62. data/config/locales/gd.yml +0 -8
  63. data/config/locales/gu.yml +0 -8
  64. data/config/locales/he.yml +0 -8
  65. data/config/locales/hi.yml +0 -8
  66. data/config/locales/hr.yml +0 -8
  67. data/config/locales/hu.yml +0 -8
  68. data/config/locales/hy.yml +0 -8
  69. data/config/locales/id.yml +0 -8
  70. data/config/locales/is.yml +0 -8
  71. data/config/locales/it.yml +0 -8
  72. data/config/locales/ja.yml +0 -8
  73. data/config/locales/ka.yml +0 -8
  74. data/config/locales/kk.yml +0 -8
  75. data/config/locales/ko.yml +0 -8
  76. data/config/locales/lt.yml +0 -8
  77. data/config/locales/lv.yml +0 -8
  78. data/config/locales/ms.yml +0 -8
  79. data/config/locales/mt.yml +0 -8
  80. data/config/locales/nl.yml +0 -8
  81. data/config/locales/no.yml +0 -8
  82. data/config/locales/pa-pk.yml +0 -8
  83. data/config/locales/pa.yml +0 -8
  84. data/config/locales/pl.yml +0 -8
  85. data/config/locales/ps.yml +0 -8
  86. data/config/locales/pt.yml +0 -8
  87. data/config/locales/ro.yml +0 -8
  88. data/config/locales/ru.yml +0 -8
  89. data/config/locales/si.yml +0 -8
  90. data/config/locales/sk.yml +0 -8
  91. data/config/locales/sl.yml +0 -8
  92. data/config/locales/so.yml +0 -8
  93. data/config/locales/sq.yml +0 -8
  94. data/config/locales/sr.yml +0 -8
  95. data/config/locales/sv.yml +0 -8
  96. data/config/locales/sw.yml +0 -8
  97. data/config/locales/ta.yml +0 -8
  98. data/config/locales/th.yml +0 -8
  99. data/config/locales/tk.yml +0 -8
  100. data/config/locales/tr.yml +0 -8
  101. data/config/locales/uk.yml +0 -8
  102. data/config/locales/ur.yml +0 -8
  103. data/config/locales/uz.yml +0 -8
  104. data/config/locales/vi.yml +0 -8
  105. data/config/locales/zh-hk.yml +0 -8
  106. data/config/locales/zh-tw.yml +0 -8
  107. data/config/locales/zh.yml +0 -8
  108. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +42 -170
  109. data/lib/govuk_publishing_components/presenters/image_card_helper.rb +11 -1
  110. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +3 -1
  111. data/lib/govuk_publishing_components/version.rb +1 -1
  112. data/lib/govuk_publishing_components.rb +0 -2
  113. metadata +13 -14
  114. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +0 -84
  115. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +0 -21
  116. data/app/views/govuk_publishing_components/components/_admin_analytics.html.erb +0 -20
  117. data/app/views/govuk_publishing_components/components/_government_navigation.html.erb +0 -86
  118. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +0 -47
  119. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +0 -30
  120. data/app/views/govuk_publishing_components/components/docs/admin_analytics.yml +0 -10
  121. data/app/views/govuk_publishing_components/components/docs/government_navigation.yml +0 -20
  122. data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +0 -171
  123. data/app/views/govuk_publishing_components/components/docs/taxonomy_list.yml +0 -112
  124. data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +0 -13
  125. data/lib/govuk_publishing_components/presenters/taxonomy_list_helper.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d9ee129bde5e753f8180b3b8dfe7f2e4fe257558ac1a6fe40bb289242d849f2
4
- data.tar.gz: 4c01bb1d55673a25eef1a408e5360da17b2d4e1a8dfc00291463ecc86dfcd81a
3
+ metadata.gz: 52ec5aa91a7d5060c6b29671f2206a967ab5af8a3891cb800c95d6b28eb09d15
4
+ data.tar.gz: 0bbf50f1bb6f0cd64af2986e72a612fe28a65df3987caf523939fcf87e3341ad
5
5
  SHA512:
6
- metadata.gz: 5eac4c820f6c86caded7a9e994f1e9e15edbb6ab7fce003ae38f9919dcc6a23f3db7f9dfcd27e0204152e17daa35ccb741ce457b6c9c3c85a8ae51350362fe3c
7
- data.tar.gz: b9e8068c2b0746134a37e21fefdd8cc6114055e133fa7240e801be587f34f8ff8a7dd218a71f34cda1fe8dce5c54da3109544d0775e103c2a90e9bec153cd018
6
+ metadata.gz: a144e7583969b1767bb25e64f64772d4c4e632814ba3863f6335570a3a83936eea4aa76daeb1b006f39910b5b6086f1f9f65ea63b3068f929bc167f2f5237ea2
7
+ data.tar.gz: 78e13b419fba7b1eac89947ca9891e87f4939ed27456e093c474fbeca3afb291c6c86b002fbed478630b78671bd061637a208cf5f043656631b5d12e7b5af72c
@@ -1,23 +1,38 @@
1
1
  ;(function (global) {
2
2
  'use strict'
3
3
 
4
- var $ = global.jQuery
5
4
  var GOVUK = global.GOVUK || {}
6
5
 
7
6
  GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
8
7
  GOVUK.analyticsPlugins.downloadLinkTracker = function (options) {
9
8
  options = options || {}
10
9
  var downloadLinkSelector = options.selector
10
+ var selectors = downloadLinkSelector.split(',')
11
11
 
12
12
  if (downloadLinkSelector) {
13
- $('body').on('click', downloadLinkSelector, trackDownload)
13
+ document.querySelector('body').addEventListener('click', function (event) {
14
+ var element = event.target
15
+ if (element.tagName !== 'A') {
16
+ element = element.closest('a')
17
+ }
18
+
19
+ if (!element) {
20
+ return
21
+ }
22
+
23
+ for (var i = 0; i < selectors.length; i++) {
24
+ if (element.matches(selectors[i].trim())) {
25
+ trackDownload(element)
26
+ break
27
+ }
28
+ }
29
+ })
14
30
  }
15
31
 
16
- function trackDownload (evt) {
17
- var $link = getLinkFromEvent(evt)
18
- var href = $link.attr('href')
32
+ function trackDownload (element) {
33
+ var href = element.getAttribute('href')
19
34
  var evtOptions = { transport: 'beacon' }
20
- var linkText = $.trim($link.text())
35
+ var linkText = element.textContent.trim()
21
36
 
22
37
  if (linkText) {
23
38
  evtOptions.label = linkText
@@ -25,16 +40,6 @@
25
40
 
26
41
  GOVUK.analytics.trackEvent('Download Link Clicked', href, evtOptions)
27
42
  }
28
-
29
- function getLinkFromEvent (evt) {
30
- var $target = $(evt.target)
31
-
32
- if (!$target.is('a')) {
33
- $target = $target.parents('a')
34
- }
35
-
36
- return $target
37
- }
38
43
  }
39
44
 
40
45
  global.GOVUK = GOVUK
@@ -75,7 +75,7 @@
75
75
 
76
76
  if (!attributeValue) { return }
77
77
 
78
- if (attributeValue.includes('?')) {
78
+ if (attributeValue.indexOf('?') !== -1) {
79
79
  attributeValue += '&' + param
80
80
  } else {
81
81
  attributeValue += '?' + param
@@ -1,49 +1,63 @@
1
+ // = require govuk/vendor/polyfills/Element/prototype/closest.js
1
2
  ;(function (global) {
2
3
  'use strict'
3
4
 
4
- var $ = global.jQuery
5
5
  var GOVUK = global.GOVUK || {}
6
6
 
7
7
  GOVUK.analyticsPlugins = GOVUK.analyticsPlugins || {}
8
8
  GOVUK.analyticsPlugins.externalLinkTracker = function (options) {
9
9
  options = options || {}
10
- var externalLinkUploadCustomDimension = options.externalLinkUploadCustomDimension
10
+ GOVUK.analyticsPlugins.externalLinkTracker.options = options
11
+ document.querySelector('body').addEventListener('click', GOVUK.analyticsPlugins.externalLinkTracker.handleClick)
12
+ }
13
+
14
+ GOVUK.analyticsPlugins.externalLinkTracker.handleClick = function (event) {
15
+ var element = event.target
16
+ if (element.tagName !== 'A') {
17
+ element = element.closest('a')
18
+ }
19
+
20
+ if (!element) {
21
+ return
22
+ }
23
+
24
+ if (GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink(element.getAttribute('href'))) {
25
+ GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent(element)
26
+ }
27
+ }
28
+
29
+ GOVUK.analyticsPlugins.externalLinkTracker.isExternalLink = function (href) {
30
+ if (!href) {
31
+ return false
32
+ }
33
+
11
34
  var currentHost = GOVUK.analyticsPlugins.externalLinkTracker.getHostname()
12
- var externalLinkSelector = 'a[href^="http"]:not(a[href*="' + currentHost + '"])'
13
- $('body').on('click', externalLinkSelector, trackClickEvent)
14
-
15
- function trackClickEvent (evt) {
16
- var $link = getLinkFromEvent(evt)
17
- var options = { transport: 'beacon' }
18
- var href = $link.attr('href')
19
- var linkText = $.trim($link.text())
20
-
21
- if (linkText) {
22
- options.label = linkText
23
- }
24
-
25
- if (externalLinkUploadCustomDimension !== undefined) {
26
- // This custom dimension will be used to duplicate the url information
27
- // that we normally send in an "event action". This will be used to join
28
- // up with a scheduled custom upload called "External Link Status".
29
- // We can only join uploads on custom dimensions, not on `event actions`
30
- // where we normally add the url info.
31
- var externalLinkToJoinUploadOn = href
32
-
33
- GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
34
- }
35
- GOVUK.analytics.trackEvent('External Link Clicked', href, options)
35
+ if (href.substring(0, 4) === 'http' && href.indexOf(currentHost) === -1) {
36
+ return true
36
37
  }
38
+ }
39
+
40
+ GOVUK.analyticsPlugins.externalLinkTracker.trackClickEvent = function (element) {
41
+ var options = { transport: 'beacon' }
42
+ var href = element.getAttribute('href')
43
+ var linkText = element.textContent.trim()
37
44
 
38
- function getLinkFromEvent (evt) {
39
- var $target = $(evt.target)
45
+ if (linkText) {
46
+ options.label = linkText
47
+ }
40
48
 
41
- if (!$target.is('a')) {
42
- $target = $target.parents('a')
43
- }
49
+ var externalLinkUploadCustomDimension = GOVUK.analyticsPlugins.externalLinkTracker.options.externalLinkUploadCustomDimension
50
+ if (externalLinkUploadCustomDimension !== undefined) {
51
+ // This custom dimension will be used to duplicate the url information
52
+ // that we normally send in an "event action". This will be used to join
53
+ // up with a scheduled custom upload called "External Link Status".
54
+ // We can only join uploads on custom dimensions, not on `event actions`
55
+ // where we normally add the url info.
56
+ var externalLinkToJoinUploadOn = href
44
57
 
45
- return $target
58
+ GOVUK.analytics.setDimension(externalLinkUploadCustomDimension, externalLinkToJoinUploadOn)
46
59
  }
60
+ GOVUK.analytics.trackEvent('External Link Clicked', href, options)
47
61
  }
48
62
 
49
63
  GOVUK.analyticsPlugins.externalLinkTracker.getHostname = function () {
@@ -1,7 +1,6 @@
1
1
  ;(function (global) {
2
2
  'use strict'
3
3
 
4
- var $ = global.jQuery
5
4
  var GOVUK = global.GOVUK || {}
6
5
  var pii
7
6
 
@@ -78,7 +77,7 @@
78
77
  // Set an options object for the pageview (e.g. transport, sessionControl)
79
78
  // https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#transport
80
79
  if (typeof options === 'object') {
81
- pageviewObject = $.extend(pageviewObject || {}, options)
80
+ pageviewObject = GOVUK.extendObject(pageviewObject || {}, options)
82
81
 
83
82
  // trackerName is optional
84
83
  if (typeof options.trackerName === 'string') {
@@ -87,10 +86,24 @@
87
86
  }
88
87
  }
89
88
 
90
- if (!$.isEmptyObject(pageviewObject)) {
91
- sendToGa(trackerName + 'send', 'pageview', pageviewObject)
92
- } else {
89
+ function isEmptyObject (obj) {
90
+ if (typeof obj === 'undefined') {
91
+ return true
92
+ }
93
+
94
+ for (var prop in obj) {
95
+ if (Object.prototype.hasOwnProperty.call(obj, prop)) {
96
+ return false
97
+ }
98
+ }
99
+
100
+ return JSON.stringify(obj) === JSON.stringify({})
101
+ }
102
+
103
+ if (isEmptyObject(pageviewObject)) {
93
104
  sendToGa(trackerName + 'send', 'pageview')
105
+ } else {
106
+ sendToGa(trackerName + 'send', 'pageview', pageviewObject)
94
107
  }
95
108
  }
96
109
 
@@ -135,7 +148,7 @@
135
148
  }
136
149
 
137
150
  if (typeof options === 'object') {
138
- $.extend(evt, options)
151
+ evt = GOVUK.extendObject(evt, options)
139
152
  }
140
153
 
141
154
  sendToGa(trackerName + 'send', evt)
@@ -156,7 +169,7 @@
156
169
  socialTarget: target
157
170
  }
158
171
 
159
- $.extend(trackingOptions, options)
172
+ trackingOptions = GOVUK.extendObject(trackingOptions, options)
160
173
 
161
174
  sendToGa('send', trackingOptions)
162
175
  }
@@ -1,4 +1,4 @@
1
- /* global GOVUK, $ */
1
+ /* global GOVUK */
2
2
 
3
3
  (function () {
4
4
  'use strict'
@@ -8,17 +8,17 @@
8
8
  PageContent.getNumberOfSections = function () {
9
9
  switch (true) {
10
10
  case isNavigationGridPage():
11
- return 1 + $('.parent-topic-contents').length
11
+ return 1 + document.querySelectorAll('.parent-topic-contents').length
12
12
  case isNavigationAccordionPage():
13
- return $('[data-track-count="accordionSection"]').length
13
+ return document.querySelectorAll('[data-track-count="accordionSection"]').length
14
14
  case isDocumentCollectionPage():
15
- return $('.document-collection .group-title').length
15
+ return document.querySelectorAll('.document-collection .group-title').length
16
16
  case isMainstreamBrowsePage():
17
- return $('#subsection ul:visible').length || $('#section ul').length
17
+ return countVisible(document.querySelectorAll('#subsection ul')) || document.querySelectorAll('#section ul').length
18
18
  case isTopicPage():
19
- return $('.topics-page nav.index-list').length
19
+ return document.querySelectorAll('.topics-page nav.index-list').length
20
20
  case isPolicyAreaPage():
21
- return $('.topic section h1.label').length
21
+ return document.querySelectorAll('.topic section h1.label').length
22
22
  case isFinderPage():
23
23
  case isWhitehallFinderPage():
24
24
  case isNavigationLeafPage():
@@ -28,8 +28,8 @@
28
28
  return 1
29
29
  default:
30
30
  // It's a content page, not a "finding" page
31
- var sidebarSections = $('[data-track-count="sidebarRelatedItemSection"]').length
32
- var sidebarTaxons = $('[data-track-count="sidebarTaxonSection"]').length
31
+ var sidebarSections = document.querySelectorAll('[data-track-count="sidebarRelatedItemSection"]').length
32
+ var sidebarTaxons = document.querySelectorAll('[data-track-count="sidebarTaxonSection"]').length
33
33
 
34
34
  return sidebarSections || sidebarTaxons
35
35
  }
@@ -38,92 +38,101 @@
38
38
  PageContent.getNumberOfLinks = function () {
39
39
  switch (true) {
40
40
  case isNavigationGridPage():
41
- return $('a[data-track-category="navGridLinkClicked"]').length +
42
- $('a[data-track-category="navGridLeafLinkClicked"]').length
41
+ return document.querySelectorAll('a[data-track-category="navGridLinkClicked"]').length +
42
+ document.querySelectorAll('a[data-track-category="navGridLeafLinkClicked"]').length
43
43
  case isNavigationAccordionPage():
44
- return $('a[data-track-category="navAccordionLinkClicked"]').length
45
- case isNavigationLeafPage():
46
- return $('a[data-track-category="navLeafLinkClicked"]').length
44
+ return document.querySelectorAll('a[data-track-category="navAccordionLinkClicked"]').length
47
45
  case isDocumentCollectionPage():
48
- return $('.document-collection .group-document-list li a').length
46
+ return document.querySelectorAll('.document-collection .group-document-list li a').length
49
47
  case isMainstreamBrowsePage():
50
- return $('#subsection ul a:visible').length ||
51
- $('#section ul a').length
48
+ return countVisible(document.querySelectorAll('#subsection ul a')) || document.querySelectorAll('#section ul a').length
52
49
  case isTopicPage():
53
- return $('.topics-page .index-list ul a').length ||
54
- $('.topics-page .topics ul a').length
50
+ return document.querySelectorAll('.topics-page .index-list ul a').length ||
51
+ document.querySelectorAll('.topics-page .topics ul a').length
55
52
  case isPolicyAreaPage():
56
- return $('section.document-block a').length +
57
- $('section .collection-list h2 a').length
58
- case isWhitehallFinderPage():
59
- return $('.document-list .document-row h3 a').length
53
+ return document.querySelectorAll('section.document-block a').length +
54
+ document.querySelectorAll('section .collection-list h2 a').length
60
55
  case isFinderPage():
61
- return $('.finder-frontend-content li.document a').length
56
+ return document.querySelectorAll('.finder-frontend-content li.document a').length
57
+ case isWhitehallFinderPage():
58
+ return document.querySelectorAll('.document-list .document-row h3 a').length
59
+ case isNavigationLeafPage():
60
+ return document.querySelectorAll('a[data-track-category="navLeafLinkClicked"]').length
62
61
  default:
63
62
  // It's a content page, not a "finding" page, count related links
64
- return $('a[data-track-category="relatedLinkClicked"]').length
63
+ return document.querySelectorAll('a[data-track-category="relatedLinkClicked"]').length
65
64
  }
66
65
  }
67
66
 
68
- function getRenderingApplication () {
69
- return $('meta[name="govuk:rendering-application"]').attr('content')
70
- };
71
-
72
- function getFormat () {
73
- return $('meta[name="govuk:format"]').attr('content')
74
- };
67
+ var metaApplicationSelector = 'meta[name="govuk:rendering-application"]'
68
+ var metaFormatSelector = 'meta[name="govuk:format"]'
69
+ var metaNavigationTypeSelector = 'meta[name="govuk:navigation-page-type"]'
75
70
 
76
- function getNavigationPageType () {
77
- return $('meta[name="govuk:navigation-page-type"]').attr('content')
78
- };
71
+ function getMetaAttribute (selector) {
72
+ var element = document.querySelector(selector)
73
+ if (element) {
74
+ return element.getAttribute('content')
75
+ }
76
+ }
79
77
 
80
78
  function isNavigationGridPage () {
81
- return getRenderingApplication() === 'collections' &&
82
- getFormat() === 'taxon' &&
83
- getNavigationPageType() === 'grid'
84
- };
79
+ return getMetaAttribute(metaApplicationSelector) === 'collections' &&
80
+ getMetaAttribute(metaFormatSelector) === 'taxon' &&
81
+ getMetaAttribute(metaNavigationTypeSelector) === 'grid'
82
+ }
85
83
 
86
84
  function isNavigationAccordionPage () {
87
- return getRenderingApplication() === 'collections' &&
88
- getFormat() === 'taxon' &&
89
- getNavigationPageType() === 'accordion'
90
- };
85
+ return getMetaAttribute(metaApplicationSelector) === 'collections' &&
86
+ getMetaAttribute(metaFormatSelector) === 'taxon' &&
87
+ getMetaAttribute(metaNavigationTypeSelector) === 'accordion'
88
+ }
91
89
 
92
90
  function isNavigationLeafPage () {
93
- return getRenderingApplication() === 'collections' &&
94
- getFormat() === 'taxon' &&
95
- getNavigationPageType() === 'leaf'
96
- };
91
+ return getMetaAttribute(metaApplicationSelector) === 'collections' &&
92
+ getMetaAttribute(metaFormatSelector) === 'taxon' &&
93
+ getMetaAttribute(metaNavigationTypeSelector) === 'leaf'
94
+ }
97
95
 
98
96
  function isMainstreamBrowsePage () {
99
- return getRenderingApplication() === 'collections' &&
100
- getFormat() === 'mainstream_browse_page'
101
- };
97
+ return getMetaAttribute(metaApplicationSelector) === 'collections' &&
98
+ getMetaAttribute(metaFormatSelector) === 'mainstream_browse_page'
99
+ }
102
100
 
103
101
  function isTopicPage () {
104
- return getRenderingApplication() === 'collections' &&
105
- getFormat() === 'topic'
106
- };
102
+ return getMetaAttribute(metaApplicationSelector) === 'collections' &&
103
+ getMetaAttribute(metaFormatSelector) === 'topic'
104
+ }
107
105
 
108
106
  function isPolicyAreaPage () {
109
- return getRenderingApplication() === 'whitehall' &&
110
- getFormat() === 'placeholder_policy_area'
111
- };
107
+ return getMetaAttribute(metaApplicationSelector) === 'whitehall' &&
108
+ getMetaAttribute(metaFormatSelector) === 'placeholder_policy_area'
109
+ }
112
110
 
113
111
  function isDocumentCollectionPage () {
114
- return getRenderingApplication() === 'government-frontend' &&
115
- getFormat() === 'document_collection'
116
- };
112
+ return getMetaAttribute(metaApplicationSelector) === 'government-frontend' &&
113
+ getMetaAttribute(metaFormatSelector) === 'document_collection'
114
+ }
117
115
 
118
116
  function isFinderPage () {
119
- return getRenderingApplication() === 'finder-frontend' &&
120
- getFormat() === 'finder'
121
- };
117
+ return getMetaAttribute(metaApplicationSelector) === 'finder-frontend' &&
118
+ getMetaAttribute(metaFormatSelector) === 'finder'
119
+ }
122
120
 
123
121
  function isWhitehallFinderPage () {
124
- return getRenderingApplication() === 'whitehall' &&
125
- getFormat() === 'finder'
126
- };
122
+ return getMetaAttribute(metaApplicationSelector) === 'whitehall' &&
123
+ getMetaAttribute(metaFormatSelector) === 'finder'
124
+ }
125
+
126
+ function countVisible (elements) {
127
+ var count = 0
128
+ for (var i = 0; i < elements.length; i++) {
129
+ var style = window.getComputedStyle(elements[i])
130
+ if (!(style.display === 'none' || style.visibility === 'hidden')) {
131
+ count++
132
+ }
133
+ }
134
+ return count
135
+ }
127
136
 
128
137
  GOVUK.PageContent = PageContent
129
138
  })()
@@ -5,132 +5,7 @@
5
5
 
6
6
  window.GOVUK = window.GOVUK || {}
7
7
 
8
- var percentages = [
9
- ['Percent', 20],
10
- ['Percent', 40],
11
- ['Percent', 60],
12
- ['Percent', 80],
13
- ['Percent', 100]
14
- ]
15
-
16
- var CONFIG = {
17
- '/brexit': percentages,
18
- '/government/publications/the-essential-trustee-what-you-need-to-know-cc3/the-essential-trustee-what-you-need-to-know-what-you-need-to-do': [
19
- ['Heading', '1. About this guidance'],
20
- ['Heading', '2. Trustees’ duties at a glance'],
21
- ['Heading', '3. Who can be a trustee and how trustees are appointed'],
22
- ['Heading', '4. Ensure your charity is carrying out its purposes for the public benefit'],
23
- ['Heading', '5. Comply with your charity’s governing document and the law'],
24
- ['Heading', '6. Act in your charity’s best interests'],
25
- ['Heading', '7. Manage your charity’s resources responsibly'],
26
- ['Heading', '8. Act with reasonable care and skill'],
27
- ['Heading', '9. Ensure your charity is accountable'],
28
- ['Heading', '10. Reduce the risk of liability'],
29
- ['Heading', '11. Your charity’s legal structure and what it means'],
30
- ['Heading', '12. Charity officers - the chair and treasurer'],
31
- ['Heading', '13. Technical terms used in this guidance']
32
- ],
33
- '/guidance/universal-credit-how-it-helps-you-into-work': [
34
- ['Heading', 'Support from your work coach'],
35
- ['Heading', 'Help available for parents'],
36
- ['Heading', 'When you can claim Universal Credit'],
37
- ['Heading', 'More detailed advice']
38
- ],
39
- '/government/publications/spring-budget-2017-documents/spring-budget-2017': [
40
- ['Heading', '1. Executive summary'],
41
- ['Heading', '2. Economic context and public finances'],
42
- ['Heading', '3. Policy decisions'],
43
- ['Heading', '4. Tax'],
44
- ['Heading', '5. Productivity'],
45
- ['Heading', '6. Public services and markets'],
46
- ['Heading', '7. Annex A: Financing'],
47
- ['Heading', '8. Annex B: Office for Budget Responsibility\'s Economic and fiscal outlook']
48
- ],
49
- '/settled-status-eu-citizens-families': [
50
- ['Heading', 'When you can apply']
51
- ],
52
- '/guidance/returning-to-the-uk': [
53
- ['Heading', 'Ending your time living abroad']
54
- ],
55
- '/council-housing': [
56
- ['Heading', 'Choice-based lettings']
57
- ],
58
- '/guidance/foreign-travel-insurance': [
59
- ['Heading', 'What your travel insurance policy should cover']
60
- ],
61
- '/guidance/living-in-france': [
62
- ['Heading', 'Passports and travel']
63
- ],
64
- '/family-permit': [
65
- ['Heading', 'EEA family permit']
66
- ],
67
- '/guidance/healthcare-for-eu-and-efta-citizens-visiting-the-uk': [
68
- ['Heading', 'Travel insurance']
69
- ],
70
- '/driving-abroad': [
71
- ['Heading', 'Check your insurance if you’re taking your own vehicle']
72
- ],
73
- '/get-a-passport-urgently': [
74
- ['Heading', 'Ways to apply']
75
- ],
76
- '/driving-abroad/international-driving-permit': [
77
- ['Heading', 'Check which IDP you need']
78
- ],
79
- '/guidance/guidance-for-suppliers-of-cattle-sheep-and-goat-ear-tags': [
80
- ['Heading', 'Tagging information for livestock keepers']
81
- ],
82
- '/guidance/how-to-move-goods-between-or-through-common-transit-countries-including-the-eu': [
83
- ['Heading', 'Start moving your goods']
84
- ],
85
- '/guidance/ecmt-international-road-haulage-permits': [
86
- ['Heading', 'Apply for permits']
87
- ],
88
- '/taking-goods-out-uk-temporarily/get-an-ata-carnet': [
89
- ['Heading', 'Using an ATA Carnet']
90
- ],
91
- '/wood-packaging-import-export': [
92
- ['Heading', 'Export solid wood packaging']
93
- ],
94
- '/coronavirus': percentages,
95
- '/coronavirus/education-and-childcare': percentages,
96
- '/coronavirus/worker-support': percentages,
97
- '/coronavirus/business-support': percentages,
98
- '/get-coronavirus-test': percentages,
99
- '/next-steps-for-your-business/results': [
100
- ['Heading', 'Things you need to do next'],
101
- ['Heading', 'Rules to follow'],
102
- ['Heading', 'Good to know'],
103
- ['Heading', 'Change your answers']
104
- ],
105
- '/guidance/brexit-guidance-for-businesses': percentages,
106
- '/guidance/brexit-guidance-for-businesses.cy': percentages,
107
- '/guidance/brexit-guidance-for-individuals-and-families': percentages,
108
- '/guidance/brexit-guidance-for-individuals-and-families.cy': percentages,
109
- '/guidance/import-and-export-goods-using-preference-agreements': percentages,
110
- '/guidance/travel-abroad-from-england-during-coronavirus-covid-19': [
111
- ['Heading', 'Before you travel abroad'],
112
- ['Heading', '1. Check the rules for the country you’re going to'],
113
- ['Heading', '2. Find out what you need to do when you return'],
114
- ['Heading', '3. Book any COVID-19 tests or quarantine hotel packages you need for your return'],
115
- ['Heading', 'Before you return'],
116
- ['Heading', 'After you return'],
117
- ['Heading', 'Travelling with children'],
118
- ['Heading', 'Ireland, the UK, the Channel Islands and the Isle of Man'],
119
- ['Heading', 'Exemptions for work, medical or compassionate reasons']
120
- ],
121
- '/guidance/travel-to-england-from-another-country-during-coronavirus-covid-19': [
122
- ['Heading', 'Before you travel'],
123
- ['Heading', '1. Check the rules for the country you’re coming from or have travelled through'],
124
- ['Heading', '2. Book any COVID-19 tests or quarantine hotel packages you need for your arrival'],
125
- ['Heading', '3. Get tested and complete documents'],
126
- ['Heading', 'When you arrive in England'],
127
- ['Heading', 'Leaving England'],
128
- ['Heading', 'Travelling with children'],
129
- ['Heading', 'Ireland, the UK, the Channel Islands and the Isle of Man'],
130
- ['Heading', 'Exemptions for work, medical or compassionate reasons']
131
- ],
132
- '/find-travel-test-provider': percentages
133
- }
8
+ var CONFIG = {}
134
9
 
135
10
  function ScrollTracker (sitewideConfig) {
136
11
  this.config = this.getConfigForCurrentPath(sitewideConfig)