Roo/bootstrap/dash/TabBox.js
authorAlan Knowles <alan@roojs.com>
Fri, 30 Jan 2015 08:05:28 +0000 (16:05 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 30 Jan 2015 08:05:28 +0000 (16:05 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/dash/TabBox.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index 671248d..ea69e4c 100644 (file)
@@ -128,6 +128,7 @@ Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component,  {
     },
     onTabClick : function(ev,un,ob,pane)
     {
+        Roo.log('tab - prev default');
         ev.preventDefault();
         
         
index f86dd85..c36c446 100644 (file)
@@ -6420,6 +6420,7 @@ Roo.form.VTypes = function(){
  * @cfg {String} labelAlign (top|left)
  * @cfg {Boolean} readOnly Specifies that the field should be read-only
  * @cfg {String} align (left|center|right) Default left
+ * @cfg {Boolean} formatedValue (true | false) Default false
  * 
  * 
  * @constructor
@@ -6478,7 +6479,14 @@ Roo.bootstrap.Input = function(config){
              * @param {Roo.form.Field} this
              * @param {Roo.EventObject}  e The event Object
              */
-            keyup : true
+            keyup : true,
+            /**
+             * @event formatedValue
+             * Fires when get the value of the formated input
+             * @param {Roo.bootstrap.Input} this
+             * @param {String} value
+             */
+            formatedValue : true
         });
 };
 
@@ -6593,6 +6601,7 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
     labelAlign : false,
     readOnly : false,
     align : false,
+    formatedValue : false,
     
     parentLabelAlign : function()
     {
@@ -6954,8 +6963,16 @@ Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component,  {
      * @return {Mixed} value The field value
      */
     getValue : function(){
+        
         var v = this.inputEl().getValue();
         
+        if(this.formatedValue){
+            
+            this.fireEvent("formatedValue", this, v);
+            
+            return this.value;
+        }
+        
         return v;
     },
     /**
@@ -19148,6 +19165,9 @@ Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component,  {
     },
     onTabClick : function(ev,un,ob,pane)
     {
+        Roo.log('tab - prev default');
+        ev.preventDefault();
+        
         
         this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
         pane.tab.addClass('active');
index 7ee0377..632d939 100644 (file)
@@ -147,11 +147,11 @@ Roo.each(el.items,function(e){A(e);});};A(this);return r;}});
 //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,4}$/;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);},'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/Input.js
-Roo.bootstrap.Input=function(A){Roo.bootstrap.Input.superclass.constructor.call(this,A);this.addEvents({focus:true,blur:true,specialkey:true,change:true,invalid:true,valid:true,keyup:true});};Roo.extend(Roo.bootstrap.Input,Roo.bootstrap.Component,{validationEvent:"keyup",validateOnBlur:true,validationDelay:250,focusClass:"x-form-focus",invalidClass:"has-error",selectOnFocus:false,maskRe:null,vtype:null,disableKeyFilter:false,disabled:false,allowBlank:true,blankText:"This field is required",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:"",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,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||''};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(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&&typeof(this.before)=='string'){E.cn.push({tag:'span',cls:'roo-input-before input-group-addon',html:this.before});}if(this.before&&typeof(this.before)=='object'){this.before=Roo.factory(this.before);Roo.log(this.before);E.cn.push({tag:'span',cls:'roo-input-before input-group-'+(this.before.xtype=='Button'?'btn':'addon')});}
+Roo.bootstrap.Input=function(A){Roo.bootstrap.Input.superclass.constructor.call(this,A);this.addEvents({focus:true,blur:true,specialkey:true,change:true,invalid:true,valid:true,keyup:true,formatedValue:true});};Roo.extend(Roo.bootstrap.Input,Roo.bootstrap.Component,{validationEvent:"keyup",validateOnBlur:true,validationDelay:250,focusClass:"x-form-focus",invalidClass:"has-error",selectOnFocus:false,maskRe:null,vtype:null,disableKeyFilter:false,disabled:false,allowBlank:true,blankText:"This field is required",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:"",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,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||''};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(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&&typeof(this.before)=='string'){E.cn.push({tag:'span',cls:'roo-input-before input-group-addon',html:this.before});}if(this.before&&typeof(this.before)=='object'){this.before=Roo.factory(this.before);Roo.log(this.before);E.cn.push({tag:'span',cls:'roo-input-before 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-addon',html:this.after});}if(this.after&&typeof(this.after)=='object'){this.after=Roo.factory(this.after);Roo.log(this.after);E.cn.push({tag:'span',cls:'roo-input-after input-group-'+(this.after.xtype=='Button'?'btn':'addon')});}};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];};Roo.log('input-parentType: '+this.parentType);if(this.parentType==='Navbar'&&this.parent().bar){B.cls+=' navbar-form';Roo.log(B);}return B;},inputEl:function(){return this.el.select('input.form-control',true).first();},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.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);}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());}},filterValidation:function(e){if(!e.isNavKeyPress()){this.validationTask.delay(this.validationDelay);}},validate:function(){if(this.disabled||this.validateValue(this.getRawValue())){this.clearInvalid();return true;}return false;},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;}}if(this.regex&&!this.regex.test(A)){this.markInvalid(this.regexText);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();}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.clearInvalid();},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.fireEvent("blur",this);},reset:function(){this.setValue(this.originalValue);this.clearInvalid();},getName:function(){return this.name;},getValue:function(){var v=this.inputEl().getValue();if(this.formatedValue){this.fireEvent("formatedValue",this,v);return this.value;}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);},markInvalid:function(A){if(!this.el||this.preventMark){return;}
 this.el.addClass(this.invalidClass);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.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
@@ -412,7 +412,7 @@ Roo.bootstrap.Graph=function(A){Roo.bootstrap.Graph.superclass.constructor.call(
 //Roo/bootstrap/dash/NumberBox.js
 Roo.bootstrap.dash=Roo.bootstrap.dash||{};Roo.bootstrap.dash.NumberBox=function(A){Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.dash.NumberBox,Roo.bootstrap.Component,{bgcolor:'aqua',headline:'',content:'',icon:'',footer:'',fhref:'',ficon:'',getAutoCreate:function(){var A={tag:'div',cls:'small-box bg-'+this.bgcolor,cn:[{tag:'div',cls:'inner',cn:[{tag:'h3',cls:'roo-headline',html:this.headline},{tag:'p',cls:'roo-content',html:this.content}]}]};if(this.icon){A.cn.push({tag:'div',cls:'icon',cn:[{tag:'i',cls:'ion '+this.icon}]});}if(this.footer){var footer={tag:'a',cls:'small-box-footer',href:this.fhref||'#',html:this.footer};A.cn.push(footer);}return A;},onRender:function(ct,A){Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,A);},setHeadline:function(A){this.el.select('.roo-headline',true).first().dom.innerHTML=A;},setFooter:function(A,B){this.el.select('a.small-box-footer',true).first().dom.innerHTML=A;if(B){this.el.select('a.small-box-footer',true).first().attr('href',B);}},setContent:function(A){this.el.select('.roo-content',true).first().dom.innerHTML=A;},initEvents:function(){}});
 //Roo/bootstrap/dash/TabBox.js
-Roo.bootstrap.dash=Roo.bootstrap.dash||{};Roo.bootstrap.dash.TabBox=function(A){Roo.bootstrap.dash.TabBox.superclass.constructor.call(this,A);this.addEvents({"addpane":true});};Roo.extend(Roo.bootstrap.dash.TabBox,Roo.bootstrap.Component,{title:'',icon:false,getChildContainer:function(){return this.el.select('.tab-content',true).first();},getAutoCreate:function(){var A={tag:'li',cls:'pull-left header',html:this.title,cn:[]};if(this.icon){A.cn.push({tag:'i',cls:'fa '+this.icon});}var B={tag:'div',cls:'nav-tabs-custom',cn:[{tag:'ul',cls:'nav nav-tabs pull-right',cn:[A]},{tag:'div',cls:'tab-content no-padding',cn:[]}]};return B;},initEvents:function(){Roo.log('add add pane handler');this.on('addpane',this.onAddPane,this);},setTitle:function(A){this.el.select('.nav-tabs .header',true).first().dom.innerHTML=A;},onAddPane:function(A){Roo.log('addpane');Roo.log(A);var B=this.el.select('.nav-tabs',true).first();var C=B.select('.nav-tab',true);var D=C.getCount();;var E=B.createChild({tag:'li',cls:'nav-tab'+(D?'':' active'),cn:[{tag:'a',href:'#',html:A.title}]},D?C.first().dom:B.select('.header',true).first().dom);A.tab=E;E.on('click',this.onTabClick.createDelegate(this,[A],true));if(!D){A.el.addClass('active');}},onTabClick:function(ev,un,ob,A){this.el.select('.nav-tabs li.nav-tab',true).removeClass('active');A.tab.addClass('active');this.getChildContainer().select('.tab-pane',true).removeClass('active');A.el.addClass('active');A.fireEvent('activate');}});
+Roo.bootstrap.dash=Roo.bootstrap.dash||{};Roo.bootstrap.dash.TabBox=function(A){Roo.bootstrap.dash.TabBox.superclass.constructor.call(this,A);this.addEvents({"addpane":true});};Roo.extend(Roo.bootstrap.dash.TabBox,Roo.bootstrap.Component,{title:'',icon:false,getChildContainer:function(){return this.el.select('.tab-content',true).first();},getAutoCreate:function(){var A={tag:'li',cls:'pull-left header',html:this.title,cn:[]};if(this.icon){A.cn.push({tag:'i',cls:'fa '+this.icon});}var B={tag:'div',cls:'nav-tabs-custom',cn:[{tag:'ul',cls:'nav nav-tabs pull-right',cn:[A]},{tag:'div',cls:'tab-content no-padding',cn:[]}]};return B;},initEvents:function(){Roo.log('add add pane handler');this.on('addpane',this.onAddPane,this);},setTitle:function(A){this.el.select('.nav-tabs .header',true).first().dom.innerHTML=A;},onAddPane:function(A){Roo.log('addpane');Roo.log(A);var B=this.el.select('.nav-tabs',true).first();var C=B.select('.nav-tab',true);var D=C.getCount();;var E=B.createChild({tag:'li',cls:'nav-tab'+(D?'':' active'),cn:[{tag:'a',href:'#',html:A.title}]},D?C.first().dom:B.select('.header',true).first().dom);A.tab=E;E.on('click',this.onTabClick.createDelegate(this,[A],true));if(!D){A.el.addClass('active');}},onTabClick:function(ev,un,ob,A){Roo.log('tab - prev default');ev.preventDefault();this.el.select('.nav-tabs li.nav-tab',true).removeClass('active');A.tab.addClass('active');this.getChildContainer().select('.tab-pane',true).removeClass('active');A.el.addClass('active');A.fireEvent('activate');}});
 //Roo/bootstrap/dash/TabPane.js
 Roo.bootstrap.dash=Roo.bootstrap.dash||{};Roo.bootstrap.dash.TabPane=function(A){Roo.bootstrap.dash.TabPane.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.dash.TabPane,Roo.bootstrap.Component,{active:false,title:'',tab:false,getAutoCreate:function(){var A={tag:'div',cls:'tab-pane'};if(this.active){A.cls+=' active';}return A;},initEvents:function(){Roo.log('trigger add pane handler');this.parent().fireEvent('addpane',this)},setTitle:function(A){if(!this.tab){return;}
 this.title=A;this.tab.select('a'.true).first().dom.innerHTML=A;}});