@ministryofjustice/frontend 3.5.0 → 3.6.0
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.js +13378 -0
- package/moj/all.jquery.min.js +1 -81
- package/moj/all.js +2577 -2853
- package/moj/all.mjs +126 -0
- package/moj/components/add-another/add-another.js +111 -132
- package/moj/components/add-another/add-another.mjs +106 -0
- package/moj/components/alert/alert.js +352 -479
- package/moj/components/alert/alert.mjs +251 -0
- package/moj/components/alert/alert.spec.helper.js +6 -24
- package/moj/components/alert/alert.spec.helper.mjs +66 -0
- package/moj/components/button-menu/button-menu.js +326 -343
- package/moj/components/button-menu/button-menu.mjs +329 -0
- package/moj/components/date-picker/date-picker.js +905 -922
- package/moj/components/date-picker/date-picker.mjs +961 -0
- package/moj/components/filter-toggle-button/filter-toggle-button.js +98 -119
- package/moj/components/filter-toggle-button/filter-toggle-button.mjs +93 -0
- package/moj/components/form-validator/form-validator.js +201 -396
- package/moj/components/form-validator/form-validator.mjs +168 -0
- package/moj/components/multi-file-upload/multi-file-upload.js +227 -441
- package/moj/components/multi-file-upload/multi-file-upload.mjs +219 -0
- package/moj/components/multi-select/multi-select.js +82 -103
- package/moj/components/multi-select/multi-select.mjs +77 -0
- package/moj/components/password-reveal/password-reveal.js +40 -61
- package/moj/components/password-reveal/password-reveal.mjs +35 -0
- package/moj/components/rich-text-editor/rich-text-editor.js +162 -183
- package/moj/components/rich-text-editor/rich-text-editor.mjs +157 -0
- package/moj/components/search-toggle/search-toggle.js +52 -73
- package/moj/components/search-toggle/search-toggle.mjs +54 -0
- package/moj/components/sortable-table/sortable-table.js +143 -164
- package/moj/components/sortable-table/sortable-table.mjs +138 -0
- package/moj/helpers.js +196 -215
- package/moj/helpers.mjs +123 -0
- package/moj/moj-frontend.min.js +1 -81
- package/moj/version.js +6 -23
- package/moj/version.mjs +3 -0
- package/package.json +13 -1
|
@@ -1,186 +1,165 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(this, (function () { 'use strict';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.updateTextarea();
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
RichTextEditor.prototype.updateTextarea = function () {
|
|
168
|
-
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
169
|
-
this.textarea.val(this.getContent());
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
RichTextEditor.prototype.onLabelClick = function (e) {
|
|
173
|
-
e.preventDefault();
|
|
174
|
-
this.container.find('.moj-rich-text-editor__content').focus();
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
richTextEditor$1 = { RichTextEditor };
|
|
178
|
-
return richTextEditor$1;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
var richTextEditorExports = requireRichTextEditor();
|
|
182
|
-
var richTextEditor = /*@__PURE__*/getDefaultExportFromCjs(richTextEditorExports);
|
|
183
|
-
|
|
184
|
-
return richTextEditor;
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function RichTextEditor(options) {
|
|
8
|
+
if (!('contentEditable' in document.documentElement)) {
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
this.options = options;
|
|
13
|
+
this.options.toolbar = this.options.toolbar || {
|
|
14
|
+
bold: false,
|
|
15
|
+
italic: false,
|
|
16
|
+
underline: false,
|
|
17
|
+
bullets: true,
|
|
18
|
+
numbers: true
|
|
19
|
+
};
|
|
20
|
+
this.textarea = this.options.textarea;
|
|
21
|
+
this.container = window.jQuery(this.textarea).parent();
|
|
22
|
+
|
|
23
|
+
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.container.data('moj-rich-text-editor-initialised', true);
|
|
28
|
+
|
|
29
|
+
this.createToolbar();
|
|
30
|
+
this.hideDefault();
|
|
31
|
+
this.configureToolbar();
|
|
32
|
+
this.keys = {
|
|
33
|
+
left: 37,
|
|
34
|
+
right: 39,
|
|
35
|
+
up: 38,
|
|
36
|
+
down: 40
|
|
37
|
+
};
|
|
38
|
+
this.container.on(
|
|
39
|
+
'click',
|
|
40
|
+
'.moj-rich-text-editor__toolbar-button',
|
|
41
|
+
window.jQuery.proxy(this, 'onButtonClick')
|
|
42
|
+
);
|
|
43
|
+
this.container
|
|
44
|
+
.find('.moj-rich-text-editor__content')
|
|
45
|
+
.on('input', window.jQuery.proxy(this, 'onEditorInput'));
|
|
46
|
+
this.container.find('label').on('click', window.jQuery.proxy(this, 'onLabelClick'));
|
|
47
|
+
this.toolbar.on('keydown', window.jQuery.proxy(this, 'onToolbarKeydown'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
51
|
+
let focusableButton;
|
|
52
|
+
switch (e.keyCode) {
|
|
53
|
+
case this.keys.right:
|
|
54
|
+
case this.keys.down: {
|
|
55
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
56
|
+
const nextButton = focusableButton.next('button');
|
|
57
|
+
if (nextButton[0]) {
|
|
58
|
+
nextButton.focus();
|
|
59
|
+
focusableButton.attr('tabindex', '-1');
|
|
60
|
+
nextButton.attr('tabindex', '0');
|
|
61
|
+
}
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
case this.keys.left:
|
|
65
|
+
case this.keys.up: {
|
|
66
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
67
|
+
const previousButton = focusableButton.prev('button');
|
|
68
|
+
if (previousButton[0]) {
|
|
69
|
+
previousButton.focus();
|
|
70
|
+
focusableButton.attr('tabindex', '-1');
|
|
71
|
+
previousButton.attr('tabindex', '0');
|
|
72
|
+
}
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
RichTextEditor.prototype.getToolbarHtml = function () {
|
|
79
|
+
let html = '';
|
|
80
|
+
|
|
81
|
+
html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">';
|
|
82
|
+
|
|
83
|
+
if (this.options.toolbar.bold) {
|
|
84
|
+
html +=
|
|
85
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (this.options.toolbar.italic) {
|
|
89
|
+
html +=
|
|
90
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.options.toolbar.underline) {
|
|
94
|
+
html +=
|
|
95
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.options.toolbar.bullets) {
|
|
99
|
+
html +=
|
|
100
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.options.toolbar.numbers) {
|
|
104
|
+
html +=
|
|
105
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
html += '</div>';
|
|
109
|
+
return html
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
RichTextEditor.prototype.getEnhancedHtml = function (val) {
|
|
113
|
+
return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
RichTextEditor.prototype.hideDefault = function () {
|
|
117
|
+
this.textarea = this.container.find('textarea');
|
|
118
|
+
this.textarea.addClass('govuk-visually-hidden');
|
|
119
|
+
this.textarea.attr('aria-hidden', true);
|
|
120
|
+
this.textarea.attr('tabindex', '-1');
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
RichTextEditor.prototype.createToolbar = function () {
|
|
124
|
+
this.toolbar = document.createElement('div');
|
|
125
|
+
this.toolbar.className = 'moj-rich-text-editor';
|
|
126
|
+
this.toolbar.innerHTML = this.getEnhancedHtml();
|
|
127
|
+
this.container.append(this.toolbar);
|
|
128
|
+
this.toolbar = this.container.find('.moj-rich-text-editor__toolbar');
|
|
129
|
+
this.container
|
|
130
|
+
.find('.moj-rich-text-editor__content')
|
|
131
|
+
.html(this.textarea.val());
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
RichTextEditor.prototype.configureToolbar = function () {
|
|
135
|
+
this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button');
|
|
136
|
+
this.buttons.prop('tabindex', '-1');
|
|
137
|
+
const firstTab = this.buttons.first();
|
|
138
|
+
firstTab.prop('tabindex', '0');
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
142
|
+
document.execCommand(window.jQuery(e.currentTarget).data('command'), false, null);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
RichTextEditor.prototype.getContent = function () {
|
|
146
|
+
return this.container.find('.moj-rich-text-editor__content').html()
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
RichTextEditor.prototype.onEditorInput = function (e) {
|
|
150
|
+
this.updateTextarea();
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
RichTextEditor.prototype.updateTextarea = function () {
|
|
154
|
+
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
155
|
+
this.textarea.val(this.getContent());
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
RichTextEditor.prototype.onLabelClick = function (e) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
this.container.find('.moj-rich-text-editor__content').focus();
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
exports.RichTextEditor = RichTextEditor;
|
|
185
164
|
|
|
186
165
|
}));
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
function RichTextEditor(options) {
|
|
2
|
+
if (!('contentEditable' in document.documentElement)) {
|
|
3
|
+
return
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
this.options = options;
|
|
7
|
+
this.options.toolbar = this.options.toolbar || {
|
|
8
|
+
bold: false,
|
|
9
|
+
italic: false,
|
|
10
|
+
underline: false,
|
|
11
|
+
bullets: true,
|
|
12
|
+
numbers: true
|
|
13
|
+
};
|
|
14
|
+
this.textarea = this.options.textarea;
|
|
15
|
+
this.container = window.jQuery(this.textarea).parent();
|
|
16
|
+
|
|
17
|
+
if (this.container.data('moj-rich-text-editor-initialised')) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this.container.data('moj-rich-text-editor-initialised', true);
|
|
22
|
+
|
|
23
|
+
this.createToolbar();
|
|
24
|
+
this.hideDefault();
|
|
25
|
+
this.configureToolbar();
|
|
26
|
+
this.keys = {
|
|
27
|
+
left: 37,
|
|
28
|
+
right: 39,
|
|
29
|
+
up: 38,
|
|
30
|
+
down: 40
|
|
31
|
+
};
|
|
32
|
+
this.container.on(
|
|
33
|
+
'click',
|
|
34
|
+
'.moj-rich-text-editor__toolbar-button',
|
|
35
|
+
window.jQuery.proxy(this, 'onButtonClick')
|
|
36
|
+
);
|
|
37
|
+
this.container
|
|
38
|
+
.find('.moj-rich-text-editor__content')
|
|
39
|
+
.on('input', window.jQuery.proxy(this, 'onEditorInput'));
|
|
40
|
+
this.container.find('label').on('click', window.jQuery.proxy(this, 'onLabelClick'));
|
|
41
|
+
this.toolbar.on('keydown', window.jQuery.proxy(this, 'onToolbarKeydown'));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
RichTextEditor.prototype.onToolbarKeydown = function (e) {
|
|
45
|
+
let focusableButton;
|
|
46
|
+
switch (e.keyCode) {
|
|
47
|
+
case this.keys.right:
|
|
48
|
+
case this.keys.down: {
|
|
49
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
50
|
+
const nextButton = focusableButton.next('button');
|
|
51
|
+
if (nextButton[0]) {
|
|
52
|
+
nextButton.focus();
|
|
53
|
+
focusableButton.attr('tabindex', '-1');
|
|
54
|
+
nextButton.attr('tabindex', '0');
|
|
55
|
+
}
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
case this.keys.left:
|
|
59
|
+
case this.keys.up: {
|
|
60
|
+
focusableButton = this.toolbar.find('button[tabindex=0]');
|
|
61
|
+
const previousButton = focusableButton.prev('button');
|
|
62
|
+
if (previousButton[0]) {
|
|
63
|
+
previousButton.focus();
|
|
64
|
+
focusableButton.attr('tabindex', '-1');
|
|
65
|
+
previousButton.attr('tabindex', '0');
|
|
66
|
+
}
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
RichTextEditor.prototype.getToolbarHtml = function () {
|
|
73
|
+
let html = '';
|
|
74
|
+
|
|
75
|
+
html += '<div class="moj-rich-text-editor__toolbar" role="toolbar">';
|
|
76
|
+
|
|
77
|
+
if (this.options.toolbar.bold) {
|
|
78
|
+
html +=
|
|
79
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--bold" type="button" data-command="bold"><span class="govuk-visually-hidden">Bold</span></button>';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.options.toolbar.italic) {
|
|
83
|
+
html +=
|
|
84
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--italic" type="button" data-command="italic"><span class="govuk-visually-hidden">Italic</span></button>';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (this.options.toolbar.underline) {
|
|
88
|
+
html +=
|
|
89
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--underline" type="button" data-command="underline"><span class="govuk-visually-hidden">Underline</span></button>';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.options.toolbar.bullets) {
|
|
93
|
+
html +=
|
|
94
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--unordered-list" type="button" data-command="insertUnorderedList"><span class="govuk-visually-hidden">Unordered list</span></button>';
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (this.options.toolbar.numbers) {
|
|
98
|
+
html +=
|
|
99
|
+
'<button class="moj-rich-text-editor__toolbar-button moj-rich-text-editor__toolbar-button--ordered-list" type="button" data-command="insertOrderedList"><span class="govuk-visually-hidden">Ordered list</span></button>';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
html += '</div>';
|
|
103
|
+
return html
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
RichTextEditor.prototype.getEnhancedHtml = function (val) {
|
|
107
|
+
return `${this.getToolbarHtml()}<div class="govuk-textarea moj-rich-text-editor__content" contenteditable="true" spellcheck="false"></div>`
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
RichTextEditor.prototype.hideDefault = function () {
|
|
111
|
+
this.textarea = this.container.find('textarea');
|
|
112
|
+
this.textarea.addClass('govuk-visually-hidden');
|
|
113
|
+
this.textarea.attr('aria-hidden', true);
|
|
114
|
+
this.textarea.attr('tabindex', '-1');
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
RichTextEditor.prototype.createToolbar = function () {
|
|
118
|
+
this.toolbar = document.createElement('div');
|
|
119
|
+
this.toolbar.className = 'moj-rich-text-editor';
|
|
120
|
+
this.toolbar.innerHTML = this.getEnhancedHtml();
|
|
121
|
+
this.container.append(this.toolbar);
|
|
122
|
+
this.toolbar = this.container.find('.moj-rich-text-editor__toolbar');
|
|
123
|
+
this.container
|
|
124
|
+
.find('.moj-rich-text-editor__content')
|
|
125
|
+
.html(this.textarea.val());
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
RichTextEditor.prototype.configureToolbar = function () {
|
|
129
|
+
this.buttons = this.container.find('.moj-rich-text-editor__toolbar-button');
|
|
130
|
+
this.buttons.prop('tabindex', '-1');
|
|
131
|
+
const firstTab = this.buttons.first();
|
|
132
|
+
firstTab.prop('tabindex', '0');
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
RichTextEditor.prototype.onButtonClick = function (e) {
|
|
136
|
+
document.execCommand(window.jQuery(e.currentTarget).data('command'), false, null);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
RichTextEditor.prototype.getContent = function () {
|
|
140
|
+
return this.container.find('.moj-rich-text-editor__content').html()
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
RichTextEditor.prototype.onEditorInput = function (e) {
|
|
144
|
+
this.updateTextarea();
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
RichTextEditor.prototype.updateTextarea = function () {
|
|
148
|
+
document.execCommand('defaultParagraphSeparator', false, 'p');
|
|
149
|
+
this.textarea.val(this.getContent());
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
RichTextEditor.prototype.onLabelClick = function (e) {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
this.container.find('.moj-rich-text-editor__content').focus();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export { RichTextEditor };
|
|
@@ -1,83 +1,62 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})(this, (function () { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MOJFrontend = global.MOJFrontend || {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function SearchToggle(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.container = window.jQuery(this.options.search.container);
|
|
10
|
+
this.toggleButtonContainer = window.jQuery(this.options.toggleButton.container);
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
if (this.container.data('moj-search-toggle-initialised')) {
|
|
13
|
+
return
|
|
14
|
+
}
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
var hasRequiredSearchToggle;
|
|
16
|
+
this.container.data('moj-search-toggle-initialised', true);
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
hasRequiredSearchToggle = 1;
|
|
19
|
-
const $ = _global_window_jQuery;
|
|
18
|
+
const svg =
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
this.container = $(this.options.search.container);
|
|
24
|
-
this.toggleButtonContainer = $(this.options.toggleButton.container);
|
|
25
|
-
|
|
26
|
-
if (this.container.data('moj-search-toggle-initialised')) {
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
this.container.data('moj-search-toggle-initialised', true);
|
|
31
|
-
|
|
32
|
-
const svg =
|
|
33
|
-
'<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>';
|
|
34
|
-
|
|
35
|
-
this.toggleButton = $(
|
|
36
|
-
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
21
|
+
this.toggleButton = window.jQuery(
|
|
22
|
+
`<button class="moj-search-toggle__button" type="button" aria-haspopup="true" aria-expanded="false">
|
|
37
23
|
${this.options.toggleButton.text} ${svg}
|
|
38
24
|
</button>`
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return searchToggle$1;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var searchToggleExports = requireSearchToggle();
|
|
79
|
-
var searchToggle = /*@__PURE__*/getDefaultExportFromCjs(searchToggleExports);
|
|
80
|
-
|
|
81
|
-
return searchToggle;
|
|
25
|
+
);
|
|
26
|
+
this.toggleButton.on('click', window.jQuery.proxy(this, 'onToggleButtonClick'));
|
|
27
|
+
this.toggleButtonContainer.append(this.toggleButton);
|
|
28
|
+
window.jQuery(document).on('click', this.onDocumentClick.bind(this));
|
|
29
|
+
window.jQuery(document).on('focusin', this.onDocumentClick.bind(this));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
SearchToggle.prototype.showMenu = function () {
|
|
33
|
+
this.toggleButton.attr('aria-expanded', 'true');
|
|
34
|
+
this.container.removeClass('moj-js-hidden');
|
|
35
|
+
this.container.find('input').first().get(0).focus();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
SearchToggle.prototype.hideMenu = function () {
|
|
39
|
+
this.container.addClass('moj-js-hidden');
|
|
40
|
+
this.toggleButton.attr('aria-expanded', 'false');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
SearchToggle.prototype.onToggleButtonClick = function () {
|
|
44
|
+
if (this.toggleButton.attr('aria-expanded') === 'false') {
|
|
45
|
+
this.showMenu();
|
|
46
|
+
} else {
|
|
47
|
+
this.hideMenu();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
SearchToggle.prototype.onDocumentClick = function (e) {
|
|
52
|
+
if (
|
|
53
|
+
!window.jQuery.contains(this.toggleButtonContainer[0], e.target) &&
|
|
54
|
+
!window.jQuery.contains(this.container[0], e.target)
|
|
55
|
+
) {
|
|
56
|
+
this.hideMenu();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.SearchToggle = SearchToggle;
|
|
82
61
|
|
|
83
62
|
}));
|