roojs-bootstrap.js
authoredward <edward@roojs.com>
Mon, 5 Oct 2015 03:17:32 +0000 (11:17 +0800)
committeredward <edward@roojs.com>
Mon, 5 Oct 2015 03:17:32 +0000 (11:17 +0800)
roojs-bootstrap-debug.js

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

index 1b399ef..259724e 100644 (file)
@@ -7238,7 +7238,6 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
     before : false,
     after : false,
     size : false,
-    // private
     hasFocus : false,
     preventMark: false,
     isFormField : true,
@@ -7560,6 +7559,7 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
                 return false;
             }
         }
+        
         if(this.regex && !this.regex.test(value)){
             return false;
         }
@@ -7747,9 +7747,6 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
         if(this.hasFeedback && this.inputType != 'hidden'){
             var feedback = this.el.select('.form-control-feedback', true).first();
             
-            Roo.log('valid!!!!!!!!!!!!!!!');
-            Roo.log(this);
-            Roo.log(this.el.select('.form-control-feedback', true).first());
             if(feedback){
                 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
                 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
@@ -7777,10 +7774,6 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
             
             var feedback = this.el.select('.form-control-feedback', true).first();
             
-            Roo.log('invalid!!!!!!!!!!!!!!!');
-            Roo.log(this);
-            Roo.log(this.el.select('.form-control-feedback', true).first());
-            
             if(feedback){
                 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
                 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
@@ -7931,6 +7924,23 @@ Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input,  {
         
         var inputblock = input;
         
+        if(this.hasFeedback){
+            
+            var feedback = {
+                tag: 'span',
+                cls: 'glyphicon form-control-feedback'
+            };
+
+            inputblock = {
+                cls : 'has-feedback',
+                cn :  [
+                    input,
+                    feedback
+                ] 
+            };  
+        }
+        
+        
         if (this.before || this.after) {
             
             inputblock = {
@@ -7944,7 +7954,14 @@ Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input,  {
                     html : this.before
                 });
             }
+            
             inputblock.cn.push(input);
+            
+            if(this.hasFeedback){
+                inputblock.cls += ' has-feedback';
+                inputblock.cn.push(feedback);
+            }
+            
             if (this.after) {
                 inputblock.cn.push({
                     tag :'span',
@@ -16659,13 +16676,8 @@ Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input,  {
             }
         });
         
-       
-        
         var inputblock = input;
-        
-        
-        
-        
+         
         if (this.before || this.after) {
             
             inputblock = {
@@ -16883,12 +16895,71 @@ Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input,  {
         if(
                 this.disabled || 
                 (this.inputType == 'radio' && this.getValue().length) ||
-                (this.inputType == 'checkbox' && this.getValue() == this.inputValue)
+                (this.inputType == 'checkbox' && this.validateGroup())
         ){
+            this.markValid();
             return true;
         }
         
+        this.markInvalid();
         return false;
+    },
+    
+    validateGroup : function()
+    {
+        if(!this.groupId){
+            return (this.getValue() == this.inputValue) ? true : false;
+        }
+        
+        var group = Roo.bootstrap.CheckBox.get(this.groupId);
+        
+        if(!group){
+            return false;
+        }
+        
+        var r = false;
+        
+        for(var i in group){
+            if(r){
+                break;
+            }
+            
+            r = (group[i].getValue() == group[i].inputValue) ? true : false;
+        }
+        
+        return r;
+    },
+    
+    /**
+     * Mark this field as valid
+     */
+    markValid : function(){
+        Roo.log('run marValid on checkbox');
+        if(!this.el  || this.preventMark){ // not rendered
+            return;
+        }
+        
+        this.el.removeClass([this.invalidClass, this.validClass]);
+        
+        this.el.addClass(this.validClass);
+        
+        this.fireEvent('valid', this);
+    },
+    
+     /**
+     * Mark this field as invalid
+     * @param {String} msg The validation message
+     */
+    markInvalid : function(){
+        if(!this.el  || this.preventMark){ // not rendered
+            return;
+        }
+        
+        this.el.removeClass([this.invalidClass, this.validClass]);
+        
+        this.el.addClass(this.invalidClass);
+        
+        this.fireEvent('invalid', this, msg);
     }
     
 });
index ee4517f..3b88f82 100644 (file)
@@ -167,13 +167,13 @@ this.markInvalid();return false;},validateValue:function(A){if(A.length<1){if(th
 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.fireEvent('change',this,v,this.startValue);}
 this.fireEvent("blur",this);},reset:function(){this.setValue(this.originalValue);this.validate();},getName:function(){return this.name;},getValue:function(){var v=this.inputEl().getValue();return v;},getRawValue:function(){var v=this.inputEl().getValue();return v;},setRawValue:function(v){return this.inputEl().dom.value=(v===null||v===undefined?'':v);},selectText:function(A,B){var v=this.getRawValue();if(v.length>0){A=A===undefined?0:A;B=B===undefined?v.length:B;var d=this.inputEl().dom;if(d.setSelectionRange){d.setSelectionRange(A,B);}else if(d.createTextRange){var C=d.createTextRange();C.moveStart("character",A);C.moveEnd("character",v.length-B);C.select();}}},setValue:function(v){this.value=v;if(this.rendered){this.inputEl().dom.value=(v===null||v===undefined?'':v);this.validate();}},preFocus:function(){if(this.selectOnFocus){this.inputEl().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();}},clearInvalid:function(){if(!this.el||this.preventMark){return;}
 this.el.removeClass(this.invalidClass);this.fireEvent('valid',this);},markValid:function(){if(!this.el||this.preventMark){return;}
-this.el.removeClass([this.invalidClass,this.validClass]);this.el.addClass(this.validClass);if(this.hasFeedback&&this.inputType!='hidden'){var A=this.el.select('.form-control-feedback',true).first();Roo.log('valid!!!!!!!!!!!!!!!');Roo.log(this);Roo.log(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.el.removeClass([this.invalidClass,this.validClass]);this.el.addClass(this.validClass);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.el.addClass(this.invalidClass);if(this.hasFeedback&&this.inputType!='hidden'){var B=this.el.select('.form-control-feedback',true).first();Roo.log('invalid!!!!!!!!!!!!!!!');Roo.log(this);Roo.log(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]);}}
+this.el.removeClass([this.invalidClass,this.validClass]);this.el.addClass(this.invalidClass);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]);}}
 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;}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(F){if(D[F]){B.cls+=' col-'+F+'-'+D[F];}});var E=C;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.after){E.cn.push({tag:'span',cls:'input-group-addon',html:this.after});}}if(A==='left'&&this.fieldLabel.length){Roo.log("left and has label");B.cn=[{tag:'label','for':id,cls:'control-label col-sm-'+this.labelWidth,html:this.fieldLabel},{cls:"col-sm-"+(12-this.labelWidth),cn:[E]}];}else if(this.fieldLabel.length){Roo.log(" label");B.cn=[{tag:'label',html:this.fieldLabel},E];}else {Roo.log(" no label && no align");B.cn=[E];}if(this.disabled){C.disabled=true;}return B;},inputEl:function(){return this.el.select('textarea.form-control',true).first();}});
