From 09a28c2e1f0fb0d61bc369b5e25e3294d8f06918 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 7 Aug 2023 01:14:15 +0200 Subject: [PATCH] refactor: progressbar.js -> progressbar.ts --- src/ui/{progressbar.js => progressbar.ts} | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) rename src/ui/{progressbar.js => progressbar.ts} (84%) diff --git a/src/ui/progressbar.js b/src/ui/progressbar.ts similarity index 84% rename from src/ui/progressbar.js rename to src/ui/progressbar.ts index 1269b4c32..2cca168df 100644 --- a/src/ui/progressbar.js +++ b/src/ui/progressbar.ts @@ -1,15 +1,29 @@ import * as $j from 'jquery'; +type ProgressBarOptions = { + height: number; + width: number; + color: string; + $bar: any; +}; + export class ProgressBar { - constructor(opts) { - const defaultOpts = { + $bar: any; + $preview: any; + $current: any; + width: number; + height: number; + color: string; + + constructor(opts: Partial) { + const defaultOpts: ProgressBarOptions = { height: 316, width: 7, color: 'red', $bar: undefined, }; - opts = $j.extend(defaultOpts, opts); + opts = Object.assign({}, defaultOpts, opts); $j.extend(this, opts); this.$bar.append('
'); @@ -24,7 +38,7 @@ export class ProgressBar { /** * @param{number} percentage - Size between 0 and 1 */ - setSize(percentage) { + setSize(percentage: number) { this.$bar.css({ width: this.width, height: this.height * percentage, @@ -43,7 +57,7 @@ export class ProgressBar { /** * @param{number} percentage - size between 0 and 1 */ - animSize(percentage) { + animSize(percentage: number) { this.$bar.transition( { queue: false, @@ -70,7 +84,7 @@ export class ProgressBar { /** * @param{number} percentage - size between 0 and 1 */ - previewSize(percentage) { + previewSize(percentage: number) { this.$preview.css( { width: this.width,