From 3256a084e9b46eea3233fd11b7f2f2612b71501a Mon Sep 17 00:00:00 2001 From: Alan Date: Wed, 11 Jan 2023 12:09:28 +0800 Subject: [PATCH] merge label code in text area and input --- Roo/bootstrap/form/Input.js | 43 +++++++++---- Roo/bootstrap/form/TextArea.js | 70 +------------------- roojs-bootstrap-debug.js | 113 ++++++++++----------------------- roojs-bootstrap.js | 55 ++++++++-------- 4 files changed, 92 insertions(+), 189 deletions(-) diff --git a/Roo/bootstrap/form/Input.js b/Roo/bootstrap/form/Input.js index 3b43fc2b7e..96fe412ad5 100644 --- a/Roo/bootstrap/form/Input.js +++ b/Roo/bootstrap/form/Input.js @@ -273,7 +273,6 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { getAutoCreate : function() { - var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign; var id = Roo.id(); @@ -402,6 +401,34 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { inputblock.cn.push(feedback); } }; + + + + cfg = this.getAutoCreateLabel( cfg, inputblock ); + + + + + if (this.parentType === 'Navbar' && this.parent().bar) { + cfg.cls += ' navbar-form'; + } + + if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) { + // on BS4 we do this only if not form + cfg.cls += ' navbar-form'; + cfg.tag = 'li'; + } + + return cfg; + + }, + /** + * autocreate the label - also used by textara... ?? and others? + */ + getAutoCreateLabel : function( cfg, inputblock ) + { + var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign; + var indicator = { tag : 'i', cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star', @@ -545,20 +572,10 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { }; - - if (this.parentType === 'Navbar' && this.parent().bar) { - cfg.cls += ' navbar-form'; - } - - if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) { - // on BS4 we do this only if not form - cfg.cls += ' navbar-form'; - cfg.tag = 'li'; - } - return cfg; - }, + + /** * return the real input element. */ diff --git a/Roo/bootstrap/form/TextArea.js b/Roo/bootstrap/form/TextArea.js index d76f2599fc..efb1a5b517 100644 --- a/Roo/bootstrap/form/TextArea.js +++ b/Roo/bootstrap/form/TextArea.js @@ -140,74 +140,10 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { } - if (align ==='left' && this.fieldLabel.length) { - cfg.cn = [ - { - tag: 'label', - 'for' : id, - cls : 'control-label', - html : this.fieldLabel - }, - { - cls : "", - cn: [ - inputblock - ] - } - - ]; - - if(this.labelWidth > 12){ - cfg.cn[0].style = "width: " + this.labelWidth + 'px'; - } - - if(this.labelWidth < 13 && this.labelmd == 0){ - this.labelmd = this.labelWidth; - } - - if(this.labellg > 0){ - cfg.cn[0].cls += ' col-lg-' + this.labellg; - cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg); - } - - if(this.labelmd > 0){ - cfg.cn[0].cls += ' col-md-' + this.labelmd; - cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd); - } - - if(this.labelsm > 0){ - cfg.cn[0].cls += ' col-sm-' + this.labelsm; - cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm); - } - - if(this.labelxs > 0){ - cfg.cn[0].cls += ' col-xs-' + this.labelxs; - cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs); - } - - } else if ( this.fieldLabel.length) { - cfg.cn = [ - - { - tag: 'label', - //cls : 'input-group-addon', - html : this.fieldLabel - - }, - - inputblock - - ]; - - } else { - - cfg.cn = [ - - inputblock + + cfg = this.getAutoCreateLabel( cfg, inputblock ); - ]; - - } + if (this.disabled) { input.disabled=true; diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index 6b251f4571..cf96159c68 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -12543,7 +12543,6 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { getAutoCreate : function() { - var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign; var id = Roo.id(); @@ -12672,6 +12671,34 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { inputblock.cn.push(feedback); } }; + + + + cfg = this.getAutoCreateLabel( cfg, inputblock ); + + + + + if (this.parentType === 'Navbar' && this.parent().bar) { + cfg.cls += ' navbar-form'; + } + + if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) { + // on BS4 we do this only if not form + cfg.cls += ' navbar-form'; + cfg.tag = 'li'; + } + + return cfg; + + }, + /** + * autocreate the label - also used by textara... ?? and others? + */ + getAutoCreateLabel : function( cfg, inputblock ) + { + var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign; + var indicator = { tag : 'i', cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star', @@ -12815,20 +12842,10 @@ Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, { }; - - if (this.parentType === 'Navbar' && this.parent().bar) { - cfg.cls += ' navbar-form'; - } - - if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) { - // on BS4 we do this only if not form - cfg.cls += ' navbar-form'; - cfg.tag = 'li'; - } - return cfg; - }, + + /** * return the real input element. */ @@ -13517,74 +13534,10 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { } - if (align ==='left' && this.fieldLabel.length) { - cfg.cn = [ - { - tag: 'label', - 'for' : id, - cls : 'control-label', - html : this.fieldLabel - }, - { - cls : "", - cn: [ - inputblock - ] - } - - ]; - - if(this.labelWidth > 12){ - cfg.cn[0].style = "width: " + this.labelWidth + 'px'; - } - - if(this.labelWidth < 13 && this.labelmd == 0){ - this.labelmd = this.labelWidth; - } - - if(this.labellg > 0){ - cfg.cn[0].cls += ' col-lg-' + this.labellg; - cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg); - } - - if(this.labelmd > 0){ - cfg.cn[0].cls += ' col-md-' + this.labelmd; - cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd); - } - - if(this.labelsm > 0){ - cfg.cn[0].cls += ' col-sm-' + this.labelsm; - cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm); - } - - if(this.labelxs > 0){ - cfg.cn[0].cls += ' col-xs-' + this.labelxs; - cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs); - } - - } else if ( this.fieldLabel.length) { - cfg.cn = [ - - { - tag: 'label', - //cls : 'input-group-addon', - html : this.fieldLabel - - }, - - inputblock - - ]; - - } else { - - cfg.cn = [ - - inputblock + + cfg = this.getAutoCreateLabel( cfg, inputblock ); - ]; - - } + if (this.disabled) { input.disabled=true; diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index c61d5c89a3..09f3c8dc23 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -526,27 +526,26 @@ Roo.form.VTypes=function(){var A=/^[a-zA-Z_]+$/;var B=/^[a-zA-Z0-9_]+$/;var C=/^ },alphaText:'This field should only contain letters and _',alphaMask:/[a-z_]/i,alphanum:function(v){return B.test(v);},alphanumText:'This field should only contain letters, numbers and _',alphanumMask:/[a-z0-9_]/i};}(); // Roo/bootstrap/form/Input.js Roo.bootstrap.form.Input=function(A){Roo.bootstrap.form.Input.superclass.constructor.call(this,A);this.addEvents({focus:true,blur:true,specialkey:true,change:true,invalid:true,valid:true,keyup:true,paste:true});};Roo.extend(Roo.bootstrap.form.Input,Roo.bootstrap.Component,{validationEvent:"keyup",validateOnBlur:true,validationDelay:250,focusClass:"x-form-focus",invalidClass:"has-warning",validClass:"has-success",hasFeedback:true,invalidFeedbackClass:"glyphicon-warning-sign",validFeedbackClass:"glyphicon-ok",selectOnFocus:false,maskRe:null,vtype:null,disableKeyFilter:false,disabled:false,allowBlank:true,blankText:"Please complete this mandatory field",minLength:0,maxLength:Number.MAX_VALUE,minLengthText:"The minimum length for this field is {0}",maxLengthText:"The maximum length for this field is {0}",validator:null,regex:null,regexText:"",invalidText:"",autocomplete:false,fieldLabel:'',inputType:'text',name:false,placeholder:false,before:false,after:false,size:false,hasFocus:false,preventMark:false,isFormField:true,value:'',labelWidth:2,labelAlign:false,readOnly:false,align:false,formatedValue:false,forceFeedback:false,indicatorpos:'left',labellg:0,labelmd:0,labelsm:0,labelxs:0,capture:'',accept:'',parentLabelAlign:function(){var A=this; -while(A.parent()){A=A.parent();if(typeof(A.labelAlign)!='undefined'){return A.labelAlign;}}return 'left';},getAutoCreate:function(){var A=(!this.labelAlign)?this.parentLabelAlign():this.labelAlign;var id=Roo.id();var B={};if(this.inputType!='hidden'){B.cls='form-group'} -var C={tag:'input',id:id,type:this.inputType,value:this.value,cls:'form-control',placeholder:this.placeholder||'',autocomplete:this.autocomplete||'new-password'};if(this.inputType=='file'){C.style='overflow:hidden';}if(this.capture.length){C.capture=this.capture; -}if(this.accept.length){C.accept=this.accept+"/*";}if(this.align){C.style=(typeof(C.style)=='undefined')?('text-align:'+this.align):(C.style+'text-align:'+this.align);}if(this.maxLength&&this.maxLength!=Number.MAX_VALUE){C.maxLength=this.maxLength;}if(this.disabled){C.disabled=true; -}if(this.readOnly){C.readonly=true;}if(this.name){C.name=this.name;}if(this.size){C.cls+=' input-'+this.size;}var D=this;['xs','sm','md','lg'].map(function(J){if(D[J]){B.cls+=' col-'+J+'-'+D[J];}});var E=C;var F={tag:'span',cls:'glyphicon form-control-feedback'} -;if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){E={cls:'has-feedback',cn:[C,F]};}if(this.before||this.after){E={cls:'input-group',cn:[]};if(this.before&&typeof(this.before)=='string'){E.cn.push({tag:'span',cls:'roo-input-before input-group-addon input-group-prepend input-group-text',html:this.before} -);}if(this.before&&typeof(this.before)=='object'){this.before=Roo.factory(this.before);E.cn.push({tag:'span',cls:'roo-input-before input-group-prepend input-group-'+(this.before.xtype=='Button'?'btn':'addon')});}E.cn.push(C);if(this.after&&typeof(this.after)=='string'){E.cn.push({tag:'span',cls:'roo-input-after input-group-append input-group-text input-group-addon',html:this.after} -);}if(this.after&&typeof(this.after)=='object'){this.after=Roo.factory(this.after);E.cn.push({tag:'span',cls:'roo-input-after input-group-append input-group-'+(this.after.xtype=='Button'?'btn':'addon')});}if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){E.cls+=' has-feedback'; -E.cn.push(F);}};var G={tag:'i',cls:'roo-required-indicator '+(this.indicatorpos=='right'?'right':'left')+'-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required'};if(this.allowBlank){G.style=this.allowBlank?' display:none':'';}if(A==='left'&&this.fieldLabel.length){B.cls+=' roo-form-group-label-left'+(Roo.bootstrap.version==4?' row':''); -B.cn=[G,{tag:'label','for':id,cls:'control-label col-form-label',html:this.fieldLabel},{cls:"",cn:[E]}];var H=B.cn[1];var I=B.cn[2];if(this.indicatorpos=='right'){B.cn=[{tag:'label','for':id,cls:'control-label col-form-label',cn:[{tag:'span',html:this.fieldLabel} -,G]},{cls:"",cn:[E]}];H=B.cn[0];I=B.cn[1];}if(this.labelWidth>12){H.style="width: "+this.labelWidth+'px';}if(this.labelWidth<13&&this.labelmd==0){this.labellg=this.labellg>0?this.labellg:this.labelWidth;}if(this.labellg>0){H.cls+=' col-lg-'+this.labellg;I.cls+=' col-lg-'+(12-this.labellg); -}if(this.labelmd>0){H.cls+=' col-md-'+this.labelmd;I.cls+=' col-md-'+(12-this.labelmd);}if(this.labelsm>0){H.cls+=' col-sm-'+this.labelsm;I.cls+=' col-sm-'+(12-this.labelsm);}if(this.labelxs>0){H.cls+=' col-xs-'+this.labelxs;I.cls+=' col-xs-'+(12-this.labelxs); -}}else if(this.fieldLabel.length){B.cn=[{tag:'i',cls:'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required',style:this.allowBlank?' display:none':''},{tag:'label',html:this.fieldLabel},E];if(this.indicatorpos=='right'){B.cn=[{tag:'label',html:this.fieldLabel} -,{tag:'i',cls:'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required',style:this.allowBlank?' display:none':''},E];}}else{B.cn=[E];};if(this.parentType==='Navbar'&&this.parent().bar){B.cls+=' navbar-form';}if(this.parentType==='NavGroup'&&!(Roo.bootstrap.version==4&&this.parent().form)){B.cls+=' navbar-form'; -B.tag='li';}return B;},inputEl:function(){return this.el.select('input.form-control',true).first();},tooltipEl:function(){return this.inputEl();},indicatorEl:function(){if(Roo.bootstrap.version==4){return false;}var A=this.el.select('i.roo-required-indicator',true).first(); -if(!A){return false;}return A;},setDisabled:function(v){var i=this.inputEl().dom;if(!v){i.removeAttribute('disabled');return;}i.setAttribute('disabled','true');},initEvents:function(){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);this.inputEl().relayEvent('paste',this);this.indicator=this.indicatorEl();if(this.indicator){this.indicator.addClass(this.indicatorpos=='right'?'hidden':'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); -}if(this.inputEl().is('input[type=password]')&&Roo.isSafari){this.inputEl().on('keydown',this.SafariOnKeyDown,this);}if(typeof(this.before)=='object'){this.before.render(this.el.select('.roo-input-before',true).first());}if(typeof(this.after)=='object'){this.after.render(this.el.select('.roo-input-after',true).first()); -}this.inputEl().on('change',this.onChange,this);},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},validate:function(){if(this.disabled||this.validateValue(this.getRawValue())){this.markValid();return true; -}this.markInvalid();return false;},validateValue:function(A){if(this.getVisibilityEl().hasClass('hidden')){return true;}if(A.length<1){if(this.allowBlank){return true;}return false;}if(A.lengththis.maxLength){return false; +while(A.parent()){A=A.parent();if(typeof(A.labelAlign)!='undefined'){return A.labelAlign;}}return 'left';},getAutoCreate:function(){var id=Roo.id();var A={};if(this.inputType!='hidden'){A.cls='form-group'}var B={tag:'input',id:id,type:this.inputType,value:this.value,cls:'form-control',placeholder:this.placeholder||'',autocomplete:this.autocomplete||'new-password'} +;if(this.inputType=='file'){B.style='overflow:hidden';}if(this.capture.length){B.capture=this.capture;}if(this.accept.length){B.accept=this.accept+"/*";}if(this.align){B.style=(typeof(B.style)=='undefined')?('text-align:'+this.align):(B.style+'text-align:'+this.align); +}if(this.maxLength&&this.maxLength!=Number.MAX_VALUE){B.maxLength=this.maxLength;}if(this.disabled){B.disabled=true;}if(this.readOnly){B.readonly=true;}if(this.name){B.name=this.name;}if(this.size){B.cls+=' input-'+this.size;}var C=this;['xs','sm','md','lg'].map(function(F){if(C[F]){A.cls+=' col-'+F+'-'+C[F]; +}});var D=B;var E={tag:'span',cls:'glyphicon form-control-feedback'};if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){D={cls:'has-feedback',cn:[B,E]};}if(this.before||this.after){D={cls:'input-group',cn:[]};if(this.before&&typeof(this.before)=='string'){D.cn.push({tag:'span',cls:'roo-input-before input-group-addon input-group-prepend input-group-text',html:this.before} +);}if(this.before&&typeof(this.before)=='object'){this.before=Roo.factory(this.before);D.cn.push({tag:'span',cls:'roo-input-before input-group-prepend input-group-'+(this.before.xtype=='Button'?'btn':'addon')});}D.cn.push(B);if(this.after&&typeof(this.after)=='string'){D.cn.push({tag:'span',cls:'roo-input-after input-group-append input-group-text input-group-addon',html:this.after} +);}if(this.after&&typeof(this.after)=='object'){this.after=Roo.factory(this.after);D.cn.push({tag:'span',cls:'roo-input-after input-group-append input-group-'+(this.after.xtype=='Button'?'btn':'addon')});}if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){D.cls+=' has-feedback'; +D.cn.push(E);}};A=this.getAutoCreateLabel(A,D);if(this.parentType==='Navbar'&&this.parent().bar){A.cls+=' navbar-form';}if(this.parentType==='NavGroup'&&!(Roo.bootstrap.version==4&&this.parent().form)){A.cls+=' navbar-form';A.tag='li';}return A;},getAutoCreateLabel:function(A,B){var C=(!this.labelAlign)?this.parentLabelAlign():this.labelAlign; +var D={tag:'i',cls:'roo-required-indicator '+(this.indicatorpos=='right'?'right':'left')+'-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required'};if(this.allowBlank){D.style=this.allowBlank?' display:none':'';}if(C==='left'&&this.fieldLabel.length){A.cls+=' roo-form-group-label-left'+(Roo.bootstrap.version==4?' row':''); +A.cn=[D,{tag:'label','for':id,cls:'control-label col-form-label',html:this.fieldLabel},{cls:"",cn:[B]}];var E=A.cn[1];var F=A.cn[2];if(this.indicatorpos=='right'){A.cn=[{tag:'label','for':id,cls:'control-label col-form-label',cn:[{tag:'span',html:this.fieldLabel} +,D]},{cls:"",cn:[B]}];E=A.cn[0];F=A.cn[1];}if(this.labelWidth>12){E.style="width: "+this.labelWidth+'px';}if(this.labelWidth<13&&this.labelmd==0){this.labellg=this.labellg>0?this.labellg:this.labelWidth;}if(this.labellg>0){E.cls+=' col-lg-'+this.labellg;F.cls+=' col-lg-'+(12-this.labellg); +}if(this.labelmd>0){E.cls+=' col-md-'+this.labelmd;F.cls+=' col-md-'+(12-this.labelmd);}if(this.labelsm>0){E.cls+=' col-sm-'+this.labelsm;F.cls+=' col-sm-'+(12-this.labelsm);}if(this.labelxs>0){E.cls+=' col-xs-'+this.labelxs;F.cls+=' col-xs-'+(12-this.labelxs); +}}else if(this.fieldLabel.length){A.cn=[{tag:'i',cls:'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required',style:this.allowBlank?' display:none':''},{tag:'label',html:this.fieldLabel},B];if(this.indicatorpos=='right'){A.cn=[{tag:'label',html:this.fieldLabel} +,{tag:'i',cls:'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',tooltip:'This field is required',style:this.allowBlank?' display:none':''},B];}}else{A.cn=[B];};return A;},inputEl:function(){return this.el.select('input.form-control',true).first(); +},tooltipEl:function(){return this.inputEl();},indicatorEl:function(){if(Roo.bootstrap.version==4){return false;}var A=this.el.select('i.roo-required-indicator',true).first();if(!A){return false;}return A;},setDisabled:function(v){var i=this.inputEl().dom; +if(!v){i.removeAttribute('disabled');return;}i.setAttribute('disabled','true');},initEvents:function(){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); +this.inputEl().relayEvent('paste',this);this.indicator=this.indicatorEl();if(this.indicator){this.indicator.addClass(this.indicatorpos=='right'?'hidden':'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);}if(this.inputEl().is('input[type=password]')&&Roo.isSafari){this.inputEl().on('keydown',this.SafariOnKeyDown,this);}if(typeof(this.before)=='object'){this.before.render(this.el.select('.roo-input-before',true).first()); +}if(typeof(this.after)=='object'){this.after.render(this.el.select('.roo-input-after',true).first());}this.inputEl().on('change',this.onChange,this);},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},validate:function(){if(this.disabled||this.validateValue(this.getRawValue())){this.markValid(); +return true;}this.markInvalid();return false;},validateValue:function(A){if(this.getVisibilityEl().hasClass('hidden')){return true;}if(A.length<1){if(this.allowBlank){return true;}return false;}if(A.lengththis.maxLength){return false; }if(this.vtype){var vt=Roo.form.VTypes;if(!vt[this.vtype](A,this)){return false;}}if(typeof this.validator=="function"){var B=this.validator(A);if(typeof(B)=='string'){this.invalidText=B;}if(B!==true){return false;}}if(this.regex&&!this.regex.test(A)){return false; }return true;},fireKey:function(e){if(e.isNavKeyPress()){this.fireEvent("specialkey",this,e);}},focus:function(A){if(this.rendered){this.inputEl().focus();if(A===true){this.inputEl().dom.select();}}return this;},onFocus:function(){if(!Roo.isOpera&&this.focusClass){} if(!this.hasFocus){this.hasFocus=true;this.startValue=this.getValue();this.fireEvent("focus",this);}},beforeBlur:Roo.emptyFn,onBlur:function(){this.beforeBlur();if(!Roo.isOpera&&this.focusClass){}this.hasFocus=false;if(this.validationEvent!==false&&this.validateOnBlur&&this.validationEvent!="blur"){this.validate(); @@ -575,14 +574,12 @@ Roo.bootstrap.form.TextArea=function(A){Roo.bootstrap.form.TextArea.superclass.c var id=Roo.id();var B={};if(this.inputType!='hidden'){B.cls='form-group'}var C={tag:'textarea',id:id,warp:this.warp,rows:this.rows,value:this.value||'',html:this.html||'',cls:'form-control',placeholder:this.placeholder||''};if(this.maxLength&&this.maxLength!=Number.MAX_VALUE){C.maxLength=this.maxLength; }if(this.resize){C.style=(typeof(C.style)=='undefined')?'resize:'+this.resize:C.style+'resize:'+this.resize;}if(this.cols){C.cols=this.cols;}if(this.readOnly){C.readonly=true;}if(this.name){C.name=this.name;}if(this.size){C.cls=(typeof(C.cls)=='undefined')?'input-'+this.size:C.cls+' input-'+this.size; }var D=this;['xs','sm','md','lg'].map(function(G){if(D[G]){B.cls+=' col-'+G+'-'+D[G];}});var E=C;if(this.hasFeedback&&!this.allowBlank){var F={tag:'span',cls:'glyphicon form-control-feedback'};E={cls:'has-feedback',cn:[C,F]};}if(this.before||this.after){E={cls:'input-group',cn:[]} -;if(this.before){E.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}E.cn.push(C);if(this.hasFeedback&&!this.allowBlank){E.cls+=' has-feedback';E.cn.push(F);}if(this.after){E.cn.push({tag:'span',cls:'input-group-addon',html:this.after});}}if(A==='left'&&this.fieldLabel.length){B.cn=[{tag:'label','for':id,cls:'control-label',html:this.fieldLabel} -,{cls:"",cn:[E]}];if(this.labelWidth>12){B.cn[0].style="width: "+this.labelWidth+'px';}if(this.labelWidth<13&&this.labelmd==0){this.labelmd=this.labelWidth;}if(this.labellg>0){B.cn[0].cls+=' col-lg-'+this.labellg;B.cn[1].cls+=' col-lg-'+(12-this.labellg); -}if(this.labelmd>0){B.cn[0].cls+=' col-md-'+this.labelmd;B.cn[1].cls+=' col-md-'+(12-this.labelmd);}if(this.labelsm>0){B.cn[0].cls+=' col-sm-'+this.labelsm;B.cn[1].cls+=' col-sm-'+(12-this.labelsm);}if(this.labelxs>0){B.cn[0].cls+=' col-xs-'+this.labelxs; -B.cn[1].cls+=' col-xs-'+(12-this.labelxs);}}else if(this.fieldLabel.length){B.cn=[{tag:'label',html:this.fieldLabel},E];}else{B.cn=[E];}if(this.disabled){C.disabled=true;}return B;},inputEl:function(){return this.el.select('textarea.form-control',true).first(); -},clearInvalid:function(){if(!this.el||this.preventMark){return;}var A=this.el.select('label',true).first();var B=this.el.select('i.fa-star',true).first();if(A&&B){B.remove();}this.el.removeClass(this.validClass);this.inputEl().removeClass('is-invalid');if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){var C=this.el.select('.form-control-feedback',true).first(); -if(C){this.el.select('.form-control-feedback',true).first().removeClass(this.invalidFeedbackClass);}}this.fireEvent('valid',this);},markValid:function(){if(!this.el||this.preventMark){return;}this.el.removeClass([this.invalidClass,this.validClass]);this.inputEl().removeClass(['is-valid','is-invalid']); -var A=this.el.select('.form-control-feedback',true).first();if(A){this.el.select('.form-control-feedback',true).first().removeClass([this.invalidFeedbackClass,this.validFeedbackClass]);}if(this.disabled||this.allowBlank){return;}var B=this.el.select('label',true).first(); -var C=this.el.select('i.fa-star',true).first();if(B&&C){C.remove();}if(Roo.bootstrap.version==3){this.el.addClass(this.validClass);}else{this.inputEl().addClass('is-valid');}if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank&&(this.getValue().length||this.forceFeedback)){var A=this.el.select('.form-control-feedback',true).first(); +;if(this.before){E.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}E.cn.push(C);if(this.hasFeedback&&!this.allowBlank){E.cls+=' has-feedback';E.cn.push(F);}if(this.after){E.cn.push({tag:'span',cls:'input-group-addon',html:this.after});}}B=this.getAutoCreateLabel(B,E); +if(this.disabled){C.disabled=true;}return B;},inputEl:function(){return this.el.select('textarea.form-control',true).first();},clearInvalid:function(){if(!this.el||this.preventMark){return;}var A=this.el.select('label',true).first();var B=this.el.select('i.fa-star',true).first(); +if(A&&B){B.remove();}this.el.removeClass(this.validClass);this.inputEl().removeClass('is-invalid');if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){var C=this.el.select('.form-control-feedback',true).first();if(C){this.el.select('.form-control-feedback',true).first().removeClass(this.invalidFeedbackClass); +}}this.fireEvent('valid',this);},markValid:function(){if(!this.el||this.preventMark){return;}this.el.removeClass([this.invalidClass,this.validClass]);this.inputEl().removeClass(['is-valid','is-invalid']);var A=this.el.select('.form-control-feedback',true).first(); +if(A){this.el.select('.form-control-feedback',true).first().removeClass([this.invalidFeedbackClass,this.validFeedbackClass]);}if(this.disabled||this.allowBlank){return;}var B=this.el.select('label',true).first();var C=this.el.select('i.fa-star',true).first(); +if(B&&C){C.remove();}if(Roo.bootstrap.version==3){this.el.addClass(this.validClass);}else{this.inputEl().addClass('is-valid');}if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank&&(this.getValue().length||this.forceFeedback)){var A=this.el.select('.form-control-feedback',true).first(); if(A){this.el.select('.form-control-feedback',true).first().removeClass([this.invalidFeedbackClass,this.validFeedbackClass]);this.el.select('.form-control-feedback',true).first().addClass([this.validFeedbackClass]);}}this.fireEvent('valid',this);},markInvalid:function(A){if(!this.el||this.preventMark){return; }this.el.removeClass([this.invalidClass,this.validClass]);this.inputEl().removeClass(['is-valid','is-invalid']);var B=this.el.select('.form-control-feedback',true).first();if(B){this.el.select('.form-control-feedback',true).first().removeClass([this.invalidFeedbackClass,this.validFeedbackClass]); }if(this.disabled||this.allowBlank){return;}var C=this.el.select('label',true).first();var D=this.el.select('i.fa-star',true).first();if(!this.getValue().length&&C&&!D){this.el.createChild({tag:'i',cls:'text-danger fa fa-lg fa-star',tooltip:'This field is required',style:'margin-right:5px;'} -- 2.39.2