+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;}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){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){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){Roo.log("left and has label");B.cn=[{tag:'label','for':id,cls:'control-label col-sm-'+this.labelWidth,html:this.fieldLabel},{cls:"col-sm-"+(12-this.labelWidth),cn:[E]}];}else if(this.fieldLabel.length){Roo.log(" label");B.cn=[{tag:'label',html:this.fieldLabel},E];}else {Roo.log(" no label && no align");B.cn=[E];}if(this.disabled){C.disabled=true;}return B;},inputEl:function(){return this.el.select('textarea.form-control',true).first();}});
 //Roo/bootstrap/TriggerField.js
 Roo.bootstrap.TriggerField=function(A){this.mimicing=false;Roo.bootstrap.TriggerField.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.TriggerField,Roo.bootstrap.Input,{hideTrigger: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;}var D=C;if(this.before||this.after){D={cls:'input-group',cn:[]};if(this.before){D.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}
 D.cn.push(C);if(this.after){D.cn.push({tag:'span',cls:'input-group-addon',html:this.after});}};var E={tag:'div',cn:[{tag:'input',type:'hidden',cls:'form-hidden-field'},D]};if(this.multiple){Roo.log('multiple');E={tag:'div',cn:[{tag:'input',type:'hidden',cls:'form-hidden-field'},{tag:'ul',cls:'select2-choices',cn:[{tag:'li',cls:'select2-search-field',cn:[D]}]}]}};var F={cls:'select2-container input-group',cn:[E]};if(!this.multiple&&this.showToggleBtn){var G={tag:'span',cls:'caret'};if(this.caret!=false){G={tag:'i',cls:'fa fa-'+this.caret};}
@@ -375,7 +375,11 @@ E.cn.push(C);if(this.after){E.cn.push({tag:'span',cls:'input-group-addon',html:t
 B.cn.push(F);}return B;},inputEl:function(){return this.el.select('input.roo-'+this.inputType,true).first();},labelEl:function(){return this.el.select('label.control-label',true).first();},label:function(){return this.labelEl();},initEvents:function(){this.inputEl().on('click',this.onClick,this);if(this.boxLabel){this.el.select('label.box-label',true).first().on('click',this.onClick,this);}
 this.startValue=this.getValue();if(this.groupId){Roo.bootstrap.CheckBox.register(this);}},onClick:function(){this.setChecked(!this.checked);},setChecked:function(A,B){this.startValue=this.getValue();if(this.inputType=='radio'){Roo.each(this.el.up('form').select('input[name='+this.name+']',true).elements,function(e){e.dom.checked=false;});this.inputEl().dom.checked=true;this.inputEl().dom.value=this.inputValue;if(B!==true){this.fireEvent('check',this,true);}return;}
 this.checked=A;this.inputEl().dom.checked=A;this.inputEl().dom.value=A?this.inputValue:this.valueOff;if(B!==true){this.fireEvent('check',this,A);}},getValue:function(){if(this.inputType=='radio'){return this.getGroupValue();}return this.inputEl().getValue();},getGroupValue:function(){if(typeof(this.el.up('form').child('input[name='+this.name+']:checked',true))=='undefined'){return '';}return this.el.up('form').child('input[name='+this.name+']:checked',true).value;},setValue:function(v,A){if(this.inputType=='radio'){this.setGroupValue(v,A);return;}
-this.setChecked(((typeof(v)=='undefined')?this.checked:(String(v)===String(this.inputValue))),A);},setGroupValue:function(v,A){this.startValue=this.getValue();Roo.each(this.el.up('form').select('input[name='+this.name+']',true).elements,function(e){e.dom.checked=false;if(e.dom.value==v){e.dom.checked=true;}});if(A!==true){this.fireEvent('check',this,true);}return;},validate:function(){if(this.disabled||(this.inputType=='radio'&&this.getValue().length)||(this.inputType=='checkbox'&&this.getValue()==this.inputValue)){return true;}return false;}});Roo.apply(Roo.bootstrap.CheckBox,{groups:{},register:function(A){if(typeof(this.groups[A.groupId])=='undefined'){this.groups[A.groupId]={};}if(this.groups[A.groupId].hasOwnProperty(A.name)){return;}
+this.setChecked(((typeof(v)=='undefined')?this.checked:(String(v)===String(this.inputValue))),A);},setGroupValue:function(v,A){this.startValue=this.getValue();Roo.each(this.el.up('form').select('input[name='+this.name+']',true).elements,function(e){e.dom.checked=false;if(e.dom.value==v){e.dom.checked=true;}});if(A!==true){this.fireEvent('check',this,true);}return;},validate:function(){if(this.disabled||(this.inputType=='radio'&&this.getValue().length)||(this.inputType=='checkbox'&&this.validateGroup())){this.markValid();return true;}
+this.markInvalid();return false;},validateGroup:function(){if(!this.groupId){return (this.getValue()==this.inputValue)?true:false;}var A=Roo.bootstrap.CheckBox.get(this.groupId);if(!A){return false;}var r=false;for(var i in A){if(r){break;}
+r=(A[i].getValue()==A[i].inputValue)?true:false;}return r;},markValid:function(){Roo.log('run marValid on checkbox');if(!this.el||this.preventMark){return;}
+this.el.removeClass([this.invalidClass,this.validClass]);this.el.addClass(this.validClass);this.fireEvent('valid',this);},markInvalid:function(){if(!this.el||this.preventMark){return;}
+this.el.removeClass([this.invalidClass,this.validClass]);this.el.addClass(this.invalidClass);this.fireEvent('invalid',this,msg);}});Roo.apply(Roo.bootstrap.CheckBox,{groups:{},register:function(A){if(typeof(this.groups[A.groupId])=='undefined'){this.groups[A.groupId]={};}if(this.groups[A.groupId].hasOwnProperty(A.name)){return;}
 this.groups[A.groupId][A.name]=A;},get:function(A){if(typeof(this.groups[A])=='undefined'){return false;}return this.groups[A];}});
 //Roo/bootstrap/Radio.js
 Roo.bootstrap.Radio=function(A){Roo.bootstrap.Radio.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Radio,Roo.bootstrap.CheckBox,{inputType:'radio',inputValue:'',valueOff:'',getAutoCreate:function(){var A=(!this.labelAlign)?this.parentLabelAlign():this.labelAlign;A=A||'left';var id=Roo.id();var B={tag:this.inline?'span':'div',cls:'',cn:[]};var C=this.inline?' radio-inline':'';var D={tag:'label','for':id,cls:'control-label box-label'+C,cn:[]};var E=this.labelWidth?this.labelWidth*1:100;var F={tag:'label',html:this.fieldLabel,style:'width:'+E+'px;line-height:1;vertical-align:bottom;cursor:default;'};var G={tag:'input',id:id,type:this.inputType,value:this.inputValue,cls:'roo-radio',placeholder:this.placeholder||''};if(this.weight){G.cls+=" radio-"+this.weight;}if(this.disabled){G.disabled=true;}if(this.checked){G.checked=this.checked;}if(this.name){G.name=this.name;}if(this.size){G.cls+=' input-'+this.size;}var H=this;['xs','sm','md','lg'].map(function(K){if(H[K]){B.cls+=' col-'+K+'-'+H[K];}});var I=G;if(this.before||this.after){I={cls:'input-group',tag:'span',cn:[]};if(this.before){I.cn.push({tag:'span',cls:'input-group-addon',html:this.before});}