|
|
|
@@ -47,6 +47,11 @@ function resetChanges() { |
|
|
|
|
|
|
|
toggleModeSelectorState(window.currentMode); |
|
|
|
setButtonsActive(false); |
|
|
|
|
|
|
|
// Expand all textareas. |
|
|
|
document.querySelectorAll("textarea").forEach(textarea => { |
|
|
|
expandTextarea(textarea); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -56,6 +61,15 @@ function setButtonsActive(active) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function expandTextarea(textarea) { |
|
|
|
let totalBorderHeight = 2; |
|
|
|
if (textarea.clientHeight == textarea.scrollHeight + totalBorderHeight) return; |
|
|
|
requestAnimationFrame(() => { |
|
|
|
textarea.style.height = 'auto'; |
|
|
|
textarea.style.height = textarea.scrollHeight + totalBorderHeight + 'px'; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/******************/ |
|
|
|
/* INITIALIZATION */ |
|
|
|
/******************/ |
|
|
|
@@ -86,6 +100,13 @@ function initialize() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// Listeners to auto-expand textareas on input. |
|
|
|
document.querySelectorAll("textarea").forEach(textarea => { |
|
|
|
textarea.addEventListener("input", (event) => { |
|
|
|
expandTextarea(textarea); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// Listeners for mode select switch. |
|
|
|
document.querySelector("input[type='checkbox']").addEventListener("change", (event) => { |
|
|
|
modeSelectorInputReceived(); |