-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextAreaInput.js
More file actions
35 lines (34 loc) · 928 Bytes
/
TextAreaInput.js
File metadata and controls
35 lines (34 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var compose = require('ksf/utils/compose');
var _Destroyable = require('ksf/base/_Destroyable');
var Elmt = require('./Element');
var _ContentDelegate = require('./_ContentDelegate');
module.exports = compose(_Destroyable, _ContentDelegate, function() {
this._content = new Elmt('textarea').styleProp('font', 'inherit');
}, {
value: function(value) {
if (arguments.length) {
this._content.prop('value', (typeof value === 'string' ? value : ''));
return this;
} else {
return this._content.prop('value');
}
},
onInput: function(cb, key) {
var self = this;
this._content.on('change', function() {
cb(self.value());
});
this._own(cb, key);
return this;
},
offInput: function(key) {
var cb = this._owned[key];
this._unown(key);
this._content.off('change', cb);
return this;
},
placeholder: function(placeholder) {
this._content.prop('placeholder', placeholder);
return this;
},
});