@ministryofjustice/frontend 3.6.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moj/all.jquery.min.js +1 -1
- package/moj/all.js +81 -81
- package/moj/all.mjs +3 -3
- package/moj/all.scss +1 -1
- package/moj/components/add-another/add-another.js +10 -10
- package/moj/components/add-another/add-another.mjs +10 -10
- package/moj/components/alert/template.njk +4 -4
- package/moj/components/badge/template.njk +1 -1
- package/moj/components/banner/template.njk +11 -11
- package/moj/components/cookie-banner/_cookie-banner.scss +1 -1
- package/moj/components/cookie-banner/template.njk +1 -1
- package/moj/components/currency-input/template.njk +10 -10
- package/moj/components/date-picker/template.njk +2 -2
- package/moj/components/filter/template.njk +1 -1
- package/moj/components/filter-toggle-button/filter-toggle-button.js +8 -8
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +8 -8
- package/moj/components/form-validator/form-validator.js +4 -4
- package/moj/components/form-validator/form-validator.mjs +4 -4
- package/moj/components/header/template.njk +8 -8
- package/moj/components/identity-bar/template.njk +1 -1
- package/moj/components/messages/template.njk +6 -6
- package/moj/components/multi-file-upload/multi-file-upload.js +23 -23
- package/moj/components/multi-file-upload/multi-file-upload.mjs +23 -23
- package/moj/components/multi-file-upload/template.njk +1 -1
- package/moj/components/multi-select/multi-select.js +7 -7
- package/moj/components/multi-select/multi-select.mjs +7 -7
- package/moj/components/notification-badge/template.njk +1 -1
- package/moj/components/organisation-switcher/template.njk +3 -3
- package/moj/components/page-header-actions/template.njk +1 -1
- package/moj/components/pagination/template.njk +2 -2
- package/moj/components/password-reveal/password-reveal.js +4 -4
- package/moj/components/password-reveal/password-reveal.mjs +4 -4
- package/moj/components/primary-navigation/template.njk +2 -2
- package/moj/components/progress-bar/template.njk +4 -4
- package/moj/components/rich-text-editor/rich-text-editor.js +6 -6
- package/moj/components/rich-text-editor/rich-text-editor.mjs +6 -6
- package/moj/components/search/template.njk +7 -7
- package/moj/components/search-toggle/search-toggle.js +8 -8
- package/moj/components/search-toggle/search-toggle.mjs +8 -8
- package/moj/components/side-navigation/template.njk +3 -3
- package/moj/components/sortable-table/sortable-table.js +11 -11
- package/moj/components/sortable-table/sortable-table.mjs +11 -11
- package/moj/components/sub-navigation/template.njk +2 -2
- package/moj/components/task-list/template.njk +4 -4
- package/moj/components/ticket-panel/template.njk +2 -2
- package/moj/components/timeline/template.njk +2 -2
- package/moj/moj-frontend.min.js +1 -1
- package/package.json +1 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div class="moj-multi-file-upload {{-
|
|
1
|
+
<div class="moj-multi-file-upload {{- " " + params.classes if params.classes}}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
2
2
|
<div class="moj-multi-file__uploaded-files {% if params.uploadedFiles.items.length == 0 %}moj-hidden{% endif%}">
|
|
3
3
|
<h2 class="govuk-heading-m">{{ params.uploadedFiles.heading.html | safe if params.uploadedFiles.heading.html else params.uploadedFiles.heading.text }}</h2>
|
|
4
4
|
<div class="govuk-summary-list moj-multi-file-upload__list">
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function MultiSelect(options) {
|
|
8
|
-
this.container =
|
|
8
|
+
this.container = $(options.container);
|
|
9
9
|
|
|
10
10
|
if (this.container.data('moj-multi-select-initialised')) {
|
|
11
11
|
return
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
allId = `${idPrefix}checkboxes-all`;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
this.toggle =
|
|
22
|
+
this.toggle = $(this.getToggleHtml(allId));
|
|
23
23
|
this.toggleButton = this.toggle.find('input');
|
|
24
|
-
this.toggleButton.on('click',
|
|
24
|
+
this.toggleButton.on('click', $.proxy(this, 'onButtonClick'));
|
|
25
25
|
this.container.append(this.toggle);
|
|
26
|
-
this.checkboxes =
|
|
27
|
-
this.checkboxes.on('click',
|
|
26
|
+
this.checkboxes = $(options.checkboxes);
|
|
27
|
+
this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick'));
|
|
28
28
|
this.checked = options.checked || false;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
MultiSelect.prototype.checkAll = function () {
|
|
54
54
|
this.checkboxes.each(
|
|
55
|
-
|
|
55
|
+
$.proxy(function (index, el) {
|
|
56
56
|
el.checked = true;
|
|
57
57
|
}, this)
|
|
58
58
|
);
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
MultiSelect.prototype.uncheckAll = function () {
|
|
63
63
|
this.checkboxes.each(
|
|
64
|
-
|
|
64
|
+
$.proxy(function (index, el) {
|
|
65
65
|
el.checked = false;
|
|
66
66
|
}, this)
|
|
67
67
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function MultiSelect(options) {
|
|
2
|
-
this.container =
|
|
2
|
+
this.container = $(options.container);
|
|
3
3
|
|
|
4
4
|
if (this.container.data('moj-multi-select-initialised')) {
|
|
5
5
|
return
|
|
@@ -13,12 +13,12 @@ function MultiSelect(options) {
|
|
|
13
13
|
allId = `${idPrefix}checkboxes-all`;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
this.toggle =
|
|
16
|
+
this.toggle = $(this.getToggleHtml(allId));
|
|
17
17
|
this.toggleButton = this.toggle.find('input');
|
|
18
|
-
this.toggleButton.on('click',
|
|
18
|
+
this.toggleButton.on('click', $.proxy(this, 'onButtonClick'));
|
|
19
19
|
this.container.append(this.toggle);
|
|
20
|
-
this.checkboxes =
|
|
21
|
-
this.checkboxes.on('click',
|
|
20
|
+
this.checkboxes = $(options.checkboxes);
|
|
21
|
+
this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick'));
|
|
22
22
|
this.checked = options.checked || false;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -46,7 +46,7 @@ MultiSelect.prototype.onButtonClick = function (e) {
|
|
|
46
46
|
|
|
47
47
|
MultiSelect.prototype.checkAll = function () {
|
|
48
48
|
this.checkboxes.each(
|
|
49
|
-
|
|
49
|
+
$.proxy(function (index, el) {
|
|
50
50
|
el.checked = true;
|
|
51
51
|
}, this)
|
|
52
52
|
);
|
|
@@ -55,7 +55,7 @@ MultiSelect.prototype.checkAll = function () {
|
|
|
55
55
|
|
|
56
56
|
MultiSelect.prototype.uncheckAll = function () {
|
|
57
57
|
this.checkboxes.each(
|
|
58
|
-
|
|
58
|
+
$.proxy(function (index, el) {
|
|
59
59
|
el.checked = false;
|
|
60
60
|
}, this)
|
|
61
61
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{%- if params.text.length %}
|
|
2
|
-
<span id="{{ params.id | default(
|
|
2
|
+
<span id="{{ params.id | default("notifications") }}" class="moj-notification-badge {{- " " + params.classes if params.classes}}" {%- if (params.label) %} aria-label="{{ params.label }}"{% endif %} {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
3
3
|
{{- params.text | safe -}}
|
|
4
4
|
</span>
|
|
5
5
|
{% endif -%}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
<div {%- if params.id %} id="{{ params.id }}"{% endif %} class="moj-organisation-nav {{-
|
|
1
|
+
<div {%- if params.id %} id="{{ params.id }}"{% endif %} class="moj-organisation-nav {{- " " + params.classes if params.classes }}" aria-label="{{ params.label | default("Organisation switcher") }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
2
2
|
<div class="moj-organisation-nav__title">
|
|
3
3
|
{{- params.html | safe if params.html else params.text -}}
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
{% if params.link %}
|
|
7
|
-
{%- set linkText = params.link.text | default(
|
|
8
|
-
<a {%- if params.link.id %} id="{{ params.link.id }}"{% endif %} href="{{ params.link.href }}" class="moj-organisation-nav__link {{-
|
|
7
|
+
{%- set linkText = params.link.text | default("Change organisation") -%}
|
|
8
|
+
<a {%- if params.link.id %} id="{{ params.link.id }}"{% endif %} href="{{ params.link.href }}" class="moj-organisation-nav__link {{- " " + params.link.classes if params.link.classes }}" {%- for attribute, value in params.link.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
9
9
|
{{- linkText -}}
|
|
10
10
|
</a>
|
|
11
11
|
{% endif %}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
{% from "govuk/macros/attributes.njk" import govukAttributes %}
|
|
3
3
|
{%- from "govuk/components/button/macro.njk" import govukButton %}
|
|
4
4
|
|
|
5
|
-
<div class="moj-page-header-actions {{-
|
|
5
|
+
<div class="moj-page-header-actions {{- " " + params.classes if params.classes}}" {{- govukAttributes(params.attributes) -}}>
|
|
6
6
|
<div class="moj-page-header-actions__title">
|
|
7
7
|
<h{{ params.heading.level | default(1) }} class="{{ params.heading.classes | default("govuk-heading-xl") }}">
|
|
8
8
|
{{- params.heading.html | safe if params.heading.html else params.heading.text -}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<nav class="moj-pagination {{-
|
|
1
|
+
<nav class="moj-pagination {{- " " + params.classes if params.classes}}" aria-label="Pagination navigation">
|
|
2
2
|
|
|
3
3
|
<ul class="moj-pagination__list">
|
|
4
4
|
{%- if params.previous %}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{% endif -%}
|
|
9
9
|
|
|
10
10
|
{%- for item in params.items %}
|
|
11
|
-
{%- if item.type ==
|
|
11
|
+
{%- if item.type == "dots" %}
|
|
12
12
|
<li class="moj-pagination__item moj-pagination__item--dots">…</li>
|
|
13
13
|
{% else %}
|
|
14
14
|
{%- if item.selected %}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
function PasswordReveal(element) {
|
|
8
8
|
this.el = element;
|
|
9
|
-
const $el =
|
|
9
|
+
const $el = $(this.el);
|
|
10
10
|
|
|
11
11
|
if ($el.data('moj-password-reveal-initialised')) {
|
|
12
12
|
return
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
$el.attr('spellcheck', 'false');
|
|
17
17
|
|
|
18
18
|
$el.wrap('<div class="moj-password-reveal"></div>');
|
|
19
|
-
this.container =
|
|
19
|
+
this.container = $(this.el).parent();
|
|
20
20
|
this.createButton();
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
PasswordReveal.prototype.createButton = function () {
|
|
24
|
-
this.button =
|
|
24
|
+
this.button = $(
|
|
25
25
|
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
26
26
|
);
|
|
27
27
|
this.container.append(this.button);
|
|
28
|
-
this.button.on('click',
|
|
28
|
+
this.button.on('click', $.proxy(this, 'onButtonClick'));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
PasswordReveal.prototype.onButtonClick = function () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function PasswordReveal(element) {
|
|
2
2
|
this.el = element;
|
|
3
|
-
const $el =
|
|
3
|
+
const $el = $(this.el);
|
|
4
4
|
|
|
5
5
|
if ($el.data('moj-password-reveal-initialised')) {
|
|
6
6
|
return
|
|
@@ -10,16 +10,16 @@ function PasswordReveal(element) {
|
|
|
10
10
|
$el.attr('spellcheck', 'false');
|
|
11
11
|
|
|
12
12
|
$el.wrap('<div class="moj-password-reveal"></div>');
|
|
13
|
-
this.container =
|
|
13
|
+
this.container = $(this.el).parent();
|
|
14
14
|
this.createButton();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
PasswordReveal.prototype.createButton = function () {
|
|
18
|
-
this.button =
|
|
18
|
+
this.button = $(
|
|
19
19
|
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
20
20
|
);
|
|
21
21
|
this.container.append(this.button);
|
|
22
|
-
this.button.on('click',
|
|
22
|
+
this.button.on('click', $.proxy(this, 'onButtonClick'));
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
PasswordReveal.prototype.onButtonClick = function () {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
<div class="moj-primary-navigation {{-
|
|
1
|
+
<div class="moj-primary-navigation {{- " " + params.containerClasses if params.containerClasses}}">
|
|
2
2
|
|
|
3
3
|
<div class="moj-primary-navigation__container">
|
|
4
4
|
|
|
5
5
|
<div class="moj-primary-navigation__nav">
|
|
6
6
|
|
|
7
|
-
<nav class="moj-primary-navigation {{-
|
|
7
|
+
<nav class="moj-primary-navigation {{- " " + params.classes if params.classes}}" {%- if (params.label) %} aria-label="{{ params.label }}"{% endif %} {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
8
8
|
|
|
9
9
|
<ul class="moj-primary-navigation__list">
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<div id="{{ params.id | default(
|
|
1
|
+
<div id="{{ params.id | default("progress") }}" class="moj-progress-bar {{- " " + params.classes if params.classes}}" {%- if (params.label) %} aria-label="{{ params.label }}"{% endif %} {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
2
2
|
<ol class="moj-progress-bar__list">
|
|
3
3
|
{%- for item in params.items %}
|
|
4
|
-
<li id="{{ item.id | default(
|
|
5
|
-
<span class="moj-progress-bar__icon {{-
|
|
6
|
-
<span class="moj-progress-bar__label {{-
|
|
4
|
+
<li id="{{ item.id | default("progress-item-" + loop.index) }}" class="moj-progress-bar__item {{- " " + item.classes if item.classes }}" {{- ' aria-current="step"' | safe if item.active }} {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
5
|
+
<span class="moj-progress-bar__icon {{- " moj-progress-bar__icon--complete" if item.complete }}"></span>
|
|
6
|
+
<span class="moj-progress-bar__label {{- " " + item.label.classes if item.label.classes }}">
|
|
7
7
|
{{- item.label.html | safe if item.label.html else item.label.text -}}
|
|
8
8
|
</span>
|
|
9
9
|
</li>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
numbers: true
|
|
19
19
|
};
|
|
20
20
|
this.textarea = this.options.textarea;
|
|
21
|
-
this.container =
|
|
21
|
+
this.container = $(this.textarea).parent();
|
|
22
22
|
|
|
23
23
|
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
24
24
|
return
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
this.container.on(
|
|
39
39
|
'click',
|
|
40
40
|
'.moj-rich-text-editor__toolbar-button',
|
|
41
|
-
|
|
41
|
+
$.proxy(this, 'onButtonClick')
|
|
42
42
|
);
|
|
43
43
|
this.container
|
|
44
44
|
.find('.moj-rich-text-editor__content')
|
|
45
|
-
.on('input',
|
|
46
|
-
this.container.find('label').on('click',
|
|
47
|
-
this.toolbar.on('keydown',
|
|
45
|
+
.on('input', $.proxy(this, 'onEditorInput'));
|
|
46
|
+
this.container.find('label').on('click', $.proxy(this, 'onLabelClick'));
|
|
47
|
+
this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'));
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
142
|
-
document.execCommand(
|
|
142
|
+
document.execCommand($(e.currentTarget).data('command'), false, null);
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
RichTextEditor.prototype.getContent = function () {
|
|
@@ -12,7 +12,7 @@ function RichTextEditor(options) {
|
|
|
12
12
|
numbers: true
|
|
13
13
|
};
|
|
14
14
|
this.textarea = this.options.textarea;
|
|
15
|
-
this.container =
|
|
15
|
+
this.container = $(this.textarea).parent();
|
|
16
16
|
|
|
17
17
|
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
18
18
|
return
|
|
@@ -32,13 +32,13 @@ function RichTextEditor(options) {
|
|
|
32
32
|
this.container.on(
|
|
33
33
|
'click',
|
|
34
34
|
'.moj-rich-text-editor__toolbar-button',
|
|
35
|
-
|
|
35
|
+
$.proxy(this, 'onButtonClick')
|
|
36
36
|
);
|
|
37
37
|
this.container
|
|
38
38
|
.find('.moj-rich-text-editor__content')
|
|
39
|
-
.on('input',
|
|
40
|
-
this.container.find('label').on('click',
|
|
41
|
-
this.toolbar.on('keydown',
|
|
39
|
+
.on('input', $.proxy(this, 'onEditorInput'));
|
|
40
|
+
this.container.find('label').on('click', $.proxy(this, 'onLabelClick'));
|
|
41
|
+
this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
@@ -133,7 +133,7 @@ RichTextEditor.prototype.configureToolbar = function () {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
136
|
-
document.execCommand(
|
|
136
|
+
document.execCommand($(e.currentTarget).data('command'), false, null);
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
RichTextEditor.prototype.getContent = function () {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{%- from "govuk/components/input/macro.njk" import govukInput %}
|
|
2
2
|
{%- from "govuk/components/button/macro.njk" import govukButton %}
|
|
3
3
|
|
|
4
|
-
<div class="moj-search {{-
|
|
4
|
+
<div class="moj-search {{- " " + params.classes if params.classes}}">
|
|
5
5
|
|
|
6
6
|
{%- if params.hint %}
|
|
7
|
-
{% set hintClasses =
|
|
7
|
+
{% set hintClasses = "moj-search__hint " + (params.hint.classes if params.hint.classes) %}
|
|
8
8
|
{% set hintText = params.hint.text %}
|
|
9
9
|
{% set hint = { classes: hintClasses, text: hintText } %}
|
|
10
10
|
{% endif -%}
|
|
@@ -13,21 +13,21 @@
|
|
|
13
13
|
{% set method = params.method %}
|
|
14
14
|
{% endif -%}
|
|
15
15
|
|
|
16
|
-
<form action="{{ params.action }}" method="{{ params.method | default(
|
|
16
|
+
<form action="{{ params.action }}" method="{{ params.method | default("get") }}">
|
|
17
17
|
{{ govukInput({
|
|
18
|
-
classes:
|
|
18
|
+
classes: "moj-search__input " + (params.input.classes if params.input.classes),
|
|
19
19
|
label: {
|
|
20
|
-
classes:
|
|
20
|
+
classes: "moj-search__label " + (params.label.classes if params.label.classes),
|
|
21
21
|
text: params.label.text
|
|
22
22
|
},
|
|
23
23
|
hint: hint,
|
|
24
24
|
id: params.input.id,
|
|
25
25
|
name: params.input.name,
|
|
26
|
-
type:
|
|
26
|
+
type: "search"
|
|
27
27
|
}) }}
|
|
28
28
|
|
|
29
29
|
{{ govukButton({
|
|
30
|
-
classes:
|
|
30
|
+
classes: "moj-search__button " + (params.button.classes if params.button.classes),
|
|
31
31
|
text: params.button.text
|
|
32
32
|
}) }}
|
|
33
33
|
</form>
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
function SearchToggle(options) {
|
|
8
8
|
this.options = options;
|
|
9
|
-
this.container =
|
|
10
|
-
this.toggleButtonContainer =
|
|
9
|
+
this.container = $(this.options.search.container);
|
|
10
|
+
this.toggleButtonContainer = $(this.options.toggleButton.container);
|
|
11
11
|
|
|
12
12
|
if (this.container.data('moj-search-toggle-initialised')) {
|
|
13
13
|
return
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
const svg =
|
|
19
19
|
'<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
|
|
20
20
|
|
|
21
|
-
this.toggleButton =
|
|
21
|
+
this.toggleButton = $(
|
|
22
22
|
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
23
23
|
${this.options.toggleButton.text} ${svg}
|
|
24
24
|
</button>`
|
|
25
25
|
);
|
|
26
|
-
this.toggleButton.on('click',
|
|
26
|
+
this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
|
|
27
27
|
this.toggleButtonContainer.append(this.toggleButton);
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
$(document).on('click', this.onDocumentClick.bind(this));
|
|
29
|
+
$(document).on('focusin', this.onDocumentClick.bind(this));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
SearchToggle.prototype.showMenu = function () {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
|
|
51
51
|
SearchToggle.prototype.onDocumentClick = function (e) {
|
|
52
52
|
if (
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
!$.contains(this.toggleButtonContainer[0], e.target) &&
|
|
54
|
+
!$.contains(this.container[0], e.target)
|
|
55
55
|
) {
|
|
56
56
|
this.hideMenu();
|
|
57
57
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function SearchToggle(options) {
|
|
2
2
|
this.options = options;
|
|
3
|
-
this.container =
|
|
4
|
-
this.toggleButtonContainer =
|
|
3
|
+
this.container = $(this.options.search.container);
|
|
4
|
+
this.toggleButtonContainer = $(this.options.toggleButton.container);
|
|
5
5
|
|
|
6
6
|
if (this.container.data('moj-search-toggle-initialised')) {
|
|
7
7
|
return
|
|
@@ -12,15 +12,15 @@ function SearchToggle(options) {
|
|
|
12
12
|
const svg =
|
|
13
13
|
'<svg viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="moj-search-toggle__button__icon"><path d="M7.433,12.5790048 C6.06762625,12.5808611 4.75763941,12.0392925 3.79217348,11.0738265 C2.82670755,10.1083606 2.28513891,8.79837375 2.28699522,7.433 C2.28513891,6.06762625 2.82670755,4.75763941 3.79217348,3.79217348 C4.75763941,2.82670755 6.06762625,2.28513891 7.433,2.28699522 C8.79837375,2.28513891 10.1083606,2.82670755 11.0738265,3.79217348 C12.0392925,4.75763941 12.5808611,6.06762625 12.5790048,7.433 C12.5808611,8.79837375 12.0392925,10.1083606 11.0738265,11.0738265 C10.1083606,12.0392925 8.79837375,12.5808611 7.433,12.5790048 L7.433,12.5790048 Z M14.293,12.579 L13.391,12.579 L13.071,12.269 C14.2300759,10.9245158 14.8671539,9.20813198 14.866,7.433 C14.866,3.32786745 11.5381325,-1.65045755e-15 7.433,-1.65045755e-15 C3.32786745,-1.65045755e-15 -1.65045755e-15,3.32786745 -1.65045755e-15,7.433 C-1.65045755e-15,11.5381325 3.32786745,14.866 7.433,14.866 C9.208604,14.8671159 10.9253982,14.2296624 12.27,13.07 L12.579,13.39 L12.579,14.294 L18.296,20 L20,18.296 L14.294,12.579 L14.293,12.579 Z"></path></svg>';
|
|
14
14
|
|
|
15
|
-
this.toggleButton =
|
|
15
|
+
this.toggleButton = $(
|
|
16
16
|
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
17
17
|
${this.options.toggleButton.text} ${svg}
|
|
18
18
|
</button>`
|
|
19
19
|
);
|
|
20
|
-
this.toggleButton.on('click',
|
|
20
|
+
this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
|
|
21
21
|
this.toggleButtonContainer.append(this.toggleButton);
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
$(document).on('click', this.onDocumentClick.bind(this));
|
|
23
|
+
$(document).on('focusin', this.onDocumentClick.bind(this));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
SearchToggle.prototype.showMenu = function () {
|
|
@@ -44,8 +44,8 @@ SearchToggle.prototype.onToggleButtonClick = function () {
|
|
|
44
44
|
|
|
45
45
|
SearchToggle.prototype.onDocumentClick = function (e) {
|
|
46
46
|
if (
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
!$.contains(this.toggleButtonContainer[0], e.target) &&
|
|
48
|
+
!$.contains(this.container[0], e.target)
|
|
49
49
|
) {
|
|
50
50
|
this.hideMenu();
|
|
51
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<nav class="moj-side-navigation {{-
|
|
1
|
+
<nav class="moj-side-navigation {{- " " + params.classes if params.classes }}" {%- if (params.label) %} aria-label="{{ params.label }}"{% endif %} {% for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
2
2
|
{%- if params.sections %}
|
|
3
3
|
{%- for section in params.sections %}
|
|
4
|
-
<h{{ section.heading.headingLevel | default(4) }} class="moj-side-navigation__title {{-
|
|
4
|
+
<h{{ section.heading.headingLevel | default(4) }} class="moj-side-navigation__title {{- " " + section.heading.classes if section.heading.classes }}"{% for attribute, value in section.heading.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
5
5
|
{{- section.heading.html | safe if section.heading.html else section.heading.text -}}
|
|
6
6
|
</h{{ section.heading.headingLevel | default(4) }}>
|
|
7
7
|
<ul class="moj-side-navigation__list">
|
|
@@ -25,4 +25,4 @@
|
|
|
25
25
|
{% endfor -%}
|
|
26
26
|
</ul>
|
|
27
27
|
{% endif -%}
|
|
28
|
-
</nav>
|
|
28
|
+
</nav>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function SortableTable(params) {
|
|
8
|
-
this.table =
|
|
8
|
+
this.table = $(params.table);
|
|
9
9
|
|
|
10
10
|
if (this.table.data('moj-search-toggle-initialised')) {
|
|
11
11
|
return
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
this.createHeadingButtons();
|
|
19
19
|
this.createStatusBox();
|
|
20
20
|
this.initialiseSortedColumn();
|
|
21
|
-
this.table.on('click', 'th button',
|
|
21
|
+
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
SortableTable.prototype.setupOptions = function (params) {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
const headings = this.table.find('thead th');
|
|
33
33
|
let heading;
|
|
34
34
|
for (let i = 0; i < headings.length; i++) {
|
|
35
|
-
heading =
|
|
35
|
+
heading = $(headings[i]);
|
|
36
36
|
if (heading.attr('aria-sort')) {
|
|
37
37
|
this.createHeadingButton(heading, i);
|
|
38
38
|
}
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
|
|
42
42
|
SortableTable.prototype.createHeadingButton = function (heading, i) {
|
|
43
43
|
const text = heading.text();
|
|
44
|
-
const button =
|
|
44
|
+
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
|
|
45
45
|
heading.text('');
|
|
46
46
|
heading.append(button);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
SortableTable.prototype.createStatusBox = function () {
|
|
50
|
-
this.status =
|
|
50
|
+
this.status = $(
|
|
51
51
|
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
52
52
|
);
|
|
53
53
|
this.table.parent().append(this.status);
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
62
62
|
.first()
|
|
63
63
|
.each((index, el) => {
|
|
64
|
-
const sortDirection =
|
|
65
|
-
const columnNumber =
|
|
64
|
+
const sortDirection = $(el).attr('aria-sort');
|
|
65
|
+
const columnNumber = $(el).find('button').attr('data-index');
|
|
66
66
|
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
67
67
|
this.addRows(sortedRows);
|
|
68
68
|
});
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
72
72
|
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
73
|
-
const sortDirection =
|
|
73
|
+
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
74
74
|
let newSortDirection;
|
|
75
75
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
76
76
|
newSortDirection = 'ascending';
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
82
82
|
this.addRows(sortedRows);
|
|
83
83
|
this.removeButtonStates();
|
|
84
|
-
this.updateButtonState(
|
|
84
|
+
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
SortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {
|
|
115
115
|
const newRows = rows.sort(
|
|
116
116
|
function (rowA, rowB) {
|
|
117
|
-
const tdA =
|
|
118
|
-
const tdB =
|
|
117
|
+
const tdA = $(rowA).find('td,th').eq(columnNumber);
|
|
118
|
+
const tdB = $(rowB).find('td,th').eq(columnNumber);
|
|
119
119
|
|
|
120
120
|
const valueA =
|
|
121
121
|
sortDirection === 'ascending'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function SortableTable(params) {
|
|
2
|
-
this.table =
|
|
2
|
+
this.table = $(params.table);
|
|
3
3
|
|
|
4
4
|
if (this.table.data('moj-search-toggle-initialised')) {
|
|
5
5
|
return
|
|
@@ -12,7 +12,7 @@ function SortableTable(params) {
|
|
|
12
12
|
this.createHeadingButtons();
|
|
13
13
|
this.createStatusBox();
|
|
14
14
|
this.initialiseSortedColumn();
|
|
15
|
-
this.table.on('click', 'th button',
|
|
15
|
+
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
SortableTable.prototype.setupOptions = function (params) {
|
|
@@ -26,7 +26,7 @@ SortableTable.prototype.createHeadingButtons = function () {
|
|
|
26
26
|
const headings = this.table.find('thead th');
|
|
27
27
|
let heading;
|
|
28
28
|
for (let i = 0; i < headings.length; i++) {
|
|
29
|
-
heading =
|
|
29
|
+
heading = $(headings[i]);
|
|
30
30
|
if (heading.attr('aria-sort')) {
|
|
31
31
|
this.createHeadingButton(heading, i);
|
|
32
32
|
}
|
|
@@ -35,13 +35,13 @@ SortableTable.prototype.createHeadingButtons = function () {
|
|
|
35
35
|
|
|
36
36
|
SortableTable.prototype.createHeadingButton = function (heading, i) {
|
|
37
37
|
const text = heading.text();
|
|
38
|
-
const button =
|
|
38
|
+
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
|
|
39
39
|
heading.text('');
|
|
40
40
|
heading.append(button);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
SortableTable.prototype.createStatusBox = function () {
|
|
44
|
-
this.status =
|
|
44
|
+
this.status = $(
|
|
45
45
|
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
46
46
|
);
|
|
47
47
|
this.table.parent().append(this.status);
|
|
@@ -55,8 +55,8 @@ SortableTable.prototype.initialiseSortedColumn = function () {
|
|
|
55
55
|
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
56
56
|
.first()
|
|
57
57
|
.each((index, el) => {
|
|
58
|
-
const sortDirection =
|
|
59
|
-
const columnNumber =
|
|
58
|
+
const sortDirection = $(el).attr('aria-sort');
|
|
59
|
+
const columnNumber = $(el).find('button').attr('data-index');
|
|
60
60
|
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
61
61
|
this.addRows(sortedRows);
|
|
62
62
|
});
|
|
@@ -64,7 +64,7 @@ SortableTable.prototype.initialiseSortedColumn = function () {
|
|
|
64
64
|
|
|
65
65
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
66
66
|
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
67
|
-
const sortDirection =
|
|
67
|
+
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
68
68
|
let newSortDirection;
|
|
69
69
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
70
70
|
newSortDirection = 'ascending';
|
|
@@ -75,7 +75,7 @@ SortableTable.prototype.onSortButtonClick = function (e) {
|
|
|
75
75
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
76
76
|
this.addRows(sortedRows);
|
|
77
77
|
this.removeButtonStates();
|
|
78
|
-
this.updateButtonState(
|
|
78
|
+
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -108,8 +108,8 @@ SortableTable.prototype.getTableRowsArray = function () {
|
|
|
108
108
|
SortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {
|
|
109
109
|
const newRows = rows.sort(
|
|
110
110
|
function (rowA, rowB) {
|
|
111
|
-
const tdA =
|
|
112
|
-
const tdB =
|
|
111
|
+
const tdA = $(rowA).find('td,th').eq(columnNumber);
|
|
112
|
+
const tdB = $(rowB).find('td,th').eq(columnNumber);
|
|
113
113
|
|
|
114
114
|
const valueA =
|
|
115
115
|
sortDirection === 'ascending'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<nav class="moj-sub-navigation {{-
|
|
1
|
+
<nav class="moj-sub-navigation {{- " " + params.classes if params.classes}}" aria-label="{{ params.label or "Secondary navigation region" }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
2
2
|
|
|
3
3
|
<ul class="moj-sub-navigation__list">
|
|
4
4
|
|
|
5
5
|
{%- for item in params.items %}
|
|
6
|
-
<li class="moj-sub-navigation__item {{-
|
|
6
|
+
<li class="moj-sub-navigation__item {{- " " + item.classes if item.classes}}">
|
|
7
7
|
<a class="moj-sub-navigation__link" {{ 'aria-current="page"' | safe if item.active }} href="{{ item.href }}" {%- for attribute, value in item.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
|
8
8
|
{{- item.html | safe if item.html else item.text -}}
|
|
9
9
|
</a>
|