govuk_publishing_components 9.3.6 → 9.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/assets/stylesheets/component_guide/application.scss +10 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/admin_styles.scss +13 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +66 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-footer.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-admin.scss +1 -0
- data/app/models/govuk_publishing_components/component_doc.rb +12 -0
- data/app/views/govuk_publishing_components/component_guide/component_doc/_preview.html.erb +7 -5
- data/app/views/govuk_publishing_components/component_guide/show.html.erb +22 -0
- data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +39 -0
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +26 -0
- data/app/views/govuk_publishing_components/components/_layout_for_admin.html.erb +10 -0
- data/app/views/govuk_publishing_components/components/docs/highlight_boxes.yml +142 -0
- data/app/views/govuk_publishing_components/components/docs/layout_footer.yml +12 -0
- data/app/views/govuk_publishing_components/components/docs/layout_for_admin.yml +28 -0
- data/app/views/govuk_publishing_components/components/docs/metadata.yml +1 -0
- data/app/views/layouts/govuk_publishing_components/application.html.erb +5 -0
- data/config/initializers/assets.rb +12 -0
- data/lib/govuk_publishing_components.rb +1 -0
- data/lib/govuk_publishing_components/presenters/highlight_boxes_helper.rb +13 -0
- data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/README.md +96 -0
- data/node_modules/govuk-frontend/all-ie8.scss +6 -0
- data/node_modules/govuk-frontend/all.js +1720 -0
- data/node_modules/govuk-frontend/all.scss +11 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-a2452cb66f-v1.woff2 +0 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-f38c792ac2-v1.woff +0 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-fb2676462a-v1.eot +0 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-tabular-357fdfbcc3-v1.eot +0 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-tabular-784c21afb8-v1.woff +0 -0
- data/node_modules/govuk-frontend/assets/fonts/bold-tabular-b89238d840-v1.woff2 +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-2c037cf7e1-v1.eot +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-458f8ea81c-v1.woff +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-f38ad40456-v1.woff2 +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-tabular-498ea8ffe2-v1.eot +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-tabular-62cc6f0a28-v1.woff +0 -0
- data/node_modules/govuk-frontend/assets/fonts/light-tabular-851b10ccdd-v1.woff2 +0 -0
- data/node_modules/govuk-frontend/assets/images/favicon.ico +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-152x152.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-167x167.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon-180x180.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-apple-touch-icon.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-crest.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-logotype-crown.png +0 -0
- data/node_modules/govuk-frontend/assets/images/govuk-mask-icon.svg +7 -0
- data/node_modules/govuk-frontend/assets/images/govuk-opengraph-image.png +0 -0
- data/node_modules/govuk-frontend/assets/images/icon-arrow-left.png +0 -0
- data/node_modules/govuk-frontend/assets/images/icon-important.png +0 -0
- data/node_modules/govuk-frontend/assets/images/icon-pointer-2x.png +0 -0
- data/node_modules/govuk-frontend/assets/images/icon-pointer.png +0 -0
- data/node_modules/govuk-frontend/common.js +39 -0
- data/node_modules/govuk-frontend/components/_all.scss +26 -0
- data/node_modules/govuk-frontend/components/back-link/README.md +142 -0
- data/node_modules/govuk-frontend/components/back-link/_back-link.scss +54 -0
- data/node_modules/govuk-frontend/components/back-link/back-link.njk +3 -0
- data/node_modules/govuk-frontend/components/back-link/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/back-link/template.njk +2 -0
- data/node_modules/govuk-frontend/components/breadcrumbs/README.md +335 -0
- data/node_modules/govuk-frontend/components/breadcrumbs/_breadcrumbs.scss +119 -0
- data/node_modules/govuk-frontend/components/breadcrumbs/breadcrumbs.njk +14 -0
- data/node_modules/govuk-frontend/components/breadcrumbs/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/breadcrumbs/template.njk +13 -0
- data/node_modules/govuk-frontend/components/button/README.md +319 -0
- data/node_modules/govuk-frontend/components/button/_button.scss +185 -0
- data/node_modules/govuk-frontend/components/button/button.js +548 -0
- data/node_modules/govuk-frontend/components/button/button.njk +3 -0
- data/node_modules/govuk-frontend/components/button/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/button/template.njk +35 -0
- data/node_modules/govuk-frontend/components/checkboxes/README.md +782 -0
- data/node_modules/govuk-frontend/components/checkboxes/_checkboxes.scss +151 -0
- data/node_modules/govuk-frontend/components/checkboxes/checkboxes.js +730 -0
- data/node_modules/govuk-frontend/components/checkboxes/checkboxes.njk +27 -0
- data/node_modules/govuk-frontend/components/checkboxes/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/checkboxes/template.njk +86 -0
- data/node_modules/govuk-frontend/components/date-input/README.md +640 -0
- data/node_modules/govuk-frontend/components/date-input/_date-input.scss +35 -0
- data/node_modules/govuk-frontend/components/date-input/date-input.njk +23 -0
- data/node_modules/govuk-frontend/components/date-input/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/date-input/template.njk +76 -0
- data/node_modules/govuk-frontend/components/details/README.md +237 -0
- data/node_modules/govuk-frontend/components/details/_details.scss +86 -0
- data/node_modules/govuk-frontend/components/details/details.js +836 -0
- data/node_modules/govuk-frontend/components/details/details.njk +7 -0
- data/node_modules/govuk-frontend/components/details/implementation.md +43 -0
- data/node_modules/govuk-frontend/components/details/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/details/template.njk +10 -0
- data/node_modules/govuk-frontend/components/error-message/README.md +143 -0
- data/node_modules/govuk-frontend/components/error-message/_error-message.scss +15 -0
- data/node_modules/govuk-frontend/components/error-message/error-message.njk +7 -0
- data/node_modules/govuk-frontend/components/error-message/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/error-message/template.njk +3 -0
- data/node_modules/govuk-frontend/components/error-summary/README.md +215 -0
- data/node_modules/govuk-frontend/components/error-summary/_error-summary.scss +68 -0
- data/node_modules/govuk-frontend/components/error-summary/error-summary.js +520 -0
- data/node_modules/govuk-frontend/components/error-summary/error-summary.njk +17 -0
- data/node_modules/govuk-frontend/components/error-summary/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/error-summary/template.njk +25 -0
- data/node_modules/govuk-frontend/components/fieldset/README.md +213 -0
- data/node_modules/govuk-frontend/components/fieldset/_fieldset.scss +58 -0
- data/node_modules/govuk-frontend/components/fieldset/fieldset.njk +13 -0
- data/node_modules/govuk-frontend/components/fieldset/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/fieldset/template.njk +17 -0
- data/node_modules/govuk-frontend/components/file-upload/README.md +332 -0
- data/node_modules/govuk-frontend/components/file-upload/_file-upload.scss +19 -0
- data/node_modules/govuk-frontend/components/file-upload/file-upload.njk +9 -0
- data/node_modules/govuk-frontend/components/file-upload/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/file-upload/template.njk +42 -0
- data/node_modules/govuk-frontend/components/footer/README.md +284 -0
- data/node_modules/govuk-frontend/components/footer/_footer.scss +216 -0
- data/node_modules/govuk-frontend/components/footer/footer.njk +3 -0
- data/node_modules/govuk-frontend/components/footer/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/footer/template.njk +80 -0
- data/node_modules/govuk-frontend/components/header/README.md +524 -0
- data/node_modules/govuk-frontend/components/header/_header.scss +285 -0
- data/node_modules/govuk-frontend/components/header/header.js +717 -0
- data/node_modules/govuk-frontend/components/header/header.njk +3 -0
- data/node_modules/govuk-frontend/components/header/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/header/template.njk +82 -0
- data/node_modules/govuk-frontend/components/hint/README.md +157 -0
- data/node_modules/govuk-frontend/components/hint/_hint.scss +29 -0
- data/node_modules/govuk-frontend/components/hint/hint.njk +7 -0
- data/node_modules/govuk-frontend/components/hint/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/hint/template.njk +4 -0
- data/node_modules/govuk-frontend/components/input/README.md +416 -0
- data/node_modules/govuk-frontend/components/input/_input.scss +62 -0
- data/node_modules/govuk-frontend/components/input/input.njk +9 -0
- data/node_modules/govuk-frontend/components/input/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/input/template.njk +42 -0
- data/node_modules/govuk-frontend/components/inset-text/README.md +157 -0
- data/node_modules/govuk-frontend/components/inset-text/_inset-text.scss +28 -0
- data/node_modules/govuk-frontend/components/inset-text/inset-text.njk +7 -0
- data/node_modules/govuk-frontend/components/inset-text/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/inset-text/template.njk +4 -0
- data/node_modules/govuk-frontend/components/label/README.md +193 -0
- data/node_modules/govuk-frontend/components/label/_label.scss +45 -0
- data/node_modules/govuk-frontend/components/label/label.njk +6 -0
- data/node_modules/govuk-frontend/components/label/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/label/template.njk +15 -0
- data/node_modules/govuk-frontend/components/panel/README.md +151 -0
- data/node_modules/govuk-frontend/components/panel/_panel.scss +42 -0
- data/node_modules/govuk-frontend/components/panel/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/panel/panel.njk +7 -0
- data/node_modules/govuk-frontend/components/panel/template.njk +12 -0
- data/node_modules/govuk-frontend/components/phase-banner/README.md +152 -0
- data/node_modules/govuk-frontend/components/phase-banner/_phase-banner.scss +31 -0
- data/node_modules/govuk-frontend/components/phase-banner/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/phase-banner/phase-banner.njk +7 -0
- data/node_modules/govuk-frontend/components/phase-banner/template.njk +17 -0
- data/node_modules/govuk-frontend/components/radios/README.md +686 -0
- data/node_modules/govuk-frontend/components/radios/_radios.scss +157 -0
- data/node_modules/govuk-frontend/components/radios/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/radios/radios.js +730 -0
- data/node_modules/govuk-frontend/components/radios/radios.njk +27 -0
- data/node_modules/govuk-frontend/components/radios/template.njk +85 -0
- data/node_modules/govuk-frontend/components/select/README.md +387 -0
- data/node_modules/govuk-frontend/components/select/_select.scss +35 -0
- data/node_modules/govuk-frontend/components/select/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/select/select.njk +24 -0
- data/node_modules/govuk-frontend/components/select/template.njk +44 -0
- data/node_modules/govuk-frontend/components/skip-link/README.md +142 -0
- data/node_modules/govuk-frontend/components/skip-link/_skip-link.scss +15 -0
- data/node_modules/govuk-frontend/components/skip-link/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/skip-link/skip-link.njk +3 -0
- data/node_modules/govuk-frontend/components/skip-link/template.njk +3 -0
- data/node_modules/govuk-frontend/components/table/README.md +585 -0
- data/node_modules/govuk-frontend/components/table/_table.scss +50 -0
- data/node_modules/govuk-frontend/components/table/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/table/table.njk +45 -0
- data/node_modules/govuk-frontend/components/table/template.njk +39 -0
- data/node_modules/govuk-frontend/components/tabs/README.md +375 -0
- data/node_modules/govuk-frontend/components/tabs/_tabs.scss +120 -0
- data/node_modules/govuk-frontend/components/tabs/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/tabs/tabs.js +1302 -0
- data/node_modules/govuk-frontend/components/tabs/tabs.njk +3 -0
- data/node_modules/govuk-frontend/components/tabs/template.njk +29 -0
- data/node_modules/govuk-frontend/components/tag/README.md +150 -0
- data/node_modules/govuk-frontend/components/tag/_tag.scss +23 -0
- data/node_modules/govuk-frontend/components/tag/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/tag/tag.njk +7 -0
- data/node_modules/govuk-frontend/components/tag/template.njk +3 -0
- data/node_modules/govuk-frontend/components/textarea/README.md +350 -0
- data/node_modules/govuk-frontend/components/textarea/_textarea.scss +31 -0
- data/node_modules/govuk-frontend/components/textarea/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/textarea/template.njk +41 -0
- data/node_modules/govuk-frontend/components/textarea/textarea.njk +11 -0
- data/node_modules/govuk-frontend/components/warning-text/README.md +148 -0
- data/node_modules/govuk-frontend/components/warning-text/_warning-text.scss +50 -0
- data/node_modules/govuk-frontend/components/warning-text/macro.njk +3 -0
- data/node_modules/govuk-frontend/components/warning-text/template.njk +9 -0
- data/node_modules/govuk-frontend/components/warning-text/warning-text.njk +9 -0
- data/node_modules/govuk-frontend/core/_all.scss +6 -0
- data/node_modules/govuk-frontend/core/_global-styles.scss +19 -0
- data/node_modules/govuk-frontend/core/_links.scss +40 -0
- data/node_modules/govuk-frontend/core/_lists.scss +63 -0
- data/node_modules/govuk-frontend/core/_section-break.scss +56 -0
- data/node_modules/govuk-frontend/core/_template.scss +16 -0
- data/node_modules/govuk-frontend/core/_typography.scss +186 -0
- data/node_modules/govuk-frontend/helpers/_all.scss +12 -0
- data/node_modules/govuk-frontend/helpers/_clearfix.scss +15 -0
- data/node_modules/govuk-frontend/helpers/_colour.scss +51 -0
- data/node_modules/govuk-frontend/helpers/_device-pixels.scss +38 -0
- data/node_modules/govuk-frontend/helpers/_focusable.scss +34 -0
- data/node_modules/govuk-frontend/helpers/_font-faces.scss +67 -0
- data/node_modules/govuk-frontend/helpers/_grid.scss +100 -0
- data/node_modules/govuk-frontend/helpers/_links.scss +149 -0
- data/node_modules/govuk-frontend/helpers/_media-queries.scss +95 -0
- data/node_modules/govuk-frontend/helpers/_shape-arrow.scss +80 -0
- data/node_modules/govuk-frontend/helpers/_spacing.scss +152 -0
- data/node_modules/govuk-frontend/helpers/_typography.scss +153 -0
- data/node_modules/govuk-frontend/helpers/_visually-hidden.scss +76 -0
- data/node_modules/govuk-frontend/objects/_all.scss +4 -0
- data/node_modules/govuk-frontend/objects/_form-group.scss +21 -0
- data/node_modules/govuk-frontend/objects/_grid.scss +10 -0
- data/node_modules/govuk-frontend/objects/_main-wrapper.scss +37 -0
- data/node_modules/govuk-frontend/objects/_width-container.scss +28 -0
- data/node_modules/govuk-frontend/overrides/_all.scss +4 -0
- data/node_modules/govuk-frontend/overrides/_display.scss +14 -0
- data/node_modules/govuk-frontend/overrides/_spacing.scss +58 -0
- data/node_modules/govuk-frontend/overrides/_typography.scss +21 -0
- data/node_modules/govuk-frontend/overrides/_width.scss +41 -0
- data/node_modules/govuk-frontend/package.json +89 -0
- data/node_modules/govuk-frontend/settings/_all.scss +21 -0
- data/node_modules/govuk-frontend/settings/_assets.scss +82 -0
- data/node_modules/govuk-frontend/settings/_colours-applied.scss +130 -0
- data/node_modules/govuk-frontend/settings/_colours-organisations.scss +136 -0
- data/node_modules/govuk-frontend/settings/_colours-palette.scss +37 -0
- data/node_modules/govuk-frontend/settings/_compatibility.scss +51 -0
- data/node_modules/govuk-frontend/settings/_global-styles.scss +13 -0
- data/node_modules/govuk-frontend/settings/_ie8.scss +18 -0
- data/node_modules/govuk-frontend/settings/_measurements.scss +85 -0
- data/node_modules/govuk-frontend/settings/_media-queries.scss +23 -0
- data/node_modules/govuk-frontend/settings/_spacing.scss +80 -0
- data/node_modules/govuk-frontend/settings/_typography-font-families.scss +22 -0
- data/node_modules/govuk-frontend/settings/_typography-font.scss +48 -0
- data/node_modules/govuk-frontend/settings/_typography-responsive.scss +138 -0
- data/node_modules/govuk-frontend/template.njk +56 -0
- data/node_modules/govuk-frontend/tools/_all.scss +7 -0
- data/node_modules/govuk-frontend/tools/_compatibility.scss +36 -0
- data/node_modules/govuk-frontend/tools/_exports.scss +33 -0
- data/node_modules/govuk-frontend/tools/_font-url.scss +28 -0
- data/node_modules/govuk-frontend/tools/_ie8.scss +51 -0
- data/node_modules/govuk-frontend/tools/_iff.scss +15 -0
- data/node_modules/govuk-frontend/tools/_image-url.scss +28 -0
- data/node_modules/govuk-frontend/tools/_px-to-em.scss +20 -0
- data/node_modules/govuk-frontend/utilities/_all.scss +2 -0
- data/node_modules/govuk-frontend/utilities/_clearfix.scss +5 -0
- data/node_modules/govuk-frontend/utilities/_visually-hidden.scss +9 -0
- data/node_modules/govuk-frontend/vendor/_sass-mq.scss +351 -0
- data/node_modules/govuk-frontend/vendor/polyfills/DOMTokenList.js +272 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Document.js +34 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Element.js +147 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Element/prototype/classList.js +449 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Event.js +504 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Function/prototype/bind.js +252 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Object/defineProperty.js +94 -0
- data/node_modules/govuk-frontend/vendor/polyfills/Window.js +28 -0
- metadata +249 -2
@@ -0,0 +1,185 @@
|
|
1
|
+
@import "../../settings/all";
|
2
|
+
@import "../../tools/all";
|
3
|
+
@import "../../helpers/all";
|
4
|
+
|
5
|
+
@include govuk-exports("govuk/component/button") {
|
6
|
+
|
7
|
+
$govuk-button-colour: #00823b;
|
8
|
+
$govuk-button-hover-colour: darken($govuk-button-colour, 5%);
|
9
|
+
$govuk-button-shadow-colour: darken($govuk-button-colour, 15%);
|
10
|
+
$govuk-button-text-colour: govuk-colour("white");
|
11
|
+
|
12
|
+
// Because the shadow (s0) is visually 'part of' the button, we need to reduce
|
13
|
+
// the height of the button to compensate by adjusting its padding (s1) and
|
14
|
+
// increase the bottom margin to include it (s2).
|
15
|
+
$button-shadow-size: $govuk-border-width-form-element;
|
16
|
+
|
17
|
+
.govuk-button {
|
18
|
+
@include govuk-font($size: 19, $line-height: 19px);
|
19
|
+
@include govuk-focusable;
|
20
|
+
|
21
|
+
-webkit-box-sizing: border-box;
|
22
|
+
|
23
|
+
box-sizing: border-box;
|
24
|
+
display: inline-block;
|
25
|
+
position: relative;
|
26
|
+
width: 100%;
|
27
|
+
margin-top: 0;
|
28
|
+
@include govuk-responsive-margin(6, "bottom", $adjustment: $button-shadow-size); // s2
|
29
|
+
padding: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2)) govuk-spacing(2); // s1
|
30
|
+
border: $govuk-border-width-form-element solid transparent;
|
31
|
+
border-radius: 0;
|
32
|
+
color: $govuk-button-text-colour;
|
33
|
+
background-color: $govuk-button-colour;
|
34
|
+
-webkit-box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour;
|
35
|
+
box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour; // s0
|
36
|
+
text-align: center;
|
37
|
+
vertical-align: top;
|
38
|
+
cursor: pointer;
|
39
|
+
-webkit-appearance: none;
|
40
|
+
|
41
|
+
@include govuk-if-ie8 {
|
42
|
+
border-bottom: $button-shadow-size solid $govuk-button-shadow-colour;
|
43
|
+
}
|
44
|
+
|
45
|
+
@include govuk-media-query($from: tablet) {
|
46
|
+
width: auto;
|
47
|
+
}
|
48
|
+
|
49
|
+
// Ensure that any global link styles are overridden
|
50
|
+
&:link,
|
51
|
+
&:visited,
|
52
|
+
&:active,
|
53
|
+
&:hover {
|
54
|
+
color: $govuk-button-text-colour;
|
55
|
+
text-decoration: none;
|
56
|
+
}
|
57
|
+
|
58
|
+
// alphagov/govuk_template includes a specific a:link:focus selector
|
59
|
+
// designed to make unvisited links a slightly darker blue when focussed, so
|
60
|
+
// we need to override the text colour for that combination of selectors so
|
61
|
+
// so that unvisited links styled as buttons do not end up with dark blue
|
62
|
+
// text when focussed.
|
63
|
+
@include govuk-compatibility(govuk_template) {
|
64
|
+
&:link:focus {
|
65
|
+
color: $govuk-button-text-colour;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
// Fix unwanted button padding in Firefox
|
70
|
+
&:-moz-focus-inner {
|
71
|
+
padding: 0;
|
72
|
+
border: 0;
|
73
|
+
}
|
74
|
+
|
75
|
+
&:hover,
|
76
|
+
&:focus {
|
77
|
+
background-color: $govuk-button-hover-colour;
|
78
|
+
}
|
79
|
+
|
80
|
+
&:active {
|
81
|
+
top: $button-shadow-size;
|
82
|
+
-webkit-box-shadow: none;
|
83
|
+
box-shadow: none;
|
84
|
+
|
85
|
+
@include govuk-if-ie8 {
|
86
|
+
border-bottom-width: 0;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
// The following adjustments do not work for <input type="button"> as
|
91
|
+
// non-container elements cannot include pseudo elements (i.e. ::before).
|
92
|
+
|
93
|
+
// Use a pseudo element to expand the click target area to include the
|
94
|
+
// button's shadow as well, in case users try to click it.
|
95
|
+
&::before {
|
96
|
+
content: "";
|
97
|
+
display: block;
|
98
|
+
|
99
|
+
position: absolute;
|
100
|
+
|
101
|
+
top: -$govuk-border-width-form-element;
|
102
|
+
right: -$govuk-border-width-form-element;
|
103
|
+
bottom: -($govuk-border-width-form-element + $button-shadow-size);
|
104
|
+
left: -$govuk-border-width-form-element;
|
105
|
+
|
106
|
+
background: transparent;
|
107
|
+
}
|
108
|
+
|
109
|
+
// When the button is active it is shifted down by $button-shadow-size to
|
110
|
+
// denote a 'pressed' state. If the user happened to click at the very top
|
111
|
+
// of the button, their mouse is no longer over the button (because it has
|
112
|
+
// 'moved beneath them') and so the click event is not fired.
|
113
|
+
//
|
114
|
+
// This corrects that by shifting the top of the pseudo element so that it
|
115
|
+
// continues to cover the area that the user originally clicked, which means
|
116
|
+
// the click event is still fired.
|
117
|
+
//
|
118
|
+
// 🎉
|
119
|
+
&:active::before {
|
120
|
+
top: -($govuk-border-width-form-element + $button-shadow-size);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
.govuk-button--disabled,
|
125
|
+
.govuk-button[disabled="disabled"],
|
126
|
+
.govuk-button[disabled] {
|
127
|
+
opacity: (.5);
|
128
|
+
background: $govuk-button-colour;
|
129
|
+
|
130
|
+
&:hover {
|
131
|
+
background-color: $govuk-button-colour;
|
132
|
+
cursor: default;
|
133
|
+
}
|
134
|
+
|
135
|
+
&:focus {
|
136
|
+
outline: none;
|
137
|
+
}
|
138
|
+
|
139
|
+
&:active {
|
140
|
+
top: 0;
|
141
|
+
-webkit-box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour;
|
142
|
+
box-shadow: 0 $button-shadow-size 0 $govuk-button-shadow-colour; // s0
|
143
|
+
@include govuk-if-ie8 {
|
144
|
+
border-bottom: $button-shadow-size solid $govuk-button-shadow-colour; // s0
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
.govuk-button--start {
|
150
|
+
@include govuk-typography-weight-bold;
|
151
|
+
@include govuk-typography-responsive($size: 24, $override-line-height: 1);
|
152
|
+
|
153
|
+
min-height: auto;
|
154
|
+
padding-top: govuk-spacing(2) - $govuk-border-width-form-element;
|
155
|
+
padding-right: govuk-spacing(7);
|
156
|
+
padding-bottom: govuk-spacing(2) - $govuk-border-width-form-element;
|
157
|
+
padding-left: govuk-spacing(3);
|
158
|
+
|
159
|
+
background-image: govuk-image-url("icon-pointer.png");
|
160
|
+
background-repeat: no-repeat;
|
161
|
+
background-position: 100% 50%;
|
162
|
+
|
163
|
+
@include govuk-device-pixel-ratio {
|
164
|
+
background-image: govuk-image-url("icon-pointer-2x.png");
|
165
|
+
background-size: 30px 19px;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
|
169
|
+
// Begin adjustments for font baseline offset
|
170
|
+
// These should be removed when the font is updated with the correct baseline
|
171
|
+
// For the 1px addition please see https://github.com/alphagov/govuk-frontend/pull/365#discussion_r154349428
|
172
|
+
|
173
|
+
$offset: 2;
|
174
|
+
|
175
|
+
.govuk-button {
|
176
|
+
padding-top: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) + $offset); // s1
|
177
|
+
padding-bottom: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) - $offset + 1); // s1
|
178
|
+
}
|
179
|
+
|
180
|
+
.govuk-button--start {
|
181
|
+
padding-top: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) + $offset); // s1
|
182
|
+
padding-bottom: (govuk-spacing(2) - $govuk-border-width-form-element - ($button-shadow-size / 2) - $offset + 1); // s1
|
183
|
+
}
|
184
|
+
|
185
|
+
}
|
@@ -0,0 +1,548 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
3
|
+
typeof define === 'function' && define.amd ? define('GOVUKFrontend', factory) :
|
4
|
+
(global.GOVUKFrontend = factory());
|
5
|
+
}(this, (function () { 'use strict';
|
6
|
+
|
7
|
+
(function(undefined) {
|
8
|
+
|
9
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Window/detect.js
|
10
|
+
var detect = ('Window' in this);
|
11
|
+
|
12
|
+
if (detect) return
|
13
|
+
|
14
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Window&flags=always
|
15
|
+
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
16
|
+
(function (global) {
|
17
|
+
if (global.constructor) {
|
18
|
+
global.Window = global.constructor;
|
19
|
+
} else {
|
20
|
+
(global.Window = global.constructor = new Function('return function Window() {}')()).prototype = this;
|
21
|
+
}
|
22
|
+
}(this));
|
23
|
+
}
|
24
|
+
|
25
|
+
})
|
26
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
27
|
+
|
28
|
+
(function(undefined) {
|
29
|
+
|
30
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
31
|
+
var detect = ("Document" in this);
|
32
|
+
|
33
|
+
if (detect) return
|
34
|
+
|
35
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
36
|
+
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
37
|
+
|
38
|
+
if (this.HTMLDocument) { // IE8
|
39
|
+
|
40
|
+
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
41
|
+
this.Document = this.HTMLDocument;
|
42
|
+
|
43
|
+
} else {
|
44
|
+
|
45
|
+
// Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
|
46
|
+
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
47
|
+
this.Document.prototype = document;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
})
|
53
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
54
|
+
|
55
|
+
(function(undefined) {
|
56
|
+
|
57
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Element/detect.js
|
58
|
+
var detect = ('Element' in this && 'HTMLElement' in this);
|
59
|
+
|
60
|
+
if (detect) return
|
61
|
+
|
62
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element&flags=always
|
63
|
+
(function () {
|
64
|
+
|
65
|
+
// IE8
|
66
|
+
if (window.Element && !window.HTMLElement) {
|
67
|
+
window.HTMLElement = window.Element;
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
|
71
|
+
// create Element constructor
|
72
|
+
window.Element = window.HTMLElement = new Function('return function Element() {}')();
|
73
|
+
|
74
|
+
// generate sandboxed iframe
|
75
|
+
var vbody = document.appendChild(document.createElement('body'));
|
76
|
+
var frame = vbody.appendChild(document.createElement('iframe'));
|
77
|
+
|
78
|
+
// use sandboxed iframe to replicate Element functionality
|
79
|
+
var frameDocument = frame.contentWindow.document;
|
80
|
+
var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
|
81
|
+
var cache = {};
|
82
|
+
|
83
|
+
// polyfill Element.prototype on an element
|
84
|
+
var shiv = function (element, deep) {
|
85
|
+
var
|
86
|
+
childNodes = element.childNodes || [],
|
87
|
+
index = -1,
|
88
|
+
key, value, childNode;
|
89
|
+
|
90
|
+
if (element.nodeType === 1 && element.constructor !== Element) {
|
91
|
+
element.constructor = Element;
|
92
|
+
|
93
|
+
for (key in cache) {
|
94
|
+
value = cache[key];
|
95
|
+
element[key] = value;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
while (childNode = deep && childNodes[++index]) {
|
100
|
+
shiv(childNode, deep);
|
101
|
+
}
|
102
|
+
|
103
|
+
return element;
|
104
|
+
};
|
105
|
+
|
106
|
+
var elements = document.getElementsByTagName('*');
|
107
|
+
var nativeCreateElement = document.createElement;
|
108
|
+
var interval;
|
109
|
+
var loopLimit = 100;
|
110
|
+
|
111
|
+
prototype.attachEvent('onpropertychange', function (event) {
|
112
|
+
var
|
113
|
+
propertyName = event.propertyName,
|
114
|
+
nonValue = !cache.hasOwnProperty(propertyName),
|
115
|
+
newValue = prototype[propertyName],
|
116
|
+
oldValue = cache[propertyName],
|
117
|
+
index = -1,
|
118
|
+
element;
|
119
|
+
|
120
|
+
while (element = elements[++index]) {
|
121
|
+
if (element.nodeType === 1) {
|
122
|
+
if (nonValue || element[propertyName] === oldValue) {
|
123
|
+
element[propertyName] = newValue;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
cache[propertyName] = newValue;
|
129
|
+
});
|
130
|
+
|
131
|
+
prototype.constructor = Element;
|
132
|
+
|
133
|
+
if (!prototype.hasAttribute) {
|
134
|
+
// <Element>.hasAttribute
|
135
|
+
prototype.hasAttribute = function hasAttribute(name) {
|
136
|
+
return this.getAttribute(name) !== null;
|
137
|
+
};
|
138
|
+
}
|
139
|
+
|
140
|
+
// Apply Element prototype to the pre-existing DOM as soon as the body element appears.
|
141
|
+
function bodyCheck() {
|
142
|
+
if (!(loopLimit--)) clearTimeout(interval);
|
143
|
+
if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
|
144
|
+
shiv(document, true);
|
145
|
+
if (interval && document.body.prototype) clearTimeout(interval);
|
146
|
+
return (!!document.body.prototype);
|
147
|
+
}
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
if (!bodyCheck()) {
|
151
|
+
document.onreadystatechange = bodyCheck;
|
152
|
+
interval = setInterval(bodyCheck, 25);
|
153
|
+
}
|
154
|
+
|
155
|
+
// Apply to any new elements created after load
|
156
|
+
document.createElement = function createElement(nodeName) {
|
157
|
+
var element = nativeCreateElement(String(nodeName).toLowerCase());
|
158
|
+
return shiv(element);
|
159
|
+
};
|
160
|
+
|
161
|
+
// remove sandboxed iframe
|
162
|
+
document.removeChild(vbody);
|
163
|
+
}());
|
164
|
+
|
165
|
+
})
|
166
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
167
|
+
|
168
|
+
(function(undefined) {
|
169
|
+
|
170
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Object/defineProperty/detect.js
|
171
|
+
var detect = (
|
172
|
+
// In IE8, defineProperty could only act on DOM elements, so full support
|
173
|
+
// for the feature requires the ability to set a property on an arbitrary object
|
174
|
+
'defineProperty' in Object && (function() {
|
175
|
+
try {
|
176
|
+
var a = {};
|
177
|
+
Object.defineProperty(a, 'test', {value:42});
|
178
|
+
return true;
|
179
|
+
} catch(e) {
|
180
|
+
return false
|
181
|
+
}
|
182
|
+
}())
|
183
|
+
);
|
184
|
+
|
185
|
+
if (detect) return
|
186
|
+
|
187
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Object.defineProperty&flags=always
|
188
|
+
(function (nativeDefineProperty) {
|
189
|
+
|
190
|
+
var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
|
191
|
+
var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
|
192
|
+
var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
|
193
|
+
|
194
|
+
Object.defineProperty = function defineProperty(object, property, descriptor) {
|
195
|
+
|
196
|
+
// Where native support exists, assume it
|
197
|
+
if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
|
198
|
+
return nativeDefineProperty(object, property, descriptor);
|
199
|
+
}
|
200
|
+
|
201
|
+
if (object === null || !(object instanceof Object || typeof object === 'object')) {
|
202
|
+
throw new TypeError('Object.defineProperty called on non-object');
|
203
|
+
}
|
204
|
+
|
205
|
+
if (!(descriptor instanceof Object)) {
|
206
|
+
throw new TypeError('Property description must be an object');
|
207
|
+
}
|
208
|
+
|
209
|
+
var propertyString = String(property);
|
210
|
+
var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
|
211
|
+
var getterType = 'get' in descriptor && typeof descriptor.get;
|
212
|
+
var setterType = 'set' in descriptor && typeof descriptor.set;
|
213
|
+
|
214
|
+
// handle descriptor.get
|
215
|
+
if (getterType) {
|
216
|
+
if (getterType !== 'function') {
|
217
|
+
throw new TypeError('Getter must be a function');
|
218
|
+
}
|
219
|
+
if (!supportsAccessors) {
|
220
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
221
|
+
}
|
222
|
+
if (hasValueOrWritable) {
|
223
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
224
|
+
}
|
225
|
+
Object.__defineGetter__.call(object, propertyString, descriptor.get);
|
226
|
+
} else {
|
227
|
+
object[propertyString] = descriptor.value;
|
228
|
+
}
|
229
|
+
|
230
|
+
// handle descriptor.set
|
231
|
+
if (setterType) {
|
232
|
+
if (setterType !== 'function') {
|
233
|
+
throw new TypeError('Setter must be a function');
|
234
|
+
}
|
235
|
+
if (!supportsAccessors) {
|
236
|
+
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
|
237
|
+
}
|
238
|
+
if (hasValueOrWritable) {
|
239
|
+
throw new TypeError(ERR_VALUE_ACCESSORS);
|
240
|
+
}
|
241
|
+
Object.__defineSetter__.call(object, propertyString, descriptor.set);
|
242
|
+
}
|
243
|
+
|
244
|
+
// OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
|
245
|
+
if ('value' in descriptor) {
|
246
|
+
object[propertyString] = descriptor.value;
|
247
|
+
}
|
248
|
+
|
249
|
+
return object;
|
250
|
+
};
|
251
|
+
}(Object.defineProperty));
|
252
|
+
})
|
253
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
254
|
+
|
255
|
+
(function(undefined) {
|
256
|
+
|
257
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Event/detect.js
|
258
|
+
var detect = (
|
259
|
+
(function(global) {
|
260
|
+
|
261
|
+
if (!('Event' in global)) return false;
|
262
|
+
if (typeof global.Event === 'function') return true;
|
263
|
+
|
264
|
+
try {
|
265
|
+
|
266
|
+
// In IE 9-11, the Event object exists but cannot be instantiated
|
267
|
+
new Event('click');
|
268
|
+
return true;
|
269
|
+
} catch(e) {
|
270
|
+
return false;
|
271
|
+
}
|
272
|
+
}(this))
|
273
|
+
);
|
274
|
+
|
275
|
+
if (detect) return
|
276
|
+
|
277
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Event&flags=always
|
278
|
+
(function () {
|
279
|
+
var unlistenableWindowEvents = {
|
280
|
+
click: 1,
|
281
|
+
dblclick: 1,
|
282
|
+
keyup: 1,
|
283
|
+
keypress: 1,
|
284
|
+
keydown: 1,
|
285
|
+
mousedown: 1,
|
286
|
+
mouseup: 1,
|
287
|
+
mousemove: 1,
|
288
|
+
mouseover: 1,
|
289
|
+
mouseenter: 1,
|
290
|
+
mouseleave: 1,
|
291
|
+
mouseout: 1,
|
292
|
+
storage: 1,
|
293
|
+
storagecommit: 1,
|
294
|
+
textinput: 1
|
295
|
+
};
|
296
|
+
|
297
|
+
// This polyfill depends on availability of `document` so will not run in a worker
|
298
|
+
// However, we asssume there are no browsers with worker support that lack proper
|
299
|
+
// support for `Event` within the worker
|
300
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') return;
|
301
|
+
|
302
|
+
function indexOf(array, element) {
|
303
|
+
var
|
304
|
+
index = -1,
|
305
|
+
length = array.length;
|
306
|
+
|
307
|
+
while (++index < length) {
|
308
|
+
if (index in array && array[index] === element) {
|
309
|
+
return index;
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
return -1;
|
314
|
+
}
|
315
|
+
|
316
|
+
var existingProto = (window.Event && window.Event.prototype) || null;
|
317
|
+
window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
|
318
|
+
if (!type) {
|
319
|
+
throw new Error('Not enough arguments');
|
320
|
+
}
|
321
|
+
|
322
|
+
var event;
|
323
|
+
// Shortcut if browser supports createEvent
|
324
|
+
if ('createEvent' in document) {
|
325
|
+
event = document.createEvent('Event');
|
326
|
+
var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
327
|
+
var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
328
|
+
|
329
|
+
event.initEvent(type, bubbles, cancelable);
|
330
|
+
|
331
|
+
return event;
|
332
|
+
}
|
333
|
+
|
334
|
+
event = document.createEventObject();
|
335
|
+
|
336
|
+
event.type = type;
|
337
|
+
event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
|
338
|
+
event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
|
339
|
+
|
340
|
+
return event;
|
341
|
+
};
|
342
|
+
if (existingProto) {
|
343
|
+
Object.defineProperty(window.Event, 'prototype', {
|
344
|
+
configurable: false,
|
345
|
+
enumerable: false,
|
346
|
+
writable: true,
|
347
|
+
value: existingProto
|
348
|
+
});
|
349
|
+
}
|
350
|
+
|
351
|
+
if (!('createEvent' in document)) {
|
352
|
+
window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
|
353
|
+
var
|
354
|
+
element = this,
|
355
|
+
type = arguments[0],
|
356
|
+
listener = arguments[1];
|
357
|
+
|
358
|
+
if (element === window && type in unlistenableWindowEvents) {
|
359
|
+
throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
|
360
|
+
}
|
361
|
+
|
362
|
+
if (!element._events) {
|
363
|
+
element._events = {};
|
364
|
+
}
|
365
|
+
|
366
|
+
if (!element._events[type]) {
|
367
|
+
element._events[type] = function (event) {
|
368
|
+
var
|
369
|
+
list = element._events[event.type].list,
|
370
|
+
events = list.slice(),
|
371
|
+
index = -1,
|
372
|
+
length = events.length,
|
373
|
+
eventElement;
|
374
|
+
|
375
|
+
event.preventDefault = function preventDefault() {
|
376
|
+
if (event.cancelable !== false) {
|
377
|
+
event.returnValue = false;
|
378
|
+
}
|
379
|
+
};
|
380
|
+
|
381
|
+
event.stopPropagation = function stopPropagation() {
|
382
|
+
event.cancelBubble = true;
|
383
|
+
};
|
384
|
+
|
385
|
+
event.stopImmediatePropagation = function stopImmediatePropagation() {
|
386
|
+
event.cancelBubble = true;
|
387
|
+
event.cancelImmediate = true;
|
388
|
+
};
|
389
|
+
|
390
|
+
event.currentTarget = element;
|
391
|
+
event.relatedTarget = event.fromElement || null;
|
392
|
+
event.target = event.target || event.srcElement || element;
|
393
|
+
event.timeStamp = new Date().getTime();
|
394
|
+
|
395
|
+
if (event.clientX) {
|
396
|
+
event.pageX = event.clientX + document.documentElement.scrollLeft;
|
397
|
+
event.pageY = event.clientY + document.documentElement.scrollTop;
|
398
|
+
}
|
399
|
+
|
400
|
+
while (++index < length && !event.cancelImmediate) {
|
401
|
+
if (index in events) {
|
402
|
+
eventElement = events[index];
|
403
|
+
|
404
|
+
if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
|
405
|
+
eventElement.call(element, event);
|
406
|
+
}
|
407
|
+
}
|
408
|
+
}
|
409
|
+
};
|
410
|
+
|
411
|
+
element._events[type].list = [];
|
412
|
+
|
413
|
+
if (element.attachEvent) {
|
414
|
+
element.attachEvent('on' + type, element._events[type]);
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
element._events[type].list.push(listener);
|
419
|
+
};
|
420
|
+
|
421
|
+
window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
|
422
|
+
var
|
423
|
+
element = this,
|
424
|
+
type = arguments[0],
|
425
|
+
listener = arguments[1],
|
426
|
+
index;
|
427
|
+
|
428
|
+
if (element._events && element._events[type] && element._events[type].list) {
|
429
|
+
index = indexOf(element._events[type].list, listener);
|
430
|
+
|
431
|
+
if (index !== -1) {
|
432
|
+
element._events[type].list.splice(index, 1);
|
433
|
+
|
434
|
+
if (!element._events[type].list.length) {
|
435
|
+
if (element.detachEvent) {
|
436
|
+
element.detachEvent('on' + type, element._events[type]);
|
437
|
+
}
|
438
|
+
delete element._events[type];
|
439
|
+
}
|
440
|
+
}
|
441
|
+
}
|
442
|
+
};
|
443
|
+
|
444
|
+
window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
|
445
|
+
if (!arguments.length) {
|
446
|
+
throw new Error('Not enough arguments');
|
447
|
+
}
|
448
|
+
|
449
|
+
if (!event || typeof event.type !== 'string') {
|
450
|
+
throw new Error('DOM Events Exception 0');
|
451
|
+
}
|
452
|
+
|
453
|
+
var element = this, type = event.type;
|
454
|
+
|
455
|
+
try {
|
456
|
+
if (!event.bubbles) {
|
457
|
+
event.cancelBubble = true;
|
458
|
+
|
459
|
+
var cancelBubbleEvent = function (event) {
|
460
|
+
event.cancelBubble = true;
|
461
|
+
|
462
|
+
(element || window).detachEvent('on' + type, cancelBubbleEvent);
|
463
|
+
};
|
464
|
+
|
465
|
+
this.attachEvent('on' + type, cancelBubbleEvent);
|
466
|
+
}
|
467
|
+
|
468
|
+
this.fireEvent('on' + type, event);
|
469
|
+
} catch (error) {
|
470
|
+
event.target = element;
|
471
|
+
|
472
|
+
do {
|
473
|
+
event.currentTarget = element;
|
474
|
+
|
475
|
+
if ('_events' in element && typeof element._events[type] === 'function') {
|
476
|
+
element._events[type].call(element, event);
|
477
|
+
}
|
478
|
+
|
479
|
+
if (typeof element['on' + type] === 'function') {
|
480
|
+
element['on' + type].call(element, event);
|
481
|
+
}
|
482
|
+
|
483
|
+
element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
|
484
|
+
} while (element && !event.cancelBubble);
|
485
|
+
}
|
486
|
+
|
487
|
+
return true;
|
488
|
+
};
|
489
|
+
|
490
|
+
// Add the DOMContentLoaded Event
|
491
|
+
document.attachEvent('onreadystatechange', function() {
|
492
|
+
if (document.readyState === 'complete') {
|
493
|
+
document.dispatchEvent(new Event('DOMContentLoaded', {
|
494
|
+
bubbles: true
|
495
|
+
}));
|
496
|
+
}
|
497
|
+
});
|
498
|
+
}
|
499
|
+
}());
|
500
|
+
|
501
|
+
})
|
502
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
503
|
+
|
504
|
+
/**
|
505
|
+
* JavaScript 'shim' to trigger the click event of element(s) when the space key is pressed.
|
506
|
+
*
|
507
|
+
* Created since some Assistive Technologies (for example some Screenreaders)
|
508
|
+
* will tell a user to press space on a 'button', so this functionality needs to be shimmed
|
509
|
+
* See https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270
|
510
|
+
*
|
511
|
+
* Usage instructions:
|
512
|
+
* the 'shim' will be automatically initialised
|
513
|
+
*/
|
514
|
+
|
515
|
+
var KEY_SPACE = 32;
|
516
|
+
|
517
|
+
function Button ($module) {
|
518
|
+
this.$module = $module;
|
519
|
+
}
|
520
|
+
|
521
|
+
/**
|
522
|
+
* Add event handler for KeyDown
|
523
|
+
* if the event target element has a role='button' and the event is key space pressed
|
524
|
+
* then it prevents the default event and triggers a click event
|
525
|
+
* @param {object} event event
|
526
|
+
*/
|
527
|
+
Button.prototype.handleKeyDown = function (event) {
|
528
|
+
// get the target element
|
529
|
+
var target = event.target;
|
530
|
+
// if the element has a role='button' and the pressed key is a space, we'll simulate a click
|
531
|
+
if (target.getAttribute('role') === 'button' && event.keyCode === KEY_SPACE) {
|
532
|
+
event.preventDefault();
|
533
|
+
// trigger the target's click event
|
534
|
+
target.click();
|
535
|
+
}
|
536
|
+
};
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Initialise an event listener for keydown at document level
|
540
|
+
* this will help listening for later inserted elements with a role="button"
|
541
|
+
*/
|
542
|
+
Button.prototype.init = function () {
|
543
|
+
this.$module.addEventListener('keydown', this.handleKeyDown);
|
544
|
+
};
|
545
|
+
|
546
|
+
return Button;
|
547
|
+
|
548
|
+
})));
|