govuk_publishing_components 16.29.0 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +46 -23
  3. data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +8 -2
  4. data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +101 -21
  5. data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +9 -2
  6. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +4 -6
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +36 -5
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +14 -14
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +23 -23
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +8 -8
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -2
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +8 -8
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +10 -10
  15. data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +11 -14
  16. data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +14 -14
  17. data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +8 -8
  18. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +7 -7
  19. data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +20 -16
  20. data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +4 -4
  21. data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +5 -5
  22. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +5 -5
  23. data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +8 -8
  24. data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +1 -1
  25. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +33 -25
  26. data/app/views/govuk_publishing_components/components/_error_summary.html.erb +4 -2
  27. data/app/views/govuk_publishing_components/components/_notice.html.erb +4 -1
  28. data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -0
  29. data/app/views/govuk_publishing_components/components/docs/error_summary.yml +6 -0
  30. data/app/views/govuk_publishing_components/components/docs/notice.yml +6 -0
  31. data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
  32. data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -4
  33. data/lib/govuk_publishing_components/version.rb +1 -1
  34. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +1 -1
  35. data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -1
  36. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +1 -1
  37. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -1
  38. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +1 -1
  39. data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -1
  40. data/node_modules/accessible-autocomplete/package.json +3 -3
  41. data/node_modules/accessible-autocomplete/src/autocomplete.js +4 -2
  42. data/node_modules/accessible-autocomplete/src/wrapper.js +5 -1
  43. data/node_modules/d/CHANGELOG.md +9 -0
  44. data/node_modules/d/CHANGES +4 -0
  45. data/node_modules/d/LICENSE +12 -16
  46. data/node_modules/d/README.md +49 -19
  47. data/node_modules/d/auto-bind.js +11 -10
  48. data/node_modules/d/index.js +23 -24
  49. data/node_modules/d/lazy.js +21 -23
  50. data/node_modules/d/package.json +63 -16
  51. data/node_modules/d/test/auto-bind.js +6 -7
  52. data/node_modules/d/test/index.js +78 -51
  53. data/node_modules/d/test/lazy.js +65 -50
  54. data/node_modules/es6-weak-map/CHANGELOG.md +5 -0
  55. data/node_modules/es6-weak-map/LICENSE +12 -16
  56. data/node_modules/es6-weak-map/README.md +34 -19
  57. data/node_modules/es6-weak-map/implement.js +9 -5
  58. data/node_modules/es6-weak-map/index.js +2 -2
  59. data/node_modules/es6-weak-map/is-implemented.js +10 -9
  60. data/node_modules/es6-weak-map/is-native-implemented.js +3 -3
  61. data/node_modules/es6-weak-map/is-weak-map.js +8 -8
  62. data/node_modules/es6-weak-map/package.json +30 -19
  63. data/node_modules/es6-weak-map/polyfill.js +31 -32
  64. data/node_modules/es6-weak-map/test/implement.js +4 -2
  65. data/node_modules/es6-weak-map/test/index.js +4 -3
  66. data/node_modules/es6-weak-map/test/is-implemented.js +9 -8
  67. data/node_modules/es6-weak-map/test/is-native-implemented.js +4 -2
  68. data/node_modules/es6-weak-map/test/is-weak-map.js +4 -4
  69. data/node_modules/es6-weak-map/test/polyfill.js +13 -13
  70. data/node_modules/es6-weak-map/test/valid-weak-map.js +22 -9
  71. data/node_modules/es6-weak-map/valid-weak-map.js +5 -5
  72. data/node_modules/resolve/lib/async.js +1 -1
  73. data/node_modules/resolve/lib/node-modules-paths.js +1 -1
  74. data/node_modules/resolve/lib/sync.js +0 -2
  75. data/node_modules/resolve/package.json +13 -13
  76. data/node_modules/resolve/test/node-modules-paths.js +0 -22
  77. data/node_modules/resolve/test/resolver.js +11 -0
  78. data/node_modules/resolve/test/resolver_sync.js +11 -0
  79. data/node_modules/standard/node_modules/ms/index.js +2 -2
  80. data/node_modules/standard/node_modules/ms/package.json +205 -16
  81. data/node_modules/standard/node_modules/ms/readme.md +1 -1
  82. data/node_modules/type/CHANGELOG.md +62 -0
  83. data/node_modules/type/README.md +743 -0
  84. data/node_modules/type/array-length/coerce.js +10 -0
  85. data/node_modules/type/array-length/ensure.js +10 -0
  86. data/node_modules/type/array-like/ensure.js +9 -0
  87. data/node_modules/type/array-like/is.js +21 -0
  88. data/node_modules/type/array/ensure.js +9 -0
  89. data/node_modules/type/array/is.js +27 -0
  90. data/node_modules/type/date/ensure.js +9 -0
  91. data/node_modules/type/date/is.js +26 -0
  92. data/node_modules/type/error/ensure.js +9 -0
  93. data/node_modules/type/error/is.js +24 -0
  94. data/node_modules/type/finite/coerce.js +8 -0
  95. data/node_modules/type/finite/ensure.js +10 -0
  96. data/node_modules/type/function/ensure.js +9 -0
  97. data/node_modules/type/function/is.js +19 -0
  98. data/node_modules/type/integer/coerce.js +11 -0
  99. data/node_modules/type/integer/ensure.js +10 -0
  100. data/node_modules/type/iterable/ensure.js +9 -0
  101. data/node_modules/type/iterable/is.js +20 -0
  102. data/node_modules/type/lib/is-to-string-tag-supported.js +3 -0
  103. data/node_modules/type/lib/resolve-exception.js +21 -0
  104. data/node_modules/type/lib/safe-to-string.js +10 -0
  105. data/node_modules/type/lib/to-short-string.js +29 -0
  106. data/node_modules/type/natural-number/coerce.js +10 -0
  107. data/node_modules/type/natural-number/ensure.js +10 -0
  108. data/node_modules/type/number/coerce.js +14 -0
  109. data/node_modules/type/number/ensure.js +10 -0
  110. data/node_modules/type/object/ensure.js +9 -0
  111. data/node_modules/type/object/is.js +11 -0
  112. data/node_modules/type/package.json +159 -0
  113. data/node_modules/type/plain-function/ensure.js +9 -0
  114. data/node_modules/type/plain-function/is.js +11 -0
  115. data/node_modules/type/plain-object/ensure.js +9 -0
  116. data/node_modules/type/plain-object/is.js +28 -0
  117. data/node_modules/type/promise/ensure.js +9 -0
  118. data/node_modules/type/promise/is.js +27 -0
  119. data/node_modules/type/prototype/is.js +13 -0
  120. data/node_modules/type/reg-exp/ensure.js +9 -0
  121. data/node_modules/type/reg-exp/is.js +37 -0
  122. data/node_modules/type/safe-integer/coerce.js +13 -0
  123. data/node_modules/type/safe-integer/ensure.js +10 -0
  124. data/node_modules/type/string/coerce.js +23 -0
  125. data/node_modules/type/string/ensure.js +10 -0
  126. data/node_modules/type/test/_lib/arrow-function-if-supported.js +4 -0
  127. data/node_modules/type/test/_lib/class-if-supported.js +4 -0
  128. data/node_modules/type/test/array-length/coerce.js +47 -0
  129. data/node_modules/type/test/array-length/ensure.js +19 -0
  130. data/node_modules/type/test/array-like/ensure.js +24 -0
  131. data/node_modules/type/test/array-like/is.js +47 -0
  132. data/node_modules/type/test/array/ensure.js +20 -0
  133. data/node_modules/type/test/array/is.js +41 -0
  134. data/node_modules/type/test/date/ensure.js +20 -0
  135. data/node_modules/type/test/date/is.js +46 -0
  136. data/node_modules/type/test/error/ensure.js +20 -0
  137. data/node_modules/type/test/error/is.js +42 -0
  138. data/node_modules/type/test/finite/coerce.js +40 -0
  139. data/node_modules/type/test/finite/ensure.js +17 -0
  140. data/node_modules/type/test/function/ensure.js +20 -0
  141. data/node_modules/type/test/function/is.js +46 -0
  142. data/node_modules/type/test/integer/coerce.js +49 -0
  143. data/node_modules/type/test/integer/ensure.js +17 -0
  144. data/node_modules/type/test/iterable/ensure.js +24 -0
  145. data/node_modules/type/test/iterable/is.js +50 -0
  146. data/node_modules/type/test/lib/is-to-string-tag-supported.js +10 -0
  147. data/node_modules/type/test/lib/resolve-exception.js +39 -0
  148. data/node_modules/type/test/lib/safe-to-string.js +32 -0
  149. data/node_modules/type/test/lib/to-short-string.js +41 -0
  150. data/node_modules/type/test/natural-number/coerce.js +47 -0
  151. data/node_modules/type/test/natural-number/ensure.js +19 -0
  152. data/node_modules/type/test/number/coerce.js +40 -0
  153. data/node_modules/type/test/number/ensure.js +17 -0
  154. data/node_modules/type/test/object/ensure.js +20 -0
  155. data/node_modules/type/test/object/is.js +30 -0
  156. data/node_modules/type/test/plain-function/ensure.js +20 -0
  157. data/node_modules/type/test/plain-function/is.js +56 -0
  158. data/node_modules/type/test/plain-object/ensure.js +20 -0
  159. data/node_modules/type/test/plain-object/is.js +47 -0
  160. data/node_modules/type/test/promise/ensure.js +20 -0
  161. data/node_modules/type/test/promise/is.js +39 -0
  162. data/node_modules/type/test/prototype/is.js +39 -0
  163. data/node_modules/type/test/reg-exp/ensure.js +20 -0
  164. data/node_modules/type/test/reg-exp/is.js +47 -0
  165. data/node_modules/type/test/safe-integer/coerce.js +49 -0
  166. data/node_modules/type/test/safe-integer/ensure.js +19 -0
  167. data/node_modules/type/test/string/coerce.js +36 -0
  168. data/node_modules/type/test/string/ensure.js +17 -0
  169. data/node_modules/type/test/thenable/ensure.js +20 -0
  170. data/node_modules/type/test/thenable/is.js +44 -0
  171. data/node_modules/type/test/time-value/coerce.js +47 -0
  172. data/node_modules/type/test/time-value/ensure.js +17 -0
  173. data/node_modules/type/test/value/ensure.js +20 -0
  174. data/node_modules/type/test/value/is.js +29 -0
  175. data/node_modules/type/thenable/ensure.js +9 -0
  176. data/node_modules/type/thenable/is.js +9 -0
  177. data/node_modules/type/time-value/coerce.js +12 -0
  178. data/node_modules/type/time-value/ensure.js +10 -0
  179. data/node_modules/type/value/ensure.js +9 -0
  180. data/node_modules/type/value/is.js +6 -0
  181. metadata +118 -21
  182. data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss +0 -94
  183. data/node_modules/resolve/reaf +0 -0
  184. data/node_modules/resolve/test/shadowed_core.js +0 -38
  185. data/node_modules/resolve/test/shadowed_core/node_modules/util/index.js +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8047aceaeee07563168532b4770f4281f8fc0d0b3269ff8b42840b713c06a67
