novo-elements
Version:
Bullhorn's NOVO Element Repository for Angular 2
91 lines (83 loc) • 2.6 kB
text/typescript
// NG2
import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/core';
export class NovoToastElement implements OnInit, OnChanges {
theme: string = 'danger';
icon: string = 'caution';
title: string;
message: string;
hasDialogue: boolean = false;
link: string;
isCloseable: boolean = false;
show: boolean = false;
animate: boolean = false;
parent: any = null;
launched: boolean = false;
position: any;
time: any;
iconClass: string;
alertTheme: string;
embedded: any;
ngOnInit() {
if (!this.launched) {
// clear position and time
this.position = null;
this.time = null;
// set icon and styling
this.iconClass = `bhi-${this.icon}`;
this.alertTheme = `${this.theme} toast-container embedded`;
if (this.hasDialogue) { this.alertTheme += ' dialogue'; }
}
}
ngOnChanges(changes?: SimpleChanges) {
// set icon and styling
this.iconClass = `bhi-${this.icon}`;
this.alertTheme = `${this.theme} toast-container embedded`;
if (this.hasDialogue) { this.alertTheme += ' dialogue'; }
}
clickHandler(event) {
if (!this.isCloseable) {
if (event) {
event.stopPropagation();
event.preventDefault();
}
if (this.parent) {
this.parent.hide(this);
}
}
}
close(event) {
if (event) {
event.stopPropagation();
event.preventDefault();
}
this.parent.hide(this);
}
}