govuk_publishing_components 29.9.0 → 29.10.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/analytics/page-content.js +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_contextual-sidebar.scss +20 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +3 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/govspeak/_attachment.scss +7 -1
- data/app/controllers/govuk_publishing_components/audit_controller.rb +3 -2
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +0 -9
- data/app/models/govuk_publishing_components/audit_comparer.rb +92 -34
- data/app/views/govuk_publishing_components/audit/_applications.html.erb +20 -9
- data/app/views/govuk_publishing_components/component_guide/index.html.erb +1 -19
- data/app/views/govuk_publishing_components/components/_layout_footer.html.erb +20 -2
- data/app/views/govuk_publishing_components/components/contextual_sidebar/_ukraine_cta.html.erb +18 -19
- data/config/locales/ar.yml +1 -2
- data/config/locales/az.yml +1 -2
- data/config/locales/be.yml +1 -2
- data/config/locales/bg.yml +1 -2
- data/config/locales/bn.yml +1 -2
- data/config/locales/cs.yml +1 -2
- data/config/locales/cy.yml +1 -2
- data/config/locales/da.yml +1 -2
- data/config/locales/de.yml +1 -2
- data/config/locales/dr.yml +1 -2
- data/config/locales/el.yml +1 -2
- data/config/locales/en.yml +9 -2
- data/config/locales/es-419.yml +1 -2
- data/config/locales/es.yml +1 -2
- data/config/locales/et.yml +1 -2
- data/config/locales/fa.yml +1 -2
- data/config/locales/fi.yml +1 -2
- data/config/locales/fr.yml +1 -2
- data/config/locales/gd.yml +1 -2
- data/config/locales/gu.yml +1 -2
- data/config/locales/he.yml +1 -2
- data/config/locales/hi.yml +1 -2
- data/config/locales/hr.yml +1 -2
- data/config/locales/hu.yml +1 -2
- data/config/locales/hy.yml +1 -2
- data/config/locales/id.yml +1 -2
- data/config/locales/is.yml +1 -2
- data/config/locales/it.yml +1 -2
- data/config/locales/ja.yml +1 -2
- data/config/locales/ka.yml +1 -2
- data/config/locales/kk.yml +1 -2
- data/config/locales/ko.yml +1 -2
- data/config/locales/lt.yml +1 -2
- data/config/locales/lv.yml +1 -2
- data/config/locales/ms.yml +1 -2
- data/config/locales/mt.yml +1 -2
- data/config/locales/nl.yml +1 -2
- data/config/locales/no.yml +1 -2
- data/config/locales/pa-pk.yml +1 -2
- data/config/locales/pa.yml +1 -2
- data/config/locales/pl.yml +1 -2
- data/config/locales/ps.yml +1 -2
- data/config/locales/pt.yml +1 -2
- data/config/locales/ro.yml +1 -2
- data/config/locales/ru.yml +1 -2
- data/config/locales/si.yml +1 -2
- data/config/locales/sk.yml +1 -2
- data/config/locales/sl.yml +1 -2
- data/config/locales/so.yml +1 -2
- data/config/locales/sq.yml +1 -2
- data/config/locales/sr.yml +1 -2
- data/config/locales/sv.yml +1 -2
- data/config/locales/sw.yml +1 -2
- data/config/locales/ta.yml +1 -2
- data/config/locales/th.yml +1 -2
- data/config/locales/tk.yml +1 -2
- data/config/locales/tr.yml +1 -2
- data/config/locales/uk.yml +1 -2
- data/config/locales/ur.yml +1 -2
- data/config/locales/uz.yml +1 -2
- data/config/locales/vi.yml +1 -2
- data/config/locales/zh-hk.yml +1 -2
- data/config/locales/zh-tw.yml +1 -2
- data/config/locales/zh.yml +1 -2
- data/lib/govuk_publishing_components/presenters/attachment_helper.rb +1 -2
- data/lib/govuk_publishing_components/presenters/public_layout_helper.rb +35 -16
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/govuk/all.js +120 -49
- data/node_modules/govuk-frontend/govuk/components/back-link/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/_index.scss +0 -2
- data/node_modules/govuk-frontend/govuk/components/breadcrumbs/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/button/_index.scss +6 -16
- data/node_modules/govuk-frontend/govuk/components/button/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/character-count.js +120 -49
- data/node_modules/govuk-frontend/govuk/components/character-count/fixtures.json +33 -17
- data/node_modules/govuk-frontend/govuk/components/character-count/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/character-count/template.njk +1 -4
- data/node_modules/govuk-frontend/govuk/components/checkboxes/_index.scss +3 -2
- data/node_modules/govuk-frontend/govuk/components/checkboxes/fixtures.json +22 -10
- data/node_modules/govuk-frontend/govuk/components/checkboxes/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/date-input/fixtures.json +23 -23
- data/node_modules/govuk-frontend/govuk/components/date-input/template.njk +1 -1
- data/node_modules/govuk-frontend/govuk/components/details/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/error-message/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/error-summary/macro-options.json +3 -3
- data/node_modules/govuk-frontend/govuk/components/fieldset/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/footer/_index.scss +12 -22
- data/node_modules/govuk-frontend/govuk/components/header/_index.scss +13 -3
- data/node_modules/govuk-frontend/govuk/components/header/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/hint/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/input/_index.scss +4 -13
- data/node_modules/govuk-frontend/govuk/components/input/macro-options.json +5 -5
- data/node_modules/govuk-frontend/govuk/components/inset-text/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/label/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/panel/_index.scss +1 -1
- data/node_modules/govuk-frontend/govuk/components/panel/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/phase-banner/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/radios/_index.scss +5 -4
- data/node_modules/govuk-frontend/govuk/components/radios/fixtures.json +17 -12
- data/node_modules/govuk-frontend/govuk/components/radios/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/skip-link/_index.scss +1 -3
- data/node_modules/govuk-frontend/govuk/components/skip-link/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/summary-list/macro-options.json +5 -5
- data/node_modules/govuk-frontend/govuk/components/table/macro-options.json +4 -4
- data/node_modules/govuk-frontend/govuk/components/tabs/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/tag/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/components/warning-text/macro-options.json +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_colour.scss +3 -3
- data/node_modules/govuk-frontend/govuk/helpers/_links.scss +7 -5
- data/node_modules/govuk-frontend/govuk/helpers/_media-queries.scss +2 -2
- data/node_modules/govuk-frontend/govuk/helpers/_shape-arrow.scss +1 -1
- data/node_modules/govuk-frontend/govuk/helpers/_spacing.scss +3 -3
- data/node_modules/govuk-frontend/govuk/helpers/_typography.scss +2 -2
- data/node_modules/govuk-frontend/govuk/objects/_button-group.scss +10 -26
- data/node_modules/govuk-frontend/govuk/objects/_template.scss +1 -1
- data/node_modules/govuk-frontend/govuk/objects/_width-container.scss +0 -4
- data/node_modules/govuk-frontend/govuk/tools/_exports.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_font-url.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_image-url.scss +1 -1
- data/node_modules/govuk-frontend/govuk/tools/_px-to-em.scss +2 -2
- data/node_modules/govuk-frontend/govuk/tools/_px-to-rem.scss +1 -1
- data/node_modules/govuk-frontend/govuk-esm/all.mjs +88 -0
- data/node_modules/govuk-frontend/govuk-esm/common.mjs +28 -0
- data/node_modules/govuk-frontend/govuk-esm/components/accordion/accordion.mjs +374 -0
- data/node_modules/govuk-frontend/govuk-esm/components/button/button.mjs +64 -0
- data/node_modules/govuk-frontend/govuk-esm/components/character-count/character-count.mjs +251 -0
- data/node_modules/govuk-frontend/govuk-esm/components/checkboxes/checkboxes.mjs +164 -0
- data/node_modules/govuk-frontend/govuk-esm/components/details/details.mjs +147 -0
- data/node_modules/govuk-frontend/govuk-esm/components/error-summary/error-summary.mjs +168 -0
- data/node_modules/govuk-frontend/govuk-esm/components/header/header.mjs +52 -0
- data/node_modules/govuk-frontend/govuk-esm/components/notification-banner/notification-banner.mjs +55 -0
- data/node_modules/govuk-frontend/govuk-esm/components/radios/radios.mjs +122 -0
- data/node_modules/govuk-frontend/govuk-esm/components/skip-link/skip-link.mjs +94 -0
- data/node_modules/govuk-frontend/govuk-esm/components/tabs/tabs.mjs +282 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/DOMTokenList.js +264 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Document.js +26 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/classList.js +93 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/closest.js +24 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/matches.js +23 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/nextElementSibling.js +22 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element/prototype/previousElementSibling.js +22 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Element.js +114 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Event.js +252 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Function/prototype/bind.js +159 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Object/defineProperty.js +86 -0
- data/node_modules/govuk-frontend/govuk-esm/vendor/polyfills/Window.js +20 -0
- data/node_modules/govuk-frontend/package.json +8 -1
- metadata +27 -2
@@ -0,0 +1,282 @@
|
|
1
|
+
import '../../vendor/polyfills/Function/prototype/bind'
|
2
|
+
import '../../vendor/polyfills/Element/prototype/classList'
|
3
|
+
import '../../vendor/polyfills/Element/prototype/nextElementSibling'
|
4
|
+
import '../../vendor/polyfills/Element/prototype/previousElementSibling'
|
5
|
+
import '../../vendor/polyfills/Event' // addEventListener and event.target normaliziation
|
6
|
+
import { nodeListForEach } from '../../common'
|
7
|
+
|
8
|
+
function Tabs ($module) {
|
9
|
+
this.$module = $module
|
10
|
+
this.$tabs = $module.querySelectorAll('.govuk-tabs__tab')
|
11
|
+
|
12
|
+
this.keys = { left: 37, right: 39, up: 38, down: 40 }
|
13
|
+
this.jsHiddenClass = 'govuk-tabs__panel--hidden'
|
14
|
+
}
|
15
|
+
|
16
|
+
Tabs.prototype.init = function () {
|
17
|
+
if (typeof window.matchMedia === 'function') {
|
18
|
+
this.setupResponsiveChecks()
|
19
|
+
} else {
|
20
|
+
this.setup()
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
Tabs.prototype.setupResponsiveChecks = function () {
|
25
|
+
this.mql = window.matchMedia('(min-width: 40.0625em)')
|
26
|
+
this.mql.addListener(this.checkMode.bind(this))
|
27
|
+
this.checkMode()
|
28
|
+
}
|
29
|
+
|
30
|
+
Tabs.prototype.checkMode = function () {
|
31
|
+
if (this.mql.matches) {
|
32
|
+
this.setup()
|
33
|
+
} else {
|
34
|
+
this.teardown()
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
Tabs.prototype.setup = function () {
|
39
|
+
var $module = this.$module
|
40
|
+
var $tabs = this.$tabs
|
41
|
+
var $tabList = $module.querySelector('.govuk-tabs__list')
|
42
|
+
var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item')
|
43
|
+
|
44
|
+
if (!$tabs || !$tabList || !$tabListItems) {
|
45
|
+
return
|
46
|
+
}
|
47
|
+
|
48
|
+
$tabList.setAttribute('role', 'tablist')
|
49
|
+
|
50
|
+
nodeListForEach($tabListItems, function ($item) {
|
51
|
+
$item.setAttribute('role', 'presentation')
|
52
|
+
})
|
53
|
+
|
54
|
+
nodeListForEach($tabs, function ($tab) {
|
55
|
+
// Set HTML attributes
|
56
|
+
this.setAttributes($tab)
|
57
|
+
|
58
|
+
// Save bounded functions to use when removing event listeners during teardown
|
59
|
+
$tab.boundTabClick = this.onTabClick.bind(this)
|
60
|
+
$tab.boundTabKeydown = this.onTabKeydown.bind(this)
|
61
|
+
|
62
|
+
// Handle events
|
63
|
+
$tab.addEventListener('click', $tab.boundTabClick, true)
|
64
|
+
$tab.addEventListener('keydown', $tab.boundTabKeydown, true)
|
65
|
+
|
66
|
+
// Remove old active panels
|
67
|
+
this.hideTab($tab)
|
68
|
+
}.bind(this))
|
69
|
+
|
70
|
+
// Show either the active tab according to the URL's hash or the first tab
|
71
|
+
var $activeTab = this.getTab(window.location.hash) || this.$tabs[0]
|
72
|
+
this.showTab($activeTab)
|
73
|
+
|
74
|
+
// Handle hashchange events
|
75
|
+
$module.boundOnHashChange = this.onHashChange.bind(this)
|
76
|
+
window.addEventListener('hashchange', $module.boundOnHashChange, true)
|
77
|
+
}
|
78
|
+
|
79
|
+
Tabs.prototype.teardown = function () {
|
80
|
+
var $module = this.$module
|
81
|
+
var $tabs = this.$tabs
|
82
|
+
var $tabList = $module.querySelector('.govuk-tabs__list')
|
83
|
+
var $tabListItems = $module.querySelectorAll('.govuk-tabs__list-item')
|
84
|
+
|
85
|
+
if (!$tabs || !$tabList || !$tabListItems) {
|
86
|
+
return
|
87
|
+
}
|
88
|
+
|
89
|
+
$tabList.removeAttribute('role')
|
90
|
+
|
91
|
+
nodeListForEach($tabListItems, function ($item) {
|
92
|
+
$item.removeAttribute('role', 'presentation')
|
93
|
+
})
|
94
|
+
|
95
|
+
nodeListForEach($tabs, function ($tab) {
|
96
|
+
// Remove events
|
97
|
+
$tab.removeEventListener('click', $tab.boundTabClick, true)
|
98
|
+
$tab.removeEventListener('keydown', $tab.boundTabKeydown, true)
|
99
|
+
|
100
|
+
// Unset HTML attributes
|
101
|
+
this.unsetAttributes($tab)
|
102
|
+
}.bind(this))
|
103
|
+
|
104
|
+
// Remove hashchange event handler
|
105
|
+
window.removeEventListener('hashchange', $module.boundOnHashChange, true)
|
106
|
+
}
|
107
|
+
|
108
|
+
Tabs.prototype.onHashChange = function (e) {
|
109
|
+
var hash = window.location.hash
|
110
|
+
var $tabWithHash = this.getTab(hash)
|
111
|
+
if (!$tabWithHash) {
|
112
|
+
return
|
113
|
+
}
|
114
|
+
|
115
|
+
// Prevent changing the hash
|
116
|
+
if (this.changingHash) {
|
117
|
+
this.changingHash = false
|
118
|
+
return
|
119
|
+
}
|
120
|
+
|
121
|
+
// Show either the active tab according to the URL's hash or the first tab
|
122
|
+
var $previousTab = this.getCurrentTab()
|
123
|
+
|
124
|
+
this.hideTab($previousTab)
|
125
|
+
this.showTab($tabWithHash)
|
126
|
+
$tabWithHash.focus()
|
127
|
+
}
|
128
|
+
|
129
|
+
Tabs.prototype.hideTab = function ($tab) {
|
130
|
+
this.unhighlightTab($tab)
|
131
|
+
this.hidePanel($tab)
|
132
|
+
}
|
133
|
+
|
134
|
+
Tabs.prototype.showTab = function ($tab) {
|
135
|
+
this.highlightTab($tab)
|
136
|
+
this.showPanel($tab)
|
137
|
+
}
|
138
|
+
|
139
|
+
Tabs.prototype.getTab = function (hash) {
|
140
|
+
return this.$module.querySelector('.govuk-tabs__tab[href="' + hash + '"]')
|
141
|
+
}
|
142
|
+
|
143
|
+
Tabs.prototype.setAttributes = function ($tab) {
|
144
|
+
// set tab attributes
|
145
|
+
var panelId = this.getHref($tab).slice(1)
|
146
|
+
$tab.setAttribute('id', 'tab_' + panelId)
|
147
|
+
$tab.setAttribute('role', 'tab')
|
148
|
+
$tab.setAttribute('aria-controls', panelId)
|
149
|
+
$tab.setAttribute('aria-selected', 'false')
|
150
|
+
$tab.setAttribute('tabindex', '-1')
|
151
|
+
|
152
|
+
// set panel attributes
|
153
|
+
var $panel = this.getPanel($tab)
|
154
|
+
$panel.setAttribute('role', 'tabpanel')
|
155
|
+
$panel.setAttribute('aria-labelledby', $tab.id)
|
156
|
+
$panel.classList.add(this.jsHiddenClass)
|
157
|
+
}
|
158
|
+
|
159
|
+
Tabs.prototype.unsetAttributes = function ($tab) {
|
160
|
+
// unset tab attributes
|
161
|
+
$tab.removeAttribute('id')
|
162
|
+
$tab.removeAttribute('role')
|
163
|
+
$tab.removeAttribute('aria-controls')
|
164
|
+
$tab.removeAttribute('aria-selected')
|
165
|
+
$tab.removeAttribute('tabindex')
|
166
|
+
|
167
|
+
// unset panel attributes
|
168
|
+
var $panel = this.getPanel($tab)
|
169
|
+
$panel.removeAttribute('role')
|
170
|
+
$panel.removeAttribute('aria-labelledby')
|
171
|
+
$panel.classList.remove(this.jsHiddenClass)
|
172
|
+
}
|
173
|
+
|
174
|
+
Tabs.prototype.onTabClick = function (e) {
|
175
|
+
if (!e.target.classList.contains('govuk-tabs__tab')) {
|
176
|
+
// Allow events on child DOM elements to bubble up to tab parent
|
177
|
+
return false
|
178
|
+
}
|
179
|
+
e.preventDefault()
|
180
|
+
var $newTab = e.target
|
181
|
+
var $currentTab = this.getCurrentTab()
|
182
|
+
this.hideTab($currentTab)
|
183
|
+
this.showTab($newTab)
|
184
|
+
this.createHistoryEntry($newTab)
|
185
|
+
}
|
186
|
+
|
187
|
+
Tabs.prototype.createHistoryEntry = function ($tab) {
|
188
|
+
var $panel = this.getPanel($tab)
|
189
|
+
|
190
|
+
// Save and restore the id
|
191
|
+
// so the page doesn't jump when a user clicks a tab (which changes the hash)
|
192
|
+
var id = $panel.id
|
193
|
+
$panel.id = ''
|
194
|
+
this.changingHash = true
|
195
|
+
window.location.hash = this.getHref($tab).slice(1)
|
196
|
+
$panel.id = id
|
197
|
+
}
|
198
|
+
|
199
|
+
Tabs.prototype.onTabKeydown = function (e) {
|
200
|
+
switch (e.keyCode) {
|
201
|
+
case this.keys.left:
|
202
|
+
case this.keys.up:
|
203
|
+
this.activatePreviousTab()
|
204
|
+
e.preventDefault()
|
205
|
+
break
|
206
|
+
case this.keys.right:
|
207
|
+
case this.keys.down:
|
208
|
+
this.activateNextTab()
|
209
|
+
e.preventDefault()
|
210
|
+
break
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
Tabs.prototype.activateNextTab = function () {
|
215
|
+
var currentTab = this.getCurrentTab()
|
216
|
+
var nextTabListItem = currentTab.parentNode.nextElementSibling
|
217
|
+
if (nextTabListItem) {
|
218
|
+
var nextTab = nextTabListItem.querySelector('.govuk-tabs__tab')
|
219
|
+
}
|
220
|
+
if (nextTab) {
|
221
|
+
this.hideTab(currentTab)
|
222
|
+
this.showTab(nextTab)
|
223
|
+
nextTab.focus()
|
224
|
+
this.createHistoryEntry(nextTab)
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
Tabs.prototype.activatePreviousTab = function () {
|
229
|
+
var currentTab = this.getCurrentTab()
|
230
|
+
var previousTabListItem = currentTab.parentNode.previousElementSibling
|
231
|
+
if (previousTabListItem) {
|
232
|
+
var previousTab = previousTabListItem.querySelector('.govuk-tabs__tab')
|
233
|
+
}
|
234
|
+
if (previousTab) {
|
235
|
+
this.hideTab(currentTab)
|
236
|
+
this.showTab(previousTab)
|
237
|
+
previousTab.focus()
|
238
|
+
this.createHistoryEntry(previousTab)
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
Tabs.prototype.getPanel = function ($tab) {
|
243
|
+
var $panel = this.$module.querySelector(this.getHref($tab))
|
244
|
+
return $panel
|
245
|
+
}
|
246
|
+
|
247
|
+
Tabs.prototype.showPanel = function ($tab) {
|
248
|
+
var $panel = this.getPanel($tab)
|
249
|
+
$panel.classList.remove(this.jsHiddenClass)
|
250
|
+
}
|
251
|
+
|
252
|
+
Tabs.prototype.hidePanel = function (tab) {
|
253
|
+
var $panel = this.getPanel(tab)
|
254
|
+
$panel.classList.add(this.jsHiddenClass)
|
255
|
+
}
|
256
|
+
|
257
|
+
Tabs.prototype.unhighlightTab = function ($tab) {
|
258
|
+
$tab.setAttribute('aria-selected', 'false')
|
259
|
+
$tab.parentNode.classList.remove('govuk-tabs__list-item--selected')
|
260
|
+
$tab.setAttribute('tabindex', '-1')
|
261
|
+
}
|
262
|
+
|
263
|
+
Tabs.prototype.highlightTab = function ($tab) {
|
264
|
+
$tab.setAttribute('aria-selected', 'true')
|
265
|
+
$tab.parentNode.classList.add('govuk-tabs__list-item--selected')
|
266
|
+
$tab.setAttribute('tabindex', '0')
|
267
|
+
}
|
268
|
+
|
269
|
+
Tabs.prototype.getCurrentTab = function () {
|
270
|
+
return this.$module.querySelector('.govuk-tabs__list-item--selected .govuk-tabs__tab')
|
271
|
+
}
|
272
|
+
|
273
|
+
// this is because IE doesn't always return the actual value but a relative full path
|
274
|
+
// should be a utility function most prob
|
275
|
+
// http://labs.thesedays.com/blog/2010/01/08/getting-the-href-value-with-jquery-in-ie/
|
276
|
+
Tabs.prototype.getHref = function ($tab) {
|
277
|
+
var href = $tab.getAttribute('href')
|
278
|
+
var hash = href.slice(href.indexOf('#'), href.length)
|
279
|
+
return hash
|
280
|
+
}
|
281
|
+
|
282
|
+
export default Tabs
|
@@ -0,0 +1,264 @@
|
|
1
|
+
(function(undefined) {
|
2
|
+
|
3
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/detect.js
|
4
|
+
var detect = (
|
5
|
+
'DOMTokenList' in this && (function (x) {
|
6
|
+
return 'classList' in x ? !x.classList.toggle('x', false) && !x.className : true;
|
7
|
+
})(document.createElement('x'))
|
8
|
+
)
|
9
|
+
|
10
|
+
if (detect) return
|
11
|
+
|
12
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/master/packages/polyfill-library/polyfills/DOMTokenList/polyfill.js
|
13
|
+
(function (global) {
|
14
|
+
var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
|
15
|
+
|
16
|
+
if (
|
17
|
+
!nativeImpl ||
|
18
|
+
(
|
19
|
+
!!document.createElementNS &&
|
20
|
+
!!document.createElementNS('http://www.w3.org/2000/svg', 'svg') &&
|
21
|
+
!(document.createElementNS("http://www.w3.org/2000/svg", "svg").classList instanceof DOMTokenList)
|
22
|
+
)
|
23
|
+
) {
|
24
|
+
global.DOMTokenList = (function() { // eslint-disable-line no-unused-vars
|
25
|
+
var dpSupport = true;
|
26
|
+
var defineGetter = function (object, name, fn, configurable) {
|
27
|
+
if (Object.defineProperty)
|
28
|
+
Object.defineProperty(object, name, {
|
29
|
+
configurable: false === dpSupport ? true : !!configurable,
|
30
|
+
get: fn
|
31
|
+
});
|
32
|
+
|
33
|
+
else object.__defineGetter__(name, fn);
|
34
|
+
};
|
35
|
+
|
36
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
37
|
+
try {
|
38
|
+
defineGetter({}, "support");
|
39
|
+
}
|
40
|
+
catch (e) {
|
41
|
+
dpSupport = false;
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
var _DOMTokenList = function (el, prop) {
|
46
|
+
var that = this;
|
47
|
+
var tokens = [];
|
48
|
+
var tokenMap = {};
|
49
|
+
var length = 0;
|
50
|
+
var maxLength = 0;
|
51
|
+
var addIndexGetter = function (i) {
|
52
|
+
defineGetter(that, i, function () {
|
53
|
+
preop();
|
54
|
+
return tokens[i];
|
55
|
+
}, false);
|
56
|
+
|
57
|
+
};
|
58
|
+
var reindex = function () {
|
59
|
+
|
60
|
+
/** Define getter functions for array-like access to the tokenList's contents. */
|
61
|
+
if (length >= maxLength)
|
62
|
+
for (; maxLength < length; ++maxLength) {
|
63
|
+
addIndexGetter(maxLength);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
/** Helper function called at the start of each class method. Internal use only. */
|
68
|
+
var preop = function () {
|
69
|
+
var error;
|
70
|
+
var i;
|
71
|
+
var args = arguments;
|
72
|
+
var rSpace = /\s+/;
|
73
|
+
|
74
|
+
/** Validate the token/s passed to an instance method, if any. */
|
75
|
+
if (args.length)
|
76
|
+
for (i = 0; i < args.length; ++i)
|
77
|
+
if (rSpace.test(args[i])) {
|
78
|
+
error = new SyntaxError('String "' + args[i] + '" ' + "contains" + ' an invalid character');
|
79
|
+
error.code = 5;
|
80
|
+
error.name = "InvalidCharacterError";
|
81
|
+
throw error;
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
/** Split the new value apart by whitespace*/
|
86
|
+
if (typeof el[prop] === "object") {
|
87
|
+
tokens = ("" + el[prop].baseVal).replace(/^\s+|\s+$/g, "").split(rSpace);
|
88
|
+
} else {
|
89
|
+
tokens = ("" + el[prop]).replace(/^\s+|\s+$/g, "").split(rSpace);
|
90
|
+
}
|
91
|
+
|
92
|
+
/** Avoid treating blank strings as single-item token lists */
|
93
|
+
if ("" === tokens[0]) tokens = [];
|
94
|
+
|
95
|
+
/** Repopulate the internal token lists */
|
96
|
+
tokenMap = {};
|
97
|
+
for (i = 0; i < tokens.length; ++i)
|
98
|
+
tokenMap[tokens[i]] = true;
|
99
|
+
length = tokens.length;
|
100
|
+
reindex();
|
101
|
+
};
|
102
|
+
|
103
|
+
/** Populate our internal token list if the targeted attribute of the subject element isn't empty. */
|
104
|
+
preop();
|
105
|
+
|
106
|
+
/** Return the number of tokens in the underlying string. Read-only. */
|
107
|
+
defineGetter(that, "length", function () {
|
108
|
+
preop();
|
109
|
+
return length;
|
110
|
+
});
|
111
|
+
|
112
|
+
/** Override the default toString/toLocaleString methods to return a space-delimited list of tokens when typecast. */
|
113
|
+
that.toLocaleString =
|
114
|
+
that.toString = function () {
|
115
|
+
preop();
|
116
|
+
return tokens.join(" ");
|
117
|
+
};
|
118
|
+
|
119
|
+
that.item = function (idx) {
|
120
|
+
preop();
|
121
|
+
return tokens[idx];
|
122
|
+
};
|
123
|
+
|
124
|
+
that.contains = function (token) {
|
125
|
+
preop();
|
126
|
+
return !!tokenMap[token];
|
127
|
+
};
|
128
|
+
|
129
|
+
that.add = function () {
|
130
|
+
preop.apply(that, args = arguments);
|
131
|
+
|
132
|
+
for (var args, token, i = 0, l = args.length; i < l; ++i) {
|
133
|
+
token = args[i];
|
134
|
+
if (!tokenMap[token]) {
|
135
|
+
tokens.push(token);
|
136
|
+
tokenMap[token] = true;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
/** Update the targeted attribute of the attached element if the token list's changed. */
|
141
|
+
if (length !== tokens.length) {
|
142
|
+
length = tokens.length >>> 0;
|
143
|
+
if (typeof el[prop] === "object") {
|
144
|
+
el[prop].baseVal = tokens.join(" ");
|
145
|
+
} else {
|
146
|
+
el[prop] = tokens.join(" ");
|
147
|
+
}
|
148
|
+
reindex();
|
149
|
+
}
|
150
|
+
};
|
151
|
+
|
152
|
+
that.remove = function () {
|
153
|
+
preop.apply(that, args = arguments);
|
154
|
+
|
155
|
+
/** Build a hash of token names to compare against when recollecting our token list. */
|
156
|
+
for (var args, ignore = {}, i = 0, t = []; i < args.length; ++i) {
|
157
|
+
ignore[args[i]] = true;
|
158
|
+
delete tokenMap[args[i]];
|
159
|
+
}
|
160
|
+
|
161
|
+
/** Run through our tokens list and reassign only those that aren't defined in the hash declared above. */
|
162
|
+
for (i = 0; i < tokens.length; ++i)
|
163
|
+
if (!ignore[tokens[i]]) t.push(tokens[i]);
|
164
|
+
|
165
|
+
tokens = t;
|
166
|
+
length = t.length >>> 0;
|
167
|
+
|
168
|
+
/** Update the targeted attribute of the attached element. */
|
169
|
+
if (typeof el[prop] === "object") {
|
170
|
+
el[prop].baseVal = tokens.join(" ");
|
171
|
+
} else {
|
172
|
+
el[prop] = tokens.join(" ");
|
173
|
+
}
|
174
|
+
reindex();
|
175
|
+
};
|
176
|
+
|
177
|
+
that.toggle = function (token, force) {
|
178
|
+
preop.apply(that, [token]);
|
179
|
+
|
180
|
+
/** Token state's being forced. */
|
181
|
+
if (undefined !== force) {
|
182
|
+
if (force) {
|
183
|
+
that.add(token);
|
184
|
+
return true;
|
185
|
+
} else {
|
186
|
+
that.remove(token);
|
187
|
+
return false;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
/** Token already exists in tokenList. Remove it, and return FALSE. */
|
192
|
+
if (tokenMap[token]) {
|
193
|
+
that.remove(token);
|
194
|
+
return false;
|
195
|
+
}
|
196
|
+
|
197
|
+
/** Otherwise, add the token and return TRUE. */
|
198
|
+
that.add(token);
|
199
|
+
return true;
|
200
|
+
};
|
201
|
+
|
202
|
+
return that;
|
203
|
+
};
|
204
|
+
|
205
|
+
return _DOMTokenList;
|
206
|
+
}());
|
207
|
+
}
|
208
|
+
|
209
|
+
// Add second argument to native DOMTokenList.toggle() if necessary
|
210
|
+
(function () {
|
211
|
+
var e = document.createElement('span');
|
212
|
+
if (!('classList' in e)) return;
|
213
|
+
e.classList.toggle('x', false);
|
214
|
+
if (!e.classList.contains('x')) return;
|
215
|
+
e.classList.constructor.prototype.toggle = function toggle(token /*, force*/) {
|
216
|
+
var force = arguments[1];
|
217
|
+
if (force === undefined) {
|
218
|
+
var add = !this.contains(token);
|
219
|
+
this[add ? 'add' : 'remove'](token);
|
220
|
+
return add;
|
221
|
+
}
|
222
|
+
force = !!force;
|
223
|
+
this[force ? 'add' : 'remove'](token);
|
224
|
+
return force;
|
225
|
+
};
|
226
|
+
}());
|
227
|
+
|
228
|
+
// Add multiple arguments to native DOMTokenList.add() if necessary
|
229
|
+
(function () {
|
230
|
+
var e = document.createElement('span');
|
231
|
+
if (!('classList' in e)) return;
|
232
|
+
e.classList.add('a', 'b');
|
233
|
+
if (e.classList.contains('b')) return;
|
234
|
+
var native = e.classList.constructor.prototype.add;
|
235
|
+
e.classList.constructor.prototype.add = function () {
|
236
|
+
var args = arguments;
|
237
|
+
var l = arguments.length;
|
238
|
+
for (var i = 0; i < l; i++) {
|
239
|
+
native.call(this, args[i]);
|
240
|
+
}
|
241
|
+
};
|
242
|
+
}());
|
243
|
+
|
244
|
+
// Add multiple arguments to native DOMTokenList.remove() if necessary
|
245
|
+
(function () {
|
246
|
+
var e = document.createElement('span');
|
247
|
+
if (!('classList' in e)) return;
|
248
|
+
e.classList.add('a');
|
249
|
+
e.classList.add('b');
|
250
|
+
e.classList.remove('a', 'b');
|
251
|
+
if (!e.classList.contains('b')) return;
|
252
|
+
var native = e.classList.constructor.prototype.remove;
|
253
|
+
e.classList.constructor.prototype.remove = function () {
|
254
|
+
var args = arguments;
|
255
|
+
var l = arguments.length;
|
256
|
+
for (var i = 0; i < l; i++) {
|
257
|
+
native.call(this, args[i]);
|
258
|
+
}
|
259
|
+
};
|
260
|
+
}());
|
261
|
+
|
262
|
+
}(this));
|
263
|
+
|
264
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
(function(undefined) {
|
2
|
+
|
3
|
+
// Detection from https://github.com/Financial-Times/polyfill-service/blob/master/packages/polyfill-library/polyfills/Document/detect.js
|
4
|
+
var detect = ("Document" in this)
|
5
|
+
|
6
|
+
if (detect) return
|
7
|
+
|
8
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Document&flags=always
|
9
|
+
if ((typeof WorkerGlobalScope === "undefined") && (typeof importScripts !== "function")) {
|
10
|
+
|
11
|
+
if (this.HTMLDocument) { // IE8
|
12
|
+
|
13
|
+
// HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
|
14
|
+
this.Document = this.HTMLDocument;
|
15
|
+
|
16
|
+
} else {
|
17
|
+
|
18
|
+
// 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.
|
19
|
+
this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
|
20
|
+
this.Document.prototype = document;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
})
|
26
|
+
.call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import '../../Object/defineProperty'
|
2
|
+
import '../../DOMTokenList'
|
3
|
+
import '../../Element'
|
4
|
+
|
5
|
+
(function(undefined) {
|
6
|
+
|
7
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/8717a9e04ac7aff99b4980fbedead98036b0929a/packages/polyfill-library/polyfills/Element/prototype/classList/detect.js
|
8
|
+
var detect = (
|
9
|
+
'document' in this && "classList" in document.documentElement && 'Element' in this && 'classList' in Element.prototype && (function () {
|
10
|
+
var e = document.createElement('span');
|
11
|
+
e.classList.add('a', 'b');
|
12
|
+
return e.classList.contains('b');
|
13
|
+
}())
|
14
|
+
)
|
15
|
+
|
16
|
+
if (detect) return
|
17
|
+
|
18
|
+
// Polyfill from https://cdn.polyfill.io/v2/polyfill.js?features=Element.prototype.classList&flags=always
|
19
|
+
(function (global) {
|
20
|
+
var dpSupport = true;
|
21
|
+
var defineGetter = function (object, name, fn, configurable) {
|
22
|
+
if (Object.defineProperty)
|
23
|
+
Object.defineProperty(object, name, {
|
24
|
+
configurable: false === dpSupport ? true : !!configurable,
|
25
|
+
get: fn
|
26
|
+
});
|
27
|
+
|
28
|
+
else object.__defineGetter__(name, fn);
|
29
|
+
};
|
30
|
+
/** Ensure the browser allows Object.defineProperty to be used on native JavaScript objects. */
|
31
|
+
try {
|
32
|
+
defineGetter({}, "support");
|
33
|
+
}
|
34
|
+
catch (e) {
|
35
|
+
dpSupport = false;
|
36
|
+
}
|
37
|
+
/** Polyfills a property with a DOMTokenList */
|
38
|
+
var addProp = function (o, name, attr) {
|
39
|
+
|
40
|
+
defineGetter(o.prototype, name, function () {
|
41
|
+
var tokenList;
|
42
|
+
|
43
|
+
var THIS = this,
|
44
|
+
|
45
|
+
/** Prevent this from firing twice for some reason. What the hell, IE. */
|
46
|
+
gibberishProperty = "__defineGetter__" + "DEFINE_PROPERTY" + name;
|
47
|
+
if(THIS[gibberishProperty]) return tokenList;
|
48
|
+
THIS[gibberishProperty] = true;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* IE8 can't define properties on native JavaScript objects, so we'll use a dumb hack instead.
|
52
|
+
*
|
53
|
+
* What this is doing is creating a dummy element ("reflection") inside a detached phantom node ("mirror")
|
54
|
+
* that serves as the target of Object.defineProperty instead. While we could simply use the subject HTML
|
55
|
+
* element instead, this would conflict with element types which use indexed properties (such as forms and
|
56
|
+
* select lists).
|
57
|
+
*/
|
58
|
+
if (false === dpSupport) {
|
59
|
+
|
60
|
+
var visage;
|
61
|
+
var mirror = addProp.mirror || document.createElement("div");
|
62
|
+
var reflections = mirror.childNodes;
|
63
|
+
var l = reflections.length;
|
64
|
+
|
65
|
+
for (var i = 0; i < l; ++i)
|
66
|
+
if (reflections[i]._R === THIS) {
|
67
|
+
visage = reflections[i];
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
|
71
|
+
/** Couldn't find an element's reflection inside the mirror. Materialise one. */
|
72
|
+
visage || (visage = mirror.appendChild(document.createElement("div")));
|
73
|
+
|
74
|
+
tokenList = DOMTokenList.call(visage, THIS, attr);
|
75
|
+
} else tokenList = new DOMTokenList(THIS, attr);
|
76
|
+
|
77
|
+
defineGetter(THIS, name, function () {
|
78
|
+
return tokenList;
|
79
|
+
});
|
80
|
+
delete THIS[gibberishProperty];
|
81
|
+
|
82
|
+
return tokenList;
|
83
|
+
}, true);
|
84
|
+
};
|
85
|
+
|
86
|
+
addProp(global.Element, "classList", "className");
|
87
|
+
addProp(global.HTMLElement, "classList", "className");
|
88
|
+
addProp(global.HTMLLinkElement, "relList", "rel");
|
89
|
+
addProp(global.HTMLAnchorElement, "relList", "rel");
|
90
|
+
addProp(global.HTMLAreaElement, "relList", "rel");
|
91
|
+
}(this));
|
92
|
+
|
93
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import './matches'
|
2
|
+
|
3
|
+
(function(undefined) {
|
4
|
+
|
5
|
+
// Detection from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/detect.js
|
6
|
+
var detect = (
|
7
|
+
'document' in this && "closest" in document.documentElement
|
8
|
+
)
|
9
|
+
|
10
|
+
if (detect) return
|
11
|
+
|
12
|
+
// Polyfill from https://raw.githubusercontent.com/Financial-Times/polyfill-service/1f3c09b402f65bf6e393f933a15ba63f1b86ef1f/packages/polyfill-library/polyfills/Element/prototype/closest/polyfill.js
|
13
|
+
Element.prototype.closest = function closest(selector) {
|
14
|
+
var node = this;
|
15
|
+
|
16
|
+
while (node) {
|
17
|
+
if (node.matches(selector)) return node;
|
18
|
+
else node = 'SVGElement' in window && node instanceof SVGElement ? node.parentNode : node.parentElement;
|
19
|
+
}
|
20
|
+
|
21
|
+
return null;
|
22
|
+
};
|
23
|
+
|
24
|
+
}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
|