react-numeral-input
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -90,37 +90,18 @@ // Generated by CoffeeScript 1.9.3 | ||
componentWillReceiveProps: function(nextProps) { | ||
var dot_sp, formatVal, node, val; | ||
var formatVal, node, val; | ||
node = this.getDOMNode(); | ||
val = nextProps.value; | ||
if (!re.test(val)) { | ||
formatVal = this.getNumeralValue(val); | ||
dot_sp = formatVal.split(','); | ||
} | ||
formatVal = this.getNumeralValue(val); | ||
return this.setState({ | ||
value: formatVal | ||
}, (function(_this) { | ||
return function() { | ||
return setCaretPosition(node, _this.state.pos); | ||
}; | ||
return function() {}; | ||
})(this)); | ||
}, | ||
changeHandler: function() { | ||
var node, oVal, pos, reTest, val; | ||
var node, val; | ||
node = this.getDOMNode(); | ||
val = node.value; | ||
pos = getCaretPosition(node); | ||
pos = this.formatPos(this.state.value, pos); | ||
reTest = re.test(val); | ||
if (!reTest) { | ||
val = numeral(val).value(); | ||
oVal = numeral(this.state.val); | ||
if ((oVal + '').length < (val + '').length) { | ||
pos = this.focusOnChar(val, pos++); | ||
} else if ((oVal + '').length > (val + '').length) { | ||
pos = this.focusOnChar(val, pos--); | ||
} else { | ||
pos = this.focusOnChar(val, pos); | ||
} | ||
} | ||
val = numeral(val).value(); | ||
return this.setState({ | ||
pos: pos, | ||
value: val | ||
@@ -127,0 +108,0 @@ }, (function(_this) { |
@@ -6,3 +6,6 @@ var React = require('react'); | ||
getInitialState: function(){ | ||
return { numeralVal: 1000000 }; | ||
return { | ||
numeralVal: 1000000, | ||
numeralVal2: 2000000 | ||
}; | ||
}, | ||
@@ -12,9 +15,20 @@ onChange: function(val){ | ||
}, | ||
onChange2: function(val){ | ||
this.setState({numeralVal2: val}) | ||
}, | ||
render: function(){ | ||
return NumeralInput({ | ||
value: this.state.numeralVal, | ||
className: "form-control input-lg", | ||
placeholder: "feed me number", | ||
onChange:this.onChange | ||
}); | ||
return React.DOM.div( {}, | ||
NumeralInput({ | ||
value: this.state.numeralVal, | ||
className: "form-control input-lg", | ||
placeholder: "feed me number", | ||
onChange:this.onChange | ||
}), | ||
NumeralInput({ | ||
value: this.state.numeralVal2, | ||
className: "form-control input-lg", | ||
placeholder: "feed me number", | ||
onChange:this.onChange2 | ||
}) | ||
) | ||
} | ||
@@ -21,0 +35,0 @@ }); |
{ | ||
"name": "react-numeral-input", | ||
"description": "numeral input", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Bingo Yang <blackbing@gmail.com>", | ||
@@ -6,0 +6,0 @@ "browserify": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
0
675721
10
18795