item_checkbox.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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.Checkbox = 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 Checkbox = (function (_super) {
  21. __extends(Checkbox, _super);
  22. function Checkbox(menu, content, variable, id) {
  23. var _this = _super.call(this, menu, 'checkbox', content, id) || this;
  24. _this.role = 'menuitemcheckbox';
  25. _this.variable = menu.pool.lookup(variable);
  26. _this.register();
  27. return _this;
  28. }
  29. Checkbox.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. Checkbox.prototype.executeAction = function () {
  34. this.variable.setValue(!this.variable.getValue());
  35. menu_util_js_1.MenuUtil.close(this);
  36. };
  37. Checkbox.prototype.generateSpan = function () {
  38. this.span = document.createElement('span');
  39. this.span.textContent = '\u2713';
  40. this.span.classList.add(html_classes_js_1.HtmlClasses['MENUCHECK']);
  41. };
  42. Checkbox.prototype.updateAria = function () {
  43. this.html.setAttribute('aria-checked', this.variable.getValue() ? 'true' : 'false');
  44. };
  45. Checkbox.prototype.updateSpan = function () {
  46. this.span.style.display = this.variable.getValue() ? '' : 'none';
  47. };
  48. Checkbox.prototype.toJson = function () {
  49. return { type: ''
  50. };
  51. };
  52. return Checkbox;
  53. }(abstract_variable_item_js_1.AbstractVariableItem));
  54. exports.Checkbox = Checkbox;
  55. //# sourceMappingURL=item_checkbox.js.map