aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/static/scripts.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-06-22 22:26:22 +0300
committerGravatar Vitaly Takmazov2017-06-22 22:26:33 +0300
commit2331a659e4ea152c536523404dff4323a59e99d4 (patch)
treea7d617ccbb394107afc104cde97acc136731ad10 /juick-www/src/main/static/scripts.js
parent2f2144b46585967996cc441378ef113d1681087b (diff)
www: fix textarea focus on mobile Safari by replacing buggy autosizer
Diffstat (limited to 'juick-www/src/main/static/scripts.js')
-rw-r--r--juick-www/src/main/static/scripts.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js
index 78dc71f4..ddcf7923 100644
--- a/juick-www/src/main/static/scripts.js
+++ b/juick-www/src/main/static/scripts.js
@@ -1,4 +1,21 @@
-var autosize = require('autosize');
+var autosize = function(t) {
+ var offset = !window.opera ? (t.offsetHeight - t.clientHeight)
+ : (t.offsetHeight + parseInt(window.getComputedStyle(t, null).getPropertyValue('border-top-width'))) ;
+
+ var resize = function(t) {
+ t.style.height = 'auto';
+ t.style.height = (t.scrollHeight + offset ) + 'px';
+ }
+
+ t.addEventListener && t.addEventListener('input', function(event) {
+ resize(t);
+ });
+
+ t['attachEvent'] && t.attachEvent('onkeyup', function() {
+ resize(t);
+ });
+}
+
require('whatwg-fetch');
require('element-closest');
require('classlist.js');
@@ -531,7 +548,9 @@ function ready(fn) {
}
ready(function () {
- autosize(document.querySelectorAll('textarea'));
+ document.querySelectorAll('textarea').forEach((ta) => {
+ autosize(ta);
+ });
var insertButtons = function (e) {
var textarea = e.target;