-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a39c04a
commit f2bd57c
Showing
87 changed files
with
3,479 additions
and
350 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
4.0.1 | ||
4.1.0 |
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
dist/govuk-frontend-4.0.1.min.js → dist/govuk-frontend-4.1.0.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,88 @@ | ||
import { nodeListForEach } from './common' | ||
import Accordion from './components/accordion/accordion' | ||
import Button from './components/button/button' | ||
import Details from './components/details/details' | ||
import CharacterCount from './components/character-count/character-count' | ||
import Checkboxes from './components/checkboxes/checkboxes' | ||
import ErrorSummary from './components/error-summary/error-summary' | ||
import NotificationBanner from './components/notification-banner/notification-banner' | ||
import Header from './components/header/header' | ||
import Radios from './components/radios/radios' | ||
import SkipLink from './components/skip-link/skip-link' | ||
import Tabs from './components/tabs/tabs' | ||
|
||
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 | ||
|
||
var $buttons = scope.querySelectorAll('[data-module="govuk-button"]') | ||
nodeListForEach($buttons, function ($button) { | ||
new Button($button).init() | ||
}) | ||
|
||
var $accordions = scope.querySelectorAll('[data-module="govuk-accordion"]') | ||
nodeListForEach($accordions, function ($accordion) { | ||
new Accordion($accordion).init() | ||
}) | ||
|
||
var $details = scope.querySelectorAll('[data-module="govuk-details"]') | ||
nodeListForEach($details, function ($detail) { | ||
new Details($detail).init() | ||
}) | ||
|
||
var $characterCounts = scope.querySelectorAll('[data-module="govuk-character-count"]') | ||
nodeListForEach($characterCounts, function ($characterCount) { | ||
new CharacterCount($characterCount).init() | ||
}) | ||
|
||
var $checkboxes = scope.querySelectorAll('[data-module="govuk-checkboxes"]') | ||
nodeListForEach($checkboxes, function ($checkbox) { | ||
new Checkboxes($checkbox).init() | ||
}) | ||
|
||
// Find first error summary module to enhance. | ||
var $errorSummary = scope.querySelector('[data-module="govuk-error-summary"]') | ||
new ErrorSummary($errorSummary).init() | ||
|
||
// Find first header module to enhance. | ||
var $toggleButton = scope.querySelector('[data-module="govuk-header"]') | ||
new Header($toggleButton).init() | ||
|
||
var $notificationBanners = scope.querySelectorAll('[data-module="govuk-notification-banner"]') | ||
nodeListForEach($notificationBanners, function ($notificationBanner) { | ||
new NotificationBanner($notificationBanner).init() | ||
}) | ||
|
||
var $radios = scope.querySelectorAll('[data-module="govuk-radios"]') | ||
nodeListForEach($radios, function ($radio) { | ||
new Radios($radio).init() | ||
}) | ||
|
||
// Find first skip link module to enhance. | ||
var $skipLink = scope.querySelector('[data-module="govuk-skip-link"]') | ||
new SkipLink($skipLink).init() | ||
|
||
var $tabs = scope.querySelectorAll('[data-module="govuk-tabs"]') | ||
nodeListForEach($tabs, function ($tabs) { | ||
new Tabs($tabs).init() | ||
}) | ||
} | ||
|
||
export { | ||
initAll, | ||
Accordion, | ||
Button, | ||
Details, | ||
CharacterCount, | ||
Checkboxes, | ||
ErrorSummary, | ||
Header, | ||
NotificationBanner, | ||
Radios, | ||
SkipLink, | ||
Tabs | ||
} |
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,28 @@ | ||
/** | ||
* TODO: Ideally this would be a NodeList.prototype.forEach polyfill | ||
* This seems to fail in IE8, requires more investigation. | ||
* See: https://github.com/imagitama/nodelist-foreach-polyfill | ||
*/ | ||
export function nodeListForEach (nodes, callback) { | ||
if (window.NodeList.prototype.forEach) { | ||
return nodes.forEach(callback) | ||
} | ||
for (var i = 0; i < nodes.length; i++) { | ||
callback.call(window, nodes[i], i, nodes) | ||
} | ||
} | ||
|
||
// Used to generate a unique string, allows multiple instances of the component without | ||
// Them conflicting with each other. | ||
// https://stackoverflow.com/a/8809472 | ||
export function generateUniqueID () { | ||
var d = new Date().getTime() | ||
if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') { | ||
d += window.performance.now() // use high-precision timer if available | ||
} | ||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | ||
var r = (d + Math.random() * 16) % 16 | 0 | ||
d = Math.floor(d / 16) | ||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16) | ||
}) | ||
} |
Oops, something went wrong.