source: code/trunk/web/static/script.js@ 45

Last change on this file since 45 was 45, checked in by zaphircd, 21 months ago

Add @license-end

File size: 974 bytes
Line 
1// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
2// this code submits the translation form when pressing Ctrl/Meta+Enter while focussed on the input text field
3document.getElementById("input").addEventListener("keydown", function (event) {
4 if (event.keyCode === 13 && (event.metaKey || event.ctrlKey)) {
5 document.getElementById("translation-form").submit();
6 }
7});
8
9// Auto resize textarea to fit words inside it without need to scroll -- Thanks to: https://stackoverflow.com/a/25621277
10var input = document.getElementById("input");
11var output = document.getElementById("output");
12input.setAttribute("style", "height:" + output.scrollHeight + "px;overflow-y:scroll;");
13output.setAttribute("style", "height:" + output.scrollHeight + "px;overflow-y:scroll;");
14input.addEventListener("input", function (e) {
15 this.style.height = 150 + "px";
16 this.style.height = this.scrollHeight + "px";
17});
18// @license-end
Note: See TracBrowser for help on using the repository browser.