/*-------------------------------------------------------------------------------------------------------------- * Copyright (c) insite-gmbh. All rights reserved. * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------------------------*/ import { Component, Input, Output, OnInit, EventEmitter } from '@angular/core'; @Component({ selector: 'pin-button', templateUrl: './@inax/commonUi/src/expandablePanel/pinButtonComponent/pinButton.component.html', styleUrls: ['./@inax/commonUi/src/expandablePanel/pinButtonComponent/pinButton.component.css'] }) export class PinButtonComponent implements OnInit { private _isPinned: boolean = false; private _wasPinned: boolean = false; get isPinned(): boolean { return this._isPinned; } @Input() autoUnpinTime: number = 5; @Output() onUnpin = new EventEmitter(); ngOnInit() { setTimeout(() => { if (!this._isPinned && !this._wasPinned) { this.onUnpin.emit(); } }, this.autoUnpinTime * 1000); } onBtnClick() { this._isPinned = !this._isPinned; if (this._isPinned) { this._wasPinned = true; } else if (this._wasPinned) { this.onUnpin.emit(); } } }