4
- data.tar.gz: 16e3fd19901d80548760a58ef8859a09a421fcc1a2faa96664801deed8b9be9c
3
+ metadata.gz: ed1bcff194d6bc6a10597abb3bbe2124905ccc3ce57325fb6821428a5bab6146
4
+ data.tar.gz: 12ebe47472df27104c8b895c8b6508438aa1beefebe93ace51973406090a92ed
5
5
  SHA512:
6
- metadata.gz: 1f17c20b503ad606df0ecc3ae95a685d28251c00350a6201d40821eaff8bc16f81638df34ecc3b8221a8d7954da2fbc7106088b25c2bc7ac32d275c088ef6c20
7
- data.tar.gz: ca2fe0a8f76a04780e378abf896ae484b54c42010ca16295275d708ed59f0ce471ebd709af91b2933adc052ecc32caba07a7ba65042a7cfebeb97a07a58f00f1
6
+ metadata.gz: eddef82c2d0e79b00a3f67b51f4ad965b0c8a706fe9ea2494f528f5ca67e7ef36bb674f2c5ff07d9dff70f14438771eba2efe5a47e69eef4384bd15c37fb752e
7
+ data.tar.gz: c8df18bbdaad629df80e26201428186515fd1f9b93d8b28c47bc9ea7adb1d68b9e2a1b1ff4bb89a422a3d9d6dafb12340a94631f0989b9ea36c963c8888f0c87
@@ -10,43 +10,66 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
10
10
  this.$module.showConfirmationMessage = this.showConfirmationMessage.bind(this)
