51 lines
877 B
JavaScript
51 lines
877 B
JavaScript
|
|
var htkRadioGroupUid = 0;
|
|
|
|
module.exports = new Class
|
|
({
|
|
Extends: Htk.Field
|
|
,Tag: 'htk-radio-group'
|
|
|
|
,radioLock: false
|
|
|
|
,initialize: function (props)
|
|
{
|
|
this.clear ();
|
|
this.parent (props);
|
|
}
|
|
|
|
,clear: function ()
|
|
{
|
|
this.name = htkRadioGroupUid++;
|
|
this.buttons = [];
|
|
}
|
|
|
|
,createButton: function (value)
|
|
{
|
|
var button = Vn.Browser.createRadio (this.name, this.doc);
|
|
button.value = value;
|
|
button.radioGroup = this;
|
|
return button;
|
|
}
|
|
|
|
,removeButton: function (button)
|
|
{
|
|
for (var i = 0; i < this.buttons.length; i++)
|
|
if (this.buttons === button) {
|
|
this.buttons.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return %true if there is an option selected, otherwise it returns %false
|
|
*/
|
|
,isSelected: function () {
|
|
for (var i = 0; i < this.buttons.length; i++)
|
|
if (this.buttons[i].value == this.value)
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
});
|