item_radio.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. exports.Radio = void 0;
  17. var abstract_variable_item_js_1 = require("./abstract_variable_item.js");
  18. var menu_util_js_1 = require("./menu_util.js");
  19. var html_classes_js_1 = require("./html_classes.js");
  20. var Radio = (function (_super) {
  21. __extends(Radio, _super);
  22. function Radio(menu, content, variable, id) {
  23. var _this = _super.call(this, menu, 'radio', content, id) || this;
  24. _this.role = 'menuitemradio';
  25. _this.variable = menu.pool.lookup(variable);
  26. _this.register();
  27. return _this;
  28. }
  29. Radio.fromJson = function (_factory, _a, menu) {
  30. var content = _a.content, variable = _a.variable, id = _a.id;
  31. return new this(menu, content, variable, id);
  32. };
  33. Radio.prototype.executeAction = function () {
  34. this.variable.setValue(this.id);
  35. menu_util_js_1.MenuUtil.close(this);
  36. };
  37. Radio.prototype.generateSpan = function () {
  38. this.span = document.createElement('span');
  39. this.span.textContent = '\u2713';
  40. this.span.classList.add(html_classes_js_1.HtmlClasses['MENURADIOCHECK']);
  41. };
  42. Radio.prototype.updateAria = function () {
  43. this.html.setAttribute('aria-checked', this.variable.getValue() === this.id ? 'true' : 'false');
  44. };
  45. Radio.prototype.updateSpan = function () {
  46. this.span.style.display =
  47. this.variable.getValue() === this.id ? '' : 'none';
  48. };
  49. Radio.prototype.toJson = function () {
  50. return { type: ''
  51. };
  52. };
  53. return Radio;
  54. }(abstract_variable_item_js_1.AbstractVariableItem));
  55. exports.Radio = Radio;
  56. //# sourceMappingURL=item_radio.js.map