1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.BreadcrumbPopupContainer = exports.BreadcrumbID = exports.BreadcrumbPopupContainerFactory = void 0;
|
28 | const inversify_1 = require("../../../shared/inversify");
|
29 | const common_1 = require("../../common");
|
30 | const disposable_1 = require("../../common/disposable");
|
31 | const context_menu_renderer_1 = require("../context-menu-renderer");
|
32 | const react_renderer_1 = require("../widgets/react-renderer");
|
33 | const breadcrumbs_constants_1 = require("./breadcrumbs-constants");
|
34 | exports.BreadcrumbPopupContainerFactory = Symbol('BreadcrumbPopupContainerFactory');
|
35 | exports.BreadcrumbID = Symbol('BreadcrumbID');
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | let BreadcrumbPopupContainer = class BreadcrumbPopupContainer {
|
44 | constructor() {
|
45 | this.onDidDisposeEmitter = new common_1.Emitter();
|
46 | this.toDispose = new disposable_1.DisposableCollection(this.onDidDisposeEmitter);
|
47 | this.onFocusOut = (event) => {
|
48 | if (!(event.relatedTarget instanceof Element) || !this._container.contains(event.relatedTarget)) {
|
49 | this.dispose();
|
50 | }
|
51 | };
|
52 | this.escFunction = (event) => {
|
53 | if (event.key === 'Escape' || event.key === 'Esc') {
|
54 | this.dispose();
|
55 | }
|
56 | };
|
57 | }
|
58 | get onDidDispose() {
|
59 | return this.onDidDisposeEmitter.event;
|
60 | }
|
61 | get container() {
|
62 | return this._container;
|
63 | }
|
64 | get isOpen() {
|
65 | return this._isOpen;
|
66 | }
|
67 | init() {
|
68 | this._container = this.createPopupDiv(this.position);
|
69 | document.addEventListener('keyup', this.escFunction);
|
70 | this._container.focus();
|
71 | this._isOpen = true;
|
72 | }
|
73 | createPopupDiv(position) {
|
74 | const result = window.document.createElement('div');
|
75 | result.className = breadcrumbs_constants_1.Styles.BREADCRUMB_POPUP;
|
76 | result.style.left = `${position.x}px`;
|
77 | result.style.top = `${position.y}px`;
|
78 | result.tabIndex = 0;
|
79 | result.addEventListener('focusout', this.onFocusOut);
|
80 | this.parent.appendChild(result);
|
81 | return result;
|
82 | }
|
83 | dispose() {
|
84 | if (!this.toDispose.disposed) {
|
85 | this.onDidDisposeEmitter.fire();
|
86 | this.toDispose.dispose();
|
87 | this._container.remove();
|
88 | this._isOpen = false;
|
89 | document.removeEventListener('keyup', this.escFunction);
|
90 | }
|
91 | }
|
92 | };
|
93 | __decorate([
|
94 | (0, inversify_1.inject)(react_renderer_1.RendererHost),
|
95 | __metadata("design:type", Object)
|
96 | ], BreadcrumbPopupContainer.prototype, "parent", void 0);
|
97 | __decorate([
|
98 | (0, inversify_1.inject)(exports.BreadcrumbID),
|
99 | __metadata("design:type", String)
|
100 | ], BreadcrumbPopupContainer.prototype, "breadcrumbId", void 0);
|
101 | __decorate([
|
102 | (0, inversify_1.inject)(context_menu_renderer_1.Coordinate),
|
103 | __metadata("design:type", Object)
|
104 | ], BreadcrumbPopupContainer.prototype, "position", void 0);
|
105 | __decorate([
|
106 | (0, inversify_1.postConstruct)(),
|
107 | __metadata("design:type", Function),
|
108 | __metadata("design:paramtypes", []),
|
109 | __metadata("design:returntype", void 0)
|
110 | ], BreadcrumbPopupContainer.prototype, "init", null);
|
111 | BreadcrumbPopupContainer = __decorate([
|
112 | (0, inversify_1.injectable)()
|
113 | ], BreadcrumbPopupContainer);
|
114 | exports.BreadcrumbPopupContainer = BreadcrumbPopupContainer;
|
115 |
|
\ | No newline at end of file |