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 : "roo-radio-set-right",
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 if(!this.fieldLabel.length){
136 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
137 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
139 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
140 this.indicatorEl().hide();
142 this.originalValue = this.getValue();
148 return this.el.select('.roo-radio-set-input', true).first();
151 getChildContainer : function()
156 register : function(item)
158 this.radioes.push(item);
162 validate : function()
166 Roo.each(this.radioes, function(i){
175 if(this.disabled || this.allowBlank || valid){
185 markValid : function()
187 if(this.labelEl.isVisible(true)){
188 this.indicatorEl().hide();
191 this.el.removeClass([this.invalidClass, this.validClass]);
192 this.el.addClass(this.validClass);
194 this.fireEvent('valid', this);
197 markInvalid : function(msg)
199 if(this.allowBlank || this.disabled){
203 if(this.labelEl.isVisible(true)){
204 this.indicatorEl().show();
207 this.el.removeClass([this.invalidClass, this.validClass]);
208 this.el.addClass(this.invalidClass);
210 this.fireEvent('invalid', this, msg);
214 setValue : function(v, suppressEvent)
216 Roo.each(this.radioes, function(i){
219 i.el.removeClass('checked');
221 if(i.value === v || i.value.toString() === v.toString()){
223 i.el.addClass('checked');
225 if(suppressEvent !== true){
226 this.fireEvent('check', this, i);
232 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
236 clearInvalid : function(){
238 if(!this.el || this.preventMark){
242 if(this.labelEl.isVisible(true)){
243 this.indicatorEl().hide();
246 this.el.removeClass([this.invalidClass]);
248 this.fireEvent('valid', this);
253 Roo.apply(Roo.bootstrap.RadioSet, {
257 register : function(set)
259 this.groups[set.name] = set;
264 if (typeof(this.groups[name]) == 'undefined') {
268 return this.groups[name] ;