govuk_publishing_components 17.13.0 → 17.14.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: 458c9dcdf7dc0578315c0d5ec5c02d5e93c155625cf53f770d9d9f1706680203
4
- data.tar.gz: 3f1f0afe46aff5ec70739b7dbc3cf79ef4d30eebcd5a08d7b165e27e87d113a6
3
+ metadata.gz: 1fae6c310eb63c511c044be1ee8cb28802b3c3d1d767d7e1878b03c819888483
4
+ data.tar.gz: 69ad960abde6fa565fe63c5a9e8bb2db1d82bd0b474d0403da0354923fbfa020
5
5
  SHA512:
6
- metadata.gz: 9608142d53358a769f304ee17898b8cdef5d3f5676da3502533d0a5052fdf003efd4ed3ee14eaa8c99a6a40c90bf369fe71f1e8bfd524d5e11009fb0250799ae
7
- data.tar.gz: 7c6765b1eb511c16fa4e74202c693b1979843a40472b43f8cb28a8dc3f8aa162a524f5d8d0ccb5d77205c03d70a74659a5b8a18e376b2ca336405991ae1c93ee
6
+ metadata.gz: '09bbfe08788bac9d3add154ac0baae7de48a581e4923fa99442f4ac24de638d000aa85654a230bbb01c758661de30ad63af8b937ebfac8d684fb86bfc76f97dd'
7
+ data.tar.gz: eab47a1574c05fb21142babbd6c51d898cc8a8809a67d05be617dbe7575a43729462f9f904e3067303693acf2dddf45ffcf3fe4703fbe4b520f8ed332ea29a2d
@@ -11,12 +11,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
11
11
  this.$module.setCookieConsent = this.setCookieConsent.bind(this)
12
12
 
13
13
  this.$module.cookieBanner = document.querySelector('.gem-c-cookie-banner')
14
- this.$module.cookieBannerConfirmationMessage = document.querySelector('.gem-c-cookie-banner__confirmation')
14
+ this.$module.cookieBannerConfirmationMessage = this.$module.querySelector('.gem-c-cookie-banner__confirmation')
15
15
 
16
- // Temporary check while we have 2 banners co-existing.
17
- // Once the new banner has been deployed, we will be able to remove code relating to the old banner
18
- // Separating the code out like this does mean some repetition, but will make it easier to remove later
19
16
  this.setupCookieMessage()
17
+
18
+ // Listen for cross-origin communication messages (e.g. hideCookieBanner for when previewing GOV.UK pages
19
+ // in publishing applications
20
+ this.listenForCrossOriginMessages()
20
21
  }
21
22
 
22
23
  CookieBanner.prototype.setupCookieMessage = function () {
@@ -84,5 +85,41 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
84
85
  this.$module.cookieBannerConfirmationMessage.style.display = 'block'
85
86
  }
86
87
 
88
+ CookieBanner.prototype.listenForCrossOriginMessages = function () {
89
+ window.addEventListener('message', this.receiveMessage.bind(this), false)
90
+ }
91
+
92
+ CookieBanner.prototype.receiveMessage = function (event) {
93
+ var trustedDomain = 'publishing.service.gov.uk'
94
+ var origin = event.origin
95
+
96
+ // Return if no origin is given or the browser doesn't support lastIndexOf
97
+ if (!origin || !origin.lastIndexOf) {
98
+ return
99
+ }
100
+
101
+ // Polyfill origin.endsWith(trustedDomain) for IE
102
+ var offset = origin.length - trustedDomain.length
103
+ var trustedOrigin = offset >= 0 && origin.lastIndexOf(trustedDomain, offset) === offset
104
+
105
+ // Return if the given origin is not trusted
106
+ if (!trustedOrigin) {
107
+ return
108
+ }
109
+
110
+ // Read JSON data from event
111
+ var dataObject = {}
112
+ try {
113
+ dataObject = JSON.parse(event.data)
114
+ } catch (err) {
115
+ // Don't throw errors as the emmited message may not be in a JSON format
116
+ } finally {
117
+ if (dataObject.hideCookieBanner === 'true') {
118
+ // Visually hide the cookie banner
119
+ this.$module.style.display = 'none'
120
+ }
121
+ }
122
+ }
123
+
87
124
  Modules.CookieBanner = CookieBanner
88
125
  })(window.GOVUK.Modules)
@@ -11,7 +11,7 @@
11
11
  <%= cb_helper.heading_markup %>
12
12
 
13
13
  <% if cb_helper.description %>
14
- <%= tag.p cb_helper.description, class: "govuk-body" %>
14
+ <%= tag.div cb_helper.description, class: "govuk-body" %>
15
15
  <% end %>
16
16
 
17
17
  <% if cb_helper.hint_text %>
@@ -42,7 +42,7 @@
42
42
  <% end %>
43
43
 
44
44
  <% if description.present? %>
45
- <%= tag.p description, class: "govuk-body" %>
45
+ <%= tag.div description, class: "govuk-body" %>
46
46
  <% end %>
47
47
 
48
48
  <% if hint %>
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '17.13.0'.freeze
2
+ VERSION = '17.14.0'.freeze
3
3
  end
@@ -49,7 +49,7 @@
49
49
  "/"
50
50
  ],
51
51
  "_resolved": "git://github.com/alphagov/accessible-autocomplete.git#3523dd9fffc70cbd9f6f555f75863c33a709f49e",
52
- "_shasum": "87e6ae08ea863c228e3338e9bc58a7ce2c9dd507",
52
+ "_shasum": "79f5e7901599aa4ed0f96da79e43f9958232ba9d",
53
53
  "_shrinkwrap": null,
54
54
  "_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
55
55
  "_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
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: 17.13.0
4
+ version: 17.14.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: 2019-07-11 00:00:00.000000000 Z
11
+ date: 2019-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gds-api-adapters