Merge commit 'bb51c0676d0cf27babc2c01ee337ca5fd24ae37c' into glitch-soc/merge-upstream

Conflicts:
- `app/javascript/packs/public.jsx`:
  Upstream refactored slightly (but touching almost all the lines in the code),
  glitch-soc had moved a few of the code to another file.
  Refactored as upstream did.
This commit is contained in:
Claire 2023-08-24 20:32:08 +02:00
commit 7b09f585fa

View file

@ -48,7 +48,6 @@ function loaded() {
};
};
ready(() => {
const locale = document.documentElement.lang;
const dateTimeFormat = new Intl.DateTimeFormat(locale, {
@ -202,9 +201,9 @@ function loaded() {
const message = (statusEl.dataset.spoiler === 'expanded') ? (localeData['status.show_less'] || 'Show less') : (localeData['status.show_more'] || 'Show more');
spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();
});
});
}
const toggleSidebar = () => {
const toggleSidebar = () => {
const sidebar = document.querySelector('.sidebar ul');
const toggleButton = document.querySelector('.sidebar__toggle__icon');
@ -218,31 +217,29 @@ function loaded() {
toggleButton.classList.toggle('active');
sidebar.classList.toggle('visible');
};
};
delegate(document, '.sidebar__toggle__icon', 'click', () => {
delegate(document, '.sidebar__toggle__icon', 'click', () => {
toggleSidebar();
});
});
delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
if (e.key === ' ' || e.key === 'Enter') {
e.preventDefault();
toggleSidebar();
}
});
});
// Empty the honeypot fields in JS in case something like an extension
// automatically filled them.
delegate(document, '#registration_new_user,#new_user', 'submit', () => {
// Empty the honeypot fields in JS in case something like an extension
// automatically filled them.
delegate(document, '#registration_new_user,#new_user', 'submit', () => {
['user_website', 'user_confirm_password', 'registration_user_website', 'registration_user_confirm_password'].forEach(id => {
const field = document.getElementById(id);
if (field) {
field.value = '';
}
});
});
}
});
function main() {
ready(loaded);