roojs-bootstrap.js
authoredward <edward@roojs.com>
Wed, 6 Apr 2016 07:53:57 +0000 (15:53 +0800)
committeredward <edward@roojs.com>
Wed, 6 Apr 2016 07:53:57 +0000 (15:53 +0800)
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index 64ab17b..f1f8941 100644 (file)
@@ -8351,7 +8351,8 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
      /**
      * Mark this field as valid
      */
-    markValid : function(){
+    markValid : function()
+    {
         if(!this.el  || this.preventMark){ // not rendered
             return;
         }
@@ -8368,6 +8369,18 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
             return;
         }
         
+        var formGroup = this.el.findParent('.form-group', false, true);
+        
+        if(formGroup){
+            
+            var label = formGroup.select('label', true).first();
+            var icon = formGroup.select('i.fa-star', true).first();
+            
+            if(label && icon){
+                icon.remove();
+            }
+        }
+        
         this.el.addClass(this.validClass);
         
         if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
@@ -8406,6 +8419,23 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
             return;
         }
         
+        var formGroup = this.el.findParent('.form-group', false, true);
+        
+        if(formGroup){
+            var label = formGroup.select('label', true).first();
+            var icon = formGroup.select('i.fa-star', true).first();
+
+            if(!this.getValue().length && label && !icon){
+                this.el.findParent('.form-group', false, true).createChild({
+                    tag : 'i',
+                    cls : 'text-danger fa fa-lg fa-star',
+                    tooltip : 'This field is required',
+                    style : 'margin-right:5px;'
+                }, label, true);
+            }
+        }
+        
+        
         this.el.addClass(this.invalidClass);
         
         if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
index 643d5ff..14bbcb4 100644 (file)
@@ -328,13 +328,14 @@ C.moveEnd("character",v.length-B);C.select();}}},setValue:function(v){this.value
 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();}},clearInvalid:function(){if(!this.el||this.preventMark){return;
 }this.el.removeClass(this.invalidClass);if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){var A=this.el.select('.form-control-feedback',true).first();if(A){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]);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;}this.el.addClass(this.validClass);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]);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;}this.el.addClass(this.invalidClass);if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){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.getValue().length||this.forceFeedback){this.el.select('.form-control-feedback',true).first().addClass([this.invalidFeedbackClass]);
-}}}this.fireEvent('invalid',this,A);},SafariOnKeyDown:function(A){var B=false;if(this.inputEl().dom.selectionEnd>0){B=(this.inputEl().dom.selectionEnd-this.inputEl().dom.selectionStart-this.getValue().length==0)?true:false;}if(((A.getKey()==8||A.getKey()==46)&&this.getValue().length==1)){A.preventDefault();
-this.setValue('');return;}if(B&&A.getCharCode()>31){A.preventDefault();var cc=String.fromCharCode(A.getCharCode());this.setValue(A.shiftKey?cc:cc.toLowerCase());}},adjustWidth:function(A,w){A=A.toLowerCase();if(typeof w=='number'&&Roo.isStrict&&!Roo.isSafari){if(Roo.isIE&&(A=='input'||A=='textarea')){if(A=='input'){return w+2;
-}if(A=='textarea'){return w-2;}}else if(Roo.isOpera){if(A=='input'){return w+2;}if(A=='textarea'){return w-2;}}}return w;}});
+}if(this.disabled||this.allowBlank){return;}var B=this.el.findParent('.form-group',false,true);if(B){var C=B.select('label',true).first();var D=B.select('i.fa-star',true).first();if(C&&D){D.remove();}}this.el.addClass(this.validClass);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]);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.findParent('.form-group',false,true);if(C){var D=C.select('label',true).first();var E=C.select('i.fa-star',true).first();if(!this.getValue().length&&D&&!E){this.el.findParent('.form-group',false,true).createChild({tag:'i',cls:'text-danger fa fa-lg fa-star',tooltip:'This field is required',style:'margin-right:5px;'}
+,D,true);}}this.el.addClass(this.invalidClass);if(this.hasFeedback&&this.inputType!='hidden'&&!this.allowBlank){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.getValue().length||this.forceFeedback){this.el.select('.form-control-feedback',true).first().addClass([this.invalidFeedbackClass]);}}}this.fireEvent('invalid',this,A);},SafariOnKeyDown:function(A){var B=false;if(this.inputEl().dom.selectionEnd>0){B=(this.inputEl().dom.selectionEnd-this.inputEl().dom.selectionStart-this.getValue().length==0)?true:false;
+}if(((A.getKey()==8||A.getKey()==46)&&this.getValue().length==1)){A.preventDefault();this.setValue('');return;}if(B&&A.getCharCode()>31){A.preventDefault();var cc=String.fromCharCode(A.getCharCode());this.setValue(A.shiftKey?cc:cc.toLowerCase());}},adjustWidth:function(A,w){A=A.toLowerCase();
+if(typeof w=='number'&&Roo.isStrict&&!Roo.isSafari){if(Roo.isIE&&(A=='input'||A=='textarea')){if(A=='input'){return w+2;}if(A=='textarea'){return w-2;}}else if(Roo.isOpera){if(A=='input'){return w+2;}if(A=='textarea'){return w-2;}}}return w;}});
 // Roo/bootstrap/TextArea.js
 Roo.bootstrap.TextArea=function(A){Roo.bootstrap.TextArea.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.TextArea,Roo.bootstrap.Input,{cols:false,rows:5,readOnly:false,warp:'soft',resize:false,value:false,html:false,getAutoCreate:function(){var A=(!this.labelAlign)?this.parentLabelAlign():this.labelAlign;
 var id=Roo.id();var B={};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;