govuk_publishing_components 17.13.0 → 17.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +41 -4
- data/app/views/govuk_publishing_components/components/_checkboxes.html.erb +1 -1
- data/app/views/govuk_publishing_components/components/_radio.html.erb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1fae6c310eb63c511c044be1ee8cb28802b3c3d1d767d7e1878b03c819888483
|
|
4
|
+
data.tar.gz: 69ad960abde6fa565fe63c5a9e8bb2db1d82bd0b474d0403da0354923fbfa020
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 =
|
|
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)
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"/"
|
|
50
50
|
],
|
|
51
51
|
"_resolved": "git://github.com/alphagov/accessible-autocomplete.git#3523dd9fffc70cbd9f6f555f75863c33a709f49e",
|
|
52
|
-
"_shasum": "
|
|
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.
|
|
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
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: gds-api-adapters
|