0
1
Fork 0
hedera-web-mindshore/package/usr/share/hedera-web/js/htk/field/radio.js

71 lines
1.2 KiB
JavaScript
Executable File

Htk.Radio = new Class
({
Extends: Htk.Field
,Tag: 'htk-radio'
,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
,initialize: function (props)
{
this.parent (props);
var radio = Vn.Browser.createRadio ('');
radio.checked = false;
radio.addEventListener ('change', this.onChange.bind (this));
this.node = radio;
}
,onChange: function ()
{
if (this.node.checked && this._radioGroup)
this._radioGroup.value = this.value;
}
,onRadioGroupChange: function ()
{
if (this._radioGroup.value && this._radioGroup.value == this.value)
this.node.checked = true;
else
this.node.checked = false;
}
,putValue: function (value)
{
if (!value)
this.node.value = '';
else
this.node.value = value;
}
,setEditable: function (editable)
{
this.node.disabled = !editable;
}
});