Improve this
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Signed-off-by: Minecon724 <minecon724@noreply.git.m724.eu>
This commit is contained in:
parent
230e2de3de
commit
e82e33e116
2 changed files with 3 additions and 81 deletions
|
@ -1,50 +1 @@
|
|||
import {hideElem, showElem} from '../utils/dom.js';
|
||||
|
||||
function onPronounsDropdownUpdate() {
|
||||
const pronounsCustom = document.getElementById('label-pronouns-custom');
|
||||
const pronounsCustomInput = pronounsCustom.querySelector('input');
|
||||
const pronounsDropdown = document.getElementById('pronouns-dropdown');
|
||||
const pronounsInput = pronounsDropdown.querySelector('input');
|
||||
// must be kept in sync with `routers/web/user/setting/profile.go`
|
||||
const isCustom = !(
|
||||
pronounsInput.value === '' ||
|
||||
pronounsInput.value === 'he/him' ||
|
||||
pronounsInput.value === 'she/her' ||
|
||||
pronounsInput.value === 'they/them' ||
|
||||
pronounsInput.value === 'it/its' ||
|
||||
pronounsInput.value === 'any pronouns'
|
||||
);
|
||||
if (isCustom) {
|
||||
if (pronounsInput.value === '!') {
|
||||
pronounsCustomInput.value = '';
|
||||
} else {
|
||||
pronounsCustomInput.value = pronounsInput.value;
|
||||
}
|
||||
showElem(pronounsCustom);
|
||||
} else {
|
||||
hideElem(pronounsCustom);
|
||||
}
|
||||
}
|
||||
function onPronounsCustomUpdate() {
|
||||
const pronounsCustomInput = document.querySelector('#label-pronouns-custom input');
|
||||
const pronounsInput = document.querySelector('#pronouns-dropdown input');
|
||||
pronounsInput.value = pronounsCustomInput.value;
|
||||
}
|
||||
|
||||
export function initUserSettings() {
|
||||
if (!document.querySelectorAll('.user.settings.profile').length) return;
|
||||
|
||||
const pronounsDropdown = document.getElementById('label-pronouns');
|
||||
const pronounsCustomInput = document.querySelector('#label-pronouns-custom input');
|
||||
const pronounsInput = pronounsDropdown.querySelector('input');
|
||||
|
||||
// If JS is disabled, the page will show the custom input, as the dropdown requires JS to work.
|
||||
// JS progressively enhances the input by adding a dropdown, but it works regardless.
|
||||
pronounsCustomInput.removeAttribute('name');
|
||||
pronounsInput.setAttribute('name', 'pronouns');
|
||||
showElem(pronounsDropdown);
|
||||
|
||||
onPronounsDropdownUpdate();
|
||||
pronounsInput.addEventListener('change', onPronounsDropdownUpdate);
|
||||
pronounsCustomInput.addEventListener('input', onPronounsCustomUpdate);
|
||||
}
|
||||
export function initUserSettings() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue