mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Move code for cleaner diff
This commit is contained in:
@@ -9726,6 +9726,26 @@ jQuery(async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const cssAutofit = CSS.supports('field-sizing', 'content');
|
const cssAutofit = CSS.supports('field-sizing', 'content');
|
||||||
|
if (!cssAutofit) {
|
||||||
|
/**
|
||||||
|
* Sets the scroll height of the edit textarea to fit the content.
|
||||||
|
* @param {HTMLTextAreaElement} e Textarea element to auto-fit
|
||||||
|
*/
|
||||||
|
function autoFitEditTextArea(e) {
|
||||||
|
e.style.height = '0px';
|
||||||
|
const newHeight = e.scrollHeight + 4;
|
||||||
|
e.style.height = `${newHeight}px`;
|
||||||
|
}
|
||||||
|
const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short);
|
||||||
|
document.addEventListener('input', e => {
|
||||||
|
if (e.target instanceof HTMLTextAreaElement && e.target.classList.contains('edit_textarea')) {
|
||||||
|
const scrollbarShown = e.target.clientWidth < e.target.offsetWidth && e.target.offsetHeight >= window.innerHeight * 0.75;
|
||||||
|
const immediately = (e.target.scrollHeight > e.target.offsetHeight && !scrollbarShown) || e.target.value === '';
|
||||||
|
immediately ? autoFitEditTextArea(e.target) : autoFitEditTextAreaDebounced(e.target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const chatElementScroll = document.getElementById('chat');
|
const chatElementScroll = document.getElementById('chat');
|
||||||
const chatScrollHandler = function () {
|
const chatScrollHandler = function () {
|
||||||
if (power_user.waifuMode) {
|
if (power_user.waifuMode) {
|
||||||
@@ -9748,26 +9768,6 @@ jQuery(async function () {
|
|||||||
chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true });
|
chatElementScroll.addEventListener('wheel', chatScrollHandler, { passive: true });
|
||||||
chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true });
|
chatElementScroll.addEventListener('touchmove', chatScrollHandler, { passive: true });
|
||||||
|
|
||||||
if (!cssAutofit) {
|
|
||||||
/**
|
|
||||||
* Sets the scroll height of the edit textarea to fit the content.
|
|
||||||
* @param {HTMLTextAreaElement} e Textarea element to auto-fit
|
|
||||||
*/
|
|
||||||
function autoFitEditTextArea(e) {
|
|
||||||
e.style.height = '0px';
|
|
||||||
const newHeight = e.scrollHeight + 4;
|
|
||||||
e.style.height = `${newHeight}px`;
|
|
||||||
}
|
|
||||||
const autoFitEditTextAreaDebounced = debounce(autoFitEditTextArea, debounce_timeout.short);
|
|
||||||
document.addEventListener('input', e => {
|
|
||||||
if (e.target instanceof HTMLTextAreaElement && e.target.classList.contains('edit_textarea')) {
|
|
||||||
const scrollbarShown = e.target.clientWidth < e.target.offsetWidth && e.target.offsetHeight >= window.innerHeight * 0.75;
|
|
||||||
const immediately = (e.target.scrollHeight > e.target.offsetHeight && !scrollbarShown) || e.target.value === '';
|
|
||||||
immediately ? autoFitEditTextArea(e.target) : autoFitEditTextAreaDebounced(e.target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).on('click', '.mes', function () {
|
$(document).on('click', '.mes', function () {
|
||||||
//when a 'delete message' parent div is clicked
|
//when a 'delete message' parent div is clicked
|
||||||
// and we are in delete mode and del_checkbox is visible
|
// and we are in delete mode and del_checkbox is visible
|
||||||
|
Reference in New Issue
Block a user