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

49 lines
885 B
JavaScript
Executable File

Htk.RadioGroup = new Class
({
Extends: Vn.Param
,radioLock: false
,initialize: function (props)
{
this.parent (props);
this.clear ();
this.on ('changed', this.onRadioGroupChange, this);
}
,clear: function ()
{
this.name = Math.random ().toString ();
this.buttons = [];
}
,onRadioGroupChange: function ()
{
for (var i = 0; i < this.buttons.length; i++)
if (this.buttons[i].value == this._value)
this.buttons[i].checked = true;
}
,onRadioChange: function (value)
{
if (this.radioLock)
return;
this.radioLock = true;
this.value = value;
this.radioLock = false;
}
,createButton: function (value)
{
var radio = createRadio (this.name);
radio.value = value;
radio.checked = value == this.value;
radio.addEventListener ('change', this.onRadioChange.bind (this, value));
this.buttons.push (radio);
return radio;
}
});