@ministryofjustice/frontend 3.6.0 → 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.js CHANGED
@@ -5,7 +5,7 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function AddAnother(container) {
8
- this.container = window.jQuery(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
- window.jQuery.proxy(this, 'onRemoveButtonClick')
19
+ $.proxy(this, 'onRemoveButtonClick')
20
20
  );
21
21
  this.container.on(
22
22
  'click',
23
23
  '.moj-add-another__add-button',
24
- window.jQuery.proxy(this, 'onAddButtonClick')
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 = window.jQuery(el)
63
+ el.name = $(el)
64
64
  .attr('data-name')
65
65
  .replace(/%index%/, index);
66
- el.id = window.jQuery(el)
66
+ el.id = $(el)
67
67
  .attr('data-id')
68
68
  .replace(/%index%/, index);
69
69
 
70
70
  const label =
71
- window.jQuery(el).siblings('label')[0] ||
72
- window.jQuery(el).parents('label')[0] ||
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
- window.jQuery(e.currentTarget).parents('.moj-add-another__item').remove();
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
- window.jQuery.proxy(function (index, el) {
102
- this.updateAttributes(index, window.jQuery(el));
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 = window.jQuery(this.options.toggleButton.container);
1773
- this.filterContainer = window.jQuery(this.options.filter.container);
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(window.jQuery.proxy(this, 'checkMode'));
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 = window.jQuery(
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', window.jQuery.proxy(this, 'onMenuButtonClick'));
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 = window.jQuery(
1817
+ this.closeButton = $(
1818
1818
  `<button class="moj-filter__close" type="button">${this.options.closeButton.text}</button>`
1819
1819
  );
1820
- this.closeButton.on('click', window.jQuery.proxy(this, 'onCloseClick'));
1821
- window.jQuery(this.options.closeButton.container).append(this.closeButton);
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: window.jQuery.noop,
1869
- uploadFileExitHook: window.jQuery.noop,
1870
- uploadFileErrorHook: window.jQuery.noop,
1871
- fileDeleteHook: window.jQuery.noop,
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 = window.jQuery.extend({}, this.defaultParams, params);
1878
- this.container = window.jQuery(this.params.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
- window.jQuery.proxy(this, 'onFileDeleteClick')
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', window.jQuery.proxy(this, 'onDragOver'));
1900
- this.dropzone.on('dragleave', window.jQuery.proxy(this, 'onDragLeave'));
1901
- this.dropzone.on('drop', window.jQuery.proxy(this, 'onDrop'));
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 = window.jQuery(
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', window.jQuery.proxy(this, 'onFileChange'));
1917
- this.fileInput.on('focus', window.jQuery.proxy(this, 'onFileFocus'));
1918
- this.fileInput.on('blur', window.jQuery.proxy(this, 'onFileBlur'));
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 = window.jQuery(
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(window.jQuery(e.currentTarget).val('').clone(true));
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 = window.jQuery(this.getFileRowHtml(file));
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
- window.jQuery.ajax({
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: window.jQuery.proxy(function (response) {
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: window.jQuery.proxy(function (jqXHR, textStatus, errorThrown) {
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 = window.jQuery(e.currentTarget);
2055
+ const button = $(e.currentTarget);
2056
2056
  const data = {};
2057
2057
  data[button[0].name] = button[0].value;
2058
- window.jQuery.ajax({
2058
+ $.ajax({
2059
2059
  url: this.params.deleteUrl,
2060
2060
  type: 'post',
2061
2061
  dataType: 'json',
2062
2062
  data,
2063
- success: window.jQuery.proxy(function (response) {
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 = window.jQuery(options.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 = window.jQuery(this.getToggleHtml(allId));
2093
+ this.toggle = $(this.getToggleHtml(allId));
2094
2094
  this.toggleButton = this.toggle.find('input');
2095
- this.toggleButton.on('click', window.jQuery.proxy(this, 'onButtonClick'));
2095
+ this.toggleButton.on('click', $.proxy(this, 'onButtonClick'));
2096
2096
  this.container.append(this.toggle);
2097
- this.checkboxes = window.jQuery(options.checkboxes);
2098
- this.checkboxes.on('click', window.jQuery.proxy(this, 'onCheckboxClick'));
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
- window.jQuery.proxy(function (index, el) {
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
- window.jQuery.proxy(function (index, el) {
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 = window.jQuery(this.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 = window.jQuery(this.el).parent();
2166
+ this.container = $(this.el).parent();
2167
2167
  this.createButton();
2168
2168
  }
2169
2169
 
2170
2170
  PasswordReveal.prototype.createButton = function () {
2171
- this.button = window.jQuery(
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', window.jQuery.proxy(this, 'onButtonClick'));
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 = window.jQuery(this.textarea).parent();
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
- window.jQuery.proxy(this, 'onButtonClick')
2222
+ $.proxy(this, 'onButtonClick')
2223
2223
  );
2224
2224
  this.container
2225
2225
  .find('.moj-rich-text-editor__content')
2226
- .on('input', window.jQuery.proxy(this, 'onEditorInput'));
2227
- this.container.find('label').on('click', window.jQuery.proxy(this, 'onLabelClick'));
2228
- this.toolbar.on('keydown', window.jQuery.proxy(this, 'onToolbarKeydown'));
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(window.jQuery(e.currentTarget).data('command'), false, null);
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 = window.jQuery(this.options.search.container);
2347
- this.toggleButtonContainer = window.jQuery(this.options.toggleButton.container);
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 = window.jQuery(
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', window.jQuery.proxy(this, 'onToggleButtonClick'));
2363
+ this.toggleButton.on('click', $.proxy(this, 'onToggleButtonClick'));
2364
2364
  this.toggleButtonContainer.append(this.toggleButton);
2365
- window.jQuery(document).on('click', this.onDocumentClick.bind(this));
2366
- window.jQuery(document).on('focusin', this.onDocumentClick.bind(this));
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
- !window.jQuery.contains(this.toggleButtonContainer[0], e.target) &&
2391
- !window.jQuery.contains(this.container[0], e.target)
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 = window.jQuery(params.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', window.jQuery.proxy(this, 'onSortButtonClick'));
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 = window.jQuery(headings[i]);
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 = window.jQuery(`<button type="button" data-index="${i}">${text}</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 = window.jQuery(
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 = window.jQuery(el).attr('aria-sort');
2455
- const columnNumber = window.jQuery(el).find('button').attr('data-index');
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 = window.jQuery(e.currentTarget).parent().attr('aria-sort');
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(window.jQuery(e.currentTarget), newSortDirection);
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 = window.jQuery(rowA).find('td,th').eq(columnNumber);
2508
- const tdB = window.jQuery(rowB).find('td,th').eq(columnNumber);
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.0';
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: window.jQuery($richTextEditor)
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: window.jQuery($searchToggle.querySelector('.moj-search-toggle__toggle')),
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: window.jQuery($searchToggle.querySelector('.moj-search'))
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: window.jQuery($richTextEditor)
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: window.jQuery($searchToggle.querySelector('.moj-search-toggle__toggle')),
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: window.jQuery($searchToggle.querySelector('.moj-search'))
93
+ container: $($searchToggle.querySelector('.moj-search'))
94
94
  }
95
95
  });
96
96
  });
package/moj/all.scss CHANGED
@@ -1,6 +1,6 @@
1
1
  $govuk-suppressed-warnings: ("govuk-typography-scale-14");
2
2
 
3
- @import "node_modules/govuk-frontend/dist/govuk/base";
3
+ @import "govuk-frontend/dist/govuk/base";
4
4
 
5
5
  @import "settings/all";
6
6
  @import "helpers/all";
@@ -5,7 +5,7 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function AddAnother(container) {
8
- this.container = window.jQuery(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
- window.jQuery.proxy(this, 'onRemoveButtonClick')
19
+ $.proxy(this, 'onRemoveButtonClick')
20
20
  );
21
21
  this.container.on(
22
22
  'click',
23
23
  '.moj-add-another__add-button',
24
- window.jQuery.proxy(this, 'onAddButtonClick')
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 = window.jQuery(el)
63
+ el.name = $(el)
64
64
  .attr('data-name')
65
65
  .replace(/%index%/, index);
66
- el.id = window.jQuery(el)
66
+ el.id = $(el)
67
67
  .attr('data-id')
68
68
  .replace(/%index%/, index);
69
69
 
70
70
  const label =
71
- window.jQuery(el).siblings('label')[0] ||
72
- window.jQuery(el).parents('label')[0] ||
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
- window.jQuery(e.currentTarget).parents('.moj-add-another__item').remove();
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
- window.jQuery.proxy(function (index, el) {
102
- this.updateAttributes(index, window.jQuery(el));
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 = window.jQuery(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
- window.jQuery.proxy(this, 'onRemoveButtonClick')
13
+ $.proxy(this, 'onRemoveButtonClick')
14
14
  );
15
15
  this.container.on(
16
16
  'click',
17
17
  '.moj-add-another__add-button',
18
- window.jQuery.proxy(this, 'onAddButtonClick')
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 = window.jQuery(el)
57
+ el.name = $(el)
58
58
  .attr('data-name')
59
59
  .replace(/%index%/, index);
60
- el.id = window.jQuery(el)
60
+ el.id = $(el)
61
61
  .attr('data-id')
62
62
  .replace(/%index%/, index);
63
63
 
64
64
  const label =
65
- window.jQuery(el).siblings('label')[0] ||
66
- window.jQuery(el).parents('label')[0] ||
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
- window.jQuery(e.currentTarget).parents('.moj-add-another__item').remove();
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
- window.jQuery.proxy(function (index, el) {
96
- this.updateAttributes(index, window.jQuery(el));
95
+ $.proxy(function (index, el) {
96
+ this.updateAttributes(index, $(el));
97
97
  }, this)
98
98
  );
99
99
  this.focusHeading();
@@ -1,4 +1,4 @@
1
- @import "node_modules/govuk-frontend/dist/govuk/objects/width-container";
1
+ @import "govuk-frontend/dist/govuk/objects/width-container";
2
2
 
3
3
  .moj-cookie-banner {
4
4
  box-sizing: border-box;