roojs-core.js
[roojs1] / roojs-bootstrap-debug.js
index 9d922d9..858b5aa 100644 (file)
@@ -7557,6 +7557,7 @@ Roo.form.Action.ACTION_TYPES = {
 
 
 Roo.bootstrap.Form = function(config){
+    
     Roo.bootstrap.Form.superclass.constructor.call(this, config);
     
     Roo.bootstrap.Form.popover.apply();
@@ -7591,7 +7592,6 @@ Roo.bootstrap.Form = function(config){
          */
         actioncomplete : true
     });
-
 };
 
 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component,  {
@@ -8063,8 +8063,6 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
            f.clearInvalid();
         });
 
-
-
         return this;
     },
 
@@ -8101,13 +8099,10 @@ clientValidation  Boolean          Applies to submit only.  Pass true to call fo
             Roo.each(el.items,function(e) {
                 iter(e);
             });
-
-
         };
 
         iter(this);
         return r;
-        
     }
 
 });
@@ -24441,7 +24436,8 @@ Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
     // private
     onLoad : function(ds, r, o)
     {
-        this.cursor = o.params ? o.params.start : 0;
+        this.cursor = o.params.start ? o.params.start : 0;
+        
         var d = this.getPageData(),
             ap = d.activePage,
             ps = d.pages;
@@ -33038,14 +33034,10 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
      * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
      */
     castInt : true,
-    /**
-     * @cfg {Boolean} allowThousandsDelimiter (true|false) display thousands delimiter if true (e.g. "100,000") (defalut false)
-     */
-    allowThousandsDelimiter : false,
     /**
      * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
      */
-    thousandsDelimiter : ",",
+    thousandsDelimiter : false,
     /**
      * @cfg {String} valueAlign alignment of value
      */
@@ -33064,12 +33056,11 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
             hiddenInput.name = this.name;
         }
         
-        //display field
-        var inputConfig = this;
+        this.name = '';
         
-        inputConfig.name = '';
+        var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
         
-        var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(inputConfig);
+        this.name = hiddenInput.name;
         
         if(cfg.cn.length > 0) {
             cfg.cn.push(hiddenInput);
@@ -33093,8 +33084,8 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
             allowed += "-";
         }
         
-        if(this.allowThousandsDelimiter) {
-            allowed += this.thousandsDelimiter;
+        if(this.thousandsDelimiter) {
+            allowed += ",";
         }
         
         this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
@@ -33161,9 +33152,9 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
 
     parseValue : function(value)
     {
-        if(this.allowThousandsDelimiter) {
+        if(this.thousandsDelimiter) {
             value += "";
-            r = new RegExp(this.thousandsDelimiter, "g");
+            r = new RegExp(",", "g");
             value = value.replace(r, "");
         }
         
@@ -33173,9 +33164,9 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
 
     fixPrecision : function(value)
     {
-        if(this.allowThousandsDelimiter) {
+        if(this.thousandsDelimiter) {
             value += "";
-            r = new RegExp(this.thousandsDelimiter, "g");
+            r = new RegExp(",", "g");
             value = value.replace(r, "");
         }
         
@@ -33197,7 +33188,13 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
             
             this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
             
-            this.inputEl().dom.value = (this.allowThousandsDelimiter ? this.addThousandsDelimiter(v) : v);
+            this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision, 
+                this.thousandsDelimiter || ''
+            );
+            
+            if(this.allowBlank && !v) {
+                this.inputEl().dom.value = '';
+            }
             
             this.validate();
         }
@@ -33220,29 +33217,6 @@ Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
         }
     },
     
-    addThousandsDelimiter : function(v)
-    {
-        if(!this.allowThousandsDelimiter) {
-            return v;
-        }
-        
-        v += "";
-        
-        var x = v.split(".");
-        
-        var x1 = x[0];
-        
-        var x2 = x.length > 1 ? "." + x[1] : "";
-        
-        var rgx = /(\d+)(\d{3})/;
-        
-        while (rgx.test(x1)) {
-            x1 = x1.replace(rgx, "$1" + this.thousandsDelimiter + "$2");
-        }
-        
-        return x1 + x2;
-    },
-    
     hiddenEl : function()
     {
         return this.el.select('input.hidden-number-input',true).first();
@@ -40056,7 +40030,7 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
     /**
      * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
      */
-    decimalPrecision : 2,
+    decimalPrecision : 0,
     /**
      * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
      */
@@ -40091,6 +40065,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
      * value should be in lkey
      */
     defaultCurrency : false,
+    /**
+     * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
+     */
+    thousandsDelimiter : false,
     
     
     inputlg : 9,
@@ -40118,8 +40096,15 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
             autocomplete: 'new-password'
         };
         
+        var hiddenInput = {
+            tag: 'input',
+            type: 'hidden',
+            id: Roo.id(),
+            cls: 'hidden-number-input'
+        };
+        
         if (this.name) {
-            input.name = this.name;
+            hiddenInput.name = this.name;
         }
 
         if (this.disabled) {
@@ -40248,9 +40233,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
 
         cfg.cn = [
             label,
-            container
+            container,
+            hiddenInput
         ];
-
+        
         var settings = this;
 
         ['xs','sm','md','lg'].map(function(size){
@@ -40260,7 +40246,6 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
         });
         
         return cfg;
-        
     },
     
     initEvents : function()
@@ -40270,7 +40255,6 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
         this.initCurrencyEvent();
         
         this.initNumberEvent();
-        
     },
     
     initCurrencyEvent : function()
@@ -40561,7 +40545,17 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
         this.value = v;
         
         if(this.rendered){
-            this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
+            
+            this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
+            
+            this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision, 
+                this.thousandsDelimiter || ','
+            );
+            
+            if(this.allowBlank && !v) {
+                this.inputEl().dom.value = '';
+            }
+            
             this.validate();
         }
     },
@@ -40693,6 +40687,11 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
     currencyEl : function()
     {
         return this.el.select('.roo-money-currency-input', true).first();
+    },
+    
+    hiddenEl : function()
+    {
+        return this.el.select('input.hidden-number-input',true).first();
     }
     
 });
\ No newline at end of file