This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault.tsx
More file actions
71 lines (68 loc) · 3.42 KB
/
default.tsx
File metadata and controls
71 lines (68 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SampleBase } from '../common/sample-base';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { isNullOrUndefined } from '@syncfusion/ej2-base';
import { ToastComponent, ToastCloseArgs } from '@syncfusion/ej2-react-notifications';
import './default.css';
export class Default extends SampleBase<{}, {}> {
private toastObj: ToastComponent;
private position: Object = { X: 'Right' };
public create(): void {
setTimeout(function(){
this.toastObj.show({
title: 'Adaptive Tiles Meeting', content: 'Conference Room 01 / Building 135 10:00 AM',
icon: 'e-meeting',
});
}.bind(this),200);
}
public hideBtnClick(): void {
this.toastObj.hide('All');
}
public showBtnClick(): void {
this.toastObj.show();
}
public onclose(e): void {
let btnEleHide: HTMLElement = document.getElementById('toastBtnHide');
if (e.toastContainer.childElementCount === 0 ) {
btnEleHide.style.display = 'none';
}
}
public onbeforeOpen(): void {
let btnEleHide: HTMLElement = document.getElementById('toastBtnHide');
btnEleHide.style.display = 'inline-block';
}
render() {
document.addEventListener('click', function(e: Event) : void {
let btnEleShow: HTMLElement = document.getElementById('toastBtnShow');
if (!isNullOrUndefined(this.toastObj) && e.target !== btnEleShow) {
this.toastObj.hide('All');
}
}.bind(this));
return (
<div className='control-pane'>
<div className='control-section col-lg-12 toast-default-section'>
<div className="e-sample-resize-container">
<ToastComponent ref={(toast) => { this.toastObj = toast }} id='toast_default' position={this.position} created={this.create.bind(this)} close={this.onclose.bind(this)} beforeOpen={this.onbeforeOpen.bind(this)}></ToastComponent>
<div id="toastBtnDefault" style={{'margin': 'auto','text-align': 'center'}}>
<ButtonComponent id='toastBtnShow' className='e-btn' onClick={ this.showBtnClick.bind(this) }>Show Toasts</ButtonComponent>
<ButtonComponent id='toastBtnHide' className='e-btn' onClick={ this.hideBtnClick.bind(this) }>Hide All</ButtonComponent>
</div>
</div>
</div>
<div id="action-description">
<p>This sample demonstrates the basic layout of a <code>Toast</code> to show simple notification and hide them.</p>
</div>
<div id="description">
<p>The <code>Toast</code> is a notification pop-up used to display on the desired position with required message and header icons.</p>
<ul>
<li>The header text is set using <code>title</code> property.</li>
<li>Information to be displayed is set using <code>content</code> property.</li>
</ul>
<p>More information about Toast can be found in this <a target="_blank" href="http://ej2.syncfusion.com/react/documentation/toast/getting-started.html">
documentation section</a>.</p>
</div>
</div>
)
}
}