| 9748 | chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true }); | 9768 | chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true }); |
| 9749 | chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true }); | 9769 | chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true }); |
| 9750 | | 9770 | |
| 9751 | if (!cssAutofit) { | | |
| 9752 | /** | | |
| 9753 | * Sets the scroll height of the edit textarea to fit the content. | | |
| 9754 | * @param {HTMLTextAreaElement} e Textarea element to auto-fit | | |
| 9755 | */ | | |
| 9756 | function autoFitEditTextArea(e) { | | |
| 9757 | e.style.height = '0px'; | | |
| 9758 | const newHeight = e.scrollHeight + 4; | | |
| 9759 | e.style.height = `${newHeight}px`; | | |
| 9760 | } | | |
| 9761 | const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short); | | |
| 9762 | document.addEventListener('input', e => { | | |
| 9763 | if (e.target instanceof HTMLTextAreaElement && e.target.classList.contains('edit_textarea')) { | | |
| 9764 | const scrollbarShown = e.target.clientWidth < e.target.offsetWidth && e.target.offsetHeight >= window.innerHeight * 0.75; | | |
| 9765 | const immediately = (e.target.scrollHeight > e.target.offsetHeight && !scrollbarShown) || e.target.value === ''; | | |
| 9766 | immediately ? autoFitEditTextArea(e.target) : autoFitEditTextAreaDebounced(e.target); | | |
| 9767 | } | | |
| 9768 | }); | | |
| 9769 | } | | |
| 9770 | | | |
| 9771 | $(document).on('click', '.mes', function () { | 9771 | $(document).on('click', '.mes', function () { |
| 9772 | //when a 'delete message' parent div is clicked | 9772 | //when a 'delete message' parent div is clicked |
| 9773 | // and we are in delete mode and del_checkbox is visible | 9773 | // and we are in delete mode and del_checkbox is visible |