forked from verdnatura/hedera-web
58 lines
982 B
JavaScript
58 lines
982 B
JavaScript
|
|
||
|
Htk.Radio = new Class
|
||
|
({
|
||
|
Extends: Vn.Object,
|
||
|
Implements: Vn.Param
|
||
|
,Tag: 'htk-radio'
|
||
|
|
||
|
,initialize: function (props)
|
||
|
{
|
||
|
this.parent (props);
|
||
|
this.rButton = new Array ();
|
||
|
this.uid = ++htkRadioUid;
|
||
|
}
|
||
|
|
||
|
,newRadio: function (value)
|
||
|
{
|
||
|
var radio;
|
||
|
var obj = this;
|
||
|
|
||
|
radio = createRadio (this.uid);
|
||
|
radio.value = value;
|
||
|
radio.checked = value == this.realValue;
|
||
|
radio.addEventListener ('change',
|
||
|
function () { obj.radioChanged (this._value); }, false);
|
||
|
this.rButton.push (radio);
|
||
|
|
||
|
return radio;
|
||
|
}
|
||
|
|
||
|
,radioChanged: function (value)
|
||
|
{
|
||
|
this.realValue = value;
|
||
|
this.signalEmit ('changed');
|
||
|
}
|
||
|
|
||
|
,setRealValue: function (value)
|
||
|
{
|
||
|
var rButton = this.rButton;
|
||
|
|
||
|
for (var n = 0; n < rButton.length; n++)
|
||
|
{
|
||
|
if (rButton[n].value == value)
|
||
|
{
|
||
|
rButton[n].checked = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
,setEditable: function (editable)
|
||
|
{
|
||
|
var rButton = this.rButton;
|
||
|
|
||
|
for (var n = 0; n < rButton.length; n++)
|
||
|
rButton[n].disabled = !editable;
|
||
|
}
|
||
|
});
|