2019-11-19 14:57:49 +00:00
|
|
|
// JS Module used to combine all the JS modules used in the application into a single entry point,
|
|
|
|
|
// a bit like `app/__init__` in the Flask app.
|
|
|
|
|
//
|
|
|
|
|
// When processed by a bundler, this is turned into a Immediately Invoked Function Expression (IIFE)
|
2019-11-20 13:43:07 +00:00
|
|
|
// The IIFE format allows it to run in browsers that don't support JS Modules.
|
2019-11-19 14:57:49 +00:00
|
|
|
//
|
|
|
|
|
// Exported items will be added to the window.GOVUK namespace.
|
2019-11-20 13:43:07 +00:00
|
|
|
// For example, `export { Frontend }` will assign `Frontend` to `window.Frontend`
|
2019-10-11 10:26:25 +01:00
|
|
|
import Header from 'govuk-frontend/components/header/header';
|
|
|
|
|
|
2019-11-19 14:57:49 +00:00
|
|
|
// Copy of the initAll function from https://github.com/alphagov/govuk-frontend/blob/v2.13.0/src/all.js
|
|
|
|
|
// except it only includes, and initialises, the components used by this application.
|
2019-10-11 10:26:25 +01:00
|
|
|
function initAll (options) {
|
|
|
|
|
// Set the options to an empty object by default if no options are passed.
|
|
|
|
|
options = typeof options !== 'undefined' ? options : {}
|
|
|
|
|
|
|
|
|
|
// Allow the user to initialise GOV.UK Frontend in only certain sections of the page
|
|
|
|
|
// Defaults to the entire document if nothing is set.
|
|
|
|
|
var scope = typeof options.scope !== 'undefined' ? options.scope : document
|
|
|
|
|
|
|
|
|
|
// Find first header module to enhance.
|
|
|
|
|
var $toggleButton = scope.querySelector('[data-module="header"]')
|
|
|
|
|
new Header($toggleButton).init()
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-19 14:57:49 +00:00
|
|
|
// Create separate namespace for GOVUK Frontend.
|
|
|
|
|
var Frontend = {
|
|
|
|
|
"Header": Header,
|
|
|
|
|
"initAll": initAll
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-11 10:26:25 +01:00
|
|
|
export {
|
2019-11-19 14:57:49 +00:00
|
|
|
Frontend
|
2019-10-11 10:26:25 +01:00
|
|
|
}
|