@ministryofjustice/frontend 3.6.1 → 3.6.2
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/components/add-another/add-another.js +10 -10
- package/moj/components/add-another/add-another.mjs +10 -10
- 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/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-select/multi-select.js +7 -7
- package/moj/components/multi-select/multi-select.mjs +7 -7
- package/moj/components/password-reveal/password-reveal.js +4 -4
- package/moj/components/password-reveal/password-reveal.mjs +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-toggle/search-toggle.js +8 -8
- package/moj/components/search-toggle/search-toggle.mjs +8 -8
- package/moj/components/sortable-table/sortable-table.js +11 -11
- package/moj/components/sortable-table/sortable-table.mjs +11 -11
- package/moj/moj-frontend.min.js +1 -1
- package/package.json +1 -1
package/moj/all.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function AddAnother(container) {
|
|
8
|
-
this.container =
|
|
8
|
+
this.container = $(container);
|
|
9
9
|
|
|
10
10
|
if (this.container.data('moj-add-another-initialised')) {
|
|
11
11
|
return
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
this.container.on(
|
|
17
17
|
'click',
|
|
18
18
|
'.moj-add-another__remove-button',
|
|
19
|
-
|
|
19
|
+
$.proxy(this, 'onRemoveButtonClick')
|
|
20
20
|
);
|
|
21
21
|
this.container.on(
|
|
22
22
|
'click',
|
|
23
23
|
'.moj-add-another__add-button',
|
|
24
|
-
|
|
24
|
+
$.proxy(this, 'onAddButtonClick')
|
|
25
25
|
);
|
|
26
26
|
this.container
|
|
27
27
|
.find('.moj-add-another__add-button, moj-add-another__remove-button')
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
item.find('[data-name]').each(function (i, el) {
|
|
61
61
|
const originalId = el.id;
|
|
62
62
|
|
|
63
|
-
el.name =
|
|
63
|
+
el.name = $(el)
|
|
64
64
|
.attr('data-name')
|
|
65
65
|
.replace(/%index%/, index);
|
|
66
|
-
el.id =
|
|
66
|
+
el.id = $(el)
|
|
67
67
|
.attr('data-id')
|
|
68
68
|
.replace(/%index%/, index);
|
|
69
69
|
|
|
70
70
|
const label =
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
$(el).siblings('label')[0] ||
|
|
72
|
+
$(el).parents('label')[0] ||
|
|
73
73
|
item.find(`[for="${originalId}"]`)[0];
|
|
74
74
|
label.htmlFor = el.id;
|
|
75
75
|
});
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
AddAnother.prototype.onRemoveButtonClick = function (e) {
|
|
95
|
-
|
|
95
|
+
$(e.currentTarget).parents('.moj-add-another__item').remove();
|
|
96
96
|
const items = this.getItems();
|
|
97
97
|
if (items.length === 1) {
|
|
98
98
|
items.find('.moj-add-another__remove-button').remove();
|
|
99
99
|
}
|
|
100
100
|
items.each(
|
|
101
|
-
|
|
102
|
-
this.updateAttributes(index,
|
|
101
|
+
$.proxy(function (index, el) {
|
|
102
|
+
this.updateAttributes(index, $(el));
|
|
103
103
|
}, this)
|
|
104
104
|
);
|
|
105
105
|
this.focusHeading();
|
|
@@ -1769,8 +1769,8 @@
|
|
|
1769
1769
|
|
|
1770
1770
|
function FilterToggleButton(options) {
|
|
1771
1771
|
this.options = options;
|
|
1772
|
-
this.container =
|
|
1773
|
-
this.filterContainer =
|
|
1772
|
+
this.container = $(this.options.toggleButton.container);
|
|
1773
|
+
this.filterContainer = $(this.options.filter.container);
|
|
1774
1774
|
|
|
1775
1775
|
this.createToggleButton();
|
|
1776
1776
|
this.setupResponsiveChecks();
|
|
@@ -1782,15 +1782,15 @@
|
|
|
1782
1782
|
|
|
1783
1783
|
FilterToggleButton.prototype.setupResponsiveChecks = function () {
|
|
1784
1784
|
this.mq = window.matchMedia(this.options.bigModeMediaQuery);
|
|
1785
|
-
this.mq.addListener(
|
|
1785
|
+
this.mq.addListener($.proxy(this, 'checkMode'));
|
|
1786
1786
|
this.checkMode(this.mq);
|
|
1787
1787
|
};
|
|
1788
1788
|
|
|
1789
1789
|
FilterToggleButton.prototype.createToggleButton = function () {
|
|
1790
|
-
this.menuButton =
|
|
1790
|
+
this.menuButton = $(
|
|
1791
1791
|
`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`
|
|
1792
1792
|
);
|
|
1793
|
-
this.menuButton.on('click',
|
|
1793
|
+
this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick'));
|
|
1794
1794
|
this.container.append(this.menuButton);
|
|
1795
1795
|
};
|
|
1796
1796
|
|
|
@@ -1814,11 +1814,11 @@
|
|
|
1814
1814
|
|
|
1815
1815
|
FilterToggleButton.prototype.addCloseButton = function () {
|
|
1816
1816
|
if (this.options.closeButton) {
|
|
1817
|
-
this.closeButton =
|
|
1817
|
+
this.closeButton = $(
|
|
1818
1818
|
`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
|
|
1819
1819
|
);
|
|
1820
|
-
this.closeButton.on('click',
|
|
1821
|
-
|
|
1820
|
+
this.closeButton.on('click', $.proxy(this, 'onCloseClick'));
|
|
1821
|
+
$(this.options.closeButton.container).append(this.closeButton);
|
|
1822
1822
|
}
|
|
1823
1823
|
};
|
|
1824
1824
|
|
|
@@ -1865,17 +1865,17 @@
|
|
|
1865
1865
|
}
|
|
1866
1866
|
|
|
1867
1867
|
this.defaultParams = {
|
|
1868
|
-
uploadFileEntryHook:
|
|
1869
|
-
uploadFileExitHook:
|
|
1870
|
-
uploadFileErrorHook:
|
|
1871
|
-
fileDeleteHook:
|
|
1868
|
+
uploadFileEntryHook: $.noop,
|
|
1869
|
+
uploadFileExitHook: $.noop,
|
|
1870
|
+
uploadFileErrorHook: $.noop,
|
|
1871
|
+
fileDeleteHook: $.noop,
|
|
1872
1872
|
uploadStatusText: 'Uploading files, please wait',
|
|
1873
1873
|
dropzoneHintText: 'Drag and drop files here or',
|
|
1874
1874
|
dropzoneButtonText: 'Choose files'
|
|
1875
1875
|
};
|
|
1876
1876
|
|
|
1877
|
-
this.params =
|
|
1878
|
-
this.container =
|
|
1877
|
+
this.params = $.extend({}, this.defaultParams, params);
|
|
1878
|
+
this.container = $(this.params.container);
|
|
1879
1879
|
|
|
1880
1880
|
this.container.addClass('moj-multi-file-upload--enhanced');
|
|
1881
1881
|
|
|
@@ -1889,20 +1889,20 @@
|
|
|
1889
1889
|
this.container.on(
|
|
1890
1890
|
'click',
|
|
1891
1891
|
'.moj-multi-file-upload__delete',
|
|
1892
|
-
|
|
1892
|
+
$.proxy(this, 'onFileDeleteClick')
|
|
1893
1893
|
);
|
|
1894
1894
|
}
|
|
1895
1895
|
|
|
1896
1896
|
MultiFileUpload.prototype.setupDropzone = function () {
|
|
1897
1897
|
this.fileInput.wrap('<div class="moj-multi-file-upload__dropzone" />');
|
|
1898
1898
|
this.dropzone = this.container.find('.moj-multi-file-upload__dropzone');
|
|
1899
|
-
this.dropzone.on('dragover',
|
|
1900
|
-
this.dropzone.on('dragleave',
|
|
1901
|
-
this.dropzone.on('drop',
|
|
1899
|
+
this.dropzone.on('dragover', $.proxy(this, 'onDragOver'));
|
|
1900
|
+
this.dropzone.on('dragleave', $.proxy(this, 'onDragLeave'));
|
|
1901
|
+
this.dropzone.on('drop', $.proxy(this, 'onDrop'));
|
|
1902
1902
|
};
|
|
1903
1903
|
|
|
1904
1904
|
MultiFileUpload.prototype.setupLabel = function () {
|
|
1905
|
-
this.label =
|
|
1905
|
+
this.label = $(
|
|
1906
1906
|
`<label for="${this.fileInput[0].id}" class="govuk-button govuk-button--secondary">${this.params.dropzoneButtonText}</label>`
|
|
1907
1907
|
);
|
|
1908
1908
|
this.dropzone.append(
|
|
@@ -1913,13 +1913,13 @@
|
|
|
1913
1913
|
|
|
1914
1914
|
MultiFileUpload.prototype.setupFileInput = function () {
|
|
1915
1915
|
this.fileInput = this.container.find('.moj-multi-file-upload__input');
|
|
1916
|
-
this.fileInput.on('change',
|
|
1917
|
-
this.fileInput.on('focus',
|
|
1918
|
-
this.fileInput.on('blur',
|
|
1916
|
+
this.fileInput.on('change', $.proxy(this, 'onFileChange'));
|
|
1917
|
+
this.fileInput.on('focus', $.proxy(this, 'onFileFocus'));
|
|
1918
|
+
this.fileInput.on('blur', $.proxy(this, 'onFileBlur'));
|
|
1919
1919
|
};
|
|
1920
1920
|
|
|
1921
1921
|
MultiFileUpload.prototype.setupStatusBox = function () {
|
|
1922
|
-
this.status =
|
|
1922
|
+
this.status = $(
|
|
1923
1923
|
'<div aria-live="polite" role="status" class="govuk-visually-hidden" />'
|
|
1924
1924
|
);
|
|
1925
1925
|
this.dropzone.append(this.status);
|
|
@@ -1952,7 +1952,7 @@
|
|
|
1952
1952
|
this.feedbackContainer.removeClass('moj-hidden');
|
|
1953
1953
|
this.status.html(this.params.uploadStatusText);
|
|
1954
1954
|
this.uploadFiles(e.currentTarget.files);
|
|
1955
|
-
this.fileInput.replaceWith(
|
|
1955
|
+
this.fileInput.replaceWith($(e.currentTarget).val('').clone(true));
|
|
1956
1956
|
this.setupFileInput();
|
|
1957
1957
|
this.fileInput.get(0).focus();
|
|
1958
1958
|
};
|
|
@@ -1993,18 +1993,18 @@
|
|
|
1993
1993
|
|
|
1994
1994
|
MultiFileUpload.prototype.uploadFile = function (file) {
|
|
1995
1995
|
this.params.uploadFileEntryHook(this, file);
|
|
1996
|
-
const item =
|
|
1996
|
+
const item = $(this.getFileRowHtml(file));
|
|
1997
1997
|
const formData = new FormData();
|
|
1998
1998
|
formData.append('documents', file);
|
|
1999
1999
|
this.feedbackContainer.find('.moj-multi-file-upload__list').append(item);
|
|
2000
2000
|
|
|
2001
|
-
|
|
2001
|
+
$.ajax({
|
|
2002
2002
|
url: this.params.uploadUrl,
|
|
2003
2003
|
type: 'post',
|
|
2004
2004
|
data: formData,
|
|
2005
2005
|
processData: false,
|
|
2006
2006
|
contentType: false,
|
|
2007
|
-
success:
|
|
2007
|
+
success: $.proxy(function (response) {
|
|
2008
2008
|
if (response.error) {
|
|
2009
2009
|
item
|
|
2010
2010
|
.find('.moj-multi-file-upload__message')
|
|
@@ -2021,7 +2021,7 @@
|
|
|
2021
2021
|
.append(this.getDeleteButtonHtml(response.file));
|
|
2022
2022
|
this.params.uploadFileExitHook(this, file, response);
|
|
2023
2023
|
}, this),
|
|
2024
|
-
error:
|
|
2024
|
+
error: $.proxy(function (jqXHR, textStatus, errorThrown) {
|
|
2025
2025
|
this.params.uploadFileErrorHook(
|
|
2026
2026
|
this,
|
|
2027
2027
|
file,
|
|
@@ -2052,15 +2052,15 @@
|
|
|
2052
2052
|
|
|
2053
2053
|
MultiFileUpload.prototype.onFileDeleteClick = function (e) {
|
|
2054
2054
|
e.preventDefault(); // if user refreshes page and then deletes
|
|
2055
|
-
const button =
|
|
2055
|
+
const button = $(e.currentTarget);
|
|
2056
2056
|
const data = {};
|
|
2057
2057
|
data[button[0].name] = button[0].value;
|
|
2058
|
-
|
|
2058
|
+
$.ajax({
|
|
2059
2059
|
url: this.params.deleteUrl,
|
|
2060
2060
|
type: 'post',
|
|
2061
2061
|
dataType: 'json',
|
|
2062
2062
|
data,
|
|
2063
|
-
success:
|
|
2063
|
+
success: $.proxy(function (response) {
|
|
2064
2064
|
if (response.error) ; else {
|
|
2065
2065
|
button.parents('.moj-multi-file-upload__row').remove();
|
|
2066
2066
|
if (
|
|
@@ -2076,7 +2076,7 @@
|
|
|
2076
2076
|
};
|
|
2077
2077
|
|
|
2078
2078
|
function MultiSelect(options) {
|
|
2079
|
-
this.container =
|
|
2079
|
+
this.container = $(options.container);
|
|
2080
2080
|
|
|
2081
2081
|
if (this.container.data('moj-multi-select-initialised')) {
|
|
2082
2082
|
return
|
|
@@ -2090,12 +2090,12 @@
|
|
|
2090
2090
|
allId = `${idPrefix}checkboxes-all`;
|
|
2091
2091
|
}
|
|
2092
2092
|
|
|
2093
|
-
this.toggle =
|
|
2093
|
+
this.toggle = $(this.getToggleHtml(allId));
|
|
2094
2094
|
this.toggleButton = this.toggle.find('input');
|
|
2095
|
-
this.toggleButton.on('click',
|
|
2095
|
+
this.toggleButton.on('click', $.proxy(this, 'onButtonClick'));
|
|
2096
2096
|
this.container.append(this.toggle);
|
|
2097
|
-
this.checkboxes =
|
|
2098
|
-
this.checkboxes.on('click',
|
|
2097
|
+
this.checkboxes = $(options.checkboxes);
|
|
2098
|
+
this.checkboxes.on('click', $.proxy(this, 'onCheckboxClick'));
|
|
2099
2099
|
this.checked = options.checked || false;
|
|
2100
2100
|
}
|
|
2101
2101
|
|
|
@@ -2123,7 +2123,7 @@
|
|
|
2123
2123
|
|
|
2124
2124
|
MultiSelect.prototype.checkAll = function () {
|
|
2125
2125
|
this.checkboxes.each(
|
|
2126
|
-
|
|
2126
|
+
$.proxy(function (index, el) {
|
|
2127
2127
|
el.checked = true;
|
|
2128
2128
|
}, this)
|
|
2129
2129
|
);
|
|
@@ -2132,7 +2132,7 @@
|
|
|
2132
2132
|
|
|
2133
2133
|
MultiSelect.prototype.uncheckAll = function () {
|
|
2134
2134
|
this.checkboxes.each(
|
|
2135
|
-
|
|
2135
|
+
$.proxy(function (index, el) {
|
|
2136
2136
|
el.checked = false;
|
|
2137
2137
|
}, this)
|
|
2138
2138
|
);
|
|
@@ -2153,7 +2153,7 @@
|
|
|
2153
2153
|
|
|
2154
2154
|
function PasswordReveal(element) {
|
|
2155
2155
|
this.el = element;
|
|
2156
|
-
const $el =
|
|
2156
|
+
const $el = $(this.el);
|
|
2157
2157
|
|
|
2158
2158
|
if ($el.data('moj-password-reveal-initialised')) {
|
|
2159
2159
|
return
|
|
@@ -2163,16 +2163,16 @@
|
|
|
2163
2163
|
$el.attr('spellcheck', 'false');
|
|
2164
2164
|
|
|
2165
2165
|
$el.wrap('<div class="moj-password-reveal"></div>');
|
|
2166
|
-
this.container =
|
|
2166
|
+
this.container = $(this.el).parent();
|
|
2167
2167
|
this.createButton();
|
|
2168
2168
|
}
|
|
2169
2169
|
|
|
2170
2170
|
PasswordReveal.prototype.createButton = function () {
|
|
2171
|
-
this.button =
|
|
2171
|
+
this.button = $(
|
|
2172
2172
|
'<button type="button" class="govuk-button govuk-button--secondary moj-password-reveal__button">Show <span class="govuk-visually-hidden">password</span></button>'
|
|
2173
2173
|
);
|
|
2174
2174
|
this.container.append(this.button);
|
|
2175
|
-
this.button.on('click',
|
|
2175
|
+
this.button.on('click', $.proxy(this, 'onButtonClick'));
|
|
2176
2176
|
};
|
|
2177
2177
|
|
|
2178
2178
|
PasswordReveal.prototype.onButtonClick = function () {
|
|
@@ -2199,7 +2199,7 @@
|
|
|
2199
2199
|
numbers: true
|
|
2200
2200
|
};
|
|
2201
2201
|
this.textarea = this.options.textarea;
|
|
2202
|
-
this.container =
|
|
2202
|
+
this.container = $(this.textarea).parent();
|
|
2203
2203
|
|
|
2204
2204
|
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
2205
2205
|
return
|
|
@@ -2219,13 +2219,13 @@
|
|
|
2219
2219
|
this.container.on(
|
|
2220
2220
|
'click',
|
|
2221
2221
|
'.moj-rich-text-editor__toolbar-button',
|
|
2222
|
-
|
|
2222
|
+
$.proxy(this, 'onButtonClick')
|
|
2223
2223
|
);
|
|
2224
2224
|
this.container
|
|
2225
2225
|
.find('.moj-rich-text-editor__content')
|
|
2226
|
-
.on('input',
|
|
2227
|
-
this.container.find('label').on('click',
|
|
2228
|
-
this.toolbar.on('keydown',
|
|
2226
|
+
.on('input', $.proxy(this, 'onEditorInput'));
|
|
2227
|
+
this.container.find('label').on('click', $.proxy(this, 'onLabelClick'));
|
|
2228
|
+
this.toolbar.on('keydown', $.proxy(this, 'onToolbarKeydown'));
|
|
2229
2229
|
}
|
|
2230
2230
|
|
|
2231
2231
|
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
@@ -2320,7 +2320,7 @@
|
|
|
2320
2320
|
};
|
|
2321
2321
|
|
|
2322
2322
|
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
2323
|
-
document.execCommand(
|
|
2323
|
+
document.execCommand($(e.currentTarget).data('command'), false, null);
|
|
2324
2324
|
};
|
|
2325
2325
|
|
|
2326
2326
|
RichTextEditor.prototype.getContent = function () {
|
|
@@ -2343,8 +2343,8 @@
|
|
|
2343
2343
|
|
|
2344
2344
|
function SearchToggle(options) {
|
|
2345
2345
|
this.options = options;
|
|
2346
|
-
this.container =
|
|
2347
|
-
this.toggleButtonContainer =
|
|
2346
|
+
this.container = $(this.options.search.container);
|
|
2347
|
+
this.toggleButtonContainer = $(this.options.toggleButton.container);
|
|
2348
2348
|
|
|
2349
2349
|
if (this.container.data('moj-search-toggle-initialised')) {
|
|
2350
2350
|
return
|
|
@@ -2355,15 +2355,15 @@
|
|
|
2355
2355
|
const svg =
|
|
2356
2356
|
'<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>';
|
|
2357
2357
|
|
|
2358
|
-
this.toggleButton =
|
|
2358
|
+
this.toggleButton = $(
|
|
2359
2359
|
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
2360
2360
|
${this.options.toggleButton.text} ${svg}
|
|
2361
2361
|
</button>`
|
|
2362
2362
|
);
|
|
2363
|
-
this.toggleButton.on('click',
|
|
2363
|
+
this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
|
|
2364
2364
|
this.toggleButtonContainer.append(this.toggleButton);
|
|
2365
|
-
|
|
2366
|
-
|
|
2365
|
+
$(document).on('click', this.onDocumentClick.bind(this));
|
|
2366
|
+
$(document).on('focusin', this.onDocumentClick.bind(this));
|
|
2367
2367
|
}
|
|
2368
2368
|
|
|
2369
2369
|
SearchToggle.prototype.showMenu = function () {
|
|
@@ -2387,15 +2387,15 @@
|
|
|
2387
2387
|
|
|
2388
2388
|
SearchToggle.prototype.onDocumentClick = function (e) {
|
|
2389
2389
|
if (
|
|
2390
|
-
|
|
2391
|
-
|
|
2390
|
+
!$.contains(this.toggleButtonContainer[0], e.target) &&
|
|
2391
|
+
!$.contains(this.container[0], e.target)
|
|
2392
2392
|
) {
|
|
2393
2393
|
this.hideMenu();
|
|
2394
2394
|
}
|
|
2395
2395
|
};
|
|
2396
2396
|
|
|
2397
2397
|
function SortableTable(params) {
|
|
2398
|
-
this.table =
|
|
2398
|
+
this.table = $(params.table);
|
|
2399
2399
|
|
|
2400
2400
|
if (this.table.data('moj-search-toggle-initialised')) {
|
|
2401
2401
|
return
|
|
@@ -2408,7 +2408,7 @@
|
|
|
2408
2408
|
this.createHeadingButtons();
|
|
2409
2409
|
this.createStatusBox();
|
|
2410
2410
|
this.initialiseSortedColumn();
|
|
2411
|
-
this.table.on('click', 'th button',
|
|
2411
|
+
this.table.on('click', 'th button', $.proxy(this, 'onSortButtonClick'));
|
|
2412
2412
|
}
|
|
2413
2413
|
|
|
2414
2414
|
SortableTable.prototype.setupOptions = function (params) {
|
|
@@ -2422,7 +2422,7 @@
|
|
|
2422
2422
|
const headings = this.table.find('thead th');
|
|
2423
2423
|
let heading;
|
|
2424
2424
|
for (let i = 0; i < headings.length; i++) {
|
|
2425
|
-
heading =
|
|
2425
|
+
heading = $(headings[i]);
|
|
2426
2426
|
if (heading.attr('aria-sort')) {
|
|
2427
2427
|
this.createHeadingButton(heading, i);
|
|
2428
2428
|
}
|
|
@@ -2431,13 +2431,13 @@
|
|
|
2431
2431
|
|
|
2432
2432
|
SortableTable.prototype.createHeadingButton = function (heading, i) {
|
|
2433
2433
|
const text = heading.text();
|
|
2434
|
-
const button =
|
|
2434
|
+
const button = $(`<button type="button" data-index="${i}">${text}</button>`);
|
|
2435
2435
|
heading.text('');
|
|
2436
2436
|
heading.append(button);
|
|
2437
2437
|
};
|
|
2438
2438
|
|
|
2439
2439
|
SortableTable.prototype.createStatusBox = function () {
|
|
2440
|
-
this.status =
|
|
2440
|
+
this.status = $(
|
|
2441
2441
|
'<div aria-live="polite" role="status" aria-atomic="true" class="govuk-visually-hidden" />'
|
|
2442
2442
|
);
|
|
2443
2443
|
this.table.parent().append(this.status);
|
|
@@ -2451,8 +2451,8 @@
|
|
|
2451
2451
|
.filter('[aria-sort="ascending"], [aria-sort="descending"]')
|
|
2452
2452
|
.first()
|
|
2453
2453
|
.each((index, el) => {
|
|
2454
|
-
const sortDirection =
|
|
2455
|
-
const columnNumber =
|
|
2454
|
+
const sortDirection = $(el).attr('aria-sort');
|
|
2455
|
+
const columnNumber = $(el).find('button').attr('data-index');
|
|
2456
2456
|
const sortedRows = this.sort(rows, columnNumber, sortDirection);
|
|
2457
2457
|
this.addRows(sortedRows);
|
|
2458
2458
|
});
|
|
@@ -2460,7 +2460,7 @@
|
|
|
2460
2460
|
|
|
2461
2461
|
SortableTable.prototype.onSortButtonClick = function (e) {
|
|
2462
2462
|
const columnNumber = e.currentTarget.getAttribute('data-index');
|
|
2463
|
-
const sortDirection =
|
|
2463
|
+
const sortDirection = $(e.currentTarget).parent().attr('aria-sort');
|
|
2464
2464
|
let newSortDirection;
|
|
2465
2465
|
if (sortDirection === 'none' || sortDirection === 'descending') {
|
|
2466
2466
|
newSortDirection = 'ascending';
|
|
@@ -2471,7 +2471,7 @@
|
|
|
2471
2471
|
const sortedRows = this.sort(rows, columnNumber, newSortDirection);
|
|
2472
2472
|
this.addRows(sortedRows);
|
|
2473
2473
|
this.removeButtonStates();
|
|
2474
|
-
this.updateButtonState(
|
|
2474
|
+
this.updateButtonState($(e.currentTarget), newSortDirection);
|
|
2475
2475
|
};
|
|
2476
2476
|
|
|
2477
2477
|
SortableTable.prototype.updateButtonState = function (button, direction) {
|
|
@@ -2504,8 +2504,8 @@
|
|
|
2504
2504
|
SortableTable.prototype.sort = function (rows, columnNumber, sortDirection) {
|
|
2505
2505
|
const newRows = rows.sort(
|
|
2506
2506
|
function (rowA, rowB) {
|
|
2507
|
-
const tdA =
|
|
2508
|
-
const tdB =
|
|
2507
|
+
const tdA = $(rowA).find('td,th').eq(columnNumber);
|
|
2508
|
+
const tdB = $(rowB).find('td,th').eq(columnNumber);
|
|
2509
2509
|
|
|
2510
2510
|
const valueA =
|
|
2511
2511
|
sortDirection === 'ascending'
|
|
@@ -2531,7 +2531,7 @@
|
|
|
2531
2531
|
return isNaN(valAsNumber) ? val : valAsNumber
|
|
2532
2532
|
};
|
|
2533
2533
|
|
|
2534
|
-
const version = '3.6.
|
|
2534
|
+
const version = '3.6.2';
|
|
2535
2535
|
|
|
2536
2536
|
/* eslint-disable no-new */
|
|
2537
2537
|
|
|
@@ -2580,7 +2580,7 @@
|
|
|
2580
2580
|
|
|
2581
2581
|
nodeListForEach($richTextEditors, function ($richTextEditor) {
|
|
2582
2582
|
const options = {
|
|
2583
|
-
textarea:
|
|
2583
|
+
textarea: $($richTextEditor)
|
|
2584
2584
|
};
|
|
2585
2585
|
|
|
2586
2586
|
const toolbarAttr = $richTextEditor.getAttribute(
|
|
@@ -2607,11 +2607,11 @@
|
|
|
2607
2607
|
nodeListForEach($searchToggles, function ($searchToggle) {
|
|
2608
2608
|
new SearchToggle({
|
|
2609
2609
|
toggleButton: {
|
|
2610
|
-
container:
|
|
2610
|
+
container: $($searchToggle.querySelector('.moj-search-toggle__toggle')),
|
|
2611
2611
|
text: $searchToggle.getAttribute('data-moj-search-toggle-text')
|
|
2612
2612
|
},
|
|
2613
2613
|
search: {
|
|
2614
|
-
container:
|
|
2614
|
+
container: $($searchToggle.querySelector('.moj-search'))
|
|
2615
2615
|
}
|
|
2616
2616
|
});
|
|
2617
2617
|
});
|
package/moj/all.mjs
CHANGED
|
@@ -59,7 +59,7 @@ function initAll(options) {
|
|
|
59
59
|
|
|
60
60
|
nodeListForEach($richTextEditors, function ($richTextEditor) {
|
|
61
61
|
const options = {
|
|
62
|
-
textarea:
|
|
62
|
+
textarea: $($richTextEditor)
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const toolbarAttr = $richTextEditor.getAttribute(
|
|
@@ -86,11 +86,11 @@ function initAll(options) {
|
|
|
86
86
|
nodeListForEach($searchToggles, function ($searchToggle) {
|
|
87
87
|
new SearchToggle({
|
|
88
88
|
toggleButton: {
|
|
89
|
-
container:
|
|
89
|
+
container: $($searchToggle.querySelector('.moj-search-toggle__toggle')),
|
|
90
90
|
text: $searchToggle.getAttribute('data-moj-search-toggle-text')
|
|
91
91
|
},
|
|
92
92
|
search: {
|
|
93
|
-
container:
|
|
93
|
+
container: $($searchToggle.querySelector('.moj-search'))
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function AddAnother(container) {
|
|
8
|
-
this.container =
|
|
8
|
+
this.container = $(container);
|
|
9
9
|
|
|
10
10
|
if (this.container.data('moj-add-another-initialised')) {
|
|
11
11
|
return
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
this.container.on(
|
|
17
17
|
'click',
|
|
18
18
|
'.moj-add-another__remove-button',
|
|
19
|
-
|
|
19
|
+
$.proxy(this, 'onRemoveButtonClick')
|
|
20
20
|
);
|
|
21
21
|
this.container.on(
|
|
22
22
|
'click',
|
|
23
23
|
'.moj-add-another__add-button',
|
|
24
|
-
|
|
24
|
+
$.proxy(this, 'onAddButtonClick')
|
|
25
25
|
);
|
|
26
26
|
this.container
|
|
27
27
|
.find('.moj-add-another__add-button, moj-add-another__remove-button')
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
item.find('[data-name]').each(function (i, el) {
|
|
61
61
|
const originalId = el.id;
|
|
62
62
|
|
|
63
|
-
el.name =
|
|
63
|
+
el.name = $(el)
|
|
64
64
|
.attr('data-name')
|
|
65
65
|
.replace(/%index%/, index);
|
|
66
|
-
el.id =
|
|
66
|
+
el.id = $(el)
|
|
67
67
|
.attr('data-id')
|
|
68
68
|
.replace(/%index%/, index);
|
|
69
69
|
|
|
70
70
|
const label =
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
$(el).siblings('label')[0] ||
|
|
72
|
+
$(el).parents('label')[0] ||
|
|
73
73
|
item.find(`[for="${originalId}"]`)[0];
|
|
74
74
|
label.htmlFor = el.id;
|
|
75
75
|
});
|
|
@@ -92,14 +92,14 @@
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
AddAnother.prototype.onRemoveButtonClick = function (e) {
|
|
95
|
-
|
|
95
|
+
$(e.currentTarget).parents('.moj-add-another__item').remove();
|
|
96
96
|
const items = this.getItems();
|
|
97
97
|
if (items.length === 1) {
|
|
98
98
|
items.find('.moj-add-another__remove-button').remove();
|
|
99
99
|
}
|
|
100
100
|
items.each(
|
|
101
|
-
|
|
102
|
-
this.updateAttributes(index,
|
|
101
|
+
$.proxy(function (index, el) {
|
|
102
|
+
this.updateAttributes(index, $(el));
|
|
103
103
|
}, this)
|
|
104
104
|
);
|
|
105
105
|
this.focusHeading();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function AddAnother(container) {
|
|
2
|
-
this.container =
|
|
2
|
+
this.container = $(container);
|
|
3
3
|
|
|
4
4
|
if (this.container.data('moj-add-another-initialised')) {
|
|
5
5
|
return
|
|
@@ -10,12 +10,12 @@ function AddAnother(container) {
|
|
|
10
10
|
this.container.on(
|
|
11
11
|
'click',
|
|
12
12
|
'.moj-add-another__remove-button',
|
|
13
|
-
|
|
13
|
+
$.proxy(this, 'onRemoveButtonClick')
|
|
14
14
|
);
|
|
15
15
|
this.container.on(
|
|
16
16
|
'click',
|
|
17
17
|
'.moj-add-another__add-button',
|
|
18
|
-
|
|
18
|
+
$.proxy(this, 'onAddButtonClick')
|
|
19
19
|
);
|
|
20
20
|
this.container
|
|
21
21
|
.find('.moj-add-another__add-button, moj-add-another__remove-button')
|
|
@@ -54,16 +54,16 @@ AddAnother.prototype.updateAttributes = function (index, item) {
|
|
|
54
54
|
item.find('[data-name]').each(function (i, el) {
|
|
55
55
|
const originalId = el.id;
|
|
56
56
|
|
|
57
|
-
el.name =
|
|
57
|
+
el.name = $(el)
|
|
58
58
|
.attr('data-name')
|
|
59
59
|
.replace(/%index%/, index);
|
|
60
|
-
el.id =
|
|
60
|
+
el.id = $(el)
|
|
61
61
|
.attr('data-id')
|
|
62
62
|
.replace(/%index%/, index);
|
|
63
63
|
|
|
64
64
|
const label =
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
$(el).siblings('label')[0] ||
|
|
66
|
+
$(el).parents('label')[0] ||
|
|
67
67
|
item.find(`[for="${originalId}"]`)[0];
|
|
68
68
|
label.htmlFor = el.id;
|
|
69
69
|
});
|
|
@@ -86,14 +86,14 @@ AddAnother.prototype.resetItem = function (item) {
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
AddAnother.prototype.onRemoveButtonClick = function (e) {
|
|
89
|
-
|
|
89
|
+
$(e.currentTarget).parents('.moj-add-another__item').remove();
|
|
90
90
|
const items = this.getItems();
|
|
91
91
|
if (items.length === 1) {
|
|
92
92
|
items.find('.moj-add-another__remove-button').remove();
|
|
93
93
|
}
|
|
94
94
|
items.each(
|
|
95
|
-
|
|
96
|
-
this.updateAttributes(index,
|
|
95
|
+
$.proxy(function (index, el) {
|
|
96
|
+
this.updateAttributes(index, $(el));
|
|
97
97
|
}, this)
|
|
98
98
|
);
|
|
99
99
|
this.focusHeading();
|