提交 a90cdb63 编写于 作者: E erik

little optimize

上级 e10cfeca
......@@ -7,22 +7,22 @@
*/
define(function() {
function _trim(str) {
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return str.replace(/^\s+/, '').replace(/\s+$/, '');
}
/**
* 百分比计算
*/
function parsePercent(value, maxValue) {
if (typeof(value) === 'string') {
if (typeof value === 'string') {
if (_trim(value).match(/%$/)) {
return parseFloat(value) / 100 * maxValue;
} else {
return parseFloat(value);
}
} else {
return value;
return parseFloat(value);
}
return value;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册