Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview v5: Update template with "supported" check #317

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/get-started/index.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ In your live application, we recommend [using an automated task or your build pi

## 5. Get the JavaScript working

1. Add the following to the top of the `<body>` section of your page template:
1. Add the following to the top of the `<body class="govuk-template__body">` section of your page template:

```html
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
```

2. Copy the `/node-modules/govuk-frontend/govuk/all.js` file to `<YOUR-JAVASCRIPT-FOLDER>/govuk.js`.

3. Import the file before the closing `</body>` tag of your page template, then run the `initAll` function to initialise all the components. For example:

```html
<body>
<body class="govuk-template__body">
...
<script src="<YOUR-JAVASCRIPT-FOLDER>/govuk.js"></script>
<script>
Expand Down
4 changes: 2 additions & 2 deletions source/importing-css-assets-and-javascript/index.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ If you decide to add the JavaScript to your HTML, first either:
Then import the JavaScript file before the closing `</body>` tag of your HTML page or page template, and run the `initAll` function to initialise all the components.

```html
<body>
<body class="govuk-template__body">
...
<script src="<YOUR-APP>/<YOUR-JS-FILE>.js"></script>
<script>
Expand Down Expand Up @@ -251,7 +251,7 @@ You can unblock inline JavaScript by including the following hash in your CSP:
%>

```
sha256-+6WnXIl4mbFTCARd8N3COQmT3bJJmo32N8q8ZSQAIcU=
sha256-GUQ5ad8JK5KmEWmROf3LZd9ge94daqNvd8xy9YS1iDw=
```

You do not need to make any changes to the HTML.
Expand Down
12 changes: 3 additions & 9 deletions source/install-using-precompiled-files/index.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You’ll not be able to:

```html
<!DOCTYPE html>
<html lang="en" class="govuk-template ">
<html lang="en" class="govuk-template">
<head>
<title>Example - GOV.UK</title>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
Expand All @@ -44,10 +44,8 @@ You’ll not be able to:
<link rel="stylesheet" href="/stylesheets/govuk-frontend-ie8-<VERSION-NUMBER>.min.css">
<![endif]-->
</head>
<body class="govuk-template__body ">
<script>
document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');
</script>
<body class="govuk-template__body">
<script>document.body.className += ' js-enabled' + ('noModule' in HTMLScriptElement.prototype ? ' govuk-frontend-supported' : '');</script>
<!-- component HTML -->
<script src="/javascript/govuk-frontend-<VERSION-NUMBER>.min.js"></script>
<script>
Expand All @@ -69,7 +67,3 @@ You’ll not be able to:
You can now get the full code for page layouts and other components from the [Design System website](https://design-system.service.gov.uk/).

If the accordion does not work, you can [find out more about how to import GOV.UK Frontend's CSS and JavaScript](/importing-css-assets-and-javascript/#import-css-assets-and-javascript).