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
39 * Fires when the element is click.
40 * @param {Roo.bootstrap.RadioSet} this This radio set
41 * @param {Roo.bootstrap.Radio} item The checked item
42 * @param {Roo.EventObject} e The event object
49 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
57 indicatorpos : 'left',
59 getAutoCreate : function()
63 cls : 'roo-radio-set-label',
67 html : this.fieldLabel
72 if(this.indicatorpos == 'left'){
75 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
76 tooltip : 'This field is required'
81 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
82 tooltip : 'This field is required'
88 cls : 'roo-radio-set-items'
91 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
93 if (align === 'left' && this.fieldLabel.length) {
96 cls : "roo-radio-set-right",
102 if(this.labelWidth > 12){
103 label.style = "width: " + this.labelWidth + 'px';
106 if(this.labelWidth < 13 && this.labelmd == 0){
107 this.labelmd = this.labelWidth;
110 if(this.labellg > 0){
111 label.cls += ' col-lg-' + this.labellg;
112 items.cls += ' col-lg-' + (12 - this.labellg);
115 if(this.labelmd > 0){
116 label.cls += ' col-md-' + this.labelmd;
117 items.cls += ' col-md-' + (12 - this.labelmd);
120 if(this.labelsm > 0){
121 label.cls += ' col-sm-' + this.labelsm;
122 items.cls += ' col-sm-' + (12 - this.labelsm);
125 if(this.labelxs > 0){
126 label.cls += ' col-xs-' + this.labelxs;
127 items.cls += ' col-xs-' + (12 - this.labelxs);
133 cls : 'roo-radio-set',
137 cls : 'roo-radio-set-input',
140 value : this.value ? this.value : ''
147 if(this.weight.length){
148 cfg.cls += ' roo-radio-' + this.weight;
152 cfg.cls += ' roo-radio-set-inline';
156 ['xs','sm','md','lg'].map(function(size){
157 if (settings[size]) {
158 cfg.cls += ' col-' + size + '-' + settings[size];
166 initEvents : function()
168 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
169 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
171 if(!this.fieldLabel.length){
175 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
176 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
178 this.indicator = this.indicatorEl();
181 this.indicator.addClass('invisible');
184 this.originalValue = this.getValue();
190 return this.el.select('.roo-radio-set-input', true).first();
193 getChildContainer : function()
198 register : function(item)
200 this.radioes.push(item);
204 validate : function()
206 if(this.getVisibilityEl().hasClass('hidden')){
212 Roo.each(this.radioes, function(i){
221 if(this.allowBlank) {
225 if(this.disabled || valid){
235 markValid : function()
237 if(this.labelEl.isVisible(true)){
238 this.indicatorEl().removeClass('visible');
239 this.indicatorEl().addClass('invisible');
242 this.el.removeClass([this.invalidClass, this.validClass]);
243 this.el.addClass(this.validClass);
245 this.fireEvent('valid', this);
248 markInvalid : function(msg)
250 if(this.allowBlank || this.disabled){
254 if(this.labelEl.isVisible(true)){
255 this.indicatorEl().removeClass('invisible');
256 this.indicatorEl().addClass('visible');
259 this.el.removeClass([this.invalidClass, this.validClass]);
260 this.el.addClass(this.invalidClass);
262 this.fireEvent('invalid', this, msg);
266 setValue : function(v, suppressEvent)
268 if(this.value === v){
275 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
278 Roo.each(this.radioes, function(i){
280 i.el.removeClass('checked');
283 Roo.each(this.radioes, function(i){
285 if(i.value === v || i.value.toString() === v.toString()){
287 i.el.addClass('checked');
289 if(suppressEvent !== true){
290 this.fireEvent('check', this, i);
301 clearInvalid : function(){
303 if(!this.el || this.preventMark){
307 this.el.removeClass([this.invalidClass]);
309 this.fireEvent('valid', this);
314 Roo.apply(Roo.bootstrap.RadioSet, {
318 register : function(set)
320 this.groups[set.name] = set;
325 if (typeof(this.groups[name]) == 'undefined') {
329 return this.groups[name] ;