X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=docs%2Fsymbols%2Fsrc%2FRoo_bootstrap_NumberField.js.html;h=f99865778d09eebd2d0c1ad73234ee5c86c96d35;hb=7d8290ee43eec264e8d9276b83debe3a035cb929;hp=f9ef21b13dff58c8be73c9125061d76a321a3b3a;hpb=2a1db797ae4360623f7e3ac751623317dada79f1;p=roojs1 diff --git a/docs/symbols/src/Roo_bootstrap_NumberField.js.html b/docs/symbols/src/Roo_bootstrap_NumberField.js.html index f9ef21b13d..f99865778d 100644 --- a/docs/symbols/src/Roo_bootstrap_NumberField.js.html +++ b/docs/symbols/src/Roo_bootstrap_NumberField.js.html @@ -1,8 +1,7 @@
/*
* - LGPL
*
- * Input
- *
+ * Number field
*/
/**
@@ -40,6 +39,11 @@
* @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
*/
allowNegative : true,
+
+ /**
+ * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
+ */
+ allowZero: true,
/**
* @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
*/
@@ -65,6 +69,40 @@
* @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
*/
castInt : true,
+ /**
+ * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
+ */
+ thousandsDelimiter : false,
+ /**
+ * @cfg {String} valueAlign alignment of value
+ */
+ valueAlign : "left",
+
+ getAutoCreate : function()
+ {
+ var hiddenInput = {
+ tag: 'input',
+ type: 'hidden',
+ id: Roo.id(),
+ cls: 'hidden-number-input'
+ };
+
+ if (this.name) {
+ hiddenInput.name = this.name;
+ }
+
+ this.name = '';
+
+ var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
+
+ this.name = hiddenInput.name;
+
+ if(cfg.cn.length > 0) {
+ cfg.cn.push(hiddenInput);
+ }
+
+ return cfg;
+ },
// private
initEvents : function()
@@ -81,6 +119,10 @@
allowed += "-";
}
+ if(this.thousandsDelimiter) {
+ allowed += ",";
+ }
+
this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
var keyPress = function(e){
@@ -138,17 +180,31 @@
getValue : function()
{
- return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
+ var v = this.hiddenEl().getValue();
+
+ return this.fixPrecision(this.parseValue(v));
},
parseValue : function(value)
{
+ if(this.thousandsDelimiter) {
+ value += "";
+ r = new RegExp(",", "g");
+ value = value.replace(r, "");
+ }
+
value = parseFloat(String(value).replace(this.decimalSeparator, "."));
return isNaN(value) ? '' : value;
},
fixPrecision : function(value)
{
+ if(this.thousandsDelimiter) {
+ value += "";
+ r = new RegExp(",", "g");
+ value = value.replace(r, "");
+ }
+
var nan = isNaN(value);
if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
@@ -159,8 +215,24 @@
setValue : function(v)
{
- v = this.fixPrecision(v);
- Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
+ v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
+
+ this.value = v;
+
+ if(this.rendered){
+
+ this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
+
+ this.inputEl().dom.value = (v == '') ? '' :
+ Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
+
+ if(!this.allowZero && v === '0') {
+ this.hiddenEl().dom.value = '';
+ this.inputEl().dom.value = '';
+ }
+
+ this.validate();
+ }
},
decimalPrecisionFcn : function(v)
@@ -175,9 +247,15 @@
}
var v = this.parseValue(this.getRawValue());
- if(v){
+
+ if(v || v === 0){
this.setValue(v);
}
+ },
+
+ hiddenEl : function()
+ {
+ return this.el.select('input.hidden-number-input',true).first();
}
});