UNPKG

4.19 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2019 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16// *****************************************************************************
17var __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};
23var __metadata = (this && this.__metadata) || function (k, v) {
24 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25};
26Object.defineProperty(exports, "__esModule", { value: true });
27exports.ProgressBar = void 0;
28const progress_location_service_1 = require("./progress-location-service");
29const common_1 = require("../common");
30const inversify_1 = require("inversify");
31const progress_bar_factory_1 = require("./progress-bar-factory");
32let 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);
85ProgressBar = __decorate([
86 (0, inversify_1.injectable)(),
87 __metadata("design:paramtypes", [])
88], ProgressBar);
89exports.ProgressBar = ProgressBar;
90//# sourceMappingURL=progress-bar.js.map
\No newline at end of file