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

44 lines
823 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var htkRadioGroupUid = 0;
2022-06-06 08:53:59 +00:00
module.exports = new Class({
Extends: Htk.Field
,Tag: 'htk-radio-group'
2022-11-16 01:46:44 +00:00
,initialize(props) {
2022-06-06 08:53:59 +00:00
this.clear();
2022-06-06 16:02:17 +00:00
Htk.Field.prototype.initialize.call(this, props);
}
2022-11-16 01:46:44 +00:00
,clear() {
this.name = htkRadioGroupUid++;
this.buttons = [];
}
2022-11-16 01:46:44 +00:00
,createButton(value) {
2022-06-06 08:53:59 +00:00
var button = Vn.Browser.createRadio(this.name, this.doc);
button.value = value;
button.radioGroup = this;
return button;
}
2022-11-16 01:46:44 +00:00
,removeButton(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
*/
2022-11-16 01:46:44 +00:00
,isSelected() {
for (var i = 0; i < this.buttons.length; i++)
if (this.buttons[i].value == this.value)
return true;
return false;
}
});