11
11
  this.$module.setCookieConsent = this.setCookieConsent.bind(this)
12
12
 
13
- var newCookieBanner = document.querySelector('.gem-c-cookie-banner--new')
13
+ this.$module.newCookieBanner = document.querySelector('.gem-c-cookie-banner--new')
14
14
 
15
- // Hide the cookie banner on the cookie settings page, to avoid circular journeys
16
- if (newCookieBanner && window.location.pathname === '/help/cookies') {
17
- this.$module.style.display = 'none'
15
+ // Temporary check while we have 2 banners co-existing.
16
+ // Once the new banner has been deployed, we will be able to remove code relating to the old banner
17
+ // Separating the code out like this does mean some repetition, but will make it easier to remove later
18
+ if (this.$module.newCookieBanner) {
19
+ this.setupNewCookieMessage()
18
20
  } else {
19
- this.$hideLink = this.$module.querySelector('a[data-hide-cookie-banner], button[data-hide-cookie-banner]')
20
- if (this.$hideLink) {
21
- this.$hideLink.addEventListener('click', this.$module.hideCookieMessage)
22
- }
21
+ this.setupCookieMessage()
22
+ }
23
+ }
23
24
 
24
- this.$acceptCookiesLink = this.$module.querySelector('button[data-accept-cookies]')
25
- if (this.$acceptCookiesLink) {
26
- this.$acceptCookiesLink.addEventListener('click', this.$module.setCookieConsent)
27
- }
25
+ CookieBanner.prototype.setupCookieMessage = function () {
26
+ this.$hideLink = this.$module.querySelector('a[data-hide-cookie-banner]')
27
+ if (this.$hideLink) {
28
+ this.$hideLink.addEventListener('click', this.$module.hideCookieMessage)
29
+ }
30
+
31
+ this.showCookieMessage()
32
+ }
28
33
 
