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, {
49 indicatorpos : 'left',
51 getAutoCreate : function()
55 cls : 'roo-radio-set-label',
59 html : this.fieldLabel
64 if(this.indicatorpos == 'left'){
67 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
68 tooltip : 'This field is required'
73 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
74 tooltip : 'This field is required'
80 cls : 'roo-radio-set-items'
83 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
85 if (align === 'left' && this.fieldLabel.length) {
88 cls : "roo-radio-set-right",
94 Roo.log(this.labelmd);
96 if(this.labelWidth > 12){
97 label.style = "width: " + this.labelWidth + 'px';
100 if(this.labelWidth < 13 && this.labelmd == 0){
101 this.labelmd = this.labelWidth;
104 if(this.labellg > 0){
105 label.cls += ' col-lg-' + this.labellg;
106 items.cls += ' col-lg-' + (12 - this.labellg);
109 if(this.labelmd > 0){
110 label.cls += ' col-md-' + this.labelmd;
111 items.cls += ' col-md-' + (12 - this.labelmd);
114 if(this.labelsm > 0){
115 label.cls += ' col-sm-' + this.labelsm;
116 items.cls += ' col-sm-' + (12 - this.labelsm);
119 if(this.labelxs > 0){
120 label.cls += ' col-xs-' + this.labelxs;
121 items.cls += ' col-xs-' + (12 - this.labelxs);
127 cls : 'roo-radio-set',
131 cls : 'roo-radio-set-input',
134 value : this.value ? this.value : ''
141 if(this.weight.length){
142 cfg.cls += ' roo-radio-' + this.weight;
146 cfg.cls += ' roo-radio-set-inline';
153 initEvents : function()
155 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
156 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
158 if(!this.fieldLabel.length){
162 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
163 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
165 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
166 this.indicatorEl().hide();
168 this.originalValue = this.getValue();
174 return this.el.select('.roo-radio-set-input', true).first();
177 getChildContainer : function()
182 register : function(item)
184 this.radioes.push(item);
188 validate : function()
192 Roo.each(this.radioes, function(i){
201 if(this.disabled || this.allowBlank || valid){
211 markValid : function()
213 if(this.labelEl.isVisible(true)){
214 this.indicatorEl().hide();
217 this.el.removeClass([this.invalidClass, this.validClass]);
218 this.el.addClass(this.validClass);
220 this.fireEvent('valid', this);
223 markInvalid : function(msg)
225 if(this.allowBlank || this.disabled){
229 if(this.labelEl.isVisible(true)){
230 this.indicatorEl().show();
233 this.el.removeClass([this.invalidClass, this.validClass]);
234 this.el.addClass(this.invalidClass);
236 this.fireEvent('invalid', this, msg);
240 setValue : function(v, suppressEvent)
242 Roo.each(this.radioes, function(i){
245 i.el.removeClass('checked');
247 if(i.value === v || i.value.toString() === v.toString()){
249 i.el.addClass('checked');
251 if(suppressEvent !== true){
252 this.fireEvent('check', this, i);
258 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
262 clearInvalid : function(){
264 if(!this.el || this.preventMark){
268 if(this.labelEl.isVisible(true)){
269 this.indicatorEl().hide();
272 this.el.removeClass([this.invalidClass]);
274 this.fireEvent('valid', this);
279 Roo.apply(Roo.bootstrap.RadioSet, {
283 register : function(set)
285 this.groups[set.name] = set;
290 if (typeof(this.groups[name]) == 'undefined') {
294 return this.groups[name] ;