mj-context-menu
Version:
A generic context menu
35 lines • 1.25 kB
JavaScript
import { AbstractVariableItem } from './abstract_variable_item.js';
import * as MenuUtil from './menu_util.js';
import { HtmlClasses } from './html_classes.js';
export class Radio extends AbstractVariableItem {
static fromJson(_factory, { content: content, variable: variable, id: id }, menu) {
return new this(menu, content, variable, id);
}
constructor(menu, content, variable, id) {
super(menu, 'radio', content, id);
this.role = 'menuitemradio';
this.variable = menu.pool.lookup(variable);
this.register();
}
executeAction() {
this.variable.setValue(this.id);
MenuUtil.close(this);
}
generateSpan() {
this.span = document.createElement('span');
this.span.textContent = '\u2713';
this.span.classList.add(HtmlClasses['MENURADIOCHECK']);
this.span.setAttribute('aria-hidden', 'true');
}
updateAria() {
this.html.setAttribute('aria-checked', this.variable.getValue() === this.id ? 'true' : 'false');
}
updateSpan() {
this.span.style.display =
this.variable.getValue() === this.id ? '' : 'none';
}
toJson() {
return { type: '' };
}
}
//# sourceMappingURL=item_radio.js.map