2016-05-25 18:34:31 +03:00
|
|
|
'use strict';
|
|
|
|
|
2017-01-19 00:48:55 +03:00
|
|
|
import { Component, EventEmitter, Output, Input, OnChanges } from '@angular/core';
|
2016-05-25 18:34:31 +03:00
|
|
|
@Component({
|
|
|
|
selector: 'zippy',
|
|
|
|
templateUrl: './zippy.html',
|
2016-08-22 12:12:13 +03:00
|
|
|
styleUrls: ['./zippy.css']
|
2016-05-25 18:34:31 +03:00
|
|
|
})
|
2017-01-19 00:48:55 +03:00
|
|
|
export class Zippy implements OnChanges {
|
2016-05-25 18:34:31 +03:00
|
|
|
@Input() type = 'general';
|
|
|
|
@Input() empty = false;
|
|
|
|
@Input() title;
|
2016-06-29 18:02:29 +03:00
|
|
|
@Input() headless: boolean = false;
|
2017-01-19 00:48:55 +03:00
|
|
|
@Input() open = false;
|
|
|
|
@Output() openChange = new EventEmitter();
|
|
|
|
|
|
|
|
|
2016-05-25 18:34:31 +03:00
|
|
|
toggle() {
|
2017-01-19 00:48:55 +03:00
|
|
|
this.open = !this.open;
|
2016-05-25 18:34:31 +03:00
|
|
|
if (this.empty) return;
|
2017-01-19 00:48:55 +03:00
|
|
|
this.openChange.emit(this.open);
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnChanges(ch) {
|
|
|
|
if (ch.open.currentValue === true) {
|
|
|
|
this.openChange.emit(ch.open.currentValue);
|
2016-06-19 17:41:04 +03:00
|
|
|
}
|
2016-05-25 18:34:31 +03:00
|
|
|
}
|
|
|
|
}
|