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 Roo.log(this.labelmd);
91 cls : "roo-radio-set-right",
97 if(this.labelWidth > 12){
98 label.style = "width: " + this.labelWidth + 'px';
101 if(this.labelWidth < 13 && this.labelmd == 0){
102 this.labelmd = this.labelWidth;
105 if(this.labellg > 0){
106 label.cls += ' col-lg-' + this.labellg;
107 items.cls += ' col-lg-' + (12 - this.labellg);
110 if(this.labelmd > 0){
111 label.cls += ' col-md-' + this.labelmd;
112 items.cls += ' col-md-' + (12 - this.labelmd);
115 if(this.labelsm > 0){
116 label.cls += ' col-sm-' + this.labelsm;
117 items.cls += ' col-sm-' + (12 - this.labelsm);
120 if(this.labelxs > 0){
121 label.cls += ' col-xs-' + this.labelxs;
122 items.cls += ' col-xs-' + (12 - this.labelxs);
128 cls : 'roo-radio-set',
132 cls : 'roo-radio-set-input',
135 value : this.value ? this.value : ''
142 if(this.weight.length){
143 cfg.cls += ' roo-radio-' + this.weight;
147 cfg.cls += ' roo-radio-set-inline';
154 initEvents : function()
156 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
157 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
159 if(!this.fieldLabel.length){
163 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
164 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
166 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
167 this.indicatorEl().hide();
169 this.originalValue = this.getValue();
175 return this.el.select('.roo-radio-set-input', true).first();
178 getChildContainer : function()
183 register : function(item)
185 this.radioes.push(item);
189 validate : function()
193 Roo.each(this.radioes, function(i){
202 if(this.disabled || this.allowBlank || valid){
212 markValid : function()
214 if(this.labelEl.isVisible(true)){
215 this.indicatorEl().hide();
218 this.el.removeClass([this.invalidClass, this.validClass]);
219 this.el.addClass(this.validClass);
221 this.fireEvent('valid', this);
224 markInvalid : function(msg)
226 if(this.allowBlank || this.disabled){
230 if(this.labelEl.isVisible(true)){
231 this.indicatorEl().show();
234 this.el.removeClass([this.invalidClass, this.validClass]);
235 this.el.addClass(this.invalidClass);
237 this.fireEvent('invalid', this, msg);
241 setValue : function(v, suppressEvent)
243 Roo.each(this.radioes, function(i){
246 i.el.removeClass('checked');
248 if(i.value === v || i.value.toString() === v.toString()){
250 i.el.addClass('checked');
252 if(suppressEvent !== true){
253 this.fireEvent('check', this, i);
259 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
263 clearInvalid : function(){
265 if(!this.el || this.preventMark){
269 if(this.labelEl.isVisible(true)){
270 this.indicatorEl().hide();
273 this.el.removeClass([this.invalidClass]);
275 this.fireEvent('valid', this);
280 Roo.apply(Roo.bootstrap.RadioSet, {
284 register : function(set)
286 this.groups[set.name] = set;
291 if (typeof(this.groups[name]) == 'undefined') {
295 return this.groups[name] ;