29
- this.showCookieMessage()
34
+ CookieBanner.prototype.setupNewCookieMessage = function () {
35
+ this.$hideLink = this.$module.querySelector('button[data-hide-cookie-banner]')
36
+ if (this.$hideLink) {
37
+ this.$hideLink.addEventListener('click', this.$module.hideCookieMessage)
30
38
  }
39
+
40
+ this.$acceptCookiesLink = this.$module.querySelector('button[data-accept-cookies]')
41
+ if (this.$acceptCookiesLink) {
42
+ this.$acceptCookiesLink.addEventListener('click', this.$module.setCookieConsent)
43
+ }
44
+
45
+ this.showNewCookieMessage()
31
46
  }
32
47
 
33
48
  CookieBanner.prototype.showCookieMessage = function () {
34
- var newCookieBanner = document.querySelector('.gem-c-cookie-banner--new')
35
- var hasCookieMessage = (this.$module && window.GOVUK.cookie('seen_cookie_message') !== 'true')
36
- if (hasCookieMessage) {
49
+ var shouldHaveCookieMessage = (this.$module && window.GOVUK.cookie('seen_cookie_message') !== 'true')
50
+
51
+ if (shouldHaveCookieMessage) {
37
52
  this.$module.style.display = 'block'
38
53
  }
54
+ }
55
+
56
+ CookieBanner.prototype.showNewCookieMessage = function () {
57
+ var newCookieBanner = document.querySelector('.gem-c-cookie-banner--new')
58
+
59
+ // Hide the cookie banner on the cookie settings page, to avoid circular journeys
60
+ if (newCookieBanner && window.location.pathname === '/help/cookies') {
61
+ this.$module.style.display = 'none'
62
+ }
63
+
64
+ var shouldHaveCookieMessage = (this.$module && window.GOVUK.cookie('seen_cookie_message') !== 'true')
39
65
 
40
- if (newCookieBanner && hasCookieMessage) {
66
+ if (shouldHaveCookieMessage) {
67
+ this.$module.style.display = 'block'
68
+
69
+ // Set the default consent cookie if it isn't already present
41
70
  if (!window.GOVUK.cookie('cookie_policy')) {
42
71
  window.GOVUK.setDefaultConsentCookie()
43
72
  }
44
- } else if (!newCookieBanner) {
45
- // Remove the consent cookie if we're using the old cookie banner
46
- // TODO: this can be removed later when we switch to the new banner
47
- if (window.GOVUK.cookie('cookie_policy')) {
48
- window.GOVUK.cookie('cookie_policy', null)
49
- }
50
73
  }
51
74
  }
52
75
 
@@ -123,7 +123,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
123
123
  }
124
124
 
125
125
  function showError (error) {
126
- error = [
126
+ var genericError = [
127
127
  '<h2 class="gem-c-feedback__heading">',
128
128
  ' Sorry, we’re unable to receive your message right now. ',
129
129
  '</h2>',
@@ -131,8 +131,14 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
131
131
  ' feedback on the <a href="/contact/govuk">contact page</a>.</p>'
132
132
  ].join('')
133
133
 
134
+ // if the response is not a 404 or 500, show the error message if it exists
135
+ // otherwise show the generic message
136
+ // this covers the 422 status the feedback application return for empty fields
137
+ // for all other, show generic error
134
138
  if (typeof (error.responseJSON) !== 'undefined') {
135
- error = typeof (error.responseJSON.message) === 'undefined' ? error : error.responseJSON.message
139
+ error = typeof (error.responseJSON.message) === 'undefined' ? genericError : error.responseJSON.message
140
+ } else {
141
+ error = genericError
136
142
  }
137
143
  var $errors = that.$activeForm.find('.js-errors')
138
144
  $errors.html(error).removeClass(jshiddenClass).focus()
@@ -3,13 +3,33 @@
3
3
  (function () {
4
4
  'use strict'
5
5
  var root = this
6
- var defaultCookieConsent = {
6
+
7
+ var DEFAULT_COOKIE_CONSENT = {
7
8
  'essential': true,
8
9
  'settings': true,
9
10
  'usage': true,
10
11
  'campaigns': true
11
12
  }
12
13
 
14
+ var COOKIE_CATEGORIES = {
15
+ 'TLSversion': 'usage',
16
+ 'cookie_policy': 'essential',
17
+ 'govuk_not_first_visit': 'essential',
18
+ 'govuk_browser_upgrade_dismisssed': 'essential',
19
+ 'seen_cookie_message': 'essential',
20
+ 'govuk_surveySeenUserSatisfactionSurvey': 'essential',
21
+ 'govuk_takenUserSatisfactionSurvey': 'essential',
22
+ '_email-alert-frontend_session': 'essential',
23
+ 'global_bar_seen': 'essential',
24
+ 'licensing_session': 'essential',
25
+ 'govuk_contact_referrer': 'essential',
26
+ 'JS-Detection': 'usage',
27
+ '_ga': 'usage',
28
+ '_gid': 'usage',
29
+ '_gat': 'usage',
30
+ 'analytics_next_page_call': 'usage'
31
+ }
32
+
13
33
  if (typeof root.GOVUK === 'undefined') { root.GOVUK = {} }
14
34
 
15
35
  /*
@@ -40,7 +60,7 @@
40
60
  }
41
61
 
42
62
  window.GOVUK.setDefaultConsentCookie = function () {
43
- window.GOVUK.setCookie('cookie_policy', JSON.stringify(defaultCookieConsent))
63
+ window.GOVUK.setCookie('cookie_policy', JSON.stringify(DEFAULT_COOKIE_CONSENT))
44
64
  }
45
65
 
46
66
  window.GOVUK.approveAllCookieTypes = function () {
@@ -65,37 +85,97 @@
65
85
  window.GOVUK.setCookie('cookie_policy', JSON.stringify(deniedConsent))
66
86
  }
67
87
 
68
- window.GOVUK.setConsentCookie = function (options) {
69
- var currentConsentCookie = window.GOVUK.getCookie('cookie_policy')
70
- var cookieConsentJSON
88
+ window.GOVUK.getConsentCookie = function () {
89
+ var consentCookie = window.GOVUK.cookie('cookie_policy')
90
+ var consentCookieObj
71
91
 
72
- if (currentConsentCookie) {
73
- cookieConsentJSON = JSON.parse(currentConsentCookie)
92
+ if (consentCookie) {
93
+ try {
94
+ consentCookieObj = JSON.parse(consentCookie)
95
+ } catch (err) {
96
+ return null
97
+ }
98
+
99
+ if (typeof consentCookieObj !== 'object' && consentCookieObj !== null) {
100
+ consentCookieObj = JSON.parse(consentCookieObj)
101
+ }
74
102
  } else {
75
- cookieConsentJSON = defaultCookieConsent
103
+ return null
104
+ }
105
+
106
+ return consentCookieObj
107
+ }
108
+
109
+ window.GOVUK.setConsentCookie = function (options) {
110
+ var cookieConsent = window.GOVUK.getConsentCookie()
111
+
112
+ if (!cookieConsent) {
113
+ cookieConsent = DEFAULT_COOKIE_CONSENT
76
114
  }
77
115
 
78
116
  for (var cookieType in options) {
79
- cookieConsentJSON[cookieType] = options[cookieType]
117
+ cookieConsent[cookieType] = options[cookieType]
80
118
  }
81
119
 
82
- window.GOVUK.setCookie('cookie_policy', JSON.stringify(cookieConsentJSON))
120
+ window.GOVUK.setCookie('cookie_policy', JSON.stringify(cookieConsent))
83
121
  }
84
122
 
85
- window.GOVUK.setCookie = function (name, value, options) {
86
- if (typeof options === 'undefined') {
87
- options = {}
123
+ window.GOVUK.checkConsentCookieCategory = function (cookieCategory) {
124
+ var currentConsentCookie = window.GOVUK.getConsentCookie()
125
+
126
+ // If the consent cookie doesn't exist, set the default consent cookie
127
+ if (!currentConsentCookie) {
128
+ window.GOVUK.setDefaultConsentCookie()
129
+ }
130
+
131
+ currentConsentCookie = window.GOVUK.getConsentCookie()
132
+
133
+ // Sometimes currentConsentCookie is malformed in some of the tests, so we need to handle these
134
+ try {
135
+ return currentConsentCookie[cookieCategory]
136
+ } catch (e) {
137
+ console.error(e)
138
+ return false
139
+ }
140
+ }
141
+
142
+ window.GOVUK.checkConsentCookie = function (cookieName, cookieValue) {
143
+ // If we're setting the consent cookie OR deleting a cookie, allow by default
144
+ if (cookieName === 'cookie_policy' || (cookieValue === null || cookieValue === false)) {
145
+ return true
146
+ }
147
+
148
+ // Survey cookies are dynamically generated, so we need to check for these separately
149
+ if (cookieName.match('^govuk_surveySeen') || cookieName.match('^govuk_taken')) {
150
+ return window.GOVUK.checkConsentCookieCategory('essential')
88
151
  }
89
- var cookieString = name + '=' + value + '; path=/'
90
- if (options.days) {
91
- var date = new Date()
92
- date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000))
93
- cookieString = cookieString + '; expires=' + date.toGMTString()
152
+
153
+ if (COOKIE_CATEGORIES[cookieName]) {
154
+ var cookieCategory = COOKIE_CATEGORIES[cookieName]
155
+
156
+ return window.GOVUK.checkConsentCookieCategory(cookieCategory)
157
+ } else {
158
+ // Deny the cookie if it is not known to us
159
+ return false
94
160
  }
95
- if (document.location.protocol === 'https:') {
96
- cookieString = cookieString + '; Secure'
161
+ }
162
+
163
+ window.GOVUK.setCookie = function (name, value, options) {
164
+ if (window.GOVUK.checkConsentCookie(name, value)) {
165
+ if (typeof options === 'undefined') {
166
+ options = {}
167
+ }
168
+ var cookieString = name + '=' + value + '; path=/'
169
+ if (options.days) {
170
+ var date = new Date()
171
+ date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000))
172
+ cookieString = cookieString + '; expires=' + date.toGMTString()
173
+ }
174
+ if (document.location.protocol === 'https:') {
175
+ cookieString = cookieString + '; Secure'
176
+ }
177
+ document.cookie = cookieString
97
178
  }
98
- document.cookie = cookieString
99
179
  }
100
180
 
101
181
  window.GOVUK.getCookie = function (name) {
@@ -13,10 +13,12 @@ window.GOVUK = window.GOVUK || {};
13
13
  YoutubeLinkEnhancement.prototype.init = function () {
14
14
  var $youtubeLinks = this.$element.find('a[href*="youtube.com"], a[href*="youtu.be"]')
15
15
  var _this = this
16
+
16
17
  $youtubeLinks.each(function () {
17
18
  var $link = $(this)
18
-
19
- if (_this.hasDisabledEmbed($link)) {
19
+ // if users have disabled 'campaigns' cookie in the new cookie page settings
20
+ // we also need to disable the youtube video embed
21
+ if (_this.hasDisabledEmbed($link) || !YoutubeLinkEnhancement.campaignCookies()) {
20
22
  return true
21
23
  }
22
24
 
@@ -61,6 +63,11 @@ window.GOVUK = window.GOVUK || {};
61
63
  }
62
64
  }
63
65
 
66
+ YoutubeLinkEnhancement.campaignCookies = function () {
67
+ var cookiePolicy = window.GOVUK.getCookie('cookie_policy') ? JSON.parse(window.GOVUK.getCookie('cookie_policy')) : 'undefined'
68
+ return cookiePolicy !== 'undefined' ? cookiePolicy.campaigns : true
69
+ }
70
+
64
71
  YoutubeLinkEnhancement.nextId = function () {
65
72
  this.embedCount = this.embedCount || 0
66
73
  this.embedCount += 1
@@ -78,7 +78,6 @@
78
78
  @import "components/tabs";
79
79
  @import "components/table";
80
80
  @import "components/taxonomy-list";
81
- @import "components/taxonomy-navigation";
82
81
  @import "components/textarea";
83
82
  @import "components/title";
84
83
  @import "components/translation-nav";
@@ -24,16 +24,14 @@ $gem-quiet-button-hover-colour: darken($gem-quiet-button-colour, 5%);
24
24
 
25
25
  .gem-c-button--inline {
26
26
  display: block;
27
+ width: 100%;
27
28
  margin-bottom: govuk-spacing(1);
28
-
29
- @include govuk-media-query($from: mobile) {
30
- @include box-sizing(border-box);
31
- display: inline-block;
32
- width: 48%;
33
- }
29
+ vertical-align: top;
34
30
 
35
31
  @include govuk-media-query($from: desktop) {
32
+ display: inline-block;
36
33
  width: auto;
34
+ vertical-align: baseline;
37
35
  }
38
36
  }
39
37
 
@@ -1,5 +1,6 @@
1
1
  $govuk-cookie-banner-background: #d5e8f3;
2
2
  $govuk-cookie-banner-background-new: govuk-colour("white");
3
+ $govuk-cookie-banner-text-green: #00823b;
3
4
 
4
5
  .js-enabled {
5
6
  .gem-c-cookie-banner,
@@ -38,33 +39,63 @@ $govuk-cookie-banner-background-new: govuk-colour("white");
38
39
  margin-bottom: govuk-spacing(1);
39
40
  padding-right: govuk-spacing(4);
40
41
  padding-bottom: govuk-spacing(2);
42
+ color: $govuk-cookie-banner-text-green;
41
43
  }
42
44
 
43
45
  .gem-c-cookie-banner__buttons {
44
- vertical-align: middle;
46
+ @include govuk-clearfix;
45
47
 
46
48
  @include govuk-media-query($from: desktop) {
47
49
  display: inline-block;
48
50
  }
49
51
  }
50
52
 
53
+ .gem-c-cookie-banner__button {
54
+ display: inline-block;
55
+ width: 100%;
56
+
57
+ @include govuk-media-query($from: mobile, $until: desktop) {
58
+ width: 49%;
59
+
60
+ &.gem-c-cookie-banner__button-accept {
61
+ float: left;
62
+ }
63
+
64
+ &.gem-c-cookie-banner__button-settings {
65
+ float: right;
66
+ }
67
+ }
68
+
69
+ @include govuk-media-query($from: desktop) {
70
+ width: auto;
71
+ }
72
+
73
+ @include govuk-media-query($until: 455px) {
74
+ width: 100%;
75
+ }
76
+ }
77
+
51
78
  .gem-c-cookie-banner__confirmation {
52
79
  display: none;
53
80
  position: relative;
54
- padding: 0 govuk-spacing(2);
81
+ padding: govuk-spacing(1);
55
82
  }
56
83
 
57
84
  .gem-c-cookie-banner__confirmation-message,
58
85
  .gem-c-cookie-banner__hide-button {
59
86
  display: block;
60
87
 
61
- @include govuk-media-query($from: tablet) {
88
+ @include govuk-media-query($from: desktop) {
62
89
  display: inline-block;
63
90
  }
64
91
  }
65
92
 
66
93
  .gem-c-cookie-banner__confirmation-message {
67
94
  margin-right: govuk-spacing(4);
95
+
96
+ @include govuk-media-query($from: desktop) {
97
+ max-width: 90%;
98
+ }
68
99
  }
69
100
 
70
101
  .gem-c-cookie-banner__hide-button {
@@ -83,10 +114,10 @@ $govuk-cookie-banner-background-new: govuk-colour("white");
83
114
  cursor: pointer;
84
115
  }
85
116
 
86
- @include govuk-media-query($from: tablet) {
117
+ @include govuk-media-query($from: desktop) {
87
118
  margin-top: govuk-spacing(0);
88
119
  position: absolute;
89
- right: 0;
120
+ right: govuk-spacing(1);
90
121
  }
91
122
  }
92
123
 
@@ -1,46 +1,46 @@
1
1
  .gem-c-heading {
2
2
  @include govuk-text-colour;
3
- @include bold-27;
3
+ @include govuk-font(27, $weight: bold);
4
4
  margin: 0;
5
5
  }
6
6
 
7
7
  .gem-c-heading--font-size-24 {
8
- @include bold-24;
8
+ @include govuk-font(24, $weight: bold);
9
9
  }
10
10
 
11
11
  .gem-c-heading--font-size-19 {
12
- @include bold-19;
12
+ @include govuk-font(19, $weight: bold);
13
13
  }
14
14
 
15
15
  // special case for publications and consultations pages
16
16
  // separated to allow normalisation of the component for wider use
17
17
  .gem-c-heading--mobile-top-margin {
18
- margin-top: $gutter;
19
- margin-bottom: $gutter-half;
18
+ margin-top: govuk-spacing(6);
19
+ margin-bottom: govuk-spacing(3);
20
20
 
21
- @include media(tablet) {
21
+ @include govuk-media-query($from: tablet) {
22
22
  margin-top: 0;
23
- margin-bottom: $gutter;
23
+ margin-bottom: govuk-spacing(6);
24
24
  }
25
25
  }
26
26
 
27
27
  .gem-c-heading--padding {
28
- padding: $gutter-half 0;
28
+ padding: govuk-spacing(3) 0;
29
29
  }
30
30
 
31
31
  // margins would ideally be handled by a general model for all components
32
32
  // but we don't have one yet, so this is in anticipation of that
33
33
  // suggested scale is as follows, not fully implemented
34
- // $gutter = 4
35
- // $gutter-two-thirds = 3
36
- // $gutter-half = 2
37
- // $gutter-one-third = 1
34
+ // govuk-spacing(6)= 4
35
+ // govuk-spacing(4) = 3
36
+ // govuk-spacing(3) = 2
37
+ // govuk-spacing(2) = 1
38
38
  .gem-c-heading--margin-bottom-4 {
39
- margin-bottom: $gutter;
39
+ margin-bottom: govuk-spacing(6);
40
40
  }
41
41
 
42
42
  .gem-c-heading--margin-bottom-2 {
43
- margin-bottom: $gutter-half;
43
+ margin-bottom: govuk-spacing(3);
44
44
  }
45
45
 
46
46
  // border color will default to black