10 * @class Roo.bootstrap.RadioSet
11 * @extends Roo.bootstrap.Input
12 * Bootstrap RadioSet class
13 * @cfg {String} indicatorpos (left|right) default left
14 * @cfg {Boolean} inline (true|false) inline the element (default true)
15 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
17 * Create a new RadioSet
18 * @param {Object} config The config object
21 Roo.bootstrap.RadioSet = function(config){
23 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
27 Roo.bootstrap.RadioSet.register(this);
32 * Fires when the element is checked or unchecked.
33 * @param {Roo.bootstrap.RadioSet} this This radio
34 * @param {Roo.bootstrap.Radio} item The checked item
41 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
51 indicatorpos : 'left',
58 getAutoCreate : function()
62 cls : 'roo-radio-set-label',
66 html : this.fieldLabel
71 if(this.indicatorpos == 'left'){
74 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
75 tooltip : 'This field is required'
80 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
81 tooltip : 'This field is required'
87 cls : 'roo-radio-set-items'
90 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
92 if (align === 'left' && this.fieldLabel.length) {
95 cls : "roo-radio-set-right",
101 Roo.log(this.labelWidth);
103 if(this.labelWidth > 12){
104 label.style = "width: " + this.labelWidth + 'px';
107 if(this.labelWidth < 13 && this.labelmd == 0){
108 this.labelmd = this.labelWidth;
111 if(this.labellg > 0){
112 label.cls += ' col-lg-' + this.labellg;
113 items.cls += ' col-lg-' + (12 - this.labellg);
116 if(this.labelmd > 0){
117 label.cls += ' col-md-' + this.labelmd;
118 items.cls += ' col-md-' + (12 - this.labelmd);
121 if(this.labelsm > 0){
122 label.cls += ' col-sm-' + this.labelsm;
123 items.cls += ' col-sm-' + (12 - this.labelsm);
126 if(this.labelxs > 0){
127 label.cls += ' col-xs-' + this.labelxs;
128 items.cls += ' col-xs-' + (12 - this.labelxs);
134 cls : 'roo-radio-set',
138 cls : 'roo-radio-set-input',
141 value : this.value ? this.value : ''
148 if(this.weight.length){
149 cfg.cls += ' roo-radio-' + this.weight;
153 cfg.cls += ' roo-radio-set-inline';
160 initEvents : function()
162 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
163 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
165 if(!this.fieldLabel.length){
169 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
170 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
172 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
173 this.indicatorEl().hide();
175 this.originalValue = this.getValue();
181 return this.el.select('.roo-radio-set-input', true).first();
184 getChildContainer : function()
189 register : function(item)
191 this.radioes.push(item);
195 validate : function()
199 Roo.each(this.radioes, function(i){
208 if(this.disabled || this.allowBlank || valid){
218 markValid : function()
220 if(this.labelEl.isVisible(true)){
221 this.indicatorEl().hide();
224 this.el.removeClass([this.invalidClass, this.validClass]);
225 this.el.addClass(this.validClass);
227 this.fireEvent('valid', this);
230 markInvalid : function(msg)
232 if(this.allowBlank || this.disabled){
236 if(this.labelEl.isVisible(true)){
237 this.indicatorEl().show();
240 this.el.removeClass([this.invalidClass, this.validClass]);
241 this.el.addClass(this.invalidClass);
243 this.fireEvent('invalid', this, msg);
247 setValue : function(v, suppressEvent)
249 Roo.each(this.radioes, function(i){
252 i.el.removeClass('checked');
254 if(i.value === v || i.value.toString() === v.toString()){
256 i.el.addClass('checked');
258 if(suppressEvent !== true){
259 this.fireEvent('check', this, i);
265 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
269 clearInvalid : function(){
271 if(!this.el || this.preventMark){
275 if(this.labelEl.isVisible(true)){
276 this.indicatorEl().hide();
279 this.el.removeClass([this.invalidClass]);
281 this.fireEvent('valid', this);
286 Roo.apply(Roo.bootstrap.RadioSet, {
290 register : function(set)
292 this.groups[set.name] = set;
297 if (typeof(this.groups[name]) == 'undefined') {
301 return this.groups[name] ;