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

30 lines
719 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'],
2016-05-06 00:48:41 +03:00
templateUrl: './lib/shared/components/Zippy/zippy.html',
styleUrls: ['./lib/shared/components/Zippy/zippy.css'],
2015-11-23 23:57:10 +03:00
directives: [CORE_DIRECTIVES]
})
2016-05-06 00:48:41 +03:00
export 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();
}
}