Move code for cleaner diff
| @@ -9726,6 +9726,26 @@ jQuery(async function () { | ||
| 9726 | 9726 | }); |
| 9727 | 9727 | |
| 9728 | 9728 | const cssAutofit = CSS.supports('field-sizing', 'content'); |
| 9729 | + if (!cssAutofit) { | |
| 9730 | + /** | |
| 9731 | + * Sets the scroll height of the edit textarea to fit the content. | |
| 9732 | + * @param {HTMLTextAreaElement} e Textarea element to auto-fit | |
| 9733 | + */ | |
| 9734 | + function autoFitEditTextArea(e) { | |
| 9735 | + e.style.height = '0px'; | |
| 9736 | + const newHeight = e.scrollHeight + 4; | |
| 9737 | + e.style.height = `${newHeight}px`; | |
| 9738 | + } | |
| 9739 | + const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short); | |
| 9740 | + document.addEventListener('input', e => { | |
| 9741 | + if (e.target instanceof HTMLTextAreaElement && e.target.classList.contains('edit_textarea')) { | |
| 9742 | + const scrollbarShown = e.target.clientWidth < e.target.offsetWidth && e.target.offsetHeight >= window.innerHeight * 0.75; | |
| 9743 | + const immediately = (e.target.scrollHeight > e.target.offsetHeight && !scrollbarShown) || e.target.value === ''; | |
| 9744 | + immediately ? autoFitEditTextArea(e.target) : autoFitEditTextAreaDebounced(e.target); | |
| 9745 | + } | |
| 9746 | + }); | |
| 9747 | + } | |
| 9748 | + | |
| 9729 | 9749 | const chatElementScroll = document.getElementById('chat'); |
| 9730 | 9750 | const chatScrollHandler = function () { |
| 9731 | 9751 | if (power_user.waifuMode) { |
| @@ -9748,26 +9768,6 @@ jQuery(async function () { | ||
| 9748 | 9768 | chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true }); |
| 9749 | 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 | 9771 | $(document).on('click', '.mes', function () { |
| 9772 | 9772 | //when a 'delete message' parent div is clicked |
| 9773 | 9773 | // and we are in delete mode and del_checkbox is visible |