1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-21 08:31:27 -05:00
forgejo/templates/base
wxiaoguang d4f35bd681
Use a general approch to improve a11y for all checkboxes and dropdowns. (#23542)
This PR follows #22599 and #23450

The major improvements:

1. The `aria-*.js` are totally transparent now, no need to call
`attachDropdownAria` explicitly anymore.
* It hooks the `$.fn.checkbox` and `$.fn.dropdown`, then our patch
works.
* It makes all dynamically generated checkbox/dropdown work with a11y
without any change
* eg: the `conversation.find('.dropdown').dropdown();` in `repo-diff.js`
2. Since it's totally transparent now, it could be easier to modify or
remove in the future.
3. It handles all selection labels as well (by onLabelCreate), so it
supports "multiple selection dropdown" now.
* It partially completes one of my TODOs: `TODO: multiple selection is
not supported yet.`
4. The code structure is clearer, code blocks are splitted into
different functions.
* The old `attachOneDropdownAria` was splitted into separate functions.
* It makes it easier to add more fine tunes in the future, and co-work
with contributors.
6. The code logic is similar as before, only two new parts: 
    1. the `ariaCheckboxFn` and `ariaDropdownFn` functions
    2. the `onLabelCreate` and `updateSelectionLabel` functions

In `aria-dropdown.js` I had to mix jQuery and Vanilla JS somewhat, I
think the code is still understandable, otherwise the code would be much
more complex to read.

Thanks to fsologureng for the idea about "improving the 'delete icon'
with aria attributes".

If there is anything unclear or incorrect, feel free to ask and discuss,
or propose new PRs for it.
2023-03-22 10:52:01 +08:00
..
alert.tmpl Support Issue forms and PR forms (#20987) 2022-09-02 15:58:49 +08:00
alert_details.tmpl Enforce tab indentation in templates (#15289) 2021-04-10 23:46:37 -04:00
delete_modal_actions.tmpl Convert <div class="button"> to <button class="button"> (#23337) 2023-03-14 11:34:09 +08:00
disable_form_autofill.tmpl Disable form autofill (#17291) 2021-10-19 01:08:41 +03:00
footer.tmpl Add new captcha: cloudflare turnstile (#22369) 2023-02-05 15:29:03 +08:00
footer_content.tmpl Fix aria.js bugs: incorrect role element problem, mobile focus problem, tippy problem (#23450) 2023-03-17 11:08:05 +08:00
head.tmpl Fix various bugs for "install" page (#23194) 2023-03-04 10:12:02 +08:00
head_navbar.tmpl Use <nav> instead of <div> in the global navbar (#23125) 2023-03-17 11:52:44 +08:00
head_script.tmpl Use a general approch to improve a11y for all checkboxes and dropdowns. (#23542) 2023-03-22 10:52:01 +08:00
paginate.tmpl Move helpers to be prefixed with gt- (#22879) 2023-02-13 17:59:59 +00:00