gamebench-ng-toasty
Version:
Angular2 Toasty component shows growl-style alerts and messages for your web app - now with more clicking!
45 lines (44 loc) • 2.17 kB
JavaScript
// Copyright (C) 2016-2017 Sergey Akopkokhyants
// This project is licensed under the terms of the MIT license.
// https://github.com/akserg/ng2-toasty
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastData } from './toasty.service';
import { isFunction } from 'util';
/**
* A Toast component shows message with title and close button.
*/
var ToastComponent = /** @class */ (function () {
function ToastComponent() {
this.closeToastEvent = new EventEmitter();
}
/**
* Event handler invokes when user clicks on close button.
* This method emit new event into ToastyContainer to close it.
*/
ToastComponent.prototype.close = function ($event) {
$event.preventDefault();
this.closeToastEvent.next(this.toast);
};
/**
* Event handler invokes when user clicks on Toast button.
* This method emit new event into ToastyContainer to close it.
*/
ToastComponent.prototype.click = function ($event) {
// $event.preventDefault();
if (this.toast.onClick && isFunction(this.toast.onClick)) {
this.toast.onClick.call(this, $event, this.toast);
}
};
ToastComponent.decorators = [
{ type: Component, args: [{
selector: 'ng2-toast',
template: "\n <div class=\"toast\" [ngClass]=\"[toast.type, toast.theme]\" (click)=\"click($event)\">\n <div *ngIf=\"toast.showClose\" class=\"close-button\" (click)=\"close($event)\"></div>\n <div *ngIf=\"toast.title || toast.msg\" class=\"toast-text\">\n <span *ngIf=\"toast.title\" class=\"toast-title\" [innerHTML]=\"toast.title | safeHtml\"></span>\n <br *ngIf=\"toast.title && toast.msg\"/>\n <span *ngIf=\"toast.msg\" class=\"toast-msg\" [innerHtml]=\"toast.msg | safeHtml\"></span>\n </div>\n </div>"
},] },
];
ToastComponent.propDecorators = {
toast: [{ type: Input }],
closeToastEvent: [{ type: Output, args: ['closeToast',] }]
};
return ToastComponent;
}());
export { ToastComponent };