2015-01-23 13:09:30 +00:00
|
|
|
Htk.Radio = new Class
|
|
|
|
({
|
2015-03-27 19:10:49 +00:00
|
|
|
Extends: Htk.Field
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'htk-radio'
|
2015-03-27 19:10:49 +00:00
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
tip:
|
|
|
|
{
|
|
|
|
type: String
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
if (x)
|
|
|
|
this.node.title = _(x);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
radioGroup:
|
|
|
|
{
|
|
|
|
type: Htk.RadioGroup
|
|
|
|
,set: function (x)
|
|
|
|
{
|
|
|
|
this.link ({_radioGroup: x}, {'changed': this.onRadioGroupChange});
|
|
|
|
this.node.name = x.name
|
|
|
|
this.onRadioGroupChange ();
|
|
|
|
}
|
|
|
|
,get: function ()
|
|
|
|
{
|
|
|
|
return this._radioGroup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
,_radioGroup: null
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
|
|
|
this.parent (props);
|
2015-03-27 19:10:49 +00:00
|
|
|
|
|
|
|
var radio = Vn.Browser.createRadio ('');
|
|
|
|
radio.checked = false;
|
|
|
|
radio.addEventListener ('change', this.onChange.bind (this));
|
|
|
|
this.node = radio;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
,onChange: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
if (this.node.checked && this._radioGroup)
|
|
|
|
this._radioGroup.value = this.value;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
|
|
|
|
,onRadioGroupChange: function ()
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
if (this._radioGroup.value == this.value)
|
|
|
|
this.node.checked = true;
|
|
|
|
else
|
|
|
|
this.node.checked = false;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
,putValue: function (value)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
if (!value)
|
|
|
|
this.node.value = '';
|
|
|
|
else
|
|
|
|
this.node.value = value;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setEditable: function (editable)
|
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
this.node.disabled = !editable;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|