Roo.bootstrap.RadioSet = function(config){
Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
-
-
this.radioes = [];
* @param {Roo.bootstrap.RadioSet} this This radio
* @param {Roo.bootstrap.Radio} item The checked item
*/
- check : true
+ check : true,
+ /**
+ * @event click
+ * Fires when the element is click.
+ * @param {Roo.bootstrap.RadioSet} this This radio set
+ * @param {Roo.bootstrap.Radio} item The checked item
+ * @param {Roo.EventObject} e The event object
+ */
+ click : true
});
};
weight : '',
- fieldLabel : '',
-
indicatorpos : 'left',
getAutoCreate : function()
}
]
};
-
- if(this.indicatorpos == 'left'){
- label.cn.unshift({
- tag : 'i',
- cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
- tooltip : 'This field is required'
- });
- } else {
- label.cn.push({
- tag : 'i',
- cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
- tooltip : 'This field is required'
- });
+ if (Roo.bootstrap.version == 3) {
+
+
+ if(this.indicatorpos == 'left'){
+ label.cn.unshift({
+ tag : 'i',
+ cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
+ tooltip : 'This field is required'
+ });
+ } else {
+ label.cn.push({
+ tag : 'i',
+ cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
+ tooltip : 'This field is required'
+ });
+ }
}
-
var items = {
tag : 'div',
cls : 'roo-radio-set-items'
if (align === 'left' && this.fieldLabel.length) {
- label.cls += ' col-md-' + this.labelWidth;
-
items = {
- cls : "roo-radio-set-right col-md-" + (12 - this.labelWidth),
+ cls : "roo-radio-set-right",
cn: [
items
]
};
+
+ if(this.labelWidth > 12){
+ label.style = "width: " + this.labelWidth + 'px';
+ }
+
+ if(this.labelWidth < 13 && this.labelmd == 0){
+ this.labelmd = this.labelWidth;
+ }
+
+ if(this.labellg > 0){
+ label.cls += ' col-lg-' + this.labellg;
+ items.cls += ' col-lg-' + (12 - this.labellg);
+ }
+
+ if(this.labelmd > 0){
+ label.cls += ' col-md-' + this.labelmd;
+ items.cls += ' col-md-' + (12 - this.labelmd);
+ }
+
+ if(this.labelsm > 0){
+ label.cls += ' col-sm-' + this.labelsm;
+ items.cls += ' col-sm-' + (12 - this.labelsm);
+ }
+
+ if(this.labelxs > 0){
+ label.cls += ' col-xs-' + this.labelxs;
+ items.cls += ' col-xs-' + (12 - this.labelxs);
+ }
}
var cfg = {
{
tag : 'input',
cls : 'roo-radio-set-input',
- type : 'text',
+ type : 'hidden',
name : this.name,
value : this.value ? this.value : ''
},
cfg.cls += ' roo-radio-set-inline';
}
+ var settings=this;
+ ['xs','sm','md','lg'].map(function(size){
+ if (settings[size]) {
+ cfg.cls += ' col-' + size + '-' + settings[size];
+ }
+ });
+
return cfg;
},
this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
- this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
- this.indicatorEl().hide();
+ this.indicator = this.indicatorEl();
+
+ if(this.indicator){
+ this.indicator.addClass('invisible');
+ }
this.originalValue = this.getValue();
validate : function()
{
+ if(this.getVisibilityEl().hasClass('hidden')){
+ return true;
+ }
+
var valid = false;
Roo.each(this.radioes, function(i){
return false;
});
- if(this.disabled || this.allowBlank || valid){
+ if(this.allowBlank) {
+ return true;
+ }
+
+ if(this.disabled || valid){
this.markValid();
return true;
}
markValid : function()
{
- if(this.labelEl.isVisible(true)){
- this.indicatorEl().hide();
+ if(this.labelEl.isVisible(true) && this.indicatorEl()){
+ this.indicatorEl().removeClass('visible');
+ this.indicatorEl().addClass('invisible');
}
- this.el.removeClass([this.invalidClass, this.validClass]);
- this.el.addClass(this.validClass);
+ if (Roo.bootstrap.version == 3) {
+ this.el.removeClass([this.invalidClass, this.validClass]);
+ this.el.addClass(this.validClass);
+ } else {
+ this.el.removeClass(['is-invalid','is-valid']);
+ this.el.addClass(['is-valid']);
+ }
this.fireEvent('valid', this);
},
return;
}
- if(this.labelEl.isVisible(true)){
- this.indicatorEl().show();
+ if(this.labelEl.isVisible(true) && this.indicatorEl()){
+ this.indicatorEl().removeClass('invisible');
+ this.indicatorEl().addClass('visible');
+ }
+ if (Roo.bootstrap.version == 3) {
+ this.el.removeClass([this.invalidClass, this.validClass]);
+ this.el.addClass(this.invalidClass);
+ } else {
+ this.el.removeClass(['is-invalid','is-valid']);
+ this.el.addClass(['is-invalid']);
}
-
- this.el.removeClass([this.invalidClass, this.validClass]);
- this.el.addClass(this.invalidClass);
this.fireEvent('invalid', this, msg);
setValue : function(v, suppressEvent)
{
+ if(this.value === v){
+ return;
+ }
+
+ this.value = v;
+
+ if(this.rendered){
+ this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
+ }
+
Roo.each(this.radioes, function(i){
-
i.checked = false;
i.el.removeClass('checked');
+ });
+
+ Roo.each(this.radioes, function(i){
if(i.value === v || i.value.toString() === v.toString()){
i.checked = true;
if(suppressEvent !== true){
this.fireEvent('check', this, i);
}
+
+ return false;
}
}, this);
- Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
-
+ this.validate();
},
clearInvalid : function(){
return;
}
- if(this.labelEl.isVisible(true)){
- this.indicatorEl().hide();
- }
-
this.el.removeClass([this.invalidClass]);
this.fireEvent('valid', this);