support sticky code
[roojs1] / roojs-bootstrap.js
1 //Roo/bootstrap/Component.js
2 Roo.bootstrap=Roo.bootstrap||{};Roo.bootstrap.Component=function(A){Roo.bootstrap.Component.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Component,Roo.BoxComponent,{cls:false,style:false,autoCreate:false,initEvents:function(){},parentId:false,parent:function(){return Roo.ComponentMgr.get(this.parentId)},onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(this.el){return;}var B=Roo.apply({},this.getAutoCreate());B.id=Roo.id();if(this.cls){B.cls+=' '+this.cls;}if(this.style){B.style=this.style;}
3 this.el=ct.createChild(B,A);if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);}
4 this.initEvents();},getChildContainer:function(){return this.el;},addxtype:function(A,B){var cn=this;B=typeof(B=='undefined')?'getChildContainer':B;if(A.xtype!='Body'){cn=Roo.factory(A);cn.parentType=this.xtype;cn.parentId=this.id;cn.render(this[B]());}var C=[];if(typeof(A.menu)!='undefined'){A.menu.parentType=cn.xtype;A.menu.triggerEl=cn.el;C.push(cn.addxtype(Roo.apply({},A.menu)));}if(typeof(A.buttons)!='undefined'&&typeof(cn.getButtonContainer)=='function'){for(var i=0;i<A.buttons.length;i++){C.push(cn.addxtype(Roo.apply({},A.buttons[i]),'getButtonContainer'));}}if(!A.items||!A.items.length){this.items=C;return this;}var D=A.items;delete A.items;for(var i=0;i<D.length;i++){C.push(cn.addxtype(Roo.apply({},D[i])));}
5 this.items=C;return this;}});
6 //Roo/bootstrap/Body.js
7 Roo.bootstrap.Body=function(A){Roo.bootstrap.Body.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Body,Roo.bootstrap.Component,{autoCreate:{cls:'container'},onRender:function(ct,A){this.el=Roo.get(document.body);}});
8 //Roo/bootstrap/ButtonGroup.js
9 Roo.bootstrap.ButtonGroup=function(A){Roo.bootstrap.ButtonGroup.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.ButtonGroup,Roo.bootstrap.Component,{size:'',align:'',direction:'',toolbar:false,btn:true,getAutoCreate:function(){var A={cls:'btn-group',html:null}
10 A.html=this.html||A.html;if(this.toolbar){A={cls:'btn-toolbar',html:null};return A;}if(['vertical','justified'].indexOf(this.align)!==-1){A.cls='btn-group-'+this.align;if(this.align=='justified'){console.log(this.items);}}if(['lg','sm','xs'].indexOf(this.size)!==-1){A.cls+=' btn-group-'+this.size;}if(this.direction=='up'){A.cls+=' dropup';}return A;}});
11 //Roo/bootstrap/Button.js
12 Roo.bootstrap.Button=function(A){Roo.bootstrap.Button.superclass.constructor.call(this,A);this.addEvents({"click":true});};Roo.extend(Roo.bootstrap.Button,Roo.bootstrap.Component,{html:false,active:false,weight:'',size:'',tag:'button',href:'',disabled:false,isClose:false,glyphicon:'',badge:'',theme:'default',inverse:false,toggle:false,ontext:'ON',offtext:'OFF',defaulton:true,getAutoCreate:function(){var A={tag:'button',html:'hello'};if(['a','button','input','submit'].indexOf(this.tag)<0){throw "Invalid value for tag: "+this.tag+". must be a, button, input or submit.";this.tag='button';}else {A.tag=this.tag;}
13 A.html=this.html||A.html;if(this.toggle===true){A={tag:'div',cls:'slider-frame',cn:[{tag:'span','data-on-text':'ON','data-off-text':'OFF',cls:'slider-button',html:this.offtext}]};if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' '+this.weight;}return A;}if(this.isClose){A.cls+=' close';A["aria-hidden"]=true;A.html="&times;";return A;}if(true){if(this.theme==='default'){A.cls='btn';if(this.parentType!='Navbar'){this.weight=this.weight.length?this.weight:'default';}if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' btn-'+this.weight;}}else if(this.theme==='glow'){A.tag='a';A.cls='btn-glow';if(['default','primary','success','info','warning','danger','link'].indexOf(this.weight)>-1){A.cls+=' '+this.weight;}}}if(this.inverse){this.cls+=' inverse';}if(this.active){A.cls+=' active';}
14 A.cls+=this.size.length?(' btn-'+this.size):'';if(this.parentType==='Navbar'){A.tag='li';A.cls='';A.cn=[{tag:'a',html:this.html,href:this.href||'#'}];if(this.menu){A.cn[0].html=this.html+' <span class="caret"></span>';A.cls+=' dropdown';}delete A.html;}else if(this.menu){A.tag='a';A.cls+=' dropdown test';}if(this.disabled){A.disabled='disabled';}if(this.items){Roo.log('changing to ul');A.tag='ul';this.glyphicon='caret';}if(this.glyphicon){A.html=' '+A.html;A.cn=[{tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon}];}if(this.badge){A.html+=' ';A.tag='a';A.cls='btn';A.href=this.href;A.cn=[A.html,{tag:'span',cls:'badge',html:this.badge}];A.html='';}if(A.tag!=='a'&&this.href!==''){throw "Tag must be a to set href.";}else if(this.href.length>0){A.href=this.href;}return A;},initEvents:function(){this.el.select('a',true).on('click',function(e){this.fireEvent('click',this);},this);}});
15 //Roo/bootstrap/Column.js
16 Roo.bootstrap.Column=function(A){Roo.bootstrap.Column.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Column,Roo.bootstrap.Component,{xs:null,sm:null,md:null,lg:null,html:'',offset:0,getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Column.superclass.getAutoCreate.call(this));A={tag:'div',cls:'column'};var B=this;['xs','sm','md','lg'].map(function(C){if(B[C]){A.cls+=' col-'+C+'-'+B[C];}});if(this.html.length){A.html=this.html;}return A;}});
17 //Roo/bootstrap/Container.js
18 Roo.bootstrap.Container=function(A){Roo.bootstrap.Container.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Container,Roo.bootstrap.Component,{jumbotron:false,well:'',panel:'',header:'',footer:'',sticky:'',getChildContainer:function(){if(this.panel.length){return this.el.select('.panel-body',true).first();}return this.el;},getAutoCreate:function(){var A={html:'',cls:''};if(this.jumbotron){A.cls='jumbotron';}if(this.cls){A.cls=this.cls+'';}if(this.sticky.length){var bd=Roo.get(document.body)if(!bd.hasClass('bootstrap-sticky')){bd.addClass('bootstrap-sticky');Roo.select('html',true).setStyle('height','100%');}
19 A.cls+='bootstrap-sticky-'+this.sticky;}if(this.well.length){switch(this.well){case 'lg':case 'sm':A.cls+=' well well-'+this.well;break;default:A.cls+=' well';break;}}var B=A;if(this.panel.length){A.cls+='panel panel-'+this.panel;A.cn=[];if(this.header.length){A.cn.push({cls:'panel-heading',cn:[{tag:'h3',cls:'panel-title',html:this.header}]});}
20 B=false;A.cn.push({cls:'panel-body',html:this.html});if(this.footer.length){A.cn.push({cls:'panel-footer',html:this.footer});}}if(B){B.html=this.html||A.html;}if(!A.cls.length){A.cls='container';}return A;}});
21 //Roo/bootstrap/Form.js
22 Roo.bootstrap.Form=function(A){Roo.bootstrap.Form.superclass.constructor.call(this,A);this.addEvents({clientvalidation:true,rendered:true});};Roo.extend(Roo.bootstrap.Form,Roo.bootstrap.Component,{getAutoCreate:function(){var A={tag:'form',method:this.method||'POST',id:this.id||Roo.id(),cls:''};if(this.labelAlign=='left'){A.cls+=' form-horizontal';}return A;}});
23 //Roo/bootstrap/Img.js
24 Roo.bootstrap.Img=function(A){Roo.bootstrap.Img.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Img,Roo.bootstrap.Component,{imgResponsive:true,border:'',src:'',getAutoCreate:function(){cfg={tag:'img',cls:'img-responsive',html:null}
25 cfg.html=this.html||cfg.html;cfg.src=this.src||cfg.src;if(['rounded','circle','thumbnail'].indexOf(this.border)>-1){cfg.cls+=' img-'+this.border;}if(this.alt){cfg.alt=this.alt;}return cfg;}});
26 //Roo/bootstrap/Input.js
27 Roo.bootstrap.Input=function(A){Roo.bootstrap.Input.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Input,Roo.bootstrap.Component,{fieldLabel:'',inputType:'text',disabled:false,name:false,placeholder:false,before:false,after:false,getAutoCreate:function(){var A=this.parent();var B=A.labelAlign;var id=Roo.id();var C={cls:'form-group'};var D={tag:'input',id:id,type:this.inputType,cls:'form-control',placeholder:this.placeholder||''};if(this.name){D.name=name;}var E=D;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});}
28 E.cn.push(D);if(this.after){E.cn.push({tag:'span',cls:'input-group-addon',html:this.after});}}
29 Roo.log(B);Roo.log(this.fieldLabel.length);if(B==='left'&&this.fieldLabel.length){Roo.log("left and has label");C.cn=[{tag:'label','for':id,cls:'col-sm-2 control-label',html:this.fieldLabel},{cls:"col-sm-10",cn:[E]}];}else if(this.fieldLabel.length){Roo.log(" label");C.cn=[{tag:'label',html:this.fieldLabel},E];}else {Roo.log(" no label && no align");C.cn=[E];}if(this.disabled){D.disabled=true;}return C;},setDisabled:function(v){var i=this.el.select('input',true).dom;if(v){i.removeAttribute('disabled');return;}
30 i.setAttribute('disabled','true');}});
31 //Roo/bootstrap/Header.js
32 Roo.bootstrap.Header=function(A){Roo.bootstrap.Header.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Header,Roo.bootstrap.Component,{html:false,level:1,getAutoCreate:function(){var A={tag:'h'+(1*this.level),html:this.html||'fill in html'};return A;}});
33 //Roo/bootstrap/Menu.js
34 Roo.bootstrap.Menu=function(A){Roo.bootstrap.Menu.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Menu,Roo.bootstrap.Component,{triggerEl:false,type:false,getChildContainer:function(){return this.el;},getAutoCreate:function(){var A={tag:'ul',cls:'dropdown-menu'};if(this.type==='submenu'){A.cls='submenu active'}return A;},initEvents:function(){this.triggerEl.on('click',this.toggle,this);this.triggerEl.addClass('dropdown-toggle');},toggle:function(e){if(Roo.get(e.getTarget()).findParent('.dropdown-menu')){return;}var A=this.triggerEl.hasClass('open');this.clearMenus(e);this.triggerEl[A?'removeClass':'addClass']('open');this.triggerEl.focus();Roo.log(e);e.preventDefault();},clearMenus:function(){Roo.select('.dropdown-toggle',true).each(function(aa){if(!aa.hasClass('open')){return;}
35 aa.removeClass('open');})}});
36 //Roo/bootstrap/MenuItem.js
37 Roo.bootstrap.MenuItem=function(A){Roo.bootstrap.MenuItem.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MenuItem,Roo.bootstrap.Component,{href:false,html:false,getAutoCreate:function(){var A={tag:'li',cn:[{tag:'a',href:'#',html:'Link'}]};A.cn[0].href=this.href||A.cn[0].href;A.cn[0].html=this.html||A.cn[0].html;return A;}});
38 //Roo/bootstrap/MenuSeparator.js
39 Roo.bootstrap.MenuSeparator=function(A){Roo.bootstrap.MenuSeparator.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.MenuSeparator,Roo.bootstrap.Component,{getAutoCreate:function(){var A={cls:'divider',tag:'li'};return A;}});
40 //Roo/bootstrap/Modal.js
41 Roo.bootstrap.Modal=function(A){Roo.bootstrap.Modal.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Modal,Roo.bootstrap.Component,{title:'test dialog',buttons:false,onRender:function(ct,A){Roo.bootstrap.Component.superclass.onRender.call(this,ct,A);if(!this.el){var B=Roo.apply({},this.getAutoCreate());B.id=Roo.id();if(this.cls){B.cls+=' '+this.cls;}if(this.style){B.style=this.style;}
42 this.el=Roo.get(document.body).createChild(B,A);}if(this.tabIndex!==undefined){this.el.dom.setAttribute('tabIndex',this.tabIndex);}
43 this.initEvents();},getAutoCreate:function(){return {cls:"modal fade",cn:[{cls:"modal-dialog",cn:[{cls:"modal-content",cn:[{cls:'modal-header',cn:[{tag:'button',cls:'close',html:'&times'},{tag:'h4',cls:'modal-title',html:this.title}]},{cls:'modal-body'},{cls:'modal-footer'}]}]}]};},getChildContainer:function(){return this.el.select('.modal-body',true).first();},getButtonContainer:function(){return this.el.select('.modal-footer',true).first();},initEvents:function(){this.el.select('.modal-header .close').on('click',this.hide,this);},show:function(){this.el.addClass('on');this.el.removeClass('fade');this.el.setStyle('display','block');},hide:function(){this.el.removeClass('on');this.el.addClass('fade');this.el.setStyle('display','none');}});
44 //Roo/bootstrap/Navbar.js
45 Roo.bootstrap.Navbar=function(A){Roo.bootstrap.Navbar.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Navbar,Roo.bootstrap.Component,{sidebar:false,bar:false,brand:'',inverse:false,position:'',align:false,type:'nav',arrangement:'',getAutoCreate:function(){var A={cls:'navbar'};if(this.sidebar===true){A={tag:'div',cls:'sidebar-nav'};return A;}if(this.bar===true){A={tag:'nav',cls:'navbar',role:'navigation',cn:[{tag:'div',cls:'navbar-header',cn:[{tag:'button',type:'button',cls:'navbar-toggle','data-toggle':'collapse',cn:[{tag:'span',cls:'sr-only',html:'Toggle navigation'},{tag:'span',cls:'icon-bar'},{tag:'span',cls:'icon-bar'},{tag:'span',cls:'icon-bar'}]}]},{tag:'div',cls:'collapse navbar-collapse'}]};A.cls+=this.inverse?' navbar-inverse':' navbar-default';if(['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1){A.cls+=' navbar-'+this.position;A.tag=this.position=='fixed-bottom'?'footer':'header';}if(this.brand!==''){A.cn[0].cn.push({tag:'a',href:'#',cls:'navbar-brand',cn:[this.brand]});}return A;}else if(this.bar===false){}else {Roo.log('Property \'bar\' in of Navbar must be either true or false')}
46 A.cn=[{cls:'nav',tag:'ul'}];if(['tabs','pills'].indexOf(this.type)!==-1){A.cn[0].cls+=' nav-'+this.type}else {if(this.type!=='nav'){Roo.log('nav type must be nav/tabs/pills')}
47 A.cn[0].cls+=' navbar-nav'}if(['stacked','justified'].indexOf(this.arrangement)!==-1){A.cn[0].cls+=' nav-'+this.arrangement;}if(this.align==='right'){A.cn[0].cls+=' navbar-right';}if(this.inverse){A.cls+=' navbar-inverse';}return A;},getChildContainer:function(){if(this.bar===true){return this.el.select('.collapse',true).first();}
48 console.log(this);return this.el;}});
49 //Roo/bootstrap/NavGroup.js
50 Roo.bootstrap.NavGroup=function(A){Roo.bootstrap.NavGroup.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.NavGroup,Roo.bootstrap.Component,{align:'',inverse:false,form:false,getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));A={tag:'ul',cls:'nav navbar-nav'};if(this.parent().sidebar===true){A={tag:'ul',cls:'dashboard-menu'};return A;}if(this.form===true){A={tag:'form',cls:'navbar-form'};if(this.align==='right'){A.cls+=' navbar-right';}else {A.cls+=' navbar-left';}}if(this.align==='right'){A.cls+=' navbar-right';}if(this.inverse){A.cls+=' navbar-inverse';}return A;}});
51 //Roo/bootstrap/Navbar/Item.js
52 Roo.bootstrap.Navbar.Item=function(A){Roo.bootstrap.Navbar.Item.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Navbar.Item,Roo.bootstrap.Component,{href:false,html:'',badge:'',icon:false,glyphicon:false,getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Navbar.Item.superclass.getAutoCreate.call(this));if(this.parent().parent().sidebar===true){A={tag:'li',cls:'',cn:[{tag:'p',cls:''}]};if(this.html){A.cn[0].html=this.html;}if(this.active){this.cls+=' active';}if(this.menu){A.cn[0].cls+=' dropdown-toggle';A.cn[0].html=(A.cn[0].html||this.html)+'<span class="glyphicon glyphicon-chevron-down"></span>';}if(this.href){A.cn[0].tag='a',A.cn[0].href=this.href;}if(this.glyphicon){A.cn[0].html='<i class="glyphicon glyphicon-'+this.glyphicon+'"></i><span>'+A.cn[0].html||this.html+'</span>'}return A;}
53 A={tag:'li'}
54 A.cn=[{tag:'p',html:'Text'}];if(this.glyphicon){if(A.html){A.html=' '+this.html};A.cn=[{tag:'span',cls:'glyphicon glyphicon-'+this.glyphicon}];}
55 A.cn[0].html=this.html||A.cn[0].html;if(this.menu){A.cn[0].tag='a';A.cn[0].href='#';A.cn[0].html+=" <span class='caret'></span>";}else {A.cn[0].tag='a';A.cn[0].href=this.href||'#';A.cn[0].html=this.html;}if(this.badge!==''){A.cn[0].cn=[A.cn[0].html+' ',{tag:'span',cls:'badge',html:this.badge}];A.cn[0].html=''}return A;},initEvents:function(){this.el.select('a',true).on('click',function(e){this.fireEvent('click',this);},this);}});
56 //Roo/bootstrap/Row.js
57 Roo.bootstrap.Row=function(A){Roo.bootstrap.Row.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Row,Roo.bootstrap.Component,{autoCreate:{cls:'row clearfix'}});
58 //Roo/bootstrap/Element.js
59 Roo.bootstrap.Element=function(A){Roo.bootstrap.Element.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Element,Roo.bootstrap.Component,{tag:'div',cls:'',html:'',getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Element.superclass.getAutoCreate.call(this));A={tag:this.tag,cls:'',html:this.html};return A;}});
60 //Roo/bootstrap/Pagination.js
61 Roo.bootstrap.Pagination=function(A){Roo.bootstrap.Pagination.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Pagination,Roo.bootstrap.Component,{cls:false,size:false,inverse:false,from:1,to:4,align:false,active:1,getAutoCreate:function(){cfg={tag:'ul',cls:'pagination',cn:[]};if(this.inverse){cfg.cls+=' inverse';}if(this.html){cfg.html=this.html;}if(this.cls){cfg.cls=this.cls;}
62 cfg.cn[0]={tag:'li',cn:[{tag:'a',href:'#',html:'&laquo;'}]};var A=this.from>0?this.from:1;var to=this.to-A<=10?this.to:A+10;var B=this.active>=A&&this.active<=to?this.active:null;for(var i=A;i<=to;i++){cfg.cn.push({tag:'li',cls:B===i?'active':'',cn:[{tag:'a',href:'#',html:i}]});}
63 cfg.cn.push({tag:'li',cn:[{tag:'a',href:'#',html:'&raquo;'}]});return cfg;}});
64 //Roo/bootstrap/Slider.js
65 Roo.bootstrap.Slider=function(A){Roo.bootstrap.Slider.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Slider,Roo.bootstrap.Component,{getAutoCreate:function(){var A={tag:'div',cls:'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',cn:[{tag:'a',cls:'ui-slider-handle ui-state-default ui-corner-all'}]};return A;}});
66 //Roo/bootstrap/Table.js
67 Roo.bootstrap.Table=function(A){Roo.bootstrap.Table.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.Table,Roo.bootstrap.Component,{html:false,cls:false,getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.Table.superclass.getAutoCreate.call(this));A={tag:'table',cn:[{tag:'tbody'}]};if(this.html){A.html=this.html}if(this.cls){A.cls=this.cls}return A;}});
68 //Roo/bootstrap/TableCell.js
69 Roo.bootstrap.TableCell=function(A){Roo.bootstrap.TableCell.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.TableCell,Roo.bootstrap.Component,{getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));A={tag:'td'};if(this.html){A.html=this.html}if(this.cls){A.cls=this.cls}return A;}});
70 //Roo/bootstrap/TableRow.js
71 Roo.bootstrap.TableRow=function(A){Roo.bootstrap.TableRow.superclass.constructor.call(this,A);};Roo.extend(Roo.bootstrap.TableRow,Roo.bootstrap.Component,{getAutoCreate:function(){var A=Roo.apply({},Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));A={tag:'tr'};return A;}});