hedera-web/web/js/htk/field/radio-group.js

49 lines
923 B
JavaScript
Raw Normal View History

Htk.RadioGroup = new Class
({
Extends: Htk.Field
,Tag: 'htk-radio-group'
,radioLock: false
,initialize: function (props)
{
this.clear ();
this.on ('changed', this._onRadioGroupChange, this);
2015-11-09 08:14:33 +00:00
this.parent (props);
}
,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)
{
2015-03-06 23:33:54 +00:00
var radio = Vn.Browser.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;
}
});