menu_element.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.MenuElement = void 0;
  17. var abstract_navigatable_js_1 = require("./abstract_navigatable.js");
  18. var MenuElement = (function (_super) {
  19. __extends(MenuElement, _super);
  20. function MenuElement() {
  21. return _super !== null && _super.apply(this, arguments) || this;
  22. }
  23. MenuElement.prototype.addAttributes = function (attributes) {
  24. for (var attr in attributes) {
  25. this.html.setAttribute(attr, attributes[attr]);
  26. }
  27. };
  28. Object.defineProperty(MenuElement.prototype, "html", {
  29. get: function () {
  30. if (!this._html) {
  31. this.generateHtml();
  32. }
  33. return this._html;
  34. },
  35. set: function (html) {
  36. this._html = html;
  37. this.addEvents(html);
  38. },
  39. enumerable: false,
  40. configurable: true
  41. });
  42. MenuElement.prototype.generateHtml = function () {
  43. var html = document.createElement('div');
  44. html.classList.add(this.className);
  45. html.setAttribute('role', this.role);
  46. this.html = html;
  47. };
  48. MenuElement.prototype.focus = function () {
  49. var html = this.html;
  50. html.setAttribute('tabindex', '0');
  51. html.focus();
  52. };
  53. MenuElement.prototype.unfocus = function () {
  54. var html = this.html;
  55. if (html.hasAttribute('tabindex')) {
  56. html.setAttribute('tabindex', '-1');
  57. }
  58. try {
  59. html.blur();
  60. }
  61. catch (e) {
  62. }
  63. html.blur();
  64. };
  65. return MenuElement;
  66. }(abstract_navigatable_js_1.AbstractNavigatable));
  67. exports.MenuElement = MenuElement;
  68. //# sourceMappingURL=menu_element.js.map