mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
Add auto resize to text areas
This commit is contained in:
parent
7c8e02d385
commit
28c105cb0c
@ -35,7 +35,7 @@ import kotlinx.coroutines.withContext
|
||||
*/
|
||||
enum class JsAssets : InjectorContract {
|
||||
MENU, CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG,
|
||||
DOCUMENT_WATCHER, HORIZONTAL_SCROLLING
|
||||
DOCUMENT_WATCHER, HORIZONTAL_SCROLLING, AUTO_RESIZE_TEXTAREA
|
||||
;
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -128,6 +128,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
|
||||
),
|
||||
JsAssets.DOCUMENT_WATCHER,
|
||||
JsAssets.HORIZONTAL_SCROLLING,
|
||||
JsAssets.AUTO_RESIZE_TEXTAREA,
|
||||
JsAssets.CLICK_A,
|
||||
CssHider.ADS.maybe(!prefs.showFacebookAds),
|
||||
JsAssets.CONTEXT_A,
|
||||
|
22
app/src/web/ts/auto_resize_textarea.ts
Normal file
22
app/src/web/ts/auto_resize_textarea.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// Credits to https://codepen.io/tomhodgins/pen/KgazaE
|
||||
(function () {
|
||||
const textareas = <NodeListOf<HTMLTextAreaElement>>document.querySelectorAll('textarea.frostAutoExpand');
|
||||
|
||||
const _frostAutoExpand = (el: HTMLElement) => {
|
||||
el.style.height = 'inherit'
|
||||
el.style.height = `${el.scrollHeight}px`
|
||||
};
|
||||
function _frostExpandAll() {
|
||||
textareas.forEach(_frostAutoExpand);
|
||||
}
|
||||
textareas.forEach(el => {
|
||||
const __frostAutoExpand = () => {
|
||||
_frostAutoExpand(el)
|
||||
};
|
||||
el.addEventListener('paste', __frostAutoExpand)
|
||||
el.addEventListener('input', __frostAutoExpand)
|
||||
el.addEventListener('keyup', __frostAutoExpand)
|
||||
});
|
||||
window.addEventListener('load', _frostExpandAll)
|
||||
window.addEventListener('resize', _frostExpandAll)
|
||||
}).call(undefined);
|
Loading…
Reference in New Issue
Block a user