@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
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
function FilterToggleButton(options) {
|
|
8
8
|
this.options = options;
|
|
9
|
-
this.container =
|
|
10
|
-
this.filterContainer =
|
|
9
|
+
this.container = $(this.options.toggleButton.container);
|
|
10
|
+
this.filterContainer = $(this.options.filter.container);
|
|
11
11
|
|
|
12
12
|
this.createToggleButton();
|
|
13
13
|
this.setupResponsiveChecks();
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
|
|
20
20
|
FilterToggleButton.prototype.setupResponsiveChecks = function () {
|
|
21
21
|
this.mq = window.matchMedia(this.options.bigModeMediaQuery);
|
|
22
|
-
this.mq.addListener(
|
|
22
|
+
this.mq.addListener($.proxy(this, 'checkMode'));
|
|
23
23
|
this.checkMode(this.mq);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
FilterToggleButton.prototype.createToggleButton = function () {
|
|
27
|
-
this.menuButton =
|
|
27
|
+
this.menuButton = $(
|
|
28
28
|
`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`
|
|
29
29
|
);
|
|
30
|
-
this.menuButton.on('click',
|
|
30
|
+
this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick'));
|
|
31
31
|
this.container.append(this.menuButton);
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
|
|
52
52
|
FilterToggleButton.prototype.addCloseButton = function () {
|
|
53
53
|
if (this.options.closeButton) {
|
|
54
|
-
this.closeButton =
|
|
54
|
+
this.closeButton = $(
|
|
55
55
|
`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
|
|
56
56
|
);
|
|
57
|
-
this.closeButton.on('click',
|
|
58
|
-
|
|
57
|
+
this.closeButton.on('click', $.proxy(this, 'onCloseClick'));
|
|
58
|
+
$(this.options.closeButton.container).append(this.closeButton);
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function FilterToggleButton(options) {
|
|
2
2
|
this.options = options;
|
|
3
|
-
this.container =
|
|
4
|
-
this.filterContainer =
|
|
3
|
+
this.container = $(this.options.toggleButton.container);
|
|
4
|
+
this.filterContainer = $(this.options.filter.container);
|
|
5
5
|
|
|
6
6
|
this.createToggleButton();
|
|
7
7
|
this.setupResponsiveChecks();
|
|
@@ -13,15 +13,15 @@ function FilterToggleButton(options) {
|
|
|
13
13
|
|
|
14
14
|
FilterToggleButton.prototype.setupResponsiveChecks = function () {
|
|
15
15
|
this.mq = window.matchMedia(this.options.bigModeMediaQuery);
|
|
16
|
-
this.mq.addListener(
|
|
16
|
+
this.mq.addListener($.proxy(this, 'checkMode'));
|
|
17
17
|
this.checkMode(this.mq);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
FilterToggleButton.prototype.createToggleButton = function () {
|
|
21
|
-
this.menuButton =
|
|
21
|
+
this.menuButton = $(
|
|
22
22
|
`<button class="govuk-button ${this.options.toggleButton.classes}" type="button" aria-haspopup="true" aria-expanded="false">${this.options.toggleButton.showText}</button>`
|
|
23
23
|
);
|
|
24
|
-
this.menuButton.on('click',
|
|
24
|
+
this.menuButton.on('click', $.proxy(this, 'onMenuButtonClick'));
|
|
25
25
|
this.container.append(this.menuButton);
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -45,11 +45,11 @@ FilterToggleButton.prototype.enableSmallMode = function () {
|
|
|
45
45
|
|
|
46
46
|
FilterToggleButton.prototype.addCloseButton = function () {
|
|
47
47
|
if (this.options.closeButton) {
|
|
48
|
-
this.closeButton =
|
|
48
|
+
this.closeButton = $(
|
|
49
49
|
`<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
|
|
50
50
|
);
|
|
51
|
-
this.closeButton.on('click',
|
|
52
|
-
|
|
51
|
+
this.closeButton.on('click', $.proxy(this, 'onCloseClick'));
|
|
52
|
+
$(this.options.closeButton.container).append(this.closeButton);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
this.form = form;
|
|
39
39
|
this.errors = [];
|
|
40
40
|
this.validators = [];
|
|
41
|
-
|
|
41
|
+
$(this.form).on('submit', $.proxy(this, 'onSubmit'));
|
|
42
42
|
this.summary =
|
|
43
|
-
options && options.summary ?
|
|
43
|
+
options && options.summary ? $(options.summary) : $('.govuk-error-summary');
|
|
44
44
|
this.originalTitle = document.title;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
const errorSpan = `<span class="govuk-error-message" id="${
|
|
123
123
|
errorSpanId
|
|
124
124
|
}">${this.escapeHtml(error.message)}</span>`;
|
|
125
|
-
const control =
|
|
125
|
+
const control = $(`#${error.fieldName}`);
|
|
126
126
|
const fieldContainer = control.parents('.govuk-form-group');
|
|
127
127
|
const label = fieldContainer.find('label');
|
|
128
128
|
const legend = fieldContainer.find('legend');
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
FormValidator.prototype.removeInlineError = function (error) {
|
|
149
|
-
const control =
|
|
149
|
+
const control = $(`#${error.fieldName}`);
|
|
150
150
|
const fieldContainer = control.parents('.govuk-form-group');
|
|
151
151
|
fieldContainer.find('.govuk-error-message').remove();
|
|
152
152
|
fieldContainer.removeClass('govuk-form-group--error');
|
|
@@ -4,9 +4,9 @@ function FormValidator(form, options) {
|
|
|
4
4
|
this.form = form;
|
|
5
5
|
this.errors = [];
|
|
6
6
|
this.validators = [];
|
|
7
|
-
|
|
7
|
+
$(this.form).on('submit', $.proxy(this, 'onSubmit'));
|
|
8
8
|
this.summary =
|
|
9
|
-
options && options.summary ?
|
|
9
|
+
options && options.summary ? $(options.summary) : $('.govuk-error-summary');
|
|
10
10
|
this.originalTitle = document.title;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -88,7 +88,7 @@ FormValidator.prototype.showInlineError = function (error) {
|
|
|
88
88
|
const errorSpan = `<span class="govuk-error-message" id="${
|
|
89
89
|
errorSpanId
|
|
90
90
|
}">${this.escapeHtml(error.message)}</span>`;
|
|
91
|
-
const control =
|
|
91
|
+
const control = $(`#${error.fieldName}`);
|
|
92
92
|
const fieldContainer = control.parents('.govuk-form-group');
|
|
93
93
|
const label = fieldContainer.find('label');
|
|
94
94
|
const legend = fieldContainer.find('legend');
|
|
@@ -112,7 +112,7 @@ FormValidator.prototype.removeInlineErrors = function () {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
FormValidator.prototype.removeInlineError = function (error) {
|
|
115
|
-
const control =
|
|
115
|
+
const control = $(`#${error.fieldName}`);
|
|
116
116
|
const fieldContainer = control.parents('.govuk-form-group');
|
|
117
117
|
fieldContainer.find('.govuk-error-message').remove();
|
|
118
118
|
fieldContainer.removeClass('govuk-form-group--error');
|
|
@@ -25,17 +25,17 @@
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
this.defaultParams = {
|
|
28
|
-
uploadFileEntryHook:
|
|
29
|
-
uploadFileExitHook:
|
|
30
|
-
uploadFileErrorHook:
|
|
31
|
-
fileDeleteHook:
|
|
28
|
+
uploadFileEntryHook: $.noop,
|
|
29
|
+
uploadFileExitHook: $.noop,
|
|
30
|
+
uploadFileErrorHook: $.noop,
|
|
31
|
+
fileDeleteHook: $.noop,
|
|
32
32
|
uploadStatusText: 'Uploading files, please wait',
|
|
33
33
|
dropzoneHintText: 'Drag and drop files here or',
|
|
34
34
|
dropzoneButtonText: 'Choose files'
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
this.params =
|
|
38
|
-
this.container =
|
|
37
|
+
this.params = $.extend({}, this.defaultParams, params);
|
|
38
|
+
this.container = $(this.params.container);
|
|
39
39
|
|
|
40
40
|
this.container.addClass('moj-multi-file-upload--enhanced');
|
|
41
41
|
|
|
@@ -49,20 +49,20 @@
|
|
|
49
49
|
this.container.on(
|
|
50
50
|
'click',
|
|
51
51
|
'.moj-multi-file-upload__delete',
|
|
52
|
-
|
|
52
|
+
$.proxy(this, 'onFileDeleteClick')
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
MultiFileUpload.prototype.setupDropzone = function () {
|
|
57
57
|
this.fileInput.wrap('<div class="moj-multi-file-upload__dropzone" />');
|
|
58
58
|
this.dropzone = this.container.find('.moj-multi-file-upload__dropzone');
|
|
59
|
-
this.dropzone.on('dragover',
|
|
60
|
-
this.dropzone.on('dragleave',
|
|
61
|
-
this.dropzone.on('drop',
|
|
59
|
+
this.dropzone.on('dragover', $.proxy(this, 'onDragOver'));
|
|
60
|
+
this.dropzone.on('dragleave', $.proxy(this, 'onDragLeave'));
|
|
61
|
+
this.dropzone.on('drop', $.proxy(this, 'onDrop'));
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
MultiFileUpload.prototype.setupLabel = function () {
|
|
65
|
-
this.label =
|
|
65
|
+
this.label = $(
|
|
66
66
|
`<label for="${this.fileInput[0].id}" class="govuk-button govuk-button--secondary">${this.params.dropzoneButtonText}</label>`
|
|
67
67
|
);
|
|
68
68
|
this.dropzone.append(
|
|
@@ -73,13 +73,13 @@
|
|
|
73
73
|
|
|
74
74
|
MultiFileUpload.prototype.setupFileInput = function () {
|
|
75
75
|
this.fileInput = this.container.find('.moj-multi-file-upload__input');
|
|
76
|
-
this.fileInput.on('change',
|
|
77
|
-
this.fileInput.on('focus',
|
|
78
|
-
this.fileInput.on('blur',
|
|
76
|
+
this.fileInput.on('change', $.proxy(this, 'onFileChange'));
|
|
77
|
+
this.fileInput.on('focus', $.proxy(this, 'onFileFocus'));
|
|
78
|
+
this.fileInput.on('blur', $.proxy(this, 'onFileBlur'));
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
MultiFileUpload.prototype.setupStatusBox = function () {
|
|
82
|
-
this.status =
|
|
82
|
+
this.status = $(
|
|
83
83
|
'<div aria-live="polite" role="status" class="govuk-visually-hidden" />'
|
|
84
84
|
);
|
|
85
85
|
this.dropzone.append(this.status);
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
this.feedbackContainer.removeClass('moj-hidden');
|
|
113
113
|
this.status.html(this.params.uploadStatusText);
|
|
114
114
|
this.uploadFiles(e.currentTarget.files);
|
|
115
|
-
this.fileInput.replaceWith(
|
|
115
|
+
this.fileInput.replaceWith($(e.currentTarget).val('').clone(true));
|
|
116
116
|
this.setupFileInput();
|
|
117
117
|
this.fileInput.get(0).focus();
|
|
118
118
|
};
|
|
@@ -153,18 +153,18 @@
|
|
|
153
153
|
|
|
154
154
|
MultiFileUpload.prototype.uploadFile = function (file) {
|
|
155
155
|
this.params.uploadFileEntryHook(this, file);
|
|
156
|
-
const item =
|
|
156
|
+
const item = $(this.getFileRowHtml(file));
|
|
157
157
|
const formData = new FormData();
|
|
158
158
|
formData.append('documents', file);
|
|
159
159
|
this.feedbackContainer.find('.moj-multi-file-upload__list').append(item);
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
$.ajax({
|
|
162
162
|
url: this.params.uploadUrl,
|
|
163
163
|
type: 'post',
|
|
164
164
|
data: formData,
|
|
165
165
|
processData: false,
|
|
166
166
|
contentType: false,
|
|
167
|
-
success:
|
|
167
|
+
success: $.proxy(function (response) {
|
|
168
168
|
if (response.error) {
|
|
169
169
|
item
|
|
170
170
|
.find('.moj-multi-file-upload__message')
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
.append(this.getDeleteButtonHtml(response.file));
|
|
182
182
|
this.params.uploadFileExitHook(this, file, response);
|
|
183
183
|
}, this),
|
|
184
|
-
error:
|
|
184
|
+
error: $.proxy(function (jqXHR, textStatus, errorThrown) {
|
|
185
185
|
this.params.uploadFileErrorHook(
|
|
186
186
|
this,
|
|
187
187
|
file,
|
|
@@ -212,15 +212,15 @@
|
|
|
212
212
|
|
|
213
213
|
MultiFileUpload.prototype.onFileDeleteClick = function (e) {
|
|
214
214
|
e.preventDefault(); // if user refreshes page and then deletes
|
|
215
|
-
const button =
|
|
215
|
+
const button = $(e.currentTarget);
|
|
216
216
|
const data = {};
|
|
217
217
|
data[button[0].name] = button[0].value;
|
|
218
|
-
|
|
218
|
+
$.ajax({
|
|
219
219
|
url: this.params.deleteUrl,
|
|
220
220
|
type: 'post',
|
|
221
221
|
dataType: 'json',
|
|
222
222
|
data,
|
|
223
|
-
success:
|
|
223
|
+
success: $.proxy(function (response) {
|
|
224
224
|
if (response.error) ; else {
|
|
225
225
|
button.parents('.moj-multi-file-upload__row').remove();
|
|
226
226
|
if (
|
|
@@ -6,17 +6,17 @@ function MultiFileUpload(params) {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
this.defaultParams = {
|
|
9
|
-
uploadFileEntryHook:
|
|
10
|
-
uploadFileExitHook:
|
|
11
|
-
uploadFileErrorHook:
|
|
12
|
-
fileDeleteHook:
|
|
9
|
+
uploadFileEntryHook: $.noop,
|
|
10
|
+
uploadFileExitHook: $.noop,
|
|
11
|
+
uploadFileErrorHook: $.noop,
|
|
12
|
+
fileDeleteHook: $.noop,
|
|
13
13
|
uploadStatusText: 'Uploading files, please wait',
|
|
14
14
|
dropzoneHintText: 'Drag and drop files here or',
|
|
15
15
|
dropzoneButtonText: 'Choose files'
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
this.params =
|
|
19
|
-
this.container =
|
|
18
|
+
this.params = $.extend({}, this.defaultParams, params);
|
|
19
|
+
this.container = $(this.params.container);
|
|
20
20
|
|
|
21
21
|
this.container.addClass('moj-multi-file-upload--enhanced');
|
|
22
22
|
|
|
@@ -30,20 +30,20 @@ function MultiFileUpload(params) {
|
|
|
30
30
|
this.container.on(
|
|
31
31
|
'click',
|
|
32
32
|
'.moj-multi-file-upload__delete',
|
|
33
|
-
|
|
33
|
+
$.proxy(this, 'onFileDeleteClick')
|
|
34
34
|
);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
MultiFileUpload.prototype.setupDropzone = function () {
|
|
38
38
|
this.fileInput.wrap('<div class="moj-multi-file-upload__dropzone" />');
|
|
39
39
|
this.dropzone = this.container.find('.moj-multi-file-upload__dropzone');
|
|
40
|
-
this.dropzone.on('dragover',
|
|
41
|
-
this.dropzone.on('dragleave',
|
|
42
|
-
this.dropzone.on('drop',
|
|
40
|
+
this.dropzone.on('dragover', $.proxy(this, 'onDragOver'));
|
|
41
|
+
this.dropzone.on('dragleave', $.proxy(this, 'onDragLeave'));
|
|
42
|
+
this.dropzone.on('drop', $.proxy(this, 'onDrop'));
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
MultiFileUpload.prototype.setupLabel = function () {
|
|
46
|
-
this.label =
|
|
46
|
+
this.label = $(
|
|
47
47
|
`<label for="${this.fileInput[0].id}" class="govuk-button govuk-button--secondary">${this.params.dropzoneButtonText}</label>`
|
|
48
48
|
);
|
|
49
49
|
this.dropzone.append(
|
|
@@ -54,13 +54,13 @@ MultiFileUpload.prototype.setupLabel = function () {
|
|
|
54
54
|
|
|
55
55
|
MultiFileUpload.prototype.setupFileInput = function () {
|
|
56
56
|
this.fileInput = this.container.find('.moj-multi-file-upload__input');
|
|
57
|
-
this.fileInput.on('change',
|
|
58
|
-
this.fileInput.on('focus',
|
|
59
|
-
this.fileInput.on('blur',
|
|
57
|
+
this.fileInput.on('change', $.proxy(this, 'onFileChange'));
|
|
58
|
+
this.fileInput.on('focus', $.proxy(this, 'onFileFocus'));
|
|
59
|
+
this.fileInput.on('blur', $.proxy(this, 'onFileBlur'));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
MultiFileUpload.prototype.setupStatusBox = function () {
|
|
63
|
-
this.status =
|
|
63
|
+
this.status = $(
|
|
64
64
|
'<div aria-live="polite" role="status" class="govuk-visually-hidden" />'
|
|
65
65
|
);
|
|
66
66
|
this.dropzone.append(this.status);
|
|
@@ -93,7 +93,7 @@ MultiFileUpload.prototype.onFileChange = function (e) {
|
|
|
93
93
|
this.feedbackContainer.removeClass('moj-hidden');
|
|
94
94
|
this.status.html(this.params.uploadStatusText);
|
|
95
95
|
this.uploadFiles(e.currentTarget.files);
|
|
96
|
-
this.fileInput.replaceWith(
|
|
96
|
+
this.fileInput.replaceWith($(e.currentTarget).val('').clone(true));
|
|
97
97
|
this.setupFileInput();
|
|
98
98
|
this.fileInput.get(0).focus();
|
|
99
99
|
};
|
|
@@ -134,18 +134,18 @@ MultiFileUpload.prototype.getDeleteButtonHtml = function (file) {
|
|
|
134
134
|
|
|
135
135
|
MultiFileUpload.prototype.uploadFile = function (file) {
|
|
136
136
|
this.params.uploadFileEntryHook(this, file);
|
|
137
|
-
const item =
|
|
137
|
+
const item = $(this.getFileRowHtml(file));
|
|
138
138
|
const formData = new FormData();
|
|
139
139
|
formData.append('documents', file);
|
|
140
140
|
this.feedbackContainer.find('.moj-multi-file-upload__list').append(item);
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
$.ajax({
|
|
143
143
|
url: this.params.uploadUrl,
|
|
144
144
|
type: 'post',
|
|
145
145
|
data: formData,
|
|
146
146
|
processData: false,
|
|
147
147
|
contentType: false,
|
|
148
|
-
success:
|
|
148
|
+
success: $.proxy(function (response) {
|
|
149
149
|
if (response.error) {
|
|
150
150
|
item
|
|
151
151
|
.find('.moj-multi-file-upload__message')
|
|
@@ -162,7 +162,7 @@ MultiFileUpload.prototype.uploadFile = function (file) {
|
|
|
162
162
|
.append(this.getDeleteButtonHtml(response.file));
|
|
163
163
|
this.params.uploadFileExitHook(this, file, response);
|
|
164
164
|
}, this),
|
|
165
|
-
error:
|
|
165
|
+
error: $.proxy(function (jqXHR, textStatus, errorThrown) {
|
|
166
166
|
this.params.uploadFileErrorHook(
|
|
167
167
|
this,
|
|
168
168
|
file,
|
|
@@ -193,15 +193,15 @@ MultiFileUpload.prototype.uploadFile = function (file) {
|
|
|
193
193
|
|
|
194
194
|
MultiFileUpload.prototype.onFileDeleteClick = function (e) {
|
|
195
195
|
e.preventDefault(); // if user refreshes page and then deletes
|
|
196
|
-
const button =
|
|
196
|
+
const button = $(e.currentTarget);
|
|
197
197
|
const data = {};
|
|
198
198
|
data[button[0].name] = button[0].value;
|
|
199
|
-
|
|
199
|
+
$.ajax({
|
|
200
200
|
url: this.params.deleteUrl,
|
|
201
201
|
type: 'post',
|
|
202
202
|
dataType: 'json',
|
|
203
203
|
data,
|
|
204
|
-
success:
|
|
204
|
+
success: $.proxy(function (response) {
|
|
205
205
|
if (response.error) ; else {
|
|
206
206
|
button.parents('.moj-multi-file-upload__row').remove();
|
|
207
207
|
if (
|
|
@@ -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
|
);
|
|
@@ -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 () {
|
|
@@ -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 () {
|
|
@@ -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
|
}
|