govuk_publishing_components 27.9.0 → 27.9.1
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/layout-super-navigation-header.js +20 -40
- data/app/assets/stylesheets/govuk_publishing_components/components/_layout-super-navigation-header.scss +434 -366
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_layout-super-navigation-header.scss +2 -2
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +81 -55
- data/app/views/govuk_publishing_components/components/docs/layout_super_navigation_header.yml +12 -3
- data/config/locales/en.yml +2 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1972033395616c1023a78e4452ac636b90a5bc7f9c7739c2a1d258e76691b900
|
4
|
+
data.tar.gz: 0c9ce6602fc0811249802d4c4db210ac2df342d35ce2b6bc2a796315d5b0213f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ea760c12bc9de04e792adfa8f37c6ffbb2a14ec58bde29a4419afcc7bdc72e7ef47b8c2f7408fddf8a2b0f494aad26947d4d5d2b896c485f72bbea2f37cebdf
|
7
|
+
data.tar.gz: c27b47624a8c10554bf33af5099f5aebc14144410692823e84c7f59a4abb009d82ec9ac1b54c707e30dcd71423e465ced00e405df1abf0ffc325db1f1d9743b0
|
data/app/assets/javascripts/govuk_publishing_components/components/layout-super-navigation-header.js
CHANGED
@@ -124,25 +124,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
124
124
|
|
125
125
|
this.hiddenButtons = this.$module.querySelectorAll('button[hidden]')
|
126
126
|
|
127
|
-
this.lastWindowSize =
|
127
|
+
this.lastWindowSize = null
|
128
128
|
}
|
129
129
|
|
130
130
|
SuperNavigationMegaMenu.prototype.windowSize = windowSize
|
131
131
|
|
132
|
-
// Resizes the space needed for the dropdown menu so that it doesn't overlap
|
133
|
-
// with the page content. As this is an event that needs to be added and
|
134
|
-
// removed it can't be be bound to `this` because that changes the fingerprint
|
135
|
-
// of the function, and makes it unable to be removed with
|
136
|
-
// `removeEventListener`.
|
137
|
-
SuperNavigationMegaMenu.prototype.resizeHandler = function () {
|
138
|
-
var $module = document.querySelector('[data-module="super-navigation-mega-menu"]')
|
139
|
-
var $openButton = $module.querySelector('[aria-expanded="true"][data-toggle-desktop-group="top"]')
|
140
|
-
var $openMenu = $openButton ? $module.querySelector('#' + $openButton.getAttribute('aria-controls')) : null
|
141
|
-
var margin = $openMenu && windowSize() === 'desktop' ? $openMenu.offsetHeight : 0
|
142
|
-
|
143
|
-
$module.style.marginBottom = margin + 'px'
|
144
|
-
}
|
145
|
-
|
146
132
|
SuperNavigationMegaMenu.prototype.updateStates = function () {
|
147
133
|
if (this.windowSize() === 'mobile' && this.lastWindowSize !== 'mobile') {
|
148
134
|
this.$navigationToggle.removeAttribute('hidden')
|
@@ -161,8 +147,21 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
161
147
|
if (this.windowSize() === 'desktop' && this.lastWindowSize !== 'desktop') {
|
162
148
|
this.$navigationToggle.setAttribute('hidden', 'hidden')
|
163
149
|
this.$navigationMenu.removeAttribute('hidden')
|
150
|
+
}
|
164
151
|
|
165
|
-
|
152
|
+
// The dropdown menu height is only needed when in desktop mode as this is
|
153
|
+
// when the dropdown menu is using `absolute` positioning. This requires
|
154
|
+
// JavaScript to work out the height and make space for the dropdown menu.
|
155
|
+
if (windowSize() === 'desktop') {
|
156
|
+
// Check whether any of the dropdown menus are open.
|
157
|
+
var $openButton = this.$module.querySelector('[aria-expanded="true"][data-toggle-desktop-group="top"]')
|
158
|
+
// Gets the open dropdown menu
|
159
|
+
var $openMenu = $openButton ? this.$module.querySelector('#' + $openButton.getAttribute('aria-controls')) : null
|
160
|
+
// If there is an open dropdown menu, get the height of the dropdown menu.
|
161
|
+
var margin = $openMenu ? $openMenu.offsetHeight : 0
|
162
|
+
|
163
|
+
// Make space for the dropdown menu.
|
164
|
+
this.$module.style.marginBottom = margin + 'px'
|
166
165
|
}
|
167
166
|
|
168
167
|
this.lastWindowSize = this.windowSize()
|
@@ -231,30 +230,11 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
231
230
|
|
232
231
|
this.lastWindowSize = this.windowSize()
|
233
232
|
|
234
|
-
// The menu needs to be updated when the window is resized
|
235
|
-
// the
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
// only does things when moving from mobile to desktop view.
|
240
|
-
var setupResizeListener = function () {
|
241
|
-
window.addEventListener('resize', this.updateStates.bind(this), { passive: true })
|
242
|
-
}.bind(this)
|
243
|
-
|
244
|
-
if (typeof window.matchMedia === 'function') {
|
245
|
-
// Internet Explorer 11 supports `matchMedia`, but doesn't support
|
246
|
-
// the `change` event[1] - so we try it, and then fail back to using
|
247
|
-
// `window.resize`.
|
248
|
-
// [1]: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/onchange
|
249
|
-
try {
|
250
|
-
window.matchMedia('screen and (min-width:' + SETTINGS.breakpoint.desktop + 'px)')
|
251
|
-
.addEventListener('change', this.updateStates.bind(this))
|
252
|
-
} catch (error) {
|
253
|
-
setupResizeListener()
|
254
|
-
}
|
255
|
-
} else {
|
256
|
-
setupResizeListener()
|
257
|
-
}
|
233
|
+
// The menu needs to be updated when the window is resized to make sure that
|
234
|
+
// the space needed for the dropdown menu is correct.
|
235
|
+
window.addEventListener('resize', this.updateStates.bind(this), { passive: true })
|
236
|
+
|
237
|
+
this.$module.classList.add('js-module-initialised')
|
258
238
|
}
|
259
239
|
|
260
240
|
Modules.SuperNavigationMegaMenu = SuperNavigationMegaMenu
|