Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/Projekte/WebDesktop/WebDesktopFrontend/src/app/desktop/components/taskbar-icon/taskbar-icon.component.ts
2022-09-04 12:45:01 +02:00

54 lines
1.7 KiB
TypeScript

import {Component, ElementRef} from '@angular/core';
import {Desktop, DesktopIcon, WindowType} from "../../desktop.component";
@Component({
selector: 'app-taskbar-icon',
templateUrl: './taskbar-icon.component.html',
styleUrls: ['./taskbar-icon.component.scss']
})
export class TaskbarIconComponent implements DesktopIcon {
type: WindowType;
desktopRef: Desktop;
focus: boolean;
instance: HTMLElement;
constructor(object: ElementRef) {
this.instance = object.nativeElement;
}
onClick(): void {
//Click Animation
const container = this.instance.children.item(0).children.item(0) as HTMLElement;
container.classList.add("click");
setTimeout(() => container.classList.remove("click"), 100);
const unfocusedWindow = this.desktopRef.doesUnfocusedWindowExist(this.type.id);
if (unfocusedWindow !== undefined) {
unfocusedWindow.focusable = true;
unfocusedWindow.object.style.opacity = "100";
unfocusedWindow.isMinimized = false;
this.desktopRef.requestFocus(unfocusedWindow);
}else this.desktopRef.openWindow(this.type.id, this.type.args);
}
public onFocus() {
const focusBar = this.instance.children.item(0).children.item(2) as HTMLElement;
focusBar.style.width = "var(--focused)";
}
public onLostFocus() {
const focusBar = this.instance.children.item(0).children.item(2) as HTMLElement;
focusBar.style.width = "var(--opened)";
}
public onClose() {
if (this.desktopRef.isWindowTypeOpen(this.type.id)) return;
const focusBar = this.instance.children.item(0).children.item(2) as HTMLElement;
focusBar.style.opacity = "0";
}
public onOpen() {
const focusBar = this.instance.children.item(0).children.item(2) as HTMLElement;
focusBar.style.opacity = "100";
}
}