govuk_publishing_components 16.3.0 → 16.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/modal-dialogue.js +92 -0
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_modal-dialogue.scss +137 -0
- data/app/views/govuk_publishing_components/components/_input.html.erb +2 -0
- data/app/views/govuk_publishing_components/components/_modal_dialogue.html.erb +21 -0
- data/app/views/govuk_publishing_components/components/docs/input.yml +7 -0
- data/app/views/govuk_publishing_components/components/docs/modal_dialogue.yml +71 -0
- data/app/views/govuk_publishing_components/components/feedback/_survey_signup_form.html.erb +1 -0
- data/lib/govuk_publishing_components/presenters/services.rb +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- data/node_modules/govuk-frontend/all.js +26 -1
- data/node_modules/govuk-frontend/components/breadcrumbs/macro-options.json +5 -0
- data/node_modules/govuk-frontend/components/button/button.js +26 -1
- data/node_modules/govuk-frontend/components/button/macro-options.json +6 -0
- data/node_modules/govuk-frontend/components/button/template.njk +1 -1
- data/node_modules/govuk-frontend/components/character-count/macro-options.json +0 -6
- data/node_modules/govuk-frontend/components/checkboxes/macro-options.json +1 -1
- data/node_modules/govuk-frontend/components/checkboxes/template.njk +2 -1
- data/node_modules/govuk-frontend/components/date-input/macro-options.json +13 -1
- data/node_modules/govuk-frontend/components/date-input/template.njk +4 -4
- data/node_modules/govuk-frontend/components/error-message/macro-options.json +5 -0
- data/node_modules/govuk-frontend/components/error-message/template.njk +3 -0
- data/node_modules/govuk-frontend/components/file-upload/macro-options.json +1 -1
- data/node_modules/govuk-frontend/components/file-upload/template.njk +2 -1
- data/node_modules/govuk-frontend/components/footer/macro-options.json +13 -3
- data/node_modules/govuk-frontend/components/footer/template.njk +6 -6
- data/node_modules/govuk-frontend/components/input/macro-options.json +8 -2
- data/node_modules/govuk-frontend/components/input/template.njk +3 -1
- data/node_modules/govuk-frontend/components/inset-text/_inset-text.scss +3 -3
- data/node_modules/govuk-frontend/components/inset-text/macro-options.json +2 -2
- data/node_modules/govuk-frontend/components/radios/macro-options.json +1 -7
- data/node_modules/govuk-frontend/components/radios/template.njk +2 -1
- data/node_modules/govuk-frontend/components/select/macro-options.json +9 -3
- data/node_modules/govuk-frontend/components/select/template.njk +2 -1
- data/node_modules/govuk-frontend/components/skip-link/_skip-link.scss +11 -0
- data/node_modules/govuk-frontend/components/summary-list/_summary-list.scss +7 -3
- data/node_modules/govuk-frontend/components/tabs/macro-options.json +33 -7
- data/node_modules/govuk-frontend/components/textarea/macro-options.json +1 -7
- data/node_modules/govuk-frontend/components/textarea/template.njk +2 -1
- data/node_modules/govuk-frontend/core/_global-styles.scss +4 -0
- data/node_modules/govuk-frontend/core/_links.scss +4 -0
- data/node_modules/govuk-frontend/core/_lists.scss +4 -0
- data/node_modules/govuk-frontend/core/_section-break.scss +4 -0
- data/node_modules/govuk-frontend/core/_template.scss +8 -0
- data/node_modules/govuk-frontend/core/_typography.scss +4 -0
- data/node_modules/govuk-frontend/objects/_form-group.scss +4 -0
- data/node_modules/govuk-frontend/objects/_grid.scss +4 -0
- data/node_modules/govuk-frontend/objects/_main-wrapper.scss +4 -0
- data/node_modules/govuk-frontend/objects/_width-container.scss +32 -0
- data/node_modules/govuk-frontend/overrides/_display.scss +4 -0
- data/node_modules/govuk-frontend/overrides/_spacing.scss +4 -0
- data/node_modules/govuk-frontend/overrides/_typography.scss +4 -0
- data/node_modules/govuk-frontend/overrides/_width.scss +4 -0
- data/node_modules/govuk-frontend/package.json +12 -12
- data/node_modules/govuk-frontend/template.njk +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85a25b42cf4c9b620303d39b346c9ea2e42e9ba2f8d373b59d9febc60860347e
|
4
|
+
data.tar.gz: af180304e40cf20db078384c3f1df96e39e7afc8ac82ad700f3443dce494a818
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36dcb8adefe3b347dda4fdfdb90ad0c68bd4e59869b836cec495a9a0cd622de9395b8f9730ac899b1c709da1874d0131f93da6e4a3d30e8d069f4d81d4d146e3
|
7
|
+
data.tar.gz: 97364626b0268892fa386e6fde4fff548fa7a71e6419d9421e4edbe252d7d9755b9f65fc29cff699f4cddd459b268c9dbb2de10bd22b25da67834eb832dc84f1
|
@@ -0,0 +1,92 @@
|
|
1
|
+
window.GOVUK = window.GOVUK || {}
|
2
|
+
window.GOVUK.Modules = window.GOVUK.Modules || {};
|
3
|
+
|
4
|
+
(function (Modules) {
|
5
|
+
function ModalDialogue () { }
|
6
|
+
|
7
|
+
ModalDialogue.prototype.start = function ($module) {
|
8
|
+
this.$module = $module[0]
|
9
|
+
this.$dialogBox = this.$module.querySelector('.gem-c-modal-dialogue__box')
|
10
|
+
this.$closeButton = this.$module.querySelector('.gem-c-modal-dialogue__close-button')
|
11
|
+
this.$body = document.querySelector('body')
|
12
|
+
|
13
|
+
this.$module.open = this.handleOpen.bind(this)
|
14
|
+
this.$module.close = this.handleClose.bind(this)
|
15
|
+
this.$module.focusDialog = this.handleFocusDialog.bind(this)
|
16
|
+
this.$module.boundKeyDown = this.handleKeyDown.bind(this)
|
17
|
+
|
18
|
+
var $triggerElement = document.querySelector(
|
19
|
+
'[data-toggle="modal"][data-target="' + this.$module.id + '"]'
|
20
|
+
)
|
21
|
+
|
22
|
+
if ($triggerElement) {
|
23
|
+
$triggerElement.addEventListener('click', this.$module.open)
|
24
|
+
}
|
25
|
+
|
26
|
+
if (this.$closeButton) {
|
27
|
+
this.$closeButton.addEventListener('click', this.$module.close)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
ModalDialogue.prototype.handleOpen = function (event) {
|
32
|
+
if (event) {
|
33
|
+
event.preventDefault()
|
34
|
+
}
|
35
|
+
|
36
|
+
this.$body.classList.add('app-o-template__body--modal')
|
37
|
+
this.$body.classList.add('app-o-template__body--blur')
|
38
|
+
this.$focusedElementBeforeOpen = document.activeElement
|
39
|
+
this.$module.style.display = 'block'
|
40
|
+
this.$dialogBox.focus()
|
41
|
+
|
42
|
+
document.addEventListener('keydown', this.$module.boundKeyDown, true)
|
43
|
+
}
|
44
|
+
|
45
|
+
ModalDialogue.prototype.handleClose = function (event) {
|
46
|
+
if (event) {
|
47
|
+
event.preventDefault()
|
48
|
+
}
|
49
|
+
|
50
|
+
this.$body.classList.remove('app-o-template__body--modal')
|
51
|
+
this.$body.classList.remove('app-o-template__body--blur')
|
52
|
+
this.$module.style.display = 'none'
|
53
|
+
this.$focusedElementBeforeOpen.focus()
|
54
|
+
|
55
|
+
document.removeEventListener('keydown', this.$module.boundKeyDown, true)
|
56
|
+
}
|
57
|
+
|
58
|
+
ModalDialogue.prototype.handleFocusDialog = function () {
|
59
|
+
this.$dialogBox.focus()
|
60
|
+
}
|
61
|
+
|
62
|
+
// while open, prevent tabbing to outside the dialogue
|
63
|
+
// and listen for ESC key to close the dialogue
|
64
|
+
ModalDialogue.prototype.handleKeyDown = function (event) {
|
65
|
+
var KEY_TAB = 9
|
66
|
+
var KEY_ESC = 27
|
67
|
+
|
68
|
+
switch (event.keyCode) {
|
69
|
+
case KEY_TAB:
|
70
|
+
if (event.shiftKey) {
|
71
|
+
if (document.activeElement === this.$dialogBox) {
|
72
|
+
event.preventDefault()
|
73
|
+
this.$closeButton.focus()
|
74
|
+
}
|
75
|
+
} else {
|
76
|
+
if (document.activeElement === this.$closeButton) {
|
77
|
+
event.preventDefault()
|
78
|
+
this.$dialogBox.focus()
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
break
|
83
|
+
case KEY_ESC:
|
84
|
+
this.$module.close()
|
85
|
+
break
|
86
|
+
default:
|
87
|
+
break
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
Modules.ModalDialogue = ModalDialogue
|
92
|
+
})(window.GOVUK.Modules)
|
@@ -0,0 +1,137 @@
|
|
1
|
+
$govuk-modal-margin: govuk-spacing(6);
|
2
|
+
$govuk-modal-close-button-size: 44px;
|
3
|
+
$govuk-modal-z-index: 1000;
|
4
|
+
$govuk-modal-wide-breakpoint: $govuk-page-width + $govuk-modal-margin * 2 + $govuk-border-width-form-element * 2;
|
5
|
+
|
6
|
+
.gem-c-modal-dialogue {
|
7
|
+
display: none;
|
8
|
+
position: fixed;
|
9
|
+
z-index: $govuk-modal-z-index;
|
10
|
+
top: 0;
|
11
|
+
left: 0;
|
12
|
+
width: 100%;
|
13
|
+
height: 100%;
|
14
|
+
overflow-x: hidden;
|
15
|
+
overflow-y: scroll;
|
16
|
+
outline: 0;
|
17
|
+
}
|
18
|
+
|
19
|
+
.gem-c-modal-dialogue__box {
|
20
|
+
display: block;
|
21
|
+
position: fixed;
|
22
|
+
background: govuk-colour('white');
|
23
|
+
top: 0;
|
24
|
+
right: 0;
|
25
|
+
bottom: 0;
|
26
|
+
left: 0;
|
27
|
+
width: 100%;
|
28
|
+
height: 100%;
|
29
|
+
margin: 0;
|
30
|
+
padding: 0;
|
31
|
+
overflow-y: auto;
|
32
|
+
border: 0;
|
33
|
+
|
34
|
+
@include govuk-font($size: 19);
|
35
|
+
@include govuk-text-colour;
|
36
|
+
@include govuk-focusable;
|
37
|
+
@include govuk-media-query($from: tablet) {
|
38
|
+
position: relative;
|
39
|
+
top: inherit;
|
40
|
+
right: inherit;
|
41
|
+
bottom: inherit;
|
42
|
+
left: inherit;
|
43
|
+
width: auto;
|
44
|
+
max-width: $govuk-page-width * 2 / 3;
|
45
|
+
height: auto;
|
46
|
+
margin: $govuk-modal-margin auto;
|
47
|
+
border: $govuk-border-width-form-element solid $govuk-input-border-colour;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
.gem-c-modal-dialogue__box--wide {
|
52
|
+
@include govuk-media-query($from: tablet) {
|
53
|
+
max-width: $govuk-page-width;
|
54
|
+
}
|
55
|
+
|
56
|
+
@include govuk-media-query($from: tablet, $until: $govuk-modal-wide-breakpoint) {
|
57
|
+
margin: $govuk-modal-margin;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
.gem-c-modal-dialogue__overlay {
|
62
|
+
position: fixed;
|
63
|
+
top: 0;
|
64
|
+
right: 0;
|
65
|
+
bottom: 0;
|
66
|
+
left: 0;
|
67
|
+
width: 100%;
|
68
|
+
height: 100%;
|
69
|
+
opacity: .8;
|
70
|
+
background: govuk-colour("black");
|
71
|
+
pointer-events: none;
|
72
|
+
touch-action: none;
|
73
|
+
}
|
74
|
+
|
75
|
+
.app-o-template__body--modal {
|
76
|
+
overflow: hidden;
|
77
|
+
}
|
78
|
+
|
79
|
+
.app-o-template__body--blur {
|
80
|
+
.govuk-skip-link,
|
81
|
+
.govuk-header,
|
82
|
+
.govuk-phase-banner,
|
83
|
+
.govuk-width-container .govuk-back-link,
|
84
|
+
.govuk-footer,
|
85
|
+
.govuk-main-wrapper {
|
86
|
+
filter: blur(2px);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
.gem-c-modal-dialogue__header {
|
91
|
+
padding: 8px govuk-spacing(3) 10px;
|
92
|
+
color: govuk-colour("white");
|
93
|
+
background: govuk-colour("black");
|
94
|
+
}
|
95
|
+
|
96
|
+
.gem-c-modal-dialogue__logotype-crown {
|
97
|
+
fill: currentColor;
|
98
|
+
vertical-align: middle;
|
99
|
+
}
|
100
|
+
|
101
|
+
.gem-c-modal-dialogue__logotype-crown-fallback-image {
|
102
|
+
width: 30px;
|
103
|
+
height: 26px;
|
104
|
+
border: 0;
|
105
|
+
vertical-align: middle;
|
106
|
+
}
|
107
|
+
|
108
|
+
.gem-c-modal-dialogue__content {
|
109
|
+
padding: govuk-spacing(3);
|
110
|
+
background: govuk-colour("white");
|
111
|
+
}
|
112
|
+
|
113
|
+
.gem-c-modal-dialogue__close-button {
|
114
|
+
position: absolute;
|
115
|
+
top: 0;
|
116
|
+
right: 0;
|
117
|
+
width: $govuk-modal-close-button-size;
|
118
|
+
height: $govuk-modal-close-button-size;
|
119
|
+
border: 0;
|
120
|
+
color: govuk-colour("white");
|
121
|
+
background: none;
|
122
|
+
cursor: pointer;
|
123
|
+
|
124
|
+
@include govuk-focusable-fill;
|
125
|
+
@include govuk-font($size: 36, $weight: bold, $line-height: 1.3);
|
126
|
+
@include govuk-media-query($until: tablet) {
|
127
|
+
font-size: 36px;
|
128
|
+
line-height: 1.3;
|
129
|
+
}
|
130
|
+
|
131
|
+
&:focus,
|
132
|
+
&:hover {
|
133
|
+
outline: none;
|
134
|
+
color: govuk-colour("black");
|
135
|
+
background: $govuk-focus-colour;
|
136
|
+
}
|
137
|
+
}
|
@@ -5,6 +5,7 @@
|
|
5
5
|
describedby ||= nil
|
6
6
|
controls ||= nil
|
7
7
|
data ||= nil
|
8
|
+
autocomplete ||= nil
|
8
9
|
|
9
10
|
label ||= nil
|
10
11
|
hint ||= nil
|
@@ -65,6 +66,7 @@
|
|
65
66
|
id: id,
|
66
67
|
type: type,
|
67
68
|
data: data,
|
69
|
+
autocomplete: autocomplete,
|
68
70
|
tabindex: tabindex,
|
69
71
|
autofocus: autofocus,
|
70
72
|
readonly: readonly,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%
|
2
|
+
id ||= "modal-dialogue-#{SecureRandom.hex(4)}"
|
3
|
+
wide ||= false
|
4
|
+
%>
|
5
|
+
<div class="gem-c-modal-dialogue" data-module="modal-dialogue" id="<%= id %>">
|
6
|
+
<div class="gem-c-modal-dialogue__overlay"></div>
|
7
|
+
<dialog class="gem-c-modal-dialogue__box <%= 'gem-c-modal-dialogue__box--wide' if wide %>"
|
8
|
+
aria-modal="true" role="dialogue" tabindex="0">
|
9
|
+
<div class="gem-c-modal-dialogue__header">
|
10
|
+
<svg role="presentation" focusable="false" class="gem-c-modal-dialogue__logotype-crown" xmlns="http://www.w3.org/2000/svg" viewbox="0 0 132 97" height="26" width="30">
|
11
|
+
<path fill="currentColor" fill-rule="evenodd"
|
12
|
+
d="M25 30.2c3.5 1.5 7.7-.2 9.1-3.7 1.5-3.6-.2-7.8-3.9-9.2-3.6-1.4-7.6.3-9.1 3.9-1.4 3.5.3 7.5 3.9 9zM9 39.5c3.6 1.5 7.8-.2 9.2-3.7 1.5-3.6-.2-7.8-3.9-9.1-3.6-1.5-7.6.2-9.1 3.8-1.4 3.5.3 7.5 3.8 9zM4.4 57.2c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.5-1.5-7.6.3-9.1 3.8-1.4 3.5.3 7.6 3.9 9.1zm38.3-21.4c3.5 1.5 7.7-.2 9.1-3.8 1.5-3.6-.2-7.7-3.9-9.1-3.6-1.5-7.6.3-9.1 3.8-1.3 3.6.4 7.7 3.9 9.1zm64.4-5.6c-3.6 1.5-7.8-.2-9.1-3.7-1.5-3.6.2-7.8 3.8-9.2 3.6-1.4 7.7.3 9.2 3.9 1.3 3.5-.4 7.5-3.9 9zm15.9 9.3c-3.6 1.5-7.7-.2-9.1-3.7-1.5-3.6.2-7.8 3.7-9.1 3.6-1.5 7.7.2 9.2 3.8 1.5 3.5-.3 7.5-3.8 9zm4.7 17.7c-3.6 1.5-7.8-.2-9.2-3.8-1.5-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.3 3.5-.4 7.6-3.9 9.1zM89.3 35.8c-3.6 1.5-7.8-.2-9.2-3.8-1.4-3.6.2-7.7 3.9-9.1 3.6-1.5 7.7.3 9.2 3.8 1.4 3.6-.3 7.7-3.9 9.1zM69.7 17.7l8.9 4.7V9.3l-8.9 2.8c-.2-.3-.5-.6-.9-.9L72.4 0H59.6l3.5 11.2c-.3.3-.6.5-.9.9l-8.8-2.8v13.1l8.8-4.7c.3.3.6.7.9.9l-5 15.4v.1c-.2.8-.4 1.6-.4 2.4 0 4.1 3.1 7.5 7 8.1h.2c.3 0 .7.1 1 .1.4 0 .7 0 1-.1h.2c4-.6 7.1-4.1 7.1-8.1 0-.8-.1-1.7-.4-2.4V34l-5.1-15.4c.4-.2.7-.6 1-.9zM66 92.8c16.9 0 32.8 1.1 47.1 3.2 4-16.9 8.9-26.7 14-33.5l-9.6-3.4c1 4.9 1.1 7.2 0 10.2-1.5-1.4-3-4.3-4.2-8.7L108.6 76c2.8-2 5-3.2 7.5-3.3-4.4 9.4-10 11.9-13.6 11.2-4.3-.8-6.3-4.6-5.6-7.9 1-4.7 5.7-5.9 8-.5 4.3-8.7-3-11.4-7.6-8.8 7.1-7.2 7.9-13.5 2.1-21.1-8 6.1-8.1 12.3-4.5 20.8-4.7-5.4-12.1-2.5-9.5 6.2 3.4-5.2 7.9-2 7.2 3.1-.6 4.3-6.4 7.8-13.5 7.2-10.3-.9-10.9-8-11.2-13.8 2.5-.5 7.1 1.8 11 7.3L80.2 60c-4.1 4.4-8 5.3-12.3 5.4 1.4-4.4 8-11.6 8-11.6H55.5s6.4 7.2 7.9 11.6c-4.2-.1-8-1-12.3-5.4l1.4 16.4c3.9-5.5 8.5-7.7 10.9-7.3-.3 5.8-.9 12.8-11.1 13.8-7.2.6-12.9-2.9-13.5-7.2-.7-5 3.8-8.3 7.1-3.1 2.7-8.7-4.6-11.6-9.4-6.2 3.7-8.5 3.6-14.7-4.6-20.8-5.8 7.6-5 13.9 2.2 21.1-4.7-2.6-11.9.1-7.7 8.8 2.3-5.5 7.1-4.2 8.1.5.7 3.3-1.3 7.1-5.7 7.9-3.5.7-9-1.8-13.5-11.2 2.5.1 4.7 1.3 7.5 3.3l-4.7-15.4c-1.2 4.4-2.7 7.2-4.3 8.7-1.1-3-.9-5.3 0-10.2l-9.5 3.4c5 6.9 9.9 16.7 14 33.5 14.8-2.1 30.8-3.2 47.7-3.2z"></path>
|
13
|
+
<image src="<%= asset_path('govuk-logotype-crown.png') %>" class="gem-c-modal-dialogue__logotype-crown-fallback-image"></image>
|
14
|
+
</svg>
|
15
|
+
</div>
|
16
|
+
<div class="gem-c-modal-dialogue__content">
|
17
|
+
<%= yield %>
|
18
|
+
</div>
|
19
|
+
<button class="gem-c-modal-dialogue__close-button" aria-label="Close modal dialogue">×</button>
|
20
|
+
</dialog>
|
21
|
+
</div>
|
@@ -103,3 +103,10 @@ examples:
|
|
103
103
|
name: "name"
|
104
104
|
value: "You can't type more"
|
105
105
|
maxlength: 10
|
106
|
+
with_autocomplete:
|
107
|
+
data:
|
108
|
+
label:
|
109
|
+
text: "Automatically complete the field with a user's email address (in supporting browsers)"
|
110
|
+
name: "name"
|
111
|
+
type: "email"
|
112
|
+
autocomplete: "email"
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: Modal dialogue (experimental)
|
2
|
+
description: Shows only one section, with no other navigation options, until the user finishes the immediate task
|
3
|
+
body: |
|
4
|
+
Use where the application has gotten into a state from which it shouldn’t or can’t proceed without input from the user or the state of the current page needs to be preserved.
|
5
|
+
|
6
|
+
In a document-centric application, for instance, adding an inline image might need the user to supply an image file, alternative text, caption and credits if not using an existing image. In other context, the user may need to search for a specific item before proceeding.
|
7
|
+
|
8
|
+
Modal instances are automatically initialised and their state can be changed programmatically using bounded functions (e.g. `$modalDialogue.open()` and `$modalDialogue.close()`)
|
9
|
+
accessibility_criteria: |
|
10
|
+
The modal dialogue box must:
|
11
|
+
|
12
|
+
- receive focus on open
|
13
|
+
- inform the user that it is a dialogue
|
14
|
+
- provide a heading that says what the dialogue is about
|
15
|
+
- prevent mouse clicks outside the dialogue while open
|
16
|
+
- prevent scrolling the page while the dialogue is open
|
17
|
+
- prevent tabbing to outside the dialogue while open
|
18
|
+
- can be operable with a keyboard (allows the ESC key to close the dialogue)
|
19
|
+
- return focus to last focused element on close
|
20
|
+
|
21
|
+
examples:
|
22
|
+
default:
|
23
|
+
embed: |
|
24
|
+
<button class="govuk-button" data-toggle="modal" data-target="modal-default">Open modal</button>
|
25
|
+
<%= component %>
|
26
|
+
data:
|
27
|
+
id: modal-default
|
28
|
+
block: |
|
29
|
+
<h1 class="govuk-heading-l">Modal title</h1>
|
30
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
31
|
+
wide:
|
32
|
+
description: |
|
33
|
+
A wide version of the modal dialogue will provide the same width with the main container
|
34
|
+
embed: |
|
35
|
+
<button class="govuk-button" data-toggle="modal" data-target="modal-wide">Open wide modal</button>
|
36
|
+
<%= component %>
|
37
|
+
data:
|
38
|
+
id: modal-wide
|
39
|
+
wide: true
|
40
|
+
block: |
|
41
|
+
<h1 class="govuk-heading-l">Modal title</h1>
|
42
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
43
|
+
with_form:
|
44
|
+
description: |
|
45
|
+
Modal dialogue with form elements inside to show how it prevents tabbing to outside the dialogue when open while preserving the tabindex on focusable elements
|
46
|
+
embed: |
|
47
|
+
<button class="govuk-button" data-toggle="modal" data-target="modal-with-form">Open modal with form</button>
|
48
|
+
<%= component %>
|
49
|
+
data:
|
50
|
+
id: modal-with-form
|
51
|
+
block: |
|
52
|
+
<h1 class="govuk-heading-l">Search contacts</h1>
|
53
|
+
<label class="govuk-label govuk-visually-hidden" for="contacts">Search contacts</label>
|
54
|
+
<div class="govuk-form-group"><input class="govuk-input" id="contacts"></div>
|
55
|
+
<button class="govuk-button">Insert contact</button>
|
56
|
+
|
57
|
+
with_large_content:
|
58
|
+
description: |
|
59
|
+
Modal dialogue with a large block content to show how the modal scrolls withing the page and how it prevents scrolling the page while the dialogue is open
|
60
|
+
embed: |
|
61
|
+
<button class="govuk-button" data-toggle="modal" data-target="modal-with-large-content">Open modal with large content</button>
|
62
|
+
<%= component %>
|
63
|
+
data:
|
64
|
+
id: modal-with-large-content
|
65
|
+
block: |
|
66
|
+
<h1 class="govuk-heading-l">Modal title</h1>
|
67
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
68
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
69
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
70
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
71
|
+
<p class="govuk-body">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed imperdiet fringilla dictum. Morbi at vehicula augue. Pellentesque varius orci et augue pellentesque, sed elementum massa posuere. Curabitur egestas consectetur arcu, in porta lorem sagittis eu. Nulla facilisi. Sed scelerisque ligula lectus. Nulla et ligula a eros laoreet lacinia nec et ipsum. Ut sagittis sapien est, ut blandit risus laoreet at. Vestibulum vitae erat sed dolor ultricies efficitur.</p>
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"/"
|
50
50
|
],
|
51
51
|
"_resolved": "git://github.com/alphagov/accessible-autocomplete.git#0c518b4fa79b9a95b544410858486ed9e6403c84",
|
52
|
-
"_shasum": "
|
52
|
+
"_shasum": "fa8269e50fd703ac8e130d8c9196b5a52745214e",
|
53
53
|
"_shrinkwrap": null,
|
54
54
|
"_spec": "accessible-autocomplete@git://github.com/alphagov/accessible-autocomplete.git#add-multiselect-support",
|
55
55
|
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ",
|
@@ -1303,13 +1303,14 @@ if (detect) return
|
|
1303
1303
|
*/
|
1304
1304
|
|
1305
1305
|
var KEY_SPACE = 32;
|
1306
|
+
var DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
|
1307
|
+
var debounceFormSubmitTimer = null;
|
1306
1308
|
|
1307
1309
|
function Button ($module) {
|
1308
1310
|
this.$module = $module;
|
1309
1311
|
}
|
1310
1312
|
|
1311
1313
|
/**
|
1312
|
-
* Add event handler for KeyDown
|
1313
1314
|
* if the event target element has a role='button' and the event is key space pressed
|
1314
1315
|
* then it prevents the default event and triggers a click event
|
1315
1316
|
* @param {object} event event
|
@@ -1325,12 +1326,36 @@ Button.prototype.handleKeyDown = function (event) {
|
|
1325
1326
|
}
|
1326
1327
|
};
|
1327
1328
|
|
1329
|
+
/**
|
1330
|
+
* If the click quickly succeeds a previous click then nothing will happen.
|
1331
|
+
* This stops people accidentally causing multiple form submissions by
|
1332
|
+
* double clicking buttons.
|
1333
|
+
*/
|
1334
|
+
Button.prototype.debounce = function (event) {
|
1335
|
+
var target = event.target;
|
1336
|
+
// Check the button that is clicked on has the preventDoubleClick feature enabled
|
1337
|
+
if (target.getAttribute('data-prevent-double-click') !== 'true') {
|
1338
|
+
return
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
// If the timer is still running then we want to prevent the click from submitting the form
|
1342
|
+
if (debounceFormSubmitTimer) {
|
1343
|
+
event.preventDefault();
|
1344
|
+
return false
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
debounceFormSubmitTimer = setTimeout(function () {
|
1348
|
+
debounceFormSubmitTimer = null;
|
1349
|
+
}, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
|
1350
|
+
};
|
1351
|
+
|
1328
1352
|
/**
|
1329
1353
|
* Initialise an event listener for keydown at document level
|
1330
1354
|
* this will help listening for later inserted elements with a role="button"
|
1331
1355
|
*/
|
1332
1356
|
Button.prototype.init = function () {
|
1333
1357
|
this.$module.addEventListener('keydown', this.handleKeyDown);
|
1358
|
+
this.$module.addEventListener('click', this.debounce);
|
1334
1359
|
};
|
1335
1360
|
|
1336
1361
|
/**
|