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