roojs-bootstrap.js
authorEdward <edward@roojs.com>
Fri, 3 Aug 2018 04:37:14 +0000 (12:37 +0800)
committerEdward <edward@roojs.com>
Fri, 3 Aug 2018 04:37:14 +0000 (12:37 +0800)
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index 17224cc..ac573c0 100644 (file)
@@ -40244,6 +40244,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
      * @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)
      */
@@ -40603,6 +40607,10 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
             allowed += "-";
         }
         
+        if(this.thousandsDelimiter) {
+            allowed += ",";
+        }
+        
         this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
         
         var keyPress = function(e){
@@ -40747,23 +40755,19 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
     
     setValue : function(v)
     {
-        v = this.fixPrecision(v);
-        
-        v = String(v).replace(".", this.decimalSeparator);
+        v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
         
-        this.value = (v === null || v === undefined) ? '' : v;
+        this.value = v;
         
         if(this.rendered){
             
-            this.inputEl().dom.value = this.hiddenEl().dom.value = this.value;
+            this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
             
-            if(this.allowDecimals && this.decimalPrecision != -1 && !isNaN(this.value)){
-                this.inputEl().dom.value = Roo.util.Format.number(v, this.decimalPrecision, 
-                    this.thousandsDelimiter || ','
-                );
-            }
+            this.inputEl().dom.value = (v == '') ? '' :
+                Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
             
-            if(this.allowBlank && !v) {
+            if(!this.allowZero && v === '0') {
+                this.hiddenEl().dom.value = '';
                 this.inputEl().dom.value = '';
             }
             
@@ -40785,18 +40789,30 @@ Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
     
     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){
             return nan ? '' : value;
         }
-        
         return parseFloat(value).toFixed(this.decimalPrecision);
     },
     
index f13e747..89c59eb 100644 (file)
@@ -1648,7 +1648,7 @@ var B="";for(var i=1;i<v.length;i++){var c=v.charAt(i);if(!isNaN(c)){B+=c;if(thi
 },onKeyUp:function(e){var k=e.getKey();var c=e.getCharCode();if((String.fromCharCode(c)=='.'||String.fromCharCode(c)=='-')&&this.allowed.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}if(this.allowed.indexOf(String.fromCharCode(c))===-1){e.stopEvent();
 }this.setValue(this.getValue());}});
 // Roo/bootstrap/MoneyField.js
-Roo.bootstrap.MoneyField=function(A){Roo.bootstrap.MoneyField.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MoneyField,Roo.bootstrap.ComboBox,{allowDecimals:true,decimalSeparator:".",decimalPrecision:0,allowNegative:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",castInt:true,defaultCurrency:false,thousandsDelimiter:false,inputlg:9,inputmd:9,inputsm:9,inputxs:6,store:false,getAutoCreate:function(){var A=this.labelAlign||this.parentLabelAlign();
+Roo.bootstrap.MoneyField=function(A){Roo.bootstrap.MoneyField.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MoneyField,Roo.bootstrap.ComboBox,{allowDecimals:true,decimalSeparator:".",decimalPrecision:0,allowNegative:true,allowZero:true,minValue:Number.NEGATIVE_INFINITY,maxValue:Number.MAX_VALUE,minText:"The minimum value for this field is {0}",maxText:"The maximum value for this field is {0}",nanText:"{0} is not a valid number",castInt:true,defaultCurrency:false,thousandsDelimiter:false,inputlg:9,inputmd:9,inputsm:9,inputxs:6,store:false,getAutoCreate:function(){var A=this.labelAlign||this.parentLabelAlign();
 var id=Roo.id();var B={cls:'form-group',cn:[]};var C={tag:'input',id:id,cls:'form-control roo-money-amount-input',autocomplete:'new-password'};var D={tag:'input',type:'hidden',id:Roo.id(),cls:'hidden-number-input'};if(this.name){D.name=this.name;}if(this.disabled){C.disabled=true;
 }var E=12-this.inputlg;var F=12-this.inputmd;var G=12-this.inputsm;var H=12-this.inputxs;var I={tag:'div',cls:'row roo-money-field',cn:[{tag:'div',cls:'roo-money-currency column col-lg-'+E+' col-md-'+F+' col-sm-'+G+' col-xs-'+H,cn:[{tag:'div',cls:'roo-select2-container input-group',cn:[{tag:'input',cls:'form-control roo-money-currency-input',autocomplete:'new-password',readOnly:1,name:this.currencyName}
 ,{tag:'span',cls:'input-group-addon',cn:[{tag:'span',cls:'caret'}]}]}]},{tag:'div',cls:'roo-money-amount column col-lg-'+this.inputlg+' col-md-'+this.inputmd+' col-sm-'+this.inputsm+' col-xs-'+this.inputxs,cn:[{tag:'div',cls:this.hasFeedback?'has-feedback':'',cn:[C]}
@@ -1665,16 +1665,17 @@ this.store.on('beforeload',this.onBeforeLoad,this);this.store.on('load',this.onL
 );},initNumberEvent:function(e){this.inputEl().on("keydown",this.fireKey,this);this.inputEl().on("focus",this.onFocus,this);this.inputEl().on("blur",this.onBlur,this);this.inputEl().relayEvent('keyup',this);if(this.indicator){this.indicator.addClass('invisible');
 }this.originalValue=this.getValue();if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(this.validate,this);this.inputEl().on('keyup',this.filterValidation,this);}else if(this.validationEvent!==false){this.inputEl().on(this.validationEvent,this.validate,this,{buffer:this.validationDelay}
 );}if(this.selectOnFocus){this.on("focus",this.preFocus,this);}if(this.maskRe||(this.vtype&&this.disableKeyFilter!==true&&(this.maskRe=Roo.form.VTypes[this.vtype+'Mask']))){this.inputEl().on("keypress",this.filterKeys,this);}else{this.inputEl().relayEvent('keypress',this);
-}var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();var c=e.getCharCode();if((String.fromCharCode(c)=='.'||String.fromCharCode(c)=='-')&&A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();
+}var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}if(this.allowNegative){A+="-";}if(this.thousandsDelimiter){A+=",";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();var c=e.getCharCode();if((String.fromCharCode(c)=='.'||String.fromCharCode(c)=='-')&&A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();
 return;}if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return;}if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.inputEl().on("keypress",B,this);},onTriggerClick:function(e){if(this.disabled){return;}this.page=0;this.loadNext=false;
 if(this.isExpanded()){this.collapse();return;}this.hasFocus=true;if(this.triggerAction=='all'){this.doQuery(this.allQuery,true);return;}this.doQuery(this.getRawValue());},getCurrency:function(){var v=this.currencyEl().getValue();return v;},restrictHeight:function(){this.list.alignTo(this.currencyEl(),this.listAlign);
 this.list.alignTo(this.currencyEl(),this.listAlign);},onViewClick:function(A,B,el,e){var C=this.view.getSelectedIndexes()[0];var r=this.store.getAt(C);if(r){this.onSelect(r,C);}},onSelect:function(A,B){if(this.fireEvent('beforeselect',this,A,B)!==false){this.setFromCurrencyData(B>-1?A.data:false);
 this.collapse();this.fireEvent('select',this,A,B);}},setFromCurrencyData:function(o){var A='';this.lastCurrency=o;if(this.currencyField){A=!o||typeof(o[this.currencyField])=='undefined'?'':o[this.currencyField];}else{Roo.log('no  currencyField value set for '+(this.name?this.name:this.id));
 }this.lastSelectionText=A;if(o[this.currencyField]*1==0&&this.defaultCurrency){this.setCurrency(this.defaultCurrency);return;}this.setCurrency(A);},setFromData:function(o){var c={};c[this.currencyField]=!o||typeof(o[this.currencyName])=='undefined'?'':o[this.currencyName];
 this.setFromCurrencyData(c);var A='';if(this.name){A=!o||typeof(o[this.name])=='undefined'?'':o[this.name];}else{Roo.log('no value set for '+(this.name?this.name:this.id));}this.setValue(A);},setCurrency:function(v){this.currencyValue=v;if(this.rendered){this.currencyEl().dom.value=(v===null||v===undefined?'':v);
-this.validate();}},setValue:function(v){v=this.fixPrecision(v);v=String(v).replace(".",this.decimalSeparator);this.value=(v===null||v===undefined)?'':v;if(this.rendered){this.inputEl().dom.value=this.hiddenEl().dom.value=this.value;if(this.allowDecimals&&this.decimalPrecision!=-1&&!isNaN(this.value)){this.inputEl().dom.value=Roo.util.Format.number(v,this.decimalPrecision,this.thousandsDelimiter||',');
-}if(this.allowBlank&&!v){this.inputEl().dom.value='';}this.validate();}},getRawValue:function(){var v=this.inputEl().getValue();return v;},getValue:function(){return this.fixPrecision(this.parseValue(this.getRawValue()));},parseValue:function(A){A=parseFloat(String(A).replace(this.decimalSeparator,"."));
-return isNaN(A)?'':A;},fixPrecision:function(A){var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision);},decimalPrecisionFcn:function(v){return Math.floor(v);},validateValue:function(A){if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this,A)){return false;
+this.validate();}},setValue:function(v){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();}},getRawValue:function(){var v=this.inputEl().getValue();return v;},getValue:function(){return this.fixPrecision(this.parseValue(this.getRawValue()));}
+,parseValue:function(A){if(this.thousandsDelimiter){A+="";r=new RegExp(",","g");A=A.replace(r,"");}A=parseFloat(String(A).replace(this.decimalSeparator,"."));return isNaN(A)?'':A;},fixPrecision:function(A){if(this.thousandsDelimiter){A+="";r=new RegExp(",","g");
+A=A.replace(r,"");}var B=isNaN(A);if(!this.allowDecimals||this.decimalPrecision==-1||B||!A){return B?'':A;}return parseFloat(A).toFixed(this.decimalPrecision);},decimalPrecisionFcn:function(v){return Math.floor(v);},validateValue:function(A){if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this,A)){return false;
 }var B=this.parseValue(A);if(isNaN(B)){this.markInvalid(String.format(this.nanText,A));return false;}if(B<this.minValue){this.markInvalid(String.format(this.minText,this.minValue));return false;}if(B>this.maxValue){this.markInvalid(String.format(this.maxText,this.maxValue));
 return false;}return true;},validate:function(){if(this.disabled||this.allowBlank){this.markValid();return true;}var A=this.getCurrency();if(this.validateValue(this.getRawValue())&&A.length){this.markValid();return true;}this.markInvalid();return false;},getName:function(){return this.name;
 },beforeBlur:function(){if(!this.castInt){return;}var v=this.parseValue(this.getRawValue());if(v||v==0){this.setValue(v);}},onBlur:function(){this.beforeBlur();if(!Roo.isOpera&&this.focusClass){}this.hasFocus=false;if(this.validationEvent!==false&&this.validateOnBlur&&this.validationEvent!="blur"){this.validate();