mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-04-02 20:19:11 +02:00
Port comment character count functionality to TypeScript
This commit is contained in:
parent
2b11834b31
commit
077e9df2a6
1 changed files with 19 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
||||||
|
export function commentCharacterCountHandler(event: Event): void {
|
||||||
|
const input = event.target as HTMLInputElement;
|
||||||
|
const id = input.dataset.aId;
|
||||||
|
const counter = document.querySelector(`#ab-comment-charcount-${id}`);
|
||||||
|
const group = document.querySelector(`[name=ab-comment-new-group][data-a-id="${id}"]`);
|
||||||
|
|
||||||
|
if (group.classList.contains('has-error')) {
|
||||||
|
group.classList.remove('has-error');
|
||||||
|
}
|
||||||
|
|
||||||
|
counter.innerHTML = String(160 - input.value.length);
|
||||||
|
if (Number(counter.innerHTML) < 0) {
|
||||||
|
counter.classList.remove('text-muted');
|
||||||
|
counter.classList.add('text-danger');
|
||||||
|
} else {
|
||||||
|
counter.classList.remove('text-danger');
|
||||||
|
counter.classList.add('text-muted');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue