2016-09-26 09:28:47 +00:00
|
|
|
|
2018-05-16 09:36:42 +00:00
|
|
|
var htkRadioGroupUid = 0;
|
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2015-03-27 19:10:49 +00:00
|
|
|
Extends: Htk.Field
|
|
|
|
,Tag: 'htk-radio-group'
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,radioLock: false
|
|
|
|
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
|
|
|
this.clear ();
|
2015-11-09 08:14:33 +00:00
|
|
|
this.parent (props);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,clear: function ()
|
|
|
|
{
|
2018-05-16 09:36:42 +00:00
|
|
|
this.name = htkRadioGroupUid++;
|
2015-01-23 13:09:30 +00:00
|
|
|
this.buttons = [];
|
|
|
|
}
|
|
|
|
|
2018-05-16 09:36:42 +00:00
|
|
|
,createButton: function (value)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2018-05-16 09:36:42 +00:00
|
|
|
var button = Vn.Browser.createRadio (this.name, this.doc);
|
|
|
|
button.value = value;
|
|
|
|
button.radioGroup = this;
|
|
|
|
return button;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2018-05-16 09:36:42 +00:00
|
|
|
|
|
|
|
,removeButton: function (button)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2018-05-16 09:36:42 +00:00
|
|
|
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;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|