forked from verdnatura/hedera-web
71 lines
1.2 KiB
JavaScript
Executable File
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)
|
|
{
|
|
var radio = Vn.Browser.createRadio ('');
|
|
radio.checked = false;
|
|
radio.addEventListener ('change', this._onChange.bind (this));
|
|
this.node = radio;
|
|
|
|
this.parent (props);
|
|
}
|
|
|
|
,_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;
|
|
}
|
|
});
|