import { Component, OnInit, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'neu-expansion-panel',
  templateUrl: './neu-expansion-panel.component.html',
  styleUrls: ['./neu-expansion-panel.component.css']
})
export class NeuExpansionPanelComponent implements OnInit {

  opened:boolean = false;
  @Output("onOpen") onOpen:EventEmitter<boolean> = new EventEmitter();

  constructor() { }

  ngOnInit() {
  }

  onClick(event) {
    if(!this.opened) {
      this.opened = true;
      this.onOpen.emit(true);
    } else {
      if (event.toElement.className.toString().includes('icon-down-arrow neu-pressed')) {
        this.opened = false;
      }
    }
  }

  close() {
    this.opened = false;
  }

}
