1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2024-11-13 09:29:01 +01:00

Added text area autoresize behaviour.

This commit is contained in:
Giulio Cesare Solaroli 2015-02-26 18:39:03 +01:00
parent 29ff09441b
commit 375fc0c10e

View File

@ -44,6 +44,35 @@ Clipperz.PM.UI.Components.Cards.Edit = React.createClass({
//----------------------------------------------------------------------------
componentDidMount: function() {
var textareas;
var autoresize = this.autoresize;
textareas = [].slice.call(this.getDOMNode().querySelectorAll('textarea'));
textareas.forEach(function(aTextarea) {
aTextarea.addEventListener('input', autoresize, false);
autoresize({target:aTextarea});
});
},
componentWillUnmount: function() {
var textareas;
var autoresize = this.autoresize;
textareas = [].slice.call(this.getDOMNode().querySelectorAll('textarea'));
textareas.forEach(function(aTextarea) {
aTextarea.removeEventListener('input', autoresize, false);
});
},
autoresize: function (anEvent) {
anEvent.target.style.height = 'auto';
anEvent.target.style.height = anEvent.target.scrollHeight+'px';
window.scrollTo(window.scrollLeft, (anEvent.target.scrollTop + anEvent.target.scrollHeight));
},
//----------------------------------------------------------------------------
record: function () {
return this.props['_record'];
},