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.ProgressBar = void 0;
|
28 | const progress_location_service_1 = require("./progress-location-service");
|
29 | const common_1 = require("../common");
|
30 | const inversify_1 = require("inversify");
|
31 | const progress_bar_factory_1 = require("./progress-bar-factory");
|
32 | let ProgressBar = class ProgressBar {
|
33 | constructor() {
|
34 | this.toDispose = new common_1.DisposableCollection();
|
35 | this.progressBar = document.createElement('div');
|
36 | this.progressBar.className = 'theia-progress-bar';
|
37 | this.progressBar.style.display = 'none';
|
38 | this.progressBarContainer = document.createElement('div');
|
39 | this.progressBarContainer.className = 'theia-progress-bar-container';
|
40 | this.progressBarContainer.append(this.progressBar);
|
41 | }
|
42 | dispose() {
|
43 | this.toDispose.dispose();
|
44 | }
|
45 | init() {
|
46 | const { container, insertMode, locationId } = this.options;
|
47 | if (insertMode === 'prepend') {
|
48 | container.prepend(this.progressBarContainer);
|
49 | }
|
50 | else {
|
51 | container.append(this.progressBarContainer);
|
52 | }
|
53 | this.toDispose.push(common_1.Disposable.create(() => this.progressBarContainer.remove()));
|
54 | const onProgress = this.progressLocationService.onProgress(locationId);
|
55 | this.toDispose.push(onProgress(event => this.onProgress(event)));
|
56 | const current = this.progressLocationService.getProgress(locationId);
|
57 | if (current) {
|
58 | this.onProgress(current);
|
59 | }
|
60 | }
|
61 | onProgress(event) {
|
62 | if (this.toDispose.disposed) {
|
63 | return;
|
64 | }
|
65 | this.setVisible(event.show);
|
66 | }
|
67 | setVisible(visible) {
|
68 | this.progressBar.style.display = visible ? 'block' : 'none';
|
69 | }
|
70 | };
|
71 | __decorate([
|
72 | (0, inversify_1.inject)(progress_location_service_1.ProgressLocationService),
|
73 | __metadata("design:type", progress_location_service_1.ProgressLocationService)
|
74 | ], ProgressBar.prototype, "progressLocationService", void 0);
|
75 | __decorate([
|
76 | (0, inversify_1.inject)(progress_bar_factory_1.ProgressBarOptions),
|
77 | __metadata("design:type", Object)
|
78 | ], ProgressBar.prototype, "options", void 0);
|
79 | __decorate([
|
80 | (0, inversify_1.postConstruct)(),
|
81 | __metadata("design:type", Function),
|
82 | __metadata("design:paramtypes", []),
|
83 | __metadata("design:returntype", void 0)
|
84 | ], ProgressBar.prototype, "init", null);
|
85 | ProgressBar = __decorate([
|
86 | (0, inversify_1.injectable)(),
|
87 | __metadata("design:paramtypes", [])
|
88 | ], ProgressBar);
|
89 | exports.ProgressBar = ProgressBar;
|
90 |
|
\ | No newline at end of file |