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) {
90 cls : "roo-radio-set-right",
96 Roo.log(this.labelmd);
98 if(this.labelWidth > 12){
99 label.style = "width: " + this.labelWidth + 'px';
102 if(this.labelWidth < 13 && this.labelmd == 0){
103 this.labelmd = this.labelWidth;
106 if(this.labellg > 0){
107 label.cls += ' col-lg-' + this.labellg;
108 items.cls += ' col-lg-' + (12 - this.labellg);
111 if(this.labelmd > 0){
112 label.cls += ' col-md-' + this.labelmd;
113 items.cls += ' col-md-' + (12 - this.labelmd);
116 if(this.labelsm > 0){
117 label.cls += ' col-sm-' + this.labelsm;
118 items.cls += ' col-sm-' + (12 - this.labelsm);
121 if(this.labelxs > 0){
122 label.cls += ' col-xs-' + this.labelxs;
123 items.cls += ' col-xs-' + (12 - this.labelxs);
129 cls : 'roo-radio-set',
133 cls : 'roo-radio-set-input',
136 value : this.value ? this.value : ''
143 if(this.weight.length){
144 cfg.cls += ' roo-radio-' + this.weight;
148 cfg.cls += ' roo-radio-set-inline';
155 initEvents : function()
157 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
158 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
160 if(!this.fieldLabel.length){
164 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
165 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
167 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
168 this.indicatorEl().hide();
170 this.originalValue = this.getValue();
176 return this.el.select('.roo-radio-set-input', true).first();
179 getChildContainer : function()
184 register : function(item)
186 this.radioes.push(item);
190 validate : function()
194 Roo.each(this.radioes, function(i){
203 if(this.disabled || this.allowBlank || valid){
213 markValid : function()
215 if(this.labelEl.isVisible(true)){
216 this.indicatorEl().hide();
219 this.el.removeClass([this.invalidClass, this.validClass]);
220 this.el.addClass(this.validClass);
222 this.fireEvent('valid', this);
225 markInvalid : function(msg)
227 if(this.allowBlank || this.disabled){
231 if(this.labelEl.isVisible(true)){
232 this.indicatorEl().show();
235 this.el.removeClass([this.invalidClass, this.validClass]);
236 this.el.addClass(this.invalidClass);
238 this.fireEvent('invalid', this, msg);
242 setValue : function(v, suppressEvent)
244 Roo.each(this.radioes, function(i){
247 i.el.removeClass('checked');
249 if(i.value === v || i.value.toString() === v.toString()){
251 i.el.addClass('checked');
253 if(suppressEvent !== true){
254 this.fireEvent('check', this, i);
260 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
264 clearInvalid : function(){
266 if(!this.el || this.preventMark){
270 if(this.labelEl.isVisible(true)){
271 this.indicatorEl().hide();
274 this.el.removeClass([this.invalidClass]);
276 this.fireEvent('valid', this);
281 Roo.apply(Roo.bootstrap.RadioSet, {
285 register : function(set)
287 this.groups[set.name] = set;
292 if (typeof(this.groups[name]) == 'undefined') {
296 return this.groups[name] ;