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',
53 getAutoCreate : function()
57 cls : 'roo-radio-set-label',
61 html : this.fieldLabel
66 if(this.indicatorpos == 'left'){
69 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
70 tooltip : 'This field is required'
75 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
76 tooltip : 'This field is required'
82 cls : 'roo-radio-set-items'
85 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
87 if (align === 'left' && this.fieldLabel.length) {
89 label.cls += ' col-md-' + this.labelWidth;
92 cls : "col-md-" + (12 - this.labelWidth),
101 cls : 'roo-radio-set',
105 cls : 'roo-radio-set-input',
108 value : this.value ? this.value : ''
115 if(this.weight.length){
116 cfg.cls += ' roo-radio-' + this.weight;
120 cfg.cls += ' roo-radio-set-inline';
127 initEvents : function()
129 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
130 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
132 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
134 if(!this.fieldLabel.length){
138 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
139 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
141 this.indicatorEl().hide();
143 this.originalValue = this.getValue();
149 return this.el.select('.roo-radio-set-input', true).first();
152 getChildContainer : function()
157 register : function(item)
159 this.radioes.push(item);
163 validate : function()
167 Roo.each(this.radioes, function(i){
176 if(this.disabled || this.allowBlank || valid){
186 markValid : function()
188 if(this.labelEl.isVisible(true)){
189 this.indicatorEl().hide();
192 this.el.removeClass([this.invalidClass, this.validClass]);
193 this.el.addClass(this.validClass);
195 this.fireEvent('valid', this);
198 markInvalid : function(msg)
200 if(this.allowBlank || this.disabled){
204 if(this.labelEl.isVisible(true)){
205 this.indicatorEl().show();
208 this.el.removeClass([this.invalidClass, this.validClass]);
209 this.el.addClass(this.invalidClass);
211 this.fireEvent('invalid', this, msg);
215 setValue : function(v, suppressEvent)
217 Roo.each(this.radioes, function(i){
220 i.el.removeClass('checked');
222 if(i.value === v || i.value.toString() === v.toString()){
224 i.el.addClass('checked');
226 if(suppressEvent !== true){
227 this.fireEvent('check', this, i);
233 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
237 clearInvalid : function(){
239 if(!this.el || this.preventMark){
243 if(this.labelEl.isVisible(true)){
244 this.indicatorEl().hide();
247 this.el.removeClass([this.invalidClass, this.validClass]);
249 this.fireEvent('valid', this);
254 Roo.apply(Roo.bootstrap.RadioSet, {
258 register : function(set)
260 this.groups[set.name] = set;
265 if (typeof(this.groups[name]) == 'undefined') {
269 return this.groups[name] ;