forked from akserg/ng2-toasty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
361 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,46 @@ | ||
import {Component, Input, OnInit, Output, EventEmitter} from 'angular2/core'; | ||
import {Component, Input, Output, EventEmitter} from 'angular2/core'; | ||
import {CORE_DIRECTIVES} from 'angular2/common'; | ||
|
||
import {ToastyConfig} from './toasty.config'; | ||
import {Toast} from './toasty.service'; | ||
|
||
/** | ||
* This a toast component. | ||
* This a toast component shows message with title and close button. | ||
*/ | ||
@Component({ | ||
selector: 'ng2-toast', | ||
directives: [CORE_DIRECTIVES], | ||
template: ` | ||
<div class="toast" [ngClass]="setClasses()" (click)="clickToasty($event)"> | ||
<div (click)="close($event)" class="close-button" *ngIf="toast.showClose"></div> | ||
<div class="toast" [ngClass]="[toast.type, toast.theme, toast.shake]" (click)="clickToasty($event)"> | ||
<div *ngIf="toast.showClose" class="close-button" (click)="close($event)"></div> | ||
<div *ngIf="toast.title || toast.msg" class="toast-text"> | ||
<span class="toast-title" *ngIf="!toast.html && toast.title" [innerHtml]="toast.title"></span> | ||
<span class="toast-title" *ngIf="toast.html && toast.title" [innerHtml]="toast.title"></span> | ||
<br *ngIf="toast.title && toast.msg" /> | ||
<span class="toast-msg" *ngIf="!toast.html && toast.msg" [innerHtml]="toast.msg"></span> | ||
<span class="toast-msg" *ngIf="toast.html && toast.msg" [innerHtml]="toast.msg"></span> | ||
<span *ngIf="toast.title" class="toast-title">{{toast.title}}</span> | ||
<br *ngIf="toast.title && toast.msg" /> | ||
<span *ngIf="toast.msg" class="toast-msg">{{toast.msg}}</span> | ||
</div> | ||
</div>` | ||
}) | ||
export class ToastyComponent implements OnInit { | ||
export class ToastyComponent { | ||
|
||
@Input() toast:Toast; | ||
@Output('closeToast') closeToastEvent = new EventEmitter(); | ||
@Output('clickOnToast') clickOnToastEvent = new EventEmitter(); | ||
|
||
constructor() {} | ||
|
||
ngOnInit(): any { | ||
// console.log('toast', this.toast); | ||
} | ||
|
||
setClasses() { | ||
return { | ||
type:this.toast.type, | ||
interact:this.toast.interact, | ||
shake:this.toast.shake, | ||
theme:this.toast.theme | ||
}; | ||
} | ||
|
||
/** | ||
* On ng-click="close", remove the specific toast | ||
* Event handler invokes when user clicks on close button. | ||
* This method emit new event to ToastyContainer to close it. | ||
*/ | ||
close($event:any) { | ||
$event.preventDefaults(); | ||
this.closeToastEvent.emit('closeToastEvent'); | ||
this.closeToastEvent.emit('closeToast'); | ||
} | ||
|
||
/** | ||
* On ng-click="close", remove the specific toast | ||
* Event handler invokes when user clicks on body of ToastyComponent. | ||
* This method emit new event to ToastyContainer call method onClick and close it if flag clickToClose set true. | ||
*/ | ||
clickToasty($event:any) { | ||
$event.preventDefaults(); | ||
this.clickOnToastEvent.emit('clickOnToastEvent'); | ||
this.clickOnToastEvent.emit('clickOnToast'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.