/*-------------------------------------------------------------------------------------------------------------- * 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 { Directive, Input, ElementRef, Inject, HostListener } from '@angular/core'; import { IExpandablePanel, IExpandablePanelCollection, IEXPANDABLEPANELCOLLECTIONSERVICE_TOKEN } from '../interfaces/index'; @Directive({ selector: '[panelExpander]' }) export class PanelExpanderDirective { @Input('panelExpander') expandablePanelId: string; @HostListener('click', ['$event.target']) onClick(target) { let p = this._expandablePanelCollection.get(this.expandablePanelId); if (p) { p.toggle(); } } constructor(private _el: ElementRef, @Inject(IEXPANDABLEPANELCOLLECTIONSERVICE_TOKEN) private _expandablePanelCollection: IExpandablePanelCollection) {} }