Move code for cleaner diff

252043ae11f51c637ebe1c5d3a58aae4352e3b2a

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +20 -20Showing whitespace changes
public/script.js+20 -20
@@ -9726,6 +9726,26 @@ jQuery(async function () {
9726 });9726 });
97279727
9728 const cssAutofit = CSS.supports('field-sizing', 'content');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 const chatElementScroll = document.getElementById('chat');9749 const chatElementScroll = document.getElementById('chat');
9730 const chatScrollHandler = function () {9750 const chatScrollHandler = function () {
9731 if (power_user.waifuMode) {9751 if (power_user.waifuMode) {
@@ -9748,26 +9768,6 @@ jQuery(async function () {
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 });
97509770
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 clicked9772 //when a 'delete message' parent div is clicked
9773 // and we are in delete mode and del_checkbox is visible9773 // and we are in delete mode and del_checkbox is visible