This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
rangitaki/rcc/res/rcc.js

33 lines
815 B
JavaScript
Raw Normal View History

2016-03-11 18:54:58 +01:00
/**
* JavaScript for RCC
*
* Copyright (c) 2016 by mmk2410
* License: MIT License
*/
2015-11-17 22:46:20 +01:00
window.onload = function () {
var t = document.getElementsByTagName('textarea')[0];
2016-03-11 18:54:58 +01:00
var offset = !window.opera ? (t.offsetHeight - t.clientHeight) : (
t.offsetHeight + parseInt(
window.getComputedStyle(t, null).getPropertyValue('border-top-width')
)
);
2015-11-17 22:46:20 +01:00
/**
2016-03-11 18:54:58 +01:00
* The following three code clocks are for proper resizing of the input
* textarea
*/
2015-11-17 22:46:20 +01:00
var resize = function (t) {
t.style.height = 'auto';
t.style.height = (t.scrollHeight + offset ) + 'px';
2016-03-11 18:54:58 +01:00
};
2015-11-17 22:46:20 +01:00
t.addEventListener && t.addEventListener('input', function (event) {
resize(t);
});
2016-03-11 18:54:58 +01:00
t.attachEvent && t.attachEvent('onkeyup', function () {
2015-11-17 22:46:20 +01:00
resize(t);
});
2016-03-11 18:54:58 +01:00
};