Number¶
-
class
webix.
Number
()¶ Number mixin
External references¶
Code¶
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 | webix.Number={
format: function(value, config){
if (value === "" || typeof value === "undefined") return value;
config = config||webix.i18n;
value = parseFloat(value);
var sign = value < 0 ? "-":"";
value = Math.abs(value);
var str = value.toFixed(config.decimalSize).toString();
str = str.split(".");
var int_value = "";
if (config.groupSize){
var step = config.groupSize;
var i=str[0].length;
do {
i-=step;
var chunk = (i>0)?str[0].substr(i,step):str[0].substr(0,step+i);
int_value = chunk+(int_value?config.groupDelimiter+int_value:"");
} while(i>0);
} else
int_value = str[0];
if (config.decimalSize)
return sign + int_value + config.decimalDelimiter + str[1];
else
return sign + int_value;
},
numToStr:function(config){
return function(value){
return webix.Number.format(value, config);
};
}
};
|