item_submenu.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.Submenu = void 0;
  17. var abstract_item_js_1 = require("./abstract_item.js");
  18. var html_classes_js_1 = require("./html_classes.js");
  19. var Submenu = (function (_super) {
  20. __extends(Submenu, _super);
  21. function Submenu(menu, content, id) {
  22. var _this = _super.call(this, menu, 'submenu', content, id) || this;
  23. _this._submenu = null;
  24. return _this;
  25. }
  26. Submenu.fromJson = function (factory, _a, menu) {
  27. var content = _a.content, submenu = _a.menu, id = _a.id;
  28. var item = new this(menu, content, id);
  29. var sm = factory.get('subMenu')(factory, submenu, item);
  30. item.submenu = sm;
  31. return item;
  32. };
  33. Object.defineProperty(Submenu.prototype, "submenu", {
  34. get: function () {
  35. return this._submenu;
  36. },
  37. set: function (menu) {
  38. this._submenu = menu;
  39. },
  40. enumerable: false,
  41. configurable: true
  42. });
  43. Submenu.prototype.mouseover = function (event) {
  44. this.focus();
  45. this.stop(event);
  46. };
  47. Submenu.prototype.mouseout = function (event) {
  48. this.stop(event);
  49. };
  50. Submenu.prototype.unfocus = function () {
  51. if (!this.submenu.isPosted()) {
  52. _super.prototype.unfocus.call(this);
  53. return;
  54. }
  55. if (this.menu.focused !== this) {
  56. _super.prototype.unfocus.call(this);
  57. this.menu.unpostSubmenus();
  58. return;
  59. }
  60. this.html.setAttribute('tabindex', '-1');
  61. this.html.blur();
  62. };
  63. Submenu.prototype.focus = function () {
  64. _super.prototype.focus.call(this);
  65. if (!this.submenu.isPosted() && !this.disabled) {
  66. this.submenu.post();
  67. }
  68. };
  69. Submenu.prototype.executeAction = function () {
  70. this.submenu.isPosted() ? this.submenu.unpost() : this.submenu.post();
  71. };
  72. Submenu.prototype.generateHtml = function () {
  73. _super.prototype.generateHtml.call(this);
  74. var html = this.html;
  75. this.span = document.createElement('span');
  76. this.span.textContent = '\u25BA';
  77. this.span.classList.add(html_classes_js_1.HtmlClasses['MENUARROW']);
  78. html.appendChild(this.span);
  79. html.setAttribute('aria-haspopup', 'true');
  80. };
  81. Submenu.prototype.left = function (event) {
  82. if (this.submenu.isPosted()) {
  83. this.submenu.unpost();
  84. }
  85. else {
  86. _super.prototype.left.call(this, event);
  87. }
  88. };
  89. Submenu.prototype.right = function (event) {
  90. if (!this.submenu.isPosted()) {
  91. this.submenu.post();
  92. }
  93. else {
  94. this.submenu.down(event);
  95. }
  96. };
  97. Submenu.prototype.toJson = function () {
  98. return { type: ''
  99. };
  100. };
  101. return Submenu;
  102. }(abstract_item_js_1.AbstractItem));
  103. exports.Submenu = Submenu;
  104. //# sourceMappingURL=item_submenu.js.map