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 pathapi.tsx
More file actions
163 lines (149 loc) · 8.42 KB
/
api.tsx
File metadata and controls
163 lines (149 loc) · 8.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { SidebarComponent, SidebarType } from '@syncfusion/ej2-react-navigations';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import { DropDownListComponent, ChangeEventArgs } from '@syncfusion/ej2-react-dropdowns';
import { enableRipple } from '@syncfusion/ej2-base';
import { SampleBase } from '../common/sample-base';
import './sidebarapi-component.css';
export class API extends SampleBase<{}, {}> {
public sidebarInstance: SidebarComponent;
public documentClickBtn: ButtonComponent;
public sidebarTypesBtn: ButtonComponent;
public backdropBtn: ButtonComponent;
private listObj: DropDownListComponent;
private dataTypes: { [key: string]: Object }[] = [
{ Type: 'Over', value: 'Over' },
{ Type: 'Push', value: 'Push' },
{ Type: 'Slide', value: 'Slide' },
{ Type: 'Auto', value: 'Auto' }
];
private fields: object = { text: 'Type', value: 'value' };
public showBackdrop: boolean = false;
public closeOnDocumentClick: boolean = false;
public waterMark: string = 'Select a Type';
public height: string = '220px';
public index: number = 3;
render() {
return (
<div className="control-section">
<div className="col-lg-12 col-sm-12 col-md-12 center">
Click the button to view the sample
</div>
<div className="col-lg-12 col-sm-12 col-md-12 center">
<a className="e-btn" id="newTab" onClick={this.newTabClick.bind(this)} target="_blank">Open in new tab</a>
</div>
<div id="wrapper">
<title>Essential JS 2 for React - Sidebar > API</title>
<div className="col-lg-12 col-sm-12 col-md-12" id="sidebar-section">
<span id="hamburger" className="e-icons menu" onClick={this.openClick.bind(this)} ></span>
<SidebarComponent id="default-sidebar" ref={Sidebar => this.sidebarInstance = Sidebar} >
<div className="title-header">
<div style={{ display: 'inline-block' }}> Sidebar </div>
<span id="close" className="e-icons" onClick={this.closeClick.bind(this)} ></span></div>
<div className="sub-title">
Place your primary content here.
</div>
</SidebarComponent>
<div className="list-group">
<div className="list-group-item">
<h2 className="title">Overview</h2><br></br>
<p>The Sidebar component is a collapsible side content placed along with the main content either in left or right side of the page.
</p>
<p></p><br></br>
<h3 className="title">Options</h3><br></br>
<div className="inline-element responsive">
<p className="inline-element" style={{ width: '70%' }} ><b>Toggle</b> - Toggles the sidebar to be open or closed state.
</p>
<ButtonComponent id="toggleSidebar" className="inline-element right" cssClass='e-info' isToggle onClick={this.toggleSidebar.bind(this)}>Toggle</ButtonComponent>
<br></br><br></br>
<p className="inline-element" style={{ width: '70%' }} ><b>Position</b> - Allows to place the sidebar in right or left side of the page.
</p>
<ButtonComponent id="togglePosition" className="inline-element right" cssClass='e-info' isToggle ref={(scope) => { this.sidebarTypesBtn = scope; }} onClick={this.onTypeChange.bind(this)}>Right</ButtonComponent>
<br></br><br></br>
<p className="inline-element" style={{ width: '70%' }} > <b>Types </b> - Specifies the act of expanding or collapsing the sidebar with main content.</p>
<div className="inline-element right" style={{ width: '75px' }}>
<DropDownListComponent id="types" className="e-textbox right" dataSource={this.dataTypes} fields={this.fields} ref={(dropdownlist) => { this.listObj = dropdownlist }} popupHeight={this.height} index={this.index} cssClass='right' change={this.onChange.bind(this)}>
</DropDownListComponent>
</div>
<br></br><br></br>
<p className=" inline-element" style={{ width: '70%' }}><b>Closing on document click</b> - Allows to collapse / close the sidebar on document click.</p>
<ButtonComponent id="documentclick" className="inline-element right" cssClass='e-info' isToggle ref={(scope) => { this.documentClickBtn = scope; }} onClick={this.documentclick.bind(this)}>True</ButtonComponent>
<br></br><br></br>
<p className=" inline-element" style={{ width: '70%' }} ><b>Backdrop</b> - Sets the backdrop over the main content area on open / expanded state.</p>
<ButtonComponent id="backdrop" className="inline-element right" cssClass='e-info' isToggle ref={(scope) => { this.backdropBtn = scope; }} onClick={this.backdrop.bind(this)} >True</ButtonComponent>
</div>
</div>
</div>
</div>
</div>
<div id="action-description">
<p>
This sample demonstrates the Sidebar component with its features. Click the button to view the Sidebar sample in a new tab.
</p>
</div>
<div id="description">
<p>
In this sample allows to configure the <code>type</code>, <code>position</code>, <code>closeOnDocumentClick</code>and
<code>showBackdrop</code> property.
</p>
</div>
</div>
);
}
// open new tab
newTabClick(): void {
document.getElementById('newTab').setAttribute('href', location.href.split('#')[0] + 'sidebar/api/index.html');
}
toggleSidebar(): void {
this.sidebarInstance.toggle();
}
//close the siebar
closeClick(): void {
this.sidebarInstance.hide();
}
//open the sidebar
openClick(): void {
this.sidebarInstance.show();
}
documentclick(): void {
let proxy: any = this;
if (proxy.documentClickBtn.element.classList.contains('e-active')) {
proxy.documentClickBtn.content = 'False';
//enable the closeOnDocumentClick property
this.sidebarInstance.closeOnDocumentClick = true;
} else {
proxy.documentClickBtn.content = 'True';
//disable the closeOnDocumentClick property
this.sidebarInstance.closeOnDocumentClick = false;
}
};
onTypeChange(): void {
let proxy: any = this;
if (proxy.sidebarTypesBtn.element.classList.contains('e-active')) {
proxy.sidebarTypesBtn.content = 'Left';
this.sidebarInstance.position = 'Right';
document.getElementById('hamburger').className += " e-rtl";
} else {
proxy.sidebarTypesBtn.content = 'Right';
this.sidebarInstance.position = 'Left';
document.getElementById('hamburger').classList.remove("e-rtl");
}
};
backdrop(): void {
let proxy: any = this;
if (proxy.backdropBtn.element.classList.contains('e-active')) {
proxy.backdropBtn.content = 'False';
//enable the backdrop property
this.sidebarInstance.showBackdrop = true;
} else {
proxy.backdropBtn.content = 'True';
//disable the backdrop property
this.sidebarInstance.showBackdrop = false;
}
};
onChange(): void {
let types: any = this.listObj.value;
this.sidebarInstance.type = types;
}
}