2015-11-23 23:57:10 +03:00
|
|
|
'use strict';
|
|
|
|
|
2015-12-14 18:20:40 +03:00
|
|
|
import {Component, View, EventEmitter} from 'angular2/core';
|
|
|
|
import {CORE_DIRECTIVES} from 'angular2/common';
|
2015-11-23 23:57:10 +03:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'zippy',
|
|
|
|
events: ['open', 'close'],
|
|
|
|
inputs: ['title', 'visible', 'type', 'empty']
|
|
|
|
})
|
|
|
|
@View({
|
|
|
|
templateUrl: './lib/common/components/Zippy/zippy.html',
|
|
|
|
styleUrls: ['./lib/common/components/Zippy/zippy.css'],
|
|
|
|
directives: [CORE_DIRECTIVES]
|
|
|
|
})
|
2015-12-19 15:16:17 +03:00
|
|
|
export default class Zippy {
|
2015-11-23 23:57:10 +03:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.type = 'general';
|
|
|
|
this.visible = false;
|
2015-12-19 15:16:17 +03:00
|
|
|
this.empty = false;
|
2015-11-23 23:57:10 +03:00
|
|
|
this.open = new EventEmitter();
|
|
|
|
this.close = new EventEmitter();
|
|
|
|
}
|
|
|
|
|
|
|
|
toggle() {
|
|
|
|
this.visible = !this.visible;
|
2015-12-19 15:16:17 +03:00
|
|
|
if (this.empty) return;
|
2015-11-23 23:57:10 +03:00
|
|
|
(this.visible) ? this.open.next() : this.close.next();
|
|
|
|
}
|
|
|
|
}
|