mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
More js cleanup
This commit is contained in:
@@ -1,27 +1,38 @@
|
|||||||
window.GOVUK.Frontend.initAll();
|
// Initialize GOV.UK Frontend components (modern init)
|
||||||
|
window.GOVUKFrontend.initAll();
|
||||||
$(() => $("time.timeago").timeago());
|
|
||||||
|
|
||||||
var showHideContent = new GOVUK.ShowHideContent();
|
var showHideContent = new GOVUK.ShowHideContent();
|
||||||
showHideContent.init();
|
showHideContent.init();
|
||||||
|
|
||||||
$(() => GOVUK.modules.start());
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
// Autofocus the first error input
|
||||||
$(() => $('.error-message, .usa-error-message').eq(0).parent('label').next('input').trigger('focus'));
|
const errorEl = document.querySelector('.error-message, .usa-error-message');
|
||||||
|
if (errorEl) {
|
||||||
$(() => $('.govuk-header__container').on('click', function() {
|
const label = errorEl.closest('label');
|
||||||
$(this).css('border-color', '#005ea5');
|
if (label) {
|
||||||
}));
|
const input = label.nextElementSibling;
|
||||||
|
if (input && input.focus) {
|
||||||
// Applies our expanded focus style to the siblings of links when that link is wrapped in a heading.
|
input.focus();
|
||||||
//
|
}
|
||||||
// This will be possible in CSS in the future, using the :has pseudo-class. When :has is available
|
}
|
||||||
// in the browsers we support, this code can be replaced with a CSS-only solution.
|
|
||||||
$('.js-mark-focus-on-parent').on('focus blur', '*', e => {
|
|
||||||
$target = $(e.target);
|
|
||||||
if (e.type === 'focusin') {
|
|
||||||
$target.parent().addClass('js-child-has-focus');
|
|
||||||
} else {
|
|
||||||
$target.parent().removeClass('js-child-has-focus');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optional: highlight header on click
|
||||||
|
const header = document.querySelector('.govuk-header__container');
|
||||||
|
if (header) {
|
||||||
|
header.addEventListener('click', () => {
|
||||||
|
header.style.borderColor = '#005ea5';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focus styling for heading-wrapped links
|
||||||
|
const containers = document.querySelectorAll('.js-mark-focus-on-parent');
|
||||||
|
containers.forEach(container => {
|
||||||
|
container.addEventListener('focusin', e => {
|
||||||
|
e.target.parentElement.classList.add('js-child-has-focus');
|
||||||
|
});
|
||||||
|
container.addEventListener('focusout', e => {
|
||||||
|
e.target.parentElement.classList.remove('js-child-has-focus');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
{{notification.key_name}}
|
{{notification.key_name}}
|
||||||
</span>
|
</span>
|
||||||
<span class="grid-col-6 api-notifications-item__meta-time">
|
<span class="grid-col-6 api-notifications-item__meta-time">
|
||||||
<time class="timeago" datetime="{{ notification.created_at }}">
|
<time datetime="{{ notification.created_at }}">
|
||||||
{{ notification.created_at|format_delta }}
|
{{ notification.created_at|format_delta }}
|
||||||
</time>
|
</time>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<p class="hint">This person has never logged in</p>
|
<p class="hint">This person has never logged in</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Last logged in
|
<p>Last logged in
|
||||||
<time class="timeago" datetime="{{ user.logged_in_at }}">
|
<time datetime="{{ user.logged_in_at }}">
|
||||||
{{ user.logged_in_at|format_delta }}
|
{{ user.logged_in_at|format_delta }}
|
||||||
</time>
|
</time>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ const javascripts = () => {
|
|||||||
paths.npm + 'hogan.js/dist/hogan-3.0.2.js',
|
paths.npm + 'hogan.js/dist/hogan-3.0.2.js',
|
||||||
paths.npm + 'jquery/dist/jquery.min.js',
|
paths.npm + 'jquery/dist/jquery.min.js',
|
||||||
paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js',
|
paths.npm + 'query-command-supported/dist/queryCommandSupported.min.js',
|
||||||
paths.npm + 'timeago/jquery.timeago.js',
|
|
||||||
paths.npm + 'textarea-caret/index.js',
|
paths.npm + 'textarea-caret/index.js',
|
||||||
paths.npm + 'cbor-js/cbor.js',
|
paths.npm + 'cbor-js/cbor.js',
|
||||||
paths.npm + 'd3/dist/d3.min.js',
|
paths.npm + 'd3/dist/d3.min.js',
|
||||||
|
|||||||
9
package-lock.json
generated
9
package-lock.json
generated
@@ -26,7 +26,6 @@
|
|||||||
"query-command-supported": "1.0.0",
|
"query-command-supported": "1.0.0",
|
||||||
"sass-embedded": "^1.86.3",
|
"sass-embedded": "^1.86.3",
|
||||||
"textarea-caret": "3.1.0",
|
"textarea-caret": "3.1.0",
|
||||||
"timeago": "1.6.7",
|
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0"
|
"vinyl-source-stream": "^2.0.0"
|
||||||
},
|
},
|
||||||
@@ -12680,14 +12679,6 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/timeago": {
|
|
||||||
"version": "1.6.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/timeago/-/timeago-1.6.7.tgz",
|
|
||||||
"integrity": "sha512-FikcjN98+ij0siKH4VO4dZ358PR3oDDq4Vdl1+sN9gWz1/+JXGr3uZbUShYH/hL7bMhcTpPbplJU5Tej4b4jbQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"jquery": ">=1.5.0 <4.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tmpl": {
|
"node_modules/tmpl": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
"query-command-supported": "1.0.0",
|
"query-command-supported": "1.0.0",
|
||||||
"sass-embedded": "^1.86.3",
|
"sass-embedded": "^1.86.3",
|
||||||
"textarea-caret": "3.1.0",
|
"textarea-caret": "3.1.0",
|
||||||
"timeago": "1.6.7",
|
|
||||||
"vinyl-buffer": "^1.0.1",
|
"vinyl-buffer": "^1.0.1",
|
||||||
"vinyl-source-stream": "^2.0.0"
|
"vinyl-source-stream": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
2
poetry.lock
generated
2
poetry.lock
generated
@@ -17,7 +17,6 @@ version = "5.0.1"
|
|||||||
description = "Timeout context manager for asyncio programs"
|
description = "Timeout context manager for asyncio programs"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.8"
|
python-versions = ">=3.8"
|
||||||
groups = ["main"]
|
|
||||||
files = [
|
files = [
|
||||||
{file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"},
|
{file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"},
|
||||||
{file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"},
|
{file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"},
|
||||||
@@ -1486,7 +1485,6 @@ version = "3.0.2"
|
|||||||
description = "Safely add untrusted strings to HTML/XML markup."
|
description = "Safely add untrusted strings to HTML/XML markup."
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.9"
|
python-versions = ">=3.9"
|
||||||
groups = ["main", "dev"]
|
|
||||||
files = [
|
files = [
|
||||||
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"},
|
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8"},
|
||||||
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"},
|
{file = "MarkupSafe-3.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158"},
|
||||||
|
|||||||
0
tests/javascripts/main.test.js
Normal file
0
tests/javascripts/main.test.js
Normal file
Reference in New Issue
Block a user