-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the only remaining scripts in govuk-template.js
- v46.4.0
- v46.3.1
- v46.3.0
- v46.2.0
- v46.1.0
- v46.0.0
- v45.10.0
- v45.9.0
- v45.8.0
- v45.7.0
- v45.6.1
- v45.6.0
- v45.5.0
- v45.4.1
- v45.4.0
- v45.3.0
- v45.2.0
- v45.1.0
- v45.0.0
- v44.11.0
- v44.10.0
- v44.9.1
- v44.9.0
- v44.8.0
- v44.7.1
- v44.7.0
- v44.6.0
- v44.5.0
- v44.4.2
- v44.4.1
- v44.4.0
- v44.3.0
- v44.2.0
- v44.1.0
- v44.0.0
- v43.5.0
- v43.4.1
- v43.4.0
- v43.3.0
- v43.2.0
- v43.1.1
- v43.1.0
- v43.0.2
- v43.0.1
- v43.0.0
- v42.1.0
- v42.0.0
- v41.1.2
- v41.1.1
- v41.1.0
- v41.0.0
- v40.1.0
- v40.0.0
- v39.2.5
- v39.2.4
- v39.2.3
- v39.2.2
- v39.2.1
- v39.2.0
- v39.1.0
- v39.0.0
- v38.4.2
- v38.4.1
- v38.4.0
- v38.3.2
- v38.3.1
- v38.3.0
- v38.2.0
- v38.1.1
- v38.1.0
- v38.0.1
- v38.0.0
- v37.10.0
- v37.9.1
- v37.9.0
- v37.8.1
- v37.8.0
- v37.7.1
- v37.7.0
- v37.6.1
- v37.6.0
- v37.5.1
- v37.5.0
- v37.4.0
- v37.3.1
- v37.3.0
- v37.2.4
- v37.2.3
- v37.2.2
- v37.2.1
- v37.2.0
- v37.1.1
- v37.1.0
- v37.0.0
- v36.1.0
- v36.0.3
- v36.0.2
- v36.0.1
- v36.0.0
- v35.23.0
- v35.22.0
- v35.21.4
- v35.21.3
- v35.21.2
- v35.21.1
- v35.21.0
- v35.20.1
- v35.20.0
- v35.19.0
- v35.18.0
- v35.17.0
- v35.16.1
- v35.16.0
- v35.15.5
- v35.15.4
- v35.15.3
- v35.15.2
- v35.15.1
- v35.15.0
- v35.14.0
- v35.13.2
- v35.13.1
- v35.13.0
- v35.12.0
- v35.11.0
- v35.10.0
- v35.9.0
- v35.8.0
- v35.7.0
- v35.6.0
- v35.5.0
- v35.4.0
- v35.3.5
- v35.3.4
- v35.3.3
- v35.3.2
- v35.3.1
- v35.3.0
- v35.2.0
- v35.1.1
- v35.1.0
- v35.0.0
- v34.14.0
- v34.13.0
- v34.12.0
- v34.11.0
- v34.10.1
- v34.10.0
- v34.9.1
- v34.9.0
- v34.8.1
- v34.8.0
- v34.7.1
- v34.7.0
- v34.6.0
- v34.5.1
- v34.5.0
- v34.4.2
- v34.4.1
- v34.4.0
- v34.3.0
- v34.2.0
- v34.1.3
- v34.1.2
- v34.1.1
- v34.1.0
- v34.0.0
- v33.1.0
- v33.0.0
- v32.1.0
- v32.0.0
- v31.2.0
- v31.1.2
- v31.1.1
- v31.1.0
- v31.0.0
- v30.7.3
- v30.7.2
- v30.7.1
- v30.7.0
- v30.6.1
- v30.6.0
- v30.5.2
- v30.5.1
- v30.5.0
- v30.4.1
- v30.4.0
- v30.3.0
- v30.2.1
- v30.2.0
- v30.1.0
- v30.0.0
- v29.15.3
- v29.15.2
- v29.15.1
- v29.15.0
- v29.14.0
- v29.13.0
- v29.12.1
- v29.12.0
- v29.11.0
- v29.10.0
- v29.9.0
- v29.8.0
- v29.7.0
- v29.6.0
- v29.5.0
- v29.4.0
- v29.3.0
- v29.2.0
- v29.1.0
- v29.0.1
- v29.0.0
- v28.9.2
- v28.9.1
- v28.9.0
- v28.8.1
- v28.8.0
- v28.7.1
- v28.7.0
- v28.6.0
- v28.5.0
- v28.4.0
- v28.3.0
- v28.2.0
- v28.1.0
- v28.0.0
- v27.20.0
- v27.19.0
- v27.18.0
- v27.17.0
- v27.16.0
- v27.15.0
- v27.14.2
- v27.14.1
- v27.14.0
- v27.13.0
- v27.12.0
- v27.11.0
- v27.10.5
- v27.10.4
- v27.10.3
- v27.10.2
- v27.10.1
- v27.10.0
- v27.9.2
- v27.9.1
- v27.9.0
- v27.8.2
- v27.8.1
- v27.8.0
- v27.7.0
- v27.6.0
- v27.5.0
- v27.4.0
- v27.3.1
- v27.3.0
- v27.2.0
- v27.1.0
- v27.0.0
- v26.0.0
- v25.7.0
- v25.6.0
- v25.5.0
- v25.4.0
- v25.3.1
- v25.3.0
- v25.2.3
- v25.2.2
- v25.2.1
- v25.2.0
- v25.1.0
- v25.0.0
- v24.21.1
- v24.21.0
- v24.20.0
- v24.19.0
- v24.18.5
- v24.18.4
- v24.18.3
- v24.18.2
- v24.18.1
- v24.18.0
- v24.17.0
- v24.16.1
- v24.16.0
- v24.15.3
- v24.15.2
- v24.15.1
- v24.15.0
- v24.14.1
- v24.14.0
- v24.13.5
- v24.13.4
- v24.13.3
- v24.13.2
- v24.13.1
- v24.13.0
- v24.12.0
- v24.11.1
- v24.11.0
- v24.10.3
- v24.10.2
- v24.10.1
- v24.10.0
- v24.9.4
- v24.9.3
- v24.9.2
- v24.9.1
- v24.9.0
- v24.8.0
- v24.7.1
- v24.7.0
- v24.6.1
- v24.6.0
- v24.5.0
- v24.4.1
- v24.4.0
- v24.3.1
- v24.3.0
- v24.2.0
- v24.1.1
- v24.1.0
- v24.0.0
- v23.15.0
- v23.14.0
- v23.13.1
- v23.13.0
- v23.12.3
- v23.12.2
- v23.12.1
- v23.12.0
- v23.11.1
- v23.11.0
- v23.10.2
- v23.10.1
- v23.10.0
- v23.9.2
- v23.9.1
- v23.9.0
- v23.8.0
- v23.7.7
- v23.7.6
- v23.7.5
- v23.7.4
- v23.7.3
- v23.7.2
- v23.7.1
- v23.7.0
- v23.6.0
- v23.5.1
- v23.5.0
- v23.4.0
- v23.3.0
- v23.2.1
- v23.2.0
- v23.1.0
- v23.0.0
- v22.0.0
- v21.69.0
- v21.68.1
- v21.68.0
- v21.67.2
- v21.67.1
- v21.67.0
- v21.66.4
- v21.66.3
- v21.66.2
- v21.66.1
- v21.66.0
- v21.65.1
- v21.65.0
- v21.64.0
- v21.63.3
- v21.63.2
- v21.63.1
- v21.63.0
- v21.62.0
- v21.61.0
- v21.60.3
- v21.60.2
- v21.60.1
- v21.60.0
- v21.59.0
- v21.58.0
- v21.57.1
- v21.57.0
- v21.56.2
- v21.56.1
- v21.56.0
- v21.55.4
- v21.55.3
- v21.55.2
- v21.55.1
- v21.55.0
- v21.54.0
- v21.53.0
- v21.52.1
- v21.52.0
- v21.51.0
- v21.50.1
- v21.50.0
- v21.49.0
- v21.48.0
- v21.47.0
- v21.46.0
- v21.45.0
- v21.44.0
- v21.43.0
- v21.42.0
- v21.41.4
- v21.41.3
- v21.41.2
- v21.41.1
- v21.41.0
- v21.40.0
- v21.39.0
- v21.38.5
- v21.38.4
- v21.38.3
- v21.38.2
- v21.38.1
- v21.38.0
- v21.37.0
- v21.36.1
- v21.36.0
- v21.35.0
- v21.34.1
- v21.34.0
- v21.33.0
- v21.32.0
- v21.31.0
- v21.30.0
- v21.29.1
- v21.29.0
- v21.28.1
- v21.28.0
- v21.27.1
- v21.27.0
- v21.26.2
- v21.26.1
- v21.26.0
- v21.25.0
- v21.24.0
- v21.23.1
- v21.23.0
- v21.22.2
- v21.22.1
- v21.22.0
- v21.21.3
- v21.21.2
- v21.21.1
- v21.21.0
- v21.20.0
- v21.19.1
- v21.19.0
- v21.18.0
- v21.17.0
- v21.16.3
- v21.16.2
- v21.16.1
- v21.16.0
- v21.15.2
- v21.15.1
- v21.15.0
- v21.14.0
- v21.13.5
- v21.13.4
- v21.13.3
- v21.13.2
- v21.13.1
- v21.13.0
- v21.12.0
- v21.11.0
- v21.10.0
- v21.9.0
- v21.8.1
- v21.8.0
- v21.7.0
- v21.6.1
- v21.6.0
- v21.5.1
- v21.5.0
- v21.4.1
- v21.4.0
- v21.3.0
- v21.2.0
- v21.1.1
- v21.1.0
- v21.0.0
- v20.5.2
- v20.5.1
- v20.5.0
- v20.4.0
- v20.3.0
- v20.2.2
- v20.2.1
- v20.2.0
- v20.1.0
- v20.0.0
- v19.0.0
- v18.3.1
- v18.3.0
- v18.2.0
- v18.1.2
- v18.1.1
- v18.1.0
- v18.0.1
- v18.0.0
- v17.21.0
- v17.20.0
- v17.19.1
- v17.19.0
- v17.18.0
- v17.17.0
- v17.16.0
- v17.15.0
- v17.14.0
- v17.13.0
- v17.12.2
- v17.12.1
- v17.12.0
- v17.11.0
- v17.10.0
- v17.9.0
- v17.8.0
- v17.7.0
- v17.6.1
- v17.6.0
- v17.5.0
- v17.4.0
- v17.3.0
- v17.2.0
- v17.1.1
- v17.1.0
- v17.0.0
- v16.29.0
- v16.28.0
- v16.27.1
- v16.27.0
- v16.26.0
- v16.25.0
- v16.24.0
- v16.23.0
- v16.22.0
- v16.21.0
- v16.20.1
- v16.20.0
- v16.19.0
- v16.18.0
- v16.17.0
- v16.16.0
- v16.15.0
- v16.14.1
- v16.14.0
- v16.13.0
- v16.12.0
- v16.11.0
- v16.10.1
- v16.10.0
- v16.9.2
- v16.9.1
- v16.9.0
- v16.8.0
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// used by the cookie banner component | ||
|
||
(function () { | ||
'use strict' | ||
var root = this | ||
if (typeof root.GOVUK === 'undefined') { root.GOVUK = {} } | ||
|
||
/* | ||
Cookie methods | ||
============== | ||
Usage: | ||
Setting a cookie: | ||
GOVUK.cookie('hobnob', 'tasty', { days: 30 }); | ||
Reading a cookie: | ||
GOVUK.cookie('hobnob'); | ||
Deleting a cookie: | ||
GOVUK.cookie('hobnob', null); | ||
*/ | ||
window.GOVUK.cookie = function (name, value, options) { | ||
if (typeof value !== 'undefined') { | ||
if (value === false || value === null) { | ||
return window.GOVUK.setCookie(name, '', { days: -1 }) | ||
} else { | ||
return window.GOVUK.setCookie(name, value, options) | ||
} | ||
} else { | ||
return window.GOVUK.getCookie(name) | ||
} | ||
} | ||
|
||
window.GOVUK.setCookie = function (name, value, options) { | ||
if (typeof options === 'undefined') { | ||
options = {} | ||
} | ||
var cookieString = name + '=' + value + '; path=/' | ||
if (options.days) { | ||
var date = new Date() | ||
date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000)) | ||
cookieString = cookieString + '; expires=' + date.toGMTString() | ||
} | ||
if (document.location.protocol === 'https:') { | ||
cookieString = cookieString + '; Secure' | ||
} | ||
document.cookie = cookieString | ||
} | ||
|
||
window.GOVUK.getCookie = function (name) { | ||
var nameEQ = name + '=' | ||
var cookies = document.cookie.split(';') | ||
for (var i = 0, len = cookies.length; i < len; i++) { | ||
var cookie = cookies[i] | ||
while (cookie.charAt(0) === ' ') { | ||
cookie = cookie.substring(1, cookie.length) | ||
} | ||
if (cookie.indexOf(nameEQ) === 0) { | ||
return decodeURIComponent(cookie.substring(nameEQ.length)) | ||
} | ||
} | ||
return null | ||
} | ||
}).call(this) |
32 changes: 32 additions & 0 deletions
32
app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// used by the header navigation from govuk_template | ||
|
||
(function () { | ||
'use strict' | ||
|
||
if (document.querySelectorAll && document.addEventListener) { | ||
var els = document.querySelectorAll('.js-header-toggle') | ||
var i | ||
var _i | ||
for (i = 0, _i = els.length; i < _i; i++) { | ||
els[i].addEventListener('click', function (e) { | ||
e.preventDefault() | ||
var target = document.getElementById(this.getAttribute('href').substr(1)) | ||
var targetClass = target.getAttribute('class') || '' | ||
var sourceClass = this.getAttribute('class') || '' | ||
|
||
if (targetClass.indexOf('js-visible') !== -1) { | ||
target.setAttribute('class', targetClass.replace(/(^|\s)js-visible(\s|$)/, '')) | ||
} else { | ||
target.setAttribute('class', targetClass + ' js-visible') | ||
} | ||
if (sourceClass.indexOf('js-visible') !== -1) { | ||
this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, '')) | ||
} else { | ||
this.setAttribute('class', sourceClass + ' js-visible') | ||
} | ||
this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true') | ||
target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === 'false') | ||
}) | ||
} | ||
} | ||
}).call(this) |