From 2d230ce3fa18e9054d30e78742092f9852452b42 Mon Sep 17 00:00:00 2001 From: Edward Date: Fri, 3 Aug 2018 12:37:14 +0800 Subject: [PATCH] roojs-bootstrap.js roojs-bootstrap-debug.js --- roojs-bootstrap-debug.js | 40 ++++++++++++++++++++++++++++------------ roojs-bootstrap.js | 11 ++++++----- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 17224cc9e2..ac573c0434 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -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); }, diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index f13e747aea..89c59eb546 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -1648,7 +1648,7 @@ var B="";for(var i=1;i-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(Bthis.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(); -- 2.39.2