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.log('run radio set...');
26 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
30 Roo.bootstrap.RadioSet.register(this);
35 * Fires when the element is checked or unchecked.
36 * @param {Roo.bootstrap.RadioSet} this This radio
37 * @param {Roo.bootstrap.Radio} item The checked item
44 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
54 indicatorpos : 'left',
56 getAutoCreate : function()
60 cls : 'roo-radio-set-label',
64 html : this.fieldLabel
69 if(this.indicatorpos == 'left'){
72 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
73 tooltip : 'This field is required'
78 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
79 tooltip : 'This field is required'
85 cls : 'roo-radio-set-items'
88 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
90 if (align === 'left' && this.fieldLabel.length) {
92 label.cls += ' col-md-' + this.labelWidth;
95 cls : "roo-radio-set-right col-md-" + (12 - this.labelWidth),
104 cls : 'roo-radio-set',
108 cls : 'roo-radio-set-input',
111 value : this.value ? this.value : ''
118 if(this.weight.length){
119 cfg.cls += ' roo-radio-' + this.weight;
123 cfg.cls += ' roo-radio-set-inline';
130 initEvents : function()
132 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
133 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
135 if(!this.fieldLabel.length){
139 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
140 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
142 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
143 this.indicatorEl().hide();
145 this.originalValue = this.getValue();
151 return this.el.select('.roo-radio-set-input', true).first();
154 getChildContainer : function()
159 register : function(item)
161 this.radioes.push(item);
165 validate : function()
169 Roo.each(this.radioes, function(i){
178 if(this.disabled || this.allowBlank || valid){
188 markValid : function()
190 if(this.labelEl.isVisible(true)){
191 this.indicatorEl().hide();
194 this.el.removeClass([this.invalidClass, this.validClass]);
195 this.el.addClass(this.validClass);
197 this.fireEvent('valid', this);
200 markInvalid : function(msg)
202 if(this.allowBlank || this.disabled){
206 if(this.labelEl.isVisible(true)){
207 this.indicatorEl().show();
210 this.el.removeClass([this.invalidClass, this.validClass]);
211 this.el.addClass(this.invalidClass);
213 this.fireEvent('invalid', this, msg);
217 setValue : function(v, suppressEvent)
219 Roo.each(this.radioes, function(i){
222 i.el.removeClass('checked');
224 if(i.value === v || i.value.toString() === v.toString()){
226 i.el.addClass('checked');
228 if(suppressEvent !== true){
229 this.fireEvent('check', this, i);
235 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
239 clearInvalid : function(){
241 if(!this.el || this.preventMark){
245 if(this.labelEl.isVisible(true)){
246 this.indicatorEl().hide();
249 this.el.removeClass([this.invalidClass]);
251 this.fireEvent('valid', this);
256 Roo.apply(Roo.bootstrap.RadioSet, {
260 register : function(set)
262 this.groups[set.name] = set;
267 if (typeof(this.groups[name]) == 'undefined') {
271 return this.groups[name] ;