major doc changes
[roojs1] / Roo / bootstrap / form / Radio.js
1 /*
2  * - LGPL
3  *
4  * RadioItem
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.form.Radio
10  * @extends Roo.bootstrap.Component
11  * Bootstrap Radio class
12  * @cfg {String} boxLabel - the label associated
13  * @cfg {String} value - the value of radio
14  * 
15  * @constructor
16  * Create a new Radio
17  * @param {Object} config The config object
18  */
19 Roo.bootstrap.form.Radio = function(config){
20     Roo.bootstrap.form.Radio.superclass.constructor.call(this, config);
21     
22 };
23
24 Roo.extend(Roo.bootstrap.form.Radio, Roo.bootstrap.Component, {
25     
26     boxLabel : '',
27     
28     value : '',
29     
30     getAutoCreate : function()
31     {
32         var cfg = {
33             tag : 'div',
34             cls : 'form-group radio',
35             cn : [
36                 {
37                     tag : 'label',
38                     cls : 'box-label',
39                     html : this.boxLabel
40                 }
41             ]
42         };
43         
44         return cfg;
45     },
46     
47     initEvents : function() 
48     {
49         this.parent().register(this);
50         
51         this.el.on('click', this.onClick, this);
52         
53     },
54     
55     onClick : function(e)
56     {
57         if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
58             this.setChecked(true);
59         }
60     },
61     
62     setChecked : function(state, suppressEvent)
63     {
64         this.parent().setValue(this.value, suppressEvent);
65         
66     },
67     
68     setBoxLabel : function(v)
69     {
70         this.boxLabel = v;
71         
72         if(this.rendered){
73             this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
74         }
75     }
76     
77 });
78  
79
80