X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-ui.js;fp=roojs-ui.js;h=68f4847dd46ca693e5142d84909573fdbd3e305d;hp=b0a1c0ea310faa1a163fea5b7b4d4eefcb15478b;hb=6c9ff83b9aeb60ee31ddcb2ccacc2b72bd3ba647;hpb=83dd319070d3735be6a0001ebccae6cc0a83e2e2 diff --git a/roojs-ui.js b/roojs-ui.js index b0a1c0ea31..68f4847dd4 100644 --- a/roojs-ui.js +++ b/roojs-ui.js @@ -874,13 +874,17 @@ Roo.form.TextArea=function(A){Roo.form.TextArea.superclass.constructor.call(this }var el=this.el;var v=el.dom.value;var ts=this.textSizeEl;ts.innerHTML='';ts.appendChild(document.createTextNode(v));v=ts.innerHTML;Roo.fly(ts).setWidth(this.el.getWidth());if(v.length<1){v=" ";}else{if(Roo.isIE){v=v.replace(/\n/g,'
'); }v+=" \n ";}ts.innerHTML=v;var h=Math.min(this.growMax,Math.max(ts.offsetHeight,this.growMin));if(h!=this.lastHeight){this.lastHeight=h;this.el.setHeight(h);this.fireEvent("autosize",this,h);}}}); // Roo/form/NumberField.js -Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",thousandSeparator:"",decimalPrecision:2,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",initEvents:function(){Roo.form.NumberField.superclass.initEvents.call(this); -var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}A+=this.thousandSeparator;if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return; +Roo.form.NumberField=function(A){Roo.form.NumberField.superclass.constructor.call(this,A);};Roo.extend(Roo.form.NumberField,Roo.form.TextField,{fieldClass:"x-form-field x-form-num-field",allowDecimals:true,decimalSeparator:".",thousandSeparator:"",decimalPrecision:2,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",hiddenField:false,onRender:function(ct,A){Roo.form.TextField.superclass.onRender.call(this,ct,A); +Roo.log("Changing name?");if(this.thousandSeparator!=''){this.el.dom.setAttribute('name',this.name+'____hidden___');this.hiddenField=this.el.insertSibling({tag:'input',type:'hidden',name:this.name},'before',true);this.hiddenField.value=this.value?this.parseValue(this.value):''; +this.el.on('blur',this.onBlur,this);}},onBlur:function(){this.beforeBlur();if(!Roo.isOpera&&this.focusClass){this.el.removeClass(this.focusClass);}this.hasFocus=false;if(this.validationEvent!==false&&this.validateOnBlur&&this.validationEvent!="blur"){this.validate(); +}var v=this.getValue();if(String(v)!==String(this.startValue)){this.setValue(this.parseValue(v));this.fireEvent('change',this,v,this.startValue);}this.fireEvent("blur",this);},getName:function(){if(this.thousandSeparator!=''){return this.name;}return Roo.form.TextField.superclass.getName.call(this); +},initEvents:function(){var A="0123456789";if(this.allowDecimals){A+=this.decimalSeparator;}A+=this.thousandSeparator;if(this.allowNegative){A+="-";}this.stripCharsRe=new RegExp('[^'+A+']','gi');var B=function(e){var k=e.getKey();if(!Roo.isIE&&(e.isSpecialKey()||k==e.BACKSPACE||k==e.DELETE)){return; }var c=e.getCharCode();if(A.indexOf(String.fromCharCode(c))===-1){e.stopEvent();}};this.el.on("keypress",B,this);},validateValue:function(A){if(!Roo.form.NumberField.superclass.validateValue.call(this,A)){return false;}if(A.length<1){return true;}var B=this.parseValue(A); if(isNaN(B)){this.markInvalid(String.format(this.nanText,A));return false;}if(B