|
1 | 1 | import $ from 'jquery'; |
2 | 2 | import {updateIssuesMeta} from './repo-issue.js'; |
3 | | -import {toggleElem, hideElem} from '../utils/dom.js'; |
| 3 | +import {toggleElem, hideElem, isElemHidden} from '../utils/dom.js'; |
4 | 4 | import {htmlEscape} from 'escape-goat'; |
5 | 5 | import {confirmModal} from './comp/ConfirmModal.js'; |
6 | 6 | import {showErrorToast} from '../modules/toast.js'; |
7 | 7 | import {createSortable} from '../modules/sortable.js'; |
8 | 8 | import {DELETE, POST} from '../modules/fetch.js'; |
9 | 9 |
|
10 | 10 | function initRepoIssueListCheckboxes() { |
11 | | - const $issueSelectAll = $('.issue-checkbox-all'); |
12 | | - const $issueCheckboxes = $('.issue-checkbox'); |
| 11 | + const issueSelectAll = document.querySelector('.issue-checkbox-all'); |
| 12 | + const issueCheckboxes = document.querySelectorAll('.issue-checkbox'); |
13 | 13 |
|
14 | 14 | const syncIssueSelectionState = () => { |
15 | | - const $checked = $issueCheckboxes.filter(':checked'); |
16 | | - const anyChecked = $checked.length !== 0; |
17 | | - const allChecked = anyChecked && $checked.length === $issueCheckboxes.length; |
| 15 | + const checkedCheckboxes = Array.from(issueCheckboxes).filter((el) => el.checked); |
| 16 | + const anyChecked = Boolean(checkedCheckboxes.length); |
| 17 | + const allChecked = anyChecked && checkedCheckboxes.length === issueCheckboxes.length; |
18 | 18 |
|
19 | 19 | if (allChecked) { |
20 | | - $issueSelectAll.prop({'checked': true, 'indeterminate': false}); |
| 20 | + issueSelectAll.checked = true; |
| 21 | + issueSelectAll.indeterminate = false; |
21 | 22 | } else if (anyChecked) { |
22 | | - $issueSelectAll.prop({'checked': false, 'indeterminate': true}); |
| 23 | + issueSelectAll.checked = false; |
| 24 | + issueSelectAll.indeterminate = true; |
23 | 25 | } else { |
24 | | - $issueSelectAll.prop({'checked': false, 'indeterminate': false}); |
| 26 | + issueSelectAll.checked = false; |
| 27 | + issueSelectAll.indeterminate = false; |
25 | 28 | } |
26 | 29 | // if any issue is selected, show the action panel, otherwise show the filter panel |
27 | 30 | toggleElem($('#issue-filters'), !anyChecked); |
28 | 31 | toggleElem($('#issue-actions'), anyChecked); |
29 | 32 | // there are two panels but only one select-all checkbox, so move the checkbox to the visible panel |
30 | | - $('#issue-filters, #issue-actions').filter(':visible').find('.issue-list-toolbar-left').prepend($issueSelectAll); |
| 33 | + const panels = document.querySelectorAll('#issue-filters, #issue-actions'); |
| 34 | + const visiblePanel = Array.from(panels).find((el) => !isElemHidden(el)); |
| 35 | + const toolbarLeft = visiblePanel.querySelector('.issue-list-toolbar-left'); |
| 36 | + toolbarLeft.prepend(issueSelectAll); |
31 | 37 | }; |
32 | 38 |
|
33 | | - $issueCheckboxes.on('change', syncIssueSelectionState); |
| 39 | + for (const el of issueCheckboxes) { |
| 40 | + el.addEventListener('change', syncIssueSelectionState); |
| 41 | + } |
34 | 42 |
|
35 | | - $issueSelectAll.on('change', () => { |
36 | | - $issueCheckboxes.prop('checked', $issueSelectAll.is(':checked')); |
| 43 | + issueSelectAll.addEventListener('change', () => { |
| 44 | + for (const el of issueCheckboxes) { |
| 45 | + el.checked = issueSelectAll.checked; |
| 46 | + } |
37 | 47 | syncIssueSelectionState(); |
38 | 48 | }); |
39 | 49 |
|
|
0 commit comments