Begin moving a few DOM manipulations to cash-do
This commit is contained in:
parent
6c399bc669
commit
2a5415bc70
|
@ -40,7 +40,6 @@ function displayError(errorDiv: HTMLElement, category: string, ex: Error) {
|
||||||
console.error(ex);
|
console.error(ex);
|
||||||
const errorHeading = errorDiv.querySelector('.alert-heading') as HTMLElement | null;
|
const errorHeading = errorDiv.querySelector('.alert-heading') as HTMLElement | null;
|
||||||
|
|
||||||
|
|
||||||
//clear all error text, but not heading
|
//clear all error text, but not heading
|
||||||
const errorMessages = errorDiv.querySelectorAll('span');
|
const errorMessages = errorDiv.querySelectorAll('span');
|
||||||
errorMessages.forEach(message => errorDiv.removeChild(message));
|
errorMessages.forEach(message => errorDiv.removeChild(message));
|
||||||
|
@ -98,17 +97,17 @@ function checkOverflow(elem: HTMLElement) {
|
||||||
|
|
||||||
function processFragment() {
|
function processFragment() {
|
||||||
// add username popover
|
// add username popover
|
||||||
document
|
$('[data-bs-toggle="popover"]')
|
||||||
.querySelectorAll('[data-bs-toggle="popover"]')
|
.each((_, popover) => new bootstrap.Popover(popover, { trigger: 'focus' }));
|
||||||
.forEach(popover => new bootstrap.Popover(popover, { trigger: 'focus' }));
|
|
||||||
|
|
||||||
// indicate overflow on mobile
|
// indicate overflow on mobile
|
||||||
document.querySelectorAll('.message-content div').forEach(div => {
|
$('.message-content div').each((_, div) => {
|
||||||
if (checkOverflow(div as HTMLElement)) {
|
if (checkOverflow(div)) {
|
||||||
div.parentElement?.classList.add('overflow-icon');
|
div.parentElement?.classList.add('overflow-icon');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// uniquely color usernames
|
||||||
const colorMap = new Map(
|
const colorMap = new Map(
|
||||||
Array.from($('.message-from-user'))
|
Array.from($('.message-from-user'))
|
||||||
.map(el => el?.textContent || '')
|
.map(el => el?.textContent || '')
|
||||||
|
|
Loading…
Reference in New Issue