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 if(this.labelWidth > 12){
95 label.style = "width: " + this.labelWidth + 'px';
98 if(this.labelWidth < 13 && this.labelmd == 0){
99 this.labelmd = this.labelWidth;
102 if(this.labellg > 0){
103 label.cls += ' col-lg-' + this.labellg;
104 items.cls += ' col-lg-' + (12 - this.labellg);
107 if(this.labelmd > 0){
108 label.cls += ' col-md-' + this.labelmd;
109 items.cls += ' col-md-' + (12 - this.labelmd);
112 if(this.labelsm > 0){
113 label.cls += ' col-sm-' + this.labelsm;
114 items.cls += ' col-sm-' + (12 - this.labelsm);
117 if(this.labelxs > 0){
118 label.cls += ' col-xs-' + this.labelxs;
119 items.cls += ' col-xs-' + (12 - this.labelxs);
125 cls : 'roo-radio-set',
129 cls : 'roo-radio-set-input',
132 value : this.value ? this.value : ''
139 if(this.weight.length){
140 cfg.cls += ' roo-radio-' + this.weight;
144 cfg.cls += ' roo-radio-set-inline';
151 initEvents : function()
153 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
154 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
156 if(!this.fieldLabel.length){
160 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
161 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
163 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
164 this.indicatorEl().hide();
166 this.originalValue = this.getValue();
172 return this.el.select('.roo-radio-set-input', true).first();
175 getChildContainer : function()
180 register : function(item)
182 this.radioes.push(item);
186 validate : function()
190 Roo.each(this.radioes, function(i){
199 if(this.allowBlank) {
203 if(this.disabled || 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){
271 this.el.removeClass([this.invalidClass]);
273 this.fireEvent('valid', this);
278 Roo.apply(Roo.bootstrap.RadioSet, {
282 register : function(set)
284 this.groups[set.name] = set;
289 if (typeof(this.groups[name]) == 'undefined') {
293 return this.groups[name] ;