-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabelInput.js
48 lines (47 loc) · 1.22 KB
/
LabelInput.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
var VFlex = require('absolute/VFlex');
var _ContentDelegate = require('absolute/_ContentDelegate');
var compose = require('ksf/utils/compose');
var common = require('./common');
var LabelInput = require('absolute/LabelInput');
var Label = require('absolute/Label');
module.exports = compose(_ContentDelegate, function() {
this._content = new VFlex([
[this._label = new Label().font({
family: common.font,
size: '13px'
}).height(15)],
this._input = new LabelInput()
.onFocus(this._focusStyle.bind(this))
]).height(46);
this._input.element.style({
border: 'none',
fontFamily: common.font,
color: '#222'
});
this._focusStyle(false);
}, {
value: function(value) {
this._input.value(value);
return this;
},
label: function(label) {
this._label.value(label);
return this;
},
placeholder: function(text) {
this._input.placeholder(text);
return this;
},
mainColor: function(color) {
this._mainColor = color;
return this;
},
onInput: function(cb) {
this._input.onInput(cb);
return this;
},
_focusStyle: function(focus) {
this._label.color(focus ? this._mainColor : '#AAA');
this._input.element.styleProp('borderBottom', (focus ? 2 : 1) + 'px solid ' + (focus ? this._mainColor : '#DDD'));
},
});