From 6a0370b1f5864f32629ae3f57b0c43d1b23a462f Mon Sep 17 00:00:00 2001 From: ksamuel Date: Wed, 12 Aug 2020 14:14:13 +0200 Subject: [PATCH] Autofit textarea --- zerobin/static/js/behavior.js | 12 ++++++++++++ zerobin/views/home.tpl | 2 +- zerobin/views/paste.tpl | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/zerobin/static/js/behavior.js b/zerobin/static/js/behavior.js index 554eb6d..6213869 100644 --- a/zerobin/static/js/behavior.js +++ b/zerobin/static/js/behavior.js @@ -844,3 +844,15 @@ if (app.support.history && zerobin.paste_not_found) { } }) } + +/* Autofit text area height */ +const tx = document.getElementsByTagName('textarea'); +for (let i = 0; i < tx.length; i++) { + tx[i].setAttribute('style', 'height:' + (tx[i].scrollHeight) + 'px;overflow-y:hidden;'); + tx[i].addEventListener("input", OnInput, false); +} + +function OnInput() { + this.style.height = 'auto'; + this.style.height = (this.scrollHeight) + 'px'; +} diff --git a/zerobin/views/home.tpl b/zerobin/views/home.tpl index b7def8d..2661949 100644 --- a/zerobin/views/home.tpl +++ b/zerobin/views/home.tpl @@ -32,7 +32,7 @@
+ @keydown.ctrl.enter="encryptAndSendPaste()">
diff --git a/zerobin/views/paste.tpl b/zerobin/views/paste.tpl index 7b902ba..3ab37d9 100644 --- a/zerobin/views/paste.tpl +++ b/zerobin/views/paste.tpl @@ -121,7 +121,7 @@
-