major doc changes
[roojs1] / Roo / bootstrap / ButtonGroup.js
1 /*
2  * - LGPL
3  *
4  * button group
5  * 
6  */
7
8
9 /**
10  * @class Roo.bootstrap.ButtonGroup
11  * @extends Roo.bootstrap.Component
12  * Bootstrap ButtonGroup class
13  * @children Roo.bootstrap.Button Roo.bootstrap.form.Form
14  * 
15  * @cfg {String} size lg | sm | xs (default empty normal)
16  * @cfg {String} align vertical | justified  (default none)
17  * @cfg {String} direction up | down (default down)
18  * @cfg {Boolean} toolbar false | true
19  * @cfg {Boolean} btn true | false
20  * 
21  * 
22  * @constructor
23  * Create a new Input
24  * @param {Object} config The config object
25  */
26
27 Roo.bootstrap.ButtonGroup = function(config){
28     Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
29 };
30
31 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component,  {
32     
33     size: '',
34     align: '',
35     direction: '',
36     toolbar: false,
37     btn: true,
38
39     getAutoCreate : function(){
40         var cfg = {
41             cls: 'btn-group',
42             html : null
43         };
44         
45         cfg.html = this.html || cfg.html;
46         
47         if (this.toolbar) {
48             cfg = {
49                 cls: 'btn-toolbar',
50                 html: null
51             };
52             
53             return cfg;
54         }
55         
56         if (['vertical','justified'].indexOf(this.align)!==-1) {
57             cfg.cls = 'btn-group-' + this.align;
58             
59             if (this.align == 'justified') {
60                 console.log(this.items);
61             }
62         }
63         
64         if (['lg','sm','xs'].indexOf(this.size)!==-1) {
65             cfg.cls += ' btn-group-' + this.size;
66         }
67         
68         if (this.direction == 'up') {
69             cfg.cls += ' dropup' ;
70         }
71         
72         return cfg;
73     },
74     /**
75      * Add a button to the group (similar to NavItem API.)
76      */
77     addItem : function(cfg)
78     {
79         var cn = new Roo.bootstrap.Button(cfg);
80         //this.register(cn);
81         cn.parentId = this.id;
82         cn.onRender(this.el, null);
83         return cn;
84     }
85    
86 });
87
88