mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-01-10 11:50:03 +01:00
Added text area autoresize behaviour.
This commit is contained in:
parent
29ff09441b
commit
375fc0c10e
@ -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 () {
|
record: function () {
|
||||||
return this.props['_record'];
|
return this.props['_record'];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user