Fix #5956 - handle file input with stripping text
authorAlan Knowles <alan@roojs.com>
Mon, 29 Jul 2019 05:43:46 +0000 (13:43 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 29 Jul 2019 05:43:46 +0000 (13:43 +0800)
Roo/form/TextField.js
roojs-all.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index 825f87f..a50d6ca 100644 (file)
@@ -174,6 +174,10 @@ Roo.extend(Roo.form.TextField, Roo.form.Field,  {
     // private - clean the leading white space
     cleanLeadingSpace : function(e)
     {
+       if (this.inputType == 'file') {
+           return;
+       }
+       
        this.setValue((this.getValue() + '').replace(/^\s+/,''));
     },
     /**
index aa18255..2c448a5 100644 (file)
@@ -1612,8 +1612,8 @@ Roo.form.TextField=function(A){Roo.form.TextField.superclass.constructor.call(th
 }Roo.form.TextField.superclass.initEvents.call(this);if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(this.validate,this);this.el.on('keyup',this.filterValidation,this);}else if(this.validationEvent!==false){this.el.on(this.validationEvent,this.validate,this,{buffer:this.validationDelay}
 );}if(this.selectOnFocus){this.on("focus",this.preFocus,this);}if(!this.allowLeadingSpace){this.on('blur',this.cleanLeadingSpace,this);}if(this.maskRe||(this.vtype&&this.disableKeyFilter!==true&&(this.maskRe=Roo.form.VTypes[this.vtype+'Mask']))){this.el.on("keypress",this.filterKeys,this);
 }if(this.grow){this.el.on("keyup",this.onKeyUp,this,{buffer:50});this.el.on("click",this.autoSize,this);}if(this.el.is('input[type=password]')&&Roo.isSafari){this.el.on('keydown',this.SafariOnKeyDown,this);}},processValue:function(A){if(this.stripCharsRe){var B=A.replace(this.stripCharsRe,'');
-if(B!==A){this.setRawValue(B);return B;}}return A;},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},onKeyUp:function(e){if(!e.isNavKeyPress()){this.autoSize();}},cleanLeadingSpace:function(e){this.setValue((this.getValue()+'').replace(/^\s+/,''));
-},reset:function(){Roo.form.TextField.superclass.reset.call(this);},preFocus:function(){if(this.selectOnFocus){this.el.dom.select();}},filterKeys:function(e){var k=e.getKey();if(!Roo.isIE&&(e.isNavKeyPress()||k==e.BACKSPACE||(k==e.DELETE&&e.button==-1))){return;
+if(B!==A){this.setRawValue(B);return B;}}return A;},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},onKeyUp:function(e){if(!e.isNavKeyPress()){this.autoSize();}},cleanLeadingSpace:function(e){if(this.inputType=='file'){return;
+}this.setValue((this.getValue()+'').replace(/^\s+/,''));},reset:function(){Roo.form.TextField.superclass.reset.call(this);},preFocus:function(){if(this.selectOnFocus){this.el.dom.select();}},filterKeys:function(e){var k=e.getKey();if(!Roo.isIE&&(e.isNavKeyPress()||k==e.BACKSPACE||(k==e.DELETE&&e.button==-1))){return;
 }var c=e.getCharCode(),cc=String.fromCharCode(c);if(Roo.isIE&&(e.isSpecialKey()||!cc)){return;}if(!this.maskRe.test(cc)){e.stopEvent();}},setValue:function(v){Roo.form.TextField.superclass.setValue.apply(this,arguments);this.autoSize();},validateValue:function(A){if(A.length<1){if(this.allowBlank){this.clearInvalid();
 return true;}else{this.markInvalid(this.blankText);return false;}}if(A.length<this.minLength){this.markInvalid(String.format(this.minLengthText,this.minLength));return false;}if(A.length>this.maxLength){this.markInvalid(String.format(this.maxLengthText,this.maxLength));
 return false;}if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){this.markInvalid(this.vtypeText||vt[this.vtype+'Text']);return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(B!==true){this.markInvalid(B);return false;
index 8541c8d..5fb01cc 100644 (file)
@@ -39532,6 +39532,10 @@ Roo.extend(Roo.form.TextField, Roo.form.Field,  {
     // private - clean the leading white space
     cleanLeadingSpace : function(e)
     {
+       if (this.inputType == 'file') {
+           return;
+       }
+       
        this.setValue((this.getValue() + '').replace(/^\s+/,''));
     },
     /**
index ac4042b..1b261d3 100644 (file)
@@ -17081,6 +17081,10 @@ Roo.extend(Roo.form.TextField, Roo.form.Field,  {
     // private - clean the leading white space
     cleanLeadingSpace : function(e)
     {
+       if (this.inputType == 'file') {
+           return;
+       }
+       
        this.setValue((this.getValue() + '').replace(/^\s+/,''));
     },
     /**
index 7898f28..4bbdd57 100644 (file)
@@ -743,8 +743,8 @@ Roo.form.TextField=function(A){Roo.form.TextField.superclass.constructor.call(th
 }Roo.form.TextField.superclass.initEvents.call(this);if(this.validationEvent=='keyup'){this.validationTask=new Roo.util.DelayedTask(this.validate,this);this.el.on('keyup',this.filterValidation,this);}else if(this.validationEvent!==false){this.el.on(this.validationEvent,this.validate,this,{buffer:this.validationDelay}
 );}if(this.selectOnFocus){this.on("focus",this.preFocus,this);}if(!this.allowLeadingSpace){this.on('blur',this.cleanLeadingSpace,this);}if(this.maskRe||(this.vtype&&this.disableKeyFilter!==true&&(this.maskRe=Roo.form.VTypes[this.vtype+'Mask']))){this.el.on("keypress",this.filterKeys,this);
 }if(this.grow){this.el.on("keyup",this.onKeyUp,this,{buffer:50});this.el.on("click",this.autoSize,this);}if(this.el.is('input[type=password]')&&Roo.isSafari){this.el.on('keydown',this.SafariOnKeyDown,this);}},processValue:function(A){if(this.stripCharsRe){var B=A.replace(this.stripCharsRe,'');
-if(B!==A){this.setRawValue(B);return B;}}return A;},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},onKeyUp:function(e){if(!e.isNavKeyPress()){this.autoSize();}},cleanLeadingSpace:function(e){this.setValue((this.getValue()+'').replace(/^\s+/,''));
-},reset:function(){Roo.form.TextField.superclass.reset.call(this);},preFocus:function(){if(this.selectOnFocus){this.el.dom.select();}},filterKeys:function(e){var k=e.getKey();if(!Roo.isIE&&(e.isNavKeyPress()||k==e.BACKSPACE||(k==e.DELETE&&e.button==-1))){return;
+if(B!==A){this.setRawValue(B);return B;}}return A;},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},onKeyUp:function(e){if(!e.isNavKeyPress()){this.autoSize();}},cleanLeadingSpace:function(e){if(this.inputType=='file'){return;
+}this.setValue((this.getValue()+'').replace(/^\s+/,''));},reset:function(){Roo.form.TextField.superclass.reset.call(this);},preFocus:function(){if(this.selectOnFocus){this.el.dom.select();}},filterKeys:function(e){var k=e.getKey();if(!Roo.isIE&&(e.isNavKeyPress()||k==e.BACKSPACE||(k==e.DELETE&&e.button==-1))){return;
 }var c=e.getCharCode(),cc=String.fromCharCode(c);if(Roo.isIE&&(e.isSpecialKey()||!cc)){return;}if(!this.maskRe.test(cc)){e.stopEvent();}},setValue:function(v){Roo.form.TextField.superclass.setValue.apply(this,arguments);this.autoSize();},validateValue:function(A){if(A.length<1){if(this.allowBlank){this.clearInvalid();
 return true;}else{this.markInvalid(this.blankText);return false;}}if(A.length<this.minLength){this.markInvalid(String.format(this.minLengthText,this.minLength));return false;}if(A.length>this.maxLength){this.markInvalid(String.format(this.maxLengthText,this.maxLength));
 return false;}if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){this.markInvalid(this.vtypeText||vt[this.vtype+'Text']);return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(B!==true){this.markInvalid(B);return false;