redoc/lib/common/components/Zippy/zippy.js

30 lines
727 B
JavaScript
Raw Normal View History

2015-11-23 23:57:10 +03:00
'use strict';
2016-05-05 11:05:02 +03:00
import {Component, EventEmitter} from '@angular/core';
import {CORE_DIRECTIVES} from '@angular/common';
2015-11-23 23:57:10 +03:00
@Component({
selector: 'zippy',
events: ['open', 'close'],
inputs: ['title', 'visible', 'type', 'empty'],
2015-11-23 23:57:10 +03:00
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();
}
}