From 837f04377ba365e5e01650d8ab199879f6682ee2 Mon Sep 17 00:00:00 2001 From: Alan Date: Mon, 5 Jun 2023 14:33:35 +0800 Subject: [PATCH] fix #7675 - formating on other link urls --- Roo/bootstrap/form/TextArea.js | 7 +++++++ Roo/form/VTypes.js | 10 +++++++++- roojs-bootstrap-debug.js | 17 ++++++++++++++++- roojs-bootstrap.js | 13 +++++++------ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Roo/bootstrap/form/TextArea.js b/Roo/bootstrap/form/TextArea.js index 8381df9cbd..b3d3486122 100644 --- a/Roo/bootstrap/form/TextArea.js +++ b/Roo/bootstrap/form/TextArea.js @@ -187,6 +187,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass); feedback.update(''); + feedback.hide(); } } @@ -211,6 +212,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(feedback){ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]); feedback.update(''); + feedback.hide(); } if(this.disabled || this.allowBlank){ @@ -262,6 +264,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(feedback){ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]); feedback.update(''); + feedback.hide(); } if(this.disabled){ @@ -302,6 +305,10 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(!this.allowBlank && !this.getRawValue().length){ feedback.update(this.blankText); } + + if(feedback.dom.innerHTML) { + feedback.show(); + } } diff --git a/Roo/form/VTypes.js b/Roo/form/VTypes.js index df3bf9215e..6b1a1e4065 100644 --- a/Roo/form/VTypes.js +++ b/Roo/form/VTypes.js @@ -18,7 +18,8 @@ Roo.form.VTypes = function(){ var alpha = /^[a-zA-Z_]+$/; var alphanum = /^[a-zA-Z0-9_]+$/; var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/; - var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; + var url = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; + var urlWeb = /^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i // All these messages and functions are configurable return { @@ -47,6 +48,13 @@ Roo.form.VTypes = function(){ url : function(v){ return url.test(v); }, + /** + * The funciton used to validate URLs (only allow schemes 'https' and 'http') + * @param {String} v The URL + */ + urlWeb : function(v) { + return urlWeb.test(v); + }, /** * The error text to display when the url validation function returns false * @type String diff --git a/roojs-bootstrap-debug.js b/roojs-bootstrap-debug.js index a458bcabc7..77159f7ad9 100644 --- a/roojs-bootstrap-debug.js +++ b/roojs-bootstrap-debug.js @@ -12200,7 +12200,8 @@ Roo.form.VTypes = function(){ var alpha = /^[a-zA-Z_]+$/; var alphanum = /^[a-zA-Z0-9_]+$/; var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/; - var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; + var url = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; + var urlWeb = /^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i // All these messages and functions are configurable return { @@ -12229,6 +12230,13 @@ Roo.form.VTypes = function(){ url : function(v){ return url.test(v); }, + /** + * The funciton used to validate URLs (only allow schemes 'https' and 'http') + * @param {String} v The URL + */ + urlWeb : function(v) { + return urlWeb.test(v); + }, /** * The error text to display when the url validation function returns false * @type String @@ -13620,6 +13628,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass); feedback.update(''); + feedback.hide(); } } @@ -13644,6 +13653,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(feedback){ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]); feedback.update(''); + feedback.hide(); } if(this.disabled || this.allowBlank){ @@ -13695,6 +13705,7 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(feedback){ this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]); feedback.update(''); + feedback.hide(); } if(this.disabled){ @@ -13735,6 +13746,10 @@ Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, { if(!this.allowBlank && !this.getRawValue().length){ feedback.update(this.blankText); } + + if(feedback.dom.innerHTML) { + feedback.show(); + } } diff --git a/roojs-bootstrap.js b/roojs-bootstrap.js index 39b33c0b8b..c92b648b14 100644 --- a/roojs-bootstrap.js +++ b/roojs-bootstrap.js @@ -525,8 +525,8 @@ this.maskEl.right.setLeft(E.right+this.padding);this.maskEl.right.setTop(E.y-thi this.maskEl.left.setSize(0,0).setXY([0,0]);this.maskEl.left.hide();this.maskEl.bottom.setStyle('position','absolute');this.maskEl.bottom.setSize(0,0).setXY([0,0]);this.maskEl.bottom.hide();this.maskEl.right.setStyle('position','absolute');this.maskEl.right.setSize(0,0).setXY([0,0]); this.maskEl.right.hide();this.toolTip.hide();this.toolTip.el.hide();window.onwheel=function(){return true;};if(this.intervalID){window.clearInterval(this.intervalID);this.intervalID=false;}this.isMasked=false;}}}); // Roo/form/VTypes.js -Roo.form.VTypes=function(){var A=/^[a-zA-Z_]+$/;var B=/^[a-zA-Z0-9_]+$/;var C=/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;var D=/(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;return {email:function(v){return C.test(v); -},emailText:'This field should be an e-mail address in the format "user@domain.com"',emailMask:/[a-z0-9_\.\-@]/i,url:function(v){return D.test(v);},urlText:'This field should be a URL in the format "http:/'+'/www.domain.com"',alpha:function(v){return A.test(v); +Roo.form.VTypes=function(){var A=/^[a-zA-Z_]+$/;var B=/^[a-zA-Z0-9_]+$/;var C=/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;var D=/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;var E=/^((https?):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/ireturn {email:function(v){return C.test(v); +},emailText:'This field should be an e-mail address in the format "user@domain.com"',emailMask:/[a-z0-9_\.\-@]/i,url:function(v){return D.test(v);},urlWeb:function(v){return E.test(v);},urlText:'This field should be a URL in the format "http:/'+'/www.domain.com"',alpha:function(v){return A.test(v); },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; @@ -583,13 +583,14 @@ var id=Roo.id();var B={};if(this.inputType!='hidden'){B.cls='form-group'}var C={ ;if(this.before){E.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}E.cn.push(C);if(this.hasFeedback){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();this.el.removeClass(this.validClass); this.inputEl().removeClass('is-invalid');if(this.hasFeedback&&this.inputType!='hidden'){var B=this.el.select('.form-control-feedback',true).first();if(B){this.el.select('.form-control-feedback',true).first().removeClass(this.invalidFeedbackClass);B.update(''); -}}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]);A.update('');}if(this.disabled||this.allowBlank){return;}var B=this.el.select('label',true).first();var C=this.el.select('i.fa-star',true).first(); +B.hide();}}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]);A.update('');A.hide();}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(Roo.bootstrap.version==3){this.el.addClass(this.validClass);}else{this.inputEl().addClass('is-valid');}if(this.hasFeedback&&this.inputType!='hidden'){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]);B.update('');}if(this.disabled){return;}var C=this.el.select('label',true).first(); +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]);B.update('');B.hide();}if(this.disabled){return;}var C=this.el.select('label',true).first(); if(Roo.bootstrap.version==3){this.el.addClass(this.invalidClass);}else{this.inputEl().addClass('is-invalid');}if(this.hasFeedback&&this.inputType!='hidden'){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]); -this.el.select('.form-control-feedback',true).first().addClass([this.invalidFeedbackClass]);B.update(this.invalidText);if(!this.allowBlank&&!this.getRawValue().length){B.update(this.blankText);}}}this.fireEvent('invalid',this,A);}}); +this.el.select('.form-control-feedback',true).first().addClass([this.invalidFeedbackClass]);B.update(this.invalidText);if(!this.allowBlank&&!this.getRawValue().length){B.update(this.blankText);}if(B.dom.innerHTML){B.show();}}}this.fireEvent('invalid',this,A); +}}); // Roo/bootstrap/form/TriggerField.js Roo.bootstrap.form.TriggerField=function(A){this.mimicing=false;Roo.bootstrap.form.TriggerField.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.form.TriggerField,Roo.bootstrap.form.Input,{hideTrigger:false,removable:false,autoSize:Roo.emptyFn,monitorTab:true,deferHeight:true,actionMode:'wrap',caret:false,getAutoCreate:function(){var A=this.labelAlign||this.parentLabelAlign(); var id=Roo.id();var B={cls:'form-group'};var C={tag:'input',id:id,type:this.inputType,cls:'form-control',autocomplete:'new-password',placeholder:this.placeholder||''};if(this.name){C.name=this.name;}if(this.size){C.cls+=' input-'+this.size;}if(this.disabled){C.disabled=true; -- 2.39.2