add textarea auto grow and some more stuff

This commit is contained in:
Henrique Dias
2016-06-27 12:19:40 +01:00
parent 44cd9bf930
commit c5d9803bae
5 changed files with 87 additions and 12 deletions

View File

@@ -429,9 +429,30 @@ document.addEventListener("DOMContentLoaded", function (event) {
handleEditorPage();
}
textareaAutoGrow();
return false;
});
var textareaAutoGrow = function() {
let autogrow = function() {
this.style.height = '5px';
this.style.height = this.scrollHeight + 'px';
}
let textareas = document.getElementsByTagName('textarea');
let addAutoGrow = () => {
Array.from(textareas).forEach(textarea => {
autogrow.bind(textarea)();
textarea.addEventListener('keyup', autogrow);
});
}
addAutoGrow();
window.addEventListener('resize', addAutoGrow)
}
var handleEditorPage = function () {
let container = document.getElementById('editor');
let kind = container.dataset.kind;