@syncfusion/ej2-navigations 30.2.5 → 31.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-navigations.min.js +2 -2
- package/dist/ej2-navigations.umd.min.js +2 -2
- package/dist/ej2-navigations.umd.min.js.map +1 -1
- package/dist/es6/ej2-navigations.es2015.js +1 -0
- package/dist/es6/ej2-navigations.es2015.js.map +1 -1
- package/dist/es6/ej2-navigations.es5.js +1 -0
- package/dist/es6/ej2-navigations.es5.js.map +1 -1
- package/dist/global/ej2-navigations.min.js +2 -2
- package/dist/global/ej2-navigations.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/dist/ts/accordion/accordion-model.d.ts +285 -0
- package/dist/ts/accordion/accordion.d.ts +458 -0
- package/dist/ts/accordion/accordion.ts +1580 -0
- package/dist/ts/accordion/index.d.ts +5 -0
- package/dist/ts/accordion/index.ts +5 -0
- package/dist/ts/appbar/appbar-model.d.ts +76 -0
- package/dist/ts/appbar/appbar.d.ts +115 -0
- package/dist/ts/appbar/appbar.ts +281 -0
- package/dist/ts/appbar/index.d.ts +3 -0
- package/dist/ts/appbar/index.ts +3 -0
- package/dist/ts/breadcrumb/breadcrumb-model.d.ts +170 -0
- package/dist/ts/breadcrumb/breadcrumb.d.ts +297 -0
- package/dist/ts/breadcrumb/breadcrumb.ts +959 -0
- package/dist/ts/breadcrumb/index.d.ts +5 -0
- package/dist/ts/breadcrumb/index.ts +5 -0
- package/dist/ts/carousel/carousel-model.d.ts +282 -0
- package/dist/ts/carousel/carousel.d.ts +439 -0
- package/dist/ts/carousel/carousel.ts +1633 -0
- package/dist/ts/carousel/index.d.ts +3 -0
- package/dist/ts/carousel/index.ts +3 -0
- package/dist/ts/common/h-scroll-model.d.ts +16 -0
- package/dist/ts/common/h-scroll.d.ts +105 -0
- package/dist/ts/common/h-scroll.ts +481 -0
- package/dist/ts/common/index.d.ts +9 -0
- package/dist/ts/common/index.ts +10 -0
- package/dist/ts/common/menu-base-model.d.ts +308 -0
- package/dist/ts/common/menu-base.d.ts +558 -0
- package/dist/ts/common/menu-base.ts +2736 -0
- package/dist/ts/common/menu-scroll.d.ts +29 -0
- package/dist/ts/common/menu-scroll.ts +105 -0
- package/dist/ts/common/v-scroll-model.d.ts +16 -0
- package/dist/ts/common/v-scroll.d.ts +106 -0
- package/dist/ts/common/v-scroll.ts +454 -0
- package/dist/ts/context-menu/context-menu-model.d.ts +47 -0
- package/dist/ts/context-menu/context-menu.d.ts +102 -0
- package/dist/ts/context-menu/context-menu.ts +165 -0
- package/dist/ts/context-menu/index.d.ts +5 -0
- package/dist/ts/context-menu/index.ts +5 -0
- package/dist/ts/index.d.ts +16 -0
- package/dist/ts/index.ts +16 -0
- package/dist/ts/menu/index.d.ts +5 -0
- package/dist/ts/menu/index.ts +5 -0
- package/dist/ts/menu/menu-model.d.ts +70 -0
- package/dist/ts/menu/menu.d.ts +127 -0
- package/dist/ts/menu/menu.ts +313 -0
- package/dist/ts/sidebar/index.d.ts +5 -0
- package/dist/ts/sidebar/index.ts +5 -0
- package/dist/ts/sidebar/sidebar-model.d.ts +200 -0
- package/dist/ts/sidebar/sidebar.d.ts +336 -0
- package/dist/ts/sidebar/sidebar.ts +907 -0
- package/dist/ts/stepper/index.d.ts +3 -0
- package/dist/ts/stepper/index.ts +3 -0
- package/dist/ts/stepper/stepper-model.d.ts +159 -0
- package/dist/ts/stepper/stepper.d.ts +381 -0
- package/dist/ts/stepper/stepper.ts +1350 -0
- package/dist/ts/stepper-base/index.d.ts +5 -0
- package/dist/ts/stepper-base/index.ts +6 -0
- package/dist/ts/stepper-base/stepper-base-model.d.ts +124 -0
- package/dist/ts/stepper-base/stepper-base.d.ts +187 -0
- package/dist/ts/stepper-base/stepper-base.ts +290 -0
- package/dist/ts/tab/index.d.ts +5 -0
- package/dist/ts/tab/index.ts +5 -0
- package/dist/ts/tab/tab-model.d.ts +408 -0
- package/dist/ts/tab/tab.d.ts +715 -0
- package/dist/ts/tab/tab.ts +2842 -0
- package/dist/ts/toolbar/index.d.ts +5 -0
- package/dist/ts/toolbar/index.ts +5 -0
- package/dist/ts/toolbar/toolbar-model.d.ts +294 -0
- package/dist/ts/toolbar/toolbar.d.ts +541 -0
- package/dist/ts/toolbar/toolbar.ts +2646 -0
- package/dist/ts/treeview/index.d.ts +5 -0
- package/dist/ts/treeview/index.ts +5 -0
- package/dist/ts/treeview/treeview-model.d.ts +637 -0
- package/dist/ts/treeview/treeview.d.ts +1518 -0
- package/dist/ts/treeview/treeview.ts +6780 -0
- package/package.json +70 -17
- package/src/context-menu/context-menu-model.d.ts +1 -1
- package/src/context-menu/context-menu.js +1 -1
- package/src/tab/tab.js +1 -0
- package/styles/accordion/_bootstrap-dark-definition.scss +1 -1
- package/styles/accordion/_bootstrap-definition.scss +1 -1
- package/styles/accordion/bootstrap-dark.css +1 -1
- package/styles/accordion/bootstrap.css +1 -1
- package/styles/bds-lite.css +1 -1
- package/styles/bds.css +1 -1
- package/styles/bootstrap-dark-lite.css +2 -2
- package/styles/bootstrap-dark.css +2 -2
- package/styles/bootstrap-lite.css +2 -2
- package/styles/bootstrap.css +2 -2
- package/styles/bootstrap4-lite.css +1 -1
- package/styles/bootstrap4.css +1 -1
- package/styles/bootstrap5-dark-lite.css +1 -1
- package/styles/bootstrap5-dark.css +1 -1
- package/styles/bootstrap5-lite.css +1 -1
- package/styles/bootstrap5.3-lite.css +1 -1
- package/styles/bootstrap5.3.css +9 -1
- package/styles/bootstrap5.css +1 -1
- package/styles/fabric-dark-lite.css +1 -1
- package/styles/fabric-dark.css +1 -1
- package/styles/fabric-lite.css +1 -1
- package/styles/fabric.css +1 -1
- package/styles/fluent-dark-lite.css +1 -1
- package/styles/fluent-dark.css +1 -1
- package/styles/fluent-lite.css +1 -1
- package/styles/fluent.css +1 -1
- package/styles/fluent2-lite.css +4 -1
- package/styles/fluent2.css +4 -1
- package/styles/h-scroll/_layout.scss +1 -1
- package/styles/h-scroll/bds.css +1 -1
- package/styles/h-scroll/bootstrap-dark.css +1 -1
- package/styles/h-scroll/bootstrap.css +1 -1
- package/styles/h-scroll/bootstrap4.css +1 -1
- package/styles/h-scroll/bootstrap5-dark.css +1 -1
- package/styles/h-scroll/bootstrap5.3.css +1 -1
- package/styles/h-scroll/bootstrap5.css +1 -1
- package/styles/h-scroll/fabric-dark.css +1 -1
- package/styles/h-scroll/fabric.css +1 -1
- package/styles/h-scroll/fluent-dark.css +1 -1
- package/styles/h-scroll/fluent.css +1 -1
- package/styles/h-scroll/fluent2.css +1 -1
- package/styles/h-scroll/highcontrast-light.css +1 -1
- package/styles/h-scroll/highcontrast.css +1 -1
- package/styles/h-scroll/material-dark.css +1 -1
- package/styles/h-scroll/material.css +1 -1
- package/styles/h-scroll/material3-dark.css +1 -1
- package/styles/h-scroll/material3.css +1 -1
- package/styles/h-scroll/tailwind-dark.css +1 -1
- package/styles/h-scroll/tailwind.css +1 -1
- package/styles/h-scroll/tailwind3.css +1 -1
- package/styles/highcontrast-light-lite.css +1 -1
- package/styles/highcontrast-light.css +1 -1
- package/styles/highcontrast-lite.css +1 -1
- package/styles/highcontrast.css +1 -1
- package/styles/material-dark-lite.css +1 -1
- package/styles/material-dark.css +1 -1
- package/styles/material-lite.css +1 -1
- package/styles/material.css +1 -1
- package/styles/material3-dark-lite.css +1 -1
- package/styles/material3-dark.css +1 -7
- package/styles/material3-lite.css +1 -1
- package/styles/material3.css +1 -7
- package/styles/tailwind-dark-lite.css +1 -1
- package/styles/tailwind-dark.css +1 -1
- package/styles/tailwind-lite.css +1 -1
- package/styles/tailwind.css +1 -1
- package/styles/tailwind3-lite.css +1 -1
- package/styles/tailwind3.css +1 -1
- package/styles/toolbar/_layout.scss +1 -1
- package/styles/treeview/_bigger.scss +2 -2
- package/styles/treeview/_bootstrap5.3-definition.scss +1 -0
- package/styles/treeview/_layout.scss +3 -0
- package/styles/treeview/bootstrap5.3.css +8 -0
- package/styles/treeview/fluent2.css +3 -0
- package/styles/treeview/material3-dark.css +0 -6
- package/styles/treeview/material3.css +0 -6
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import { Component, formatUnit, EventHandler, Event, isNullOrUndefined, closest, Browser } from '@syncfusion/ej2-base';
|
|
2
|
+
import { Property, EmitType, NotifyPropertyChanges, INotifyPropertyChanged, isNullOrUndefined as isNOU } from '@syncfusion/ej2-base';
|
|
3
|
+
import { setStyleAttribute as setStyle, addClass, removeClass, Touch, SwipeEventArgs } from '@syncfusion/ej2-base';
|
|
4
|
+
import { SidebarModel } from './sidebar-model';
|
|
5
|
+
|
|
6
|
+
const CONTROL: string = 'e-control';
|
|
7
|
+
const ROOT: string = 'e-sidebar';
|
|
8
|
+
const DOCKER: string = 'e-dock';
|
|
9
|
+
const CLOSE: string = 'e-close';
|
|
10
|
+
const OPEN: string = 'e-open';
|
|
11
|
+
const TRASITION: string = 'e-transition';
|
|
12
|
+
const DEFAULTBACKDROP: string = 'e-sidebar-overlay';
|
|
13
|
+
const RTL: string = 'e-rtl';
|
|
14
|
+
const RIGHT: string = 'e-right';
|
|
15
|
+
const LEFT: string = 'e-left';
|
|
16
|
+
const OVER: string = 'e-over';
|
|
17
|
+
const PUSH: string = 'e-push';
|
|
18
|
+
const SLIDE: string = 'e-slide';
|
|
19
|
+
const VISIBILITY: string = 'e-visibility';
|
|
20
|
+
const DISPLAY: string = 'e-sidebar-display';
|
|
21
|
+
const MAINCONTENTANIMATION: string = 'e-content-animation';
|
|
22
|
+
const DISABLEANIMATION: string = 'e-disable-animation';
|
|
23
|
+
const CONTEXT: string = 'e-sidebar-context';
|
|
24
|
+
const SIDEBARABSOLUTE: string = 'e-sidebar-absolute';
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the Sidebar types.
|
|
29
|
+
* ```props
|
|
30
|
+
* Slide :- Specifies the animation sliding while opening the sidebar.
|
|
31
|
+
* Over :- Specifies the sidebar appearing over the main content.
|
|
32
|
+
* Push :- Specifies the sidebar pushing the main content.
|
|
33
|
+
* Auto :- Specifies that the sidebar opens automatically.
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export type SidebarType = 'Slide' | 'Over' | 'Push' | 'Auto';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Specifies the Sidebar positions.
|
|
40
|
+
* ```props
|
|
41
|
+
* Left :- Sidebar positions to the Left in relation to the main content.
|
|
42
|
+
* Right :- Sidebar positions to the Right in relation to the main content.
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export type SidebarPosition = 'Left' | 'Right';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Sidebar is an expandable or collapsible
|
|
49
|
+
* component that typically act as a side container to place the primary or secondary content alongside of the main content.
|
|
50
|
+
* ```html
|
|
51
|
+
* <aside id="sidebar">
|
|
52
|
+
* </aside>
|
|
53
|
+
* ```
|
|
54
|
+
* ```typescript
|
|
55
|
+
* <script>
|
|
56
|
+
* let sidebarObject: Sidebar = new Sidebar();
|
|
57
|
+
* sidebarObject.appendTo("#sidebar");
|
|
58
|
+
* </script>
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
@NotifyPropertyChanges
|
|
62
|
+
export class Sidebar extends Component<HTMLElement> implements INotifyPropertyChanged {
|
|
63
|
+
private modal: HTMLElement;
|
|
64
|
+
private mainContentEle: Touch;
|
|
65
|
+
private sidebarEle: Touch;
|
|
66
|
+
private sidebarEleCopy: HTMLElement;
|
|
67
|
+
protected tabIndex: string;
|
|
68
|
+
private windowWidth: number;
|
|
69
|
+
private targetEle: HTMLElement;
|
|
70
|
+
// Specifies the first render of Sidebar component.
|
|
71
|
+
private firstRender: boolean;
|
|
72
|
+
private documentClickContext: EventListenerObject = this.documentclickHandler.bind(this);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Specifies the size of the Sidebar in dock state.
|
|
76
|
+
* > For more details about dockSize refer to
|
|
77
|
+
* [`Dock`](https://ej2.syncfusion.com/documentation/sidebar/docking-sidebar/) documentation.
|
|
78
|
+
*
|
|
79
|
+
* @default 'auto'
|
|
80
|
+
*/
|
|
81
|
+
@Property('auto')
|
|
82
|
+
public dockSize: string | number;
|
|
83
|
+
/**
|
|
84
|
+
* Specifies the media query string for resolution, which when met opens the Sidebar.
|
|
85
|
+
* ```typescript
|
|
86
|
+
* let defaultSidebar: Sidebar = new Sidebar({
|
|
87
|
+
* mediaQuery:'(min-width: 600px)'
|
|
88
|
+
* });
|
|
89
|
+
* ```
|
|
90
|
+
* > For more details about mediaQuery refer to
|
|
91
|
+
* [`Auto Close`](https://ej2.syncfusion.com/documentation/sidebar/auto-close/) documentation.
|
|
92
|
+
*
|
|
93
|
+
* @default null
|
|
94
|
+
* @aspType string
|
|
95
|
+
*/
|
|
96
|
+
@Property(null)
|
|
97
|
+
public mediaQuery: string | MediaQueryList;
|
|
98
|
+
/**
|
|
99
|
+
* Specifies the docking state of the component.
|
|
100
|
+
* > For more details about enableDock refer to
|
|
101
|
+
* [`Dock`](https://ej2.syncfusion.com/documentation/sidebar/docking-sidebar/) documentation.
|
|
102
|
+
*
|
|
103
|
+
* @default false
|
|
104
|
+
*/
|
|
105
|
+
@Property(false)
|
|
106
|
+
public enableDock: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Enables the expand or collapse while swiping in touch devices.
|
|
109
|
+
* This is not a sidebar property.
|
|
110
|
+
*
|
|
111
|
+
* @default 'en-US'
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
@Property('en-US')
|
|
115
|
+
public locale: string;
|
|
116
|
+
/**
|
|
117
|
+
* Enable or disable persisting component's state between page reloads. If enabled, following list of states will be persisted.
|
|
118
|
+
* 1. Position
|
|
119
|
+
* 2. Type
|
|
120
|
+
*
|
|
121
|
+
* @default false
|
|
122
|
+
*/
|
|
123
|
+
@Property(false)
|
|
124
|
+
public enablePersistence: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Enables the expand or collapse while swiping in touch devices.
|
|
127
|
+
*
|
|
128
|
+
* @default true
|
|
129
|
+
*/
|
|
130
|
+
@Property(true)
|
|
131
|
+
public enableGestures: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Gets or sets the Sidebar component is open or close.
|
|
134
|
+
* > When the Sidebar type is set to `Auto`,
|
|
135
|
+
* the component will be expanded in the desktop and collapsed in the mobile mode regardless of the isOpen property.
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
@Property(false)
|
|
140
|
+
public isOpen: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Specifies the Sidebar in RTL mode that displays the content in the right-to-left direction.
|
|
143
|
+
*
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
@Property(false)
|
|
147
|
+
public enableRtl: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Enable or disable the animation transitions on expanding or collapsing the Sidebar.
|
|
150
|
+
*
|
|
151
|
+
* @default true
|
|
152
|
+
*/
|
|
153
|
+
@Property(true)
|
|
154
|
+
public animate: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Specifies the height of the Sidebar.
|
|
157
|
+
*
|
|
158
|
+
* @default 'auto'
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
@Property('auto')
|
|
162
|
+
public height: string | number;
|
|
163
|
+
/**
|
|
164
|
+
* Specifies whether the Sidebar need to be closed or not when document area is clicked.
|
|
165
|
+
*
|
|
166
|
+
* @default false
|
|
167
|
+
*/
|
|
168
|
+
@Property(false)
|
|
169
|
+
public closeOnDocumentClick: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Specifies the position of the Sidebar (Left/Right) corresponding to the main content.
|
|
172
|
+
* > For more details about SidebarPosition refer to
|
|
173
|
+
* [`position`](https://ej2.syncfusion.com/documentation/sidebar/getting-started/#position) documentation.
|
|
174
|
+
*
|
|
175
|
+
* @default 'Left'
|
|
176
|
+
*/
|
|
177
|
+
@Property('Left')
|
|
178
|
+
public position: SidebarPosition;
|
|
179
|
+
/**
|
|
180
|
+
* Allows to place the sidebar inside the target element.
|
|
181
|
+
* > For more details about target refer to
|
|
182
|
+
* [`Custom Context`](https://ej2.syncfusion.com/documentation/sidebar/custom-context/) documentation.
|
|
183
|
+
*
|
|
184
|
+
* @default null
|
|
185
|
+
*/
|
|
186
|
+
@Property(null)
|
|
187
|
+
public target: HTMLElement | string;
|
|
188
|
+
/**
|
|
189
|
+
* Specifies the whether to apply overlay options to main content when the Sidebar is in an open state.
|
|
190
|
+
* > For more details about showBackdrop refer to
|
|
191
|
+
* [`Backdrop`](https://ej2.syncfusion.com/documentation/sidebar/getting-started/#enable-backdrop) documentation.
|
|
192
|
+
*
|
|
193
|
+
* @default false
|
|
194
|
+
*/
|
|
195
|
+
@Property(false)
|
|
196
|
+
public showBackdrop: boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Specifies the expanding types of the Sidebar.
|
|
199
|
+
* * `Over` - The sidebar floats over the main content area.
|
|
200
|
+
* * `Push` - The sidebar pushes the main content area to appear side-by-side, and shrinks the main content within the screen width.
|
|
201
|
+
* * `Slide` - The sidebar translates the x and y positions of main content area based on the sidebar width.
|
|
202
|
+
* The main content area will not be adjusted within the screen width.
|
|
203
|
+
* * `Auto` - Sidebar with `Over` type in mobile resolution and `Push` type in other higher resolutions.
|
|
204
|
+
* > For more details about SidebarType refer to
|
|
205
|
+
* [`SidebarType`](../../sidebar/variations/) documentation.
|
|
206
|
+
*
|
|
207
|
+
* @default 'Auto'
|
|
208
|
+
*/
|
|
209
|
+
@Property('Auto')
|
|
210
|
+
public type: SidebarType;
|
|
211
|
+
/**
|
|
212
|
+
* Specifies the width of the Sidebar. By default, the width of the Sidebar sets based on the size of its content.
|
|
213
|
+
* Width can also be set in pixel values.
|
|
214
|
+
*
|
|
215
|
+
* @default 'auto'
|
|
216
|
+
*/
|
|
217
|
+
@Property('auto')
|
|
218
|
+
public width: string | number;
|
|
219
|
+
/**
|
|
220
|
+
* Specifies the z-index of the Sidebar. It is applicable only when sidebar act as overlay type.
|
|
221
|
+
*
|
|
222
|
+
* @default 1000
|
|
223
|
+
* @aspType double
|
|
224
|
+
*/
|
|
225
|
+
@Property(1000)
|
|
226
|
+
public zIndex: string | number;
|
|
227
|
+
/**
|
|
228
|
+
* Triggers when component is created.
|
|
229
|
+
*
|
|
230
|
+
* @event created
|
|
231
|
+
*
|
|
232
|
+
*
|
|
233
|
+
*/
|
|
234
|
+
@Event()
|
|
235
|
+
public created: EmitType<Object>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Triggers when component is closed.
|
|
239
|
+
*
|
|
240
|
+
* @event close
|
|
241
|
+
*/
|
|
242
|
+
@Event()
|
|
243
|
+
public close: EmitType<EventArgs>;
|
|
244
|
+
/**
|
|
245
|
+
* Triggers when component is opened.
|
|
246
|
+
*
|
|
247
|
+
* @event open
|
|
248
|
+
*/
|
|
249
|
+
@Event()
|
|
250
|
+
public open: EmitType<EventArgs>;
|
|
251
|
+
/**
|
|
252
|
+
* Triggers when the state(expand/collapse) of the component is changed.
|
|
253
|
+
*
|
|
254
|
+
* @event change
|
|
255
|
+
*/
|
|
256
|
+
@Event()
|
|
257
|
+
public change: EmitType<ChangeEventArgs>;
|
|
258
|
+
/**
|
|
259
|
+
* Triggers when component gets destroyed.
|
|
260
|
+
*
|
|
261
|
+
* @event destroyed
|
|
262
|
+
*/
|
|
263
|
+
@Event()
|
|
264
|
+
public destroyed: EmitType<Object>;
|
|
265
|
+
defaultBackdropDiv: HTMLElement;
|
|
266
|
+
|
|
267
|
+
constructor(options?: SidebarModel, element?: string | HTMLElement) {
|
|
268
|
+
super(options, element);
|
|
269
|
+
}
|
|
270
|
+
protected preRender(): void {
|
|
271
|
+
this.setWidth();
|
|
272
|
+
}
|
|
273
|
+
protected render(): void {
|
|
274
|
+
this.initialize();
|
|
275
|
+
this.wireEvents();
|
|
276
|
+
this.renderComplete();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
protected initialize(): void {
|
|
280
|
+
this.setTarget();
|
|
281
|
+
this.addClass();
|
|
282
|
+
this.setZindex();
|
|
283
|
+
if (this.enableDock) {
|
|
284
|
+
this.setDock();
|
|
285
|
+
}
|
|
286
|
+
if (this.isOpen) {
|
|
287
|
+
this.show();
|
|
288
|
+
this.firstRender = true;
|
|
289
|
+
} else {
|
|
290
|
+
this.setMediaQuery();
|
|
291
|
+
}
|
|
292
|
+
this.checkType(true);
|
|
293
|
+
this.setType(this.type);
|
|
294
|
+
this.setCloseOnDocumentClick();
|
|
295
|
+
this.setEnableRTL();
|
|
296
|
+
if (Browser.isDevice) {
|
|
297
|
+
this.windowWidth = window.innerWidth;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private setEnableRTL(): void {
|
|
302
|
+
(this.enableRtl ? addClass : removeClass)([this.element], RTL);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private setTarget(): void {
|
|
306
|
+
this.targetEle = <HTMLElement>this.element.nextElementSibling;
|
|
307
|
+
this.sidebarEleCopy = <HTMLElement>this.element.cloneNode(true);
|
|
308
|
+
if (typeof (this.target) === 'string') {
|
|
309
|
+
this.setProperties({ target: <HTMLElement>document.querySelector(this.target) }, true);
|
|
310
|
+
}
|
|
311
|
+
if (this.target) {
|
|
312
|
+
(<HTMLElement>this.target).insertBefore(this.element, (<HTMLElement>this.target).children[0]);
|
|
313
|
+
addClass([this.element], SIDEBARABSOLUTE);
|
|
314
|
+
addClass([(<HTMLElement>this.target)], CONTEXT);
|
|
315
|
+
this.targetEle = this.getTargetElement();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
private getTargetElement(): HTMLElement {
|
|
320
|
+
let siblingElement: HTMLElement = <HTMLElement>this.element.nextElementSibling;
|
|
321
|
+
while (!isNOU(siblingElement)) {
|
|
322
|
+
if (!siblingElement.classList.contains(ROOT)) {
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
siblingElement = <HTMLElement>siblingElement.nextElementSibling;
|
|
326
|
+
}
|
|
327
|
+
return siblingElement;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private setCloseOnDocumentClick(): void {
|
|
331
|
+
if (this.closeOnDocumentClick) {
|
|
332
|
+
document.addEventListener('mousedown', this.documentClickContext);
|
|
333
|
+
document.addEventListener('touchstart', this.documentClickContext);
|
|
334
|
+
} else {
|
|
335
|
+
document.removeEventListener('mousedown', this.documentClickContext);
|
|
336
|
+
document.removeEventListener('touchstart', this.documentClickContext);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
private setWidth(): void {
|
|
341
|
+
if (this.enableDock && this.position === 'Left') {
|
|
342
|
+
setStyle(this.element, { 'width': this.setDimension(this.dockSize) });
|
|
343
|
+
} else if (this.enableDock && this.position === 'Right') {
|
|
344
|
+
setStyle(this.element, { 'width': this.setDimension(this.dockSize) });
|
|
345
|
+
} else if (!this.enableDock) {
|
|
346
|
+
setStyle(this.element, { 'width': this.setDimension(this.width) });
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
private setDimension(width: number | string): string {
|
|
351
|
+
if (typeof width === 'number') {
|
|
352
|
+
width = formatUnit(width);
|
|
353
|
+
} else if (typeof width === 'string') {
|
|
354
|
+
width = (width.match(/px|%|em/)) ? width : formatUnit(width);
|
|
355
|
+
} else {
|
|
356
|
+
width = '100%';
|
|
357
|
+
}
|
|
358
|
+
return width;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private setZindex(): void {
|
|
362
|
+
setStyle(this.element, { 'z-index': '' + this.zIndex });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
private addClass(): void {
|
|
366
|
+
if (this.element.tagName === 'EJS-SIDEBAR') {
|
|
367
|
+
addClass([this.element], DISPLAY);
|
|
368
|
+
}
|
|
369
|
+
const classELement: HTMLElement = <HTMLElement>document.querySelector('.e-main-content');
|
|
370
|
+
if (!isNullOrUndefined(classELement || this.targetEle)) {
|
|
371
|
+
addClass([classELement || this.targetEle], [MAINCONTENTANIMATION]);
|
|
372
|
+
}
|
|
373
|
+
this.tabIndex = this.element.hasAttribute('tabindex') ? this.element.getAttribute('tabindex') : null;
|
|
374
|
+
if (!this.enableDock && this.type !== 'Auto') {
|
|
375
|
+
addClass([this.element], [VISIBILITY]);
|
|
376
|
+
}
|
|
377
|
+
removeClass([this.element], [OPEN, CLOSE, RIGHT, LEFT, SLIDE, PUSH, OVER]);
|
|
378
|
+
this.element.classList.add(ROOT);
|
|
379
|
+
addClass([this.element], (this.position === 'Right') ? RIGHT : LEFT);
|
|
380
|
+
if (this.enableDock) {
|
|
381
|
+
addClass([this.element], DOCKER);
|
|
382
|
+
}
|
|
383
|
+
if (!isNullOrUndefined(this.tabIndex)) {
|
|
384
|
+
this.element.setAttribute('tabindex', this.tabIndex);
|
|
385
|
+
}
|
|
386
|
+
if (this.type === 'Auto' && !Browser.isDevice && this.checkMediaQuery()) {
|
|
387
|
+
this.show();
|
|
388
|
+
} else if (!this.isOpen) {
|
|
389
|
+
addClass([this.element], [CLOSE, DISABLEANIMATION]);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
private checkType(val: boolean): void {
|
|
393
|
+
if (!(this.type === 'Push' || this.type === 'Over' || this.type === 'Slide')) {
|
|
394
|
+
this.type = 'Auto';
|
|
395
|
+
} else {
|
|
396
|
+
if (!this.element.classList.contains(CLOSE) && !val) {
|
|
397
|
+
this.hide();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
private transitionEnd(e: Event): void {
|
|
402
|
+
this.setDock();
|
|
403
|
+
if (!isNullOrUndefined(e) && !this.firstRender) {
|
|
404
|
+
this.triggerChange();
|
|
405
|
+
}
|
|
406
|
+
this.firstRender = false;
|
|
407
|
+
EventHandler.remove(this.element, 'transitionend', this.transitionEnd);
|
|
408
|
+
}
|
|
409
|
+
private destroyBackDrop(): void {
|
|
410
|
+
const sibling: HTMLElement = (<HTMLElement>document.querySelector('.e-main-content')) || this.targetEle;
|
|
411
|
+
if (this.target && this.showBackdrop && sibling && !isNullOrUndefined(this.defaultBackdropDiv)) {
|
|
412
|
+
removeClass([this.defaultBackdropDiv], DEFAULTBACKDROP);
|
|
413
|
+
this.defaultBackdropDiv.remove();
|
|
414
|
+
this.defaultBackdropDiv = null;
|
|
415
|
+
} else if (this.showBackdrop && this.modal) {
|
|
416
|
+
this.modal.style.display = 'none';
|
|
417
|
+
this.modal.outerHTML = '';
|
|
418
|
+
this.modal = null;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Hide the Sidebar component, if it is in an open state.
|
|
424
|
+
*
|
|
425
|
+
* @param {Event} e - The event triggering the hide action.
|
|
426
|
+
* @returns {void}
|
|
427
|
+
*
|
|
428
|
+
*/
|
|
429
|
+
public hide(e?: Event): void {
|
|
430
|
+
const closeArguments: EventArgs = {
|
|
431
|
+
model: this,
|
|
432
|
+
element: this.element,
|
|
433
|
+
cancel: false,
|
|
434
|
+
isInteracted: !isNullOrUndefined(e),
|
|
435
|
+
event: (e || null)
|
|
436
|
+
};
|
|
437
|
+
this.trigger('close', closeArguments, (observedcloseArgs: EventArgs) => {
|
|
438
|
+
if (!observedcloseArgs.cancel) {
|
|
439
|
+
if (this.element.classList.contains(CLOSE)) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (this.element.classList.contains(OPEN) && !this.animate) {
|
|
443
|
+
this.triggerChange();
|
|
444
|
+
}
|
|
445
|
+
addClass([this.element], CLOSE);
|
|
446
|
+
removeClass([this.element], OPEN);
|
|
447
|
+
setStyle(this.element, { 'width': formatUnit(this.enableDock ? this.dockSize : this.width) });
|
|
448
|
+
this.setType(this.type);
|
|
449
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
450
|
+
if (!this.enableDock && sibling) {
|
|
451
|
+
sibling.style.transform = 'translateX(' + 0 + 'px)';
|
|
452
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = '0px';
|
|
453
|
+
}
|
|
454
|
+
this.destroyBackDrop();
|
|
455
|
+
this.setAnimation();
|
|
456
|
+
if (this.type === 'Slide') {
|
|
457
|
+
document.body.classList.remove('e-sidebar-overflow');
|
|
458
|
+
}
|
|
459
|
+
this.setProperties({ isOpen: false }, true);
|
|
460
|
+
if (this.enableDock) {
|
|
461
|
+
setTimeout((): void => this.setTimeOut(), 50);
|
|
462
|
+
}
|
|
463
|
+
EventHandler.add(this.element, 'transitionend', this.transitionEnd, this);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
private setTimeOut(): void {
|
|
469
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
470
|
+
const elementWidth: number = this.element.getBoundingClientRect().width;
|
|
471
|
+
if (this.element.classList.contains(OPEN) && sibling && !(this.type === 'Over' && this.enableDock)) {
|
|
472
|
+
if (this.position === 'Left') {
|
|
473
|
+
sibling.style.marginLeft = this.setDimension(this.width === 'auto' ? elementWidth : this.width);
|
|
474
|
+
} else {
|
|
475
|
+
sibling.style.marginRight = this.setDimension(this.width === 'auto' ? elementWidth : this.width);
|
|
476
|
+
}
|
|
477
|
+
} else if (this.element.classList.contains(CLOSE) && sibling) {
|
|
478
|
+
if (this.position === 'Left') {
|
|
479
|
+
sibling.style.marginLeft = this.setDimension(this.dockSize === 'auto' ? elementWidth : this.dockSize);
|
|
480
|
+
} else {
|
|
481
|
+
sibling.style.marginRight = this.setDimension(this.dockSize === 'auto' ? elementWidth : this.dockSize);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Shows the Sidebar component, if it is in closed state.
|
|
488
|
+
*
|
|
489
|
+
* @param {Event} e - The optional event triggering the show action.
|
|
490
|
+
* @returns {void}
|
|
491
|
+
*/
|
|
492
|
+
public show(e?: Event): void {
|
|
493
|
+
const openArguments: EventArgs = {
|
|
494
|
+
model: this,
|
|
495
|
+
element: this.element,
|
|
496
|
+
cancel: false,
|
|
497
|
+
isInteracted: !isNullOrUndefined(e),
|
|
498
|
+
event: (e || null)
|
|
499
|
+
};
|
|
500
|
+
this.trigger('open', openArguments, (observedopenArgs: EventArgs) => {
|
|
501
|
+
if (!observedopenArgs.cancel) {
|
|
502
|
+
removeClass([this.element], [VISIBILITY, DISABLEANIMATION]);
|
|
503
|
+
if (this.element.classList.contains(OPEN)) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
if (this.element.classList.contains(CLOSE) && !this.animate) {
|
|
507
|
+
this.triggerChange();
|
|
508
|
+
}
|
|
509
|
+
addClass([this.element], [OPEN, TRASITION]);
|
|
510
|
+
setStyle(this.element, { 'transform': '' });
|
|
511
|
+
removeClass([this.element], CLOSE);
|
|
512
|
+
setStyle(this.element, { 'width': formatUnit(this.width) });
|
|
513
|
+
this.setType(this.type);
|
|
514
|
+
if (this.targetEle && !this.targetEle.querySelector('.e-sidebar-overlay')) {
|
|
515
|
+
this.createBackDrop();
|
|
516
|
+
}
|
|
517
|
+
this.setAnimation();
|
|
518
|
+
if (this.type === 'Slide') {
|
|
519
|
+
document.body.classList.add('e-sidebar-overflow');
|
|
520
|
+
}
|
|
521
|
+
this.setProperties({ isOpen: true }, true);
|
|
522
|
+
EventHandler.add(this.element, 'transitionend', this.transitionEnd, this);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
private setAnimation(): void {
|
|
528
|
+
if (this.animate) {
|
|
529
|
+
removeClass([this.element], DISABLEANIMATION);
|
|
530
|
+
} else {
|
|
531
|
+
addClass([this.element], DISABLEANIMATION);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
private triggerChange(): void {
|
|
536
|
+
const changeArguments: ChangeEventArgs = { name: 'change', element: this.element };
|
|
537
|
+
this.trigger('change', changeArguments);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
private setDock(): void {
|
|
541
|
+
if (this.enableDock && this.position === 'Left' && !this.getState()) {
|
|
542
|
+
setStyle(this.element, { 'transform': 'translateX(' + -100 + '%) translateX(' + this.setDimension(this.dockSize) + ')' });
|
|
543
|
+
} else if (this.enableDock && this.position === 'Right' && !this.getState()) {
|
|
544
|
+
setStyle(this.element, { 'transform': 'translateX(' + 100 + '%) translateX(' + '-' + this.setDimension(this.dockSize) + ')' });
|
|
545
|
+
}
|
|
546
|
+
if (this.element.classList.contains(CLOSE) && this.enableDock) {
|
|
547
|
+
setStyle(this.element, { 'width': this.setDimension(this.dockSize) });
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
private createBackDrop(): void {
|
|
551
|
+
if (this.target && this.showBackdrop && this.getState()) {
|
|
552
|
+
const targetString: HTMLElement = <HTMLElement>this.target;
|
|
553
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
554
|
+
this.defaultBackdropDiv = this.createElement('div');
|
|
555
|
+
addClass([this.defaultBackdropDiv], DEFAULTBACKDROP);
|
|
556
|
+
setStyle(this.defaultBackdropDiv, {height: targetString.style.height});
|
|
557
|
+
sibling.appendChild(this.defaultBackdropDiv);
|
|
558
|
+
} else if (this.showBackdrop && !this.modal && this.getState()) {
|
|
559
|
+
this.modal = this.createElement('div');
|
|
560
|
+
this.modal.className = DEFAULTBACKDROP;
|
|
561
|
+
this.modal.style.display = 'block';
|
|
562
|
+
document.body.appendChild(this.modal);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
protected getPersistData(): string {
|
|
567
|
+
return this.addOnPersist(['type', 'position', 'isOpen']);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Returns the current module name.
|
|
572
|
+
*
|
|
573
|
+
* @returns {string} - returns module name.
|
|
574
|
+
* @private
|
|
575
|
+
*
|
|
576
|
+
*/
|
|
577
|
+
protected getModuleName(): string {
|
|
578
|
+
return 'sidebar';
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Shows or hides the Sidebar based on the current state.
|
|
583
|
+
*
|
|
584
|
+
* @returns {void}
|
|
585
|
+
*/
|
|
586
|
+
public toggle(): void {
|
|
587
|
+
if (this.element.classList.contains(OPEN)) {
|
|
588
|
+
this.hide();
|
|
589
|
+
} else {
|
|
590
|
+
this.show();
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
protected getState(): boolean {
|
|
595
|
+
return this.element.classList.contains(OPEN) ? true : false;
|
|
596
|
+
}
|
|
597
|
+
private setMediaQuery(): void {
|
|
598
|
+
if (this.mediaQuery) {
|
|
599
|
+
let media: boolean = false;
|
|
600
|
+
if (typeof (this.mediaQuery) === 'string') {
|
|
601
|
+
media = window.matchMedia(this.mediaQuery).matches;
|
|
602
|
+
} else {
|
|
603
|
+
media = (this.mediaQuery).matches;
|
|
604
|
+
}
|
|
605
|
+
if (media && this.windowWidth !== window.innerWidth) {
|
|
606
|
+
this.show();
|
|
607
|
+
} else if (this.getState() && this.windowWidth !== window.innerWidth) {
|
|
608
|
+
this.hide();
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
private checkMediaQuery(): boolean {
|
|
613
|
+
if (isNullOrUndefined(this.mediaQuery)) {
|
|
614
|
+
return true;
|
|
615
|
+
}
|
|
616
|
+
return (typeof (this.mediaQuery) === 'string') ?
|
|
617
|
+
window.matchMedia(this.mediaQuery).matches : (this.mediaQuery).matches;
|
|
618
|
+
}
|
|
619
|
+
protected resize(): void {
|
|
620
|
+
if (!isNullOrUndefined(this.width) && this.width !== 'auto' && typeof this.width === 'string' && !this.width.includes('px')) {
|
|
621
|
+
this.setType(this.type);
|
|
622
|
+
}
|
|
623
|
+
if (this.type === 'Auto') {
|
|
624
|
+
if (Browser.isDevice) {
|
|
625
|
+
addClass([this.element], OVER);
|
|
626
|
+
} else {
|
|
627
|
+
addClass([this.element], PUSH);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
this.setMediaQuery();
|
|
631
|
+
if (Browser.isDevice) {
|
|
632
|
+
this.windowWidth = window.innerWidth;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
private documentclickHandler(e: MouseEvent): void {
|
|
637
|
+
if (closest((<HTMLElement>e.target), '.' + CONTROL + '' + '.' + ROOT)) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
this.hide(e);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
private enableGestureHandler(args: SwipeEventArgs): void {
|
|
644
|
+
if (!this.isOpen && this.position === 'Left' && args.swipeDirection === 'Right' &&
|
|
645
|
+
(args.startX <= 20 && args.distanceX >= 50 && args.velocity >= 0.5)) {
|
|
646
|
+
this.show();
|
|
647
|
+
} else if (this.isOpen && this.position === 'Left' && args.swipeDirection === 'Left') {
|
|
648
|
+
this.hide(args.originalEvent as Event);
|
|
649
|
+
} else if (this.isOpen && this.position === 'Right' && args.swipeDirection === 'Right') {
|
|
650
|
+
this.hide(args.originalEvent as Event);
|
|
651
|
+
} else if (!this.isOpen && this.position === 'Right' && args.swipeDirection === 'Left'
|
|
652
|
+
&& (window.innerWidth - args.startX <= 20 && args.distanceX >= 50 && args.velocity >= 0.5)) {
|
|
653
|
+
this.show();
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
private setEnableGestures(): void {
|
|
657
|
+
if (this.enableGestures) {
|
|
658
|
+
this.mainContentEle = new Touch(document.body, { swipe: this.enableGestureHandler.bind(this) });
|
|
659
|
+
this.sidebarEle = new Touch(<HTMLElement>this.element, { swipe: this.enableGestureHandler.bind(this) });
|
|
660
|
+
} else {
|
|
661
|
+
if (this.mainContentEle && this.sidebarEle) {
|
|
662
|
+
this.mainContentEle.destroy();
|
|
663
|
+
this.sidebarEle.destroy();
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
private wireEvents(): void {
|
|
668
|
+
this.setEnableGestures();
|
|
669
|
+
EventHandler.add(<HTMLElement & Window><unknown>window, 'resize', this.resize, this);
|
|
670
|
+
}
|
|
671
|
+
private unWireEvents(): void {
|
|
672
|
+
EventHandler.remove(<HTMLElement & Window><unknown>window, 'resize', this.resize);
|
|
673
|
+
EventHandler.remove(document, 'mousedown touchstart', this.documentclickHandler);
|
|
674
|
+
if (this.mainContentEle) { this.mainContentEle.destroy(); }
|
|
675
|
+
if (this.sidebarEle) { this.sidebarEle.destroy(); }
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Called internally if any of the property value changed.
|
|
679
|
+
*
|
|
680
|
+
* @param {SidebarModel} newProp - specifies newProp value.
|
|
681
|
+
* @param {SidebarModel} oldProp - specifies oldProp value.
|
|
682
|
+
* @returns {void}
|
|
683
|
+
* @private
|
|
684
|
+
*
|
|
685
|
+
*/
|
|
686
|
+
public onPropertyChanged(newProp: SidebarModel, oldProp: SidebarModel): void {
|
|
687
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
688
|
+
const isRendered: boolean = this.isServerRendered;
|
|
689
|
+
for (const prop of Object.keys(newProp)) {
|
|
690
|
+
switch (prop) {
|
|
691
|
+
case 'isOpen':
|
|
692
|
+
if (this.isOpen) {
|
|
693
|
+
this.show();
|
|
694
|
+
} else {
|
|
695
|
+
this.hide();
|
|
696
|
+
}
|
|
697
|
+
break;
|
|
698
|
+
case 'width':
|
|
699
|
+
this.setWidth();
|
|
700
|
+
if (!this.getState()) {
|
|
701
|
+
this.setDock();
|
|
702
|
+
}
|
|
703
|
+
break;
|
|
704
|
+
case 'animate':
|
|
705
|
+
this.setAnimation();
|
|
706
|
+
break;
|
|
707
|
+
case 'type':
|
|
708
|
+
this.checkType(false);
|
|
709
|
+
removeClass([this.element], [VISIBILITY]);
|
|
710
|
+
this.addClass();
|
|
711
|
+
addClass([this.element], this.type === 'Auto' ? (Browser.isDevice ? ['e-over'] :
|
|
712
|
+
['e-push']) : ['e-' + this.type.toLowerCase()]);
|
|
713
|
+
break;
|
|
714
|
+
case 'position':
|
|
715
|
+
this.element.style.transform = '';
|
|
716
|
+
this.setDock();
|
|
717
|
+
if (sibling) {
|
|
718
|
+
sibling.style[this.position === 'Left' ? 'marginRight' : 'marginLeft'] = '0px';
|
|
719
|
+
}
|
|
720
|
+
if (this.position === 'Right') {
|
|
721
|
+
removeClass([this.element], LEFT);
|
|
722
|
+
addClass([this.element], RIGHT);
|
|
723
|
+
} else {
|
|
724
|
+
removeClass([this.element], RIGHT);
|
|
725
|
+
addClass([this.element], LEFT);
|
|
726
|
+
}
|
|
727
|
+
this.setType(this.type);
|
|
728
|
+
break;
|
|
729
|
+
case 'showBackdrop':
|
|
730
|
+
if (this.showBackdrop) { this.createBackDrop(); } else {
|
|
731
|
+
if (this.modal) {
|
|
732
|
+
this.modal.style.display = 'none';
|
|
733
|
+
this.modal.outerHTML = '';
|
|
734
|
+
this.modal = null;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
break;
|
|
738
|
+
case 'target':
|
|
739
|
+
if (typeof (this.target) === 'string') {
|
|
740
|
+
this.setProperties({ target: <HTMLElement>document.querySelector(this.target) }, true);
|
|
741
|
+
}
|
|
742
|
+
if (isNullOrUndefined(this.target)) {
|
|
743
|
+
removeClass([this.element], SIDEBARABSOLUTE);
|
|
744
|
+
removeClass([<HTMLElement>oldProp.target], CONTEXT);
|
|
745
|
+
setStyle(sibling, { 'margin-left': 0, 'margin-right': 0 });
|
|
746
|
+
document.body.insertAdjacentElement('afterbegin', this.element);
|
|
747
|
+
}
|
|
748
|
+
this.isServerRendered = false;
|
|
749
|
+
super.refresh();
|
|
750
|
+
this.isServerRendered = isRendered;
|
|
751
|
+
break;
|
|
752
|
+
case 'closeOnDocumentClick':
|
|
753
|
+
this.setCloseOnDocumentClick();
|
|
754
|
+
break;
|
|
755
|
+
case 'enableDock':
|
|
756
|
+
if (!this.getState()) {
|
|
757
|
+
this.setDock();
|
|
758
|
+
}
|
|
759
|
+
break;
|
|
760
|
+
case 'zIndex':
|
|
761
|
+
this.setZindex();
|
|
762
|
+
break;
|
|
763
|
+
case 'mediaQuery':
|
|
764
|
+
this.setMediaQuery();
|
|
765
|
+
break;
|
|
766
|
+
case 'enableGestures':
|
|
767
|
+
this.setEnableGestures();
|
|
768
|
+
break;
|
|
769
|
+
case 'enableRtl':
|
|
770
|
+
this.setEnableRTL();
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
protected setType(type?: string): void {
|
|
777
|
+
const elementWidth: number = this.element.getBoundingClientRect().width;
|
|
778
|
+
this.setZindex();
|
|
779
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
780
|
+
if (sibling) {
|
|
781
|
+
sibling.style.transform = 'translateX(' + 0 + 'px)';
|
|
782
|
+
if (!Browser.isDevice && this.type !== 'Auto' && !(this.type === 'Over' && this.enableDock)) {
|
|
783
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = '0px';
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
const margin: string = this.position === 'Left' ? elementWidth + 'px' : elementWidth + 'px';
|
|
787
|
+
const eleWidth: number = this.position === 'Left' ? elementWidth : - (elementWidth);
|
|
788
|
+
removeClass([this.element], [PUSH, OVER, SLIDE]);
|
|
789
|
+
switch (type) {
|
|
790
|
+
case 'Push':
|
|
791
|
+
addClass([this.element], [PUSH]);
|
|
792
|
+
if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
|
|
793
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
|
|
794
|
+
} break;
|
|
795
|
+
case 'Slide':
|
|
796
|
+
addClass([this.element], [SLIDE]);
|
|
797
|
+
if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
|
|
798
|
+
sibling.style.transform = 'translateX(' + eleWidth + 'px)';
|
|
799
|
+
} break;
|
|
800
|
+
case 'Over':
|
|
801
|
+
addClass([this.element], [OVER]);
|
|
802
|
+
if (this.enableDock && (this.element.classList.contains(CLOSE) || this.isOpen)) {
|
|
803
|
+
if (sibling) {
|
|
804
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = this.setDimension(this.dockSize);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
case 'Auto':
|
|
809
|
+
addClass([this.element], [TRASITION]);
|
|
810
|
+
if (Browser.isDevice) {
|
|
811
|
+
if (sibling && (this.enableDock) && !this.getState()) {
|
|
812
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
|
|
813
|
+
addClass([this.element], PUSH);
|
|
814
|
+
} else {
|
|
815
|
+
addClass([this.element], OVER);
|
|
816
|
+
}
|
|
817
|
+
} else {
|
|
818
|
+
addClass([this.element], PUSH);
|
|
819
|
+
if (sibling && (this.enableDock || this.element.classList.contains(OPEN))) {
|
|
820
|
+
sibling.style[this.position === 'Left' ? 'marginLeft' : 'marginRight'] = margin;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
this.createBackDrop();
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Removes the control from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.
|
|
829
|
+
*
|
|
830
|
+
* @returns {void}
|
|
831
|
+
*
|
|
832
|
+
*/
|
|
833
|
+
public destroy(): void {
|
|
834
|
+
super.destroy();
|
|
835
|
+
if (this.target) {
|
|
836
|
+
removeClass([<HTMLElement>this.target], CONTEXT);
|
|
837
|
+
}
|
|
838
|
+
this.destroyBackDrop();
|
|
839
|
+
if (this.element) {
|
|
840
|
+
removeClass([this.element], [OPEN, CLOSE, PUSH, SLIDE, OVER, LEFT, RIGHT, TRASITION, DISABLEANIMATION]);
|
|
841
|
+
removeClass([this.element], SIDEBARABSOLUTE);
|
|
842
|
+
this.element.style.width = '';
|
|
843
|
+
this.element.style.zIndex = '';
|
|
844
|
+
this.element.style.transform = '';
|
|
845
|
+
if (!isNullOrUndefined(this.sidebarEleCopy.getAttribute('tabindex'))){
|
|
846
|
+
this.element.setAttribute('tabindex', this.tabIndex);
|
|
847
|
+
} else{
|
|
848
|
+
this.element.removeAttribute('tabindex');
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
this.windowWidth = null;
|
|
852
|
+
const sibling: HTMLElement = <HTMLElement>document.querySelector('.e-main-content') || this.targetEle;
|
|
853
|
+
if (!isNullOrUndefined(sibling)) {
|
|
854
|
+
sibling.style.margin = '';
|
|
855
|
+
sibling.style.transform = '';
|
|
856
|
+
}
|
|
857
|
+
this.unWireEvents();
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
*
|
|
862
|
+
* Defines the event arguments for the event.
|
|
863
|
+
*
|
|
864
|
+
* @returns void
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
export interface ChangeEventArgs {
|
|
868
|
+
/**
|
|
869
|
+
* Returns event name
|
|
870
|
+
*/
|
|
871
|
+
name: string;
|
|
872
|
+
/**
|
|
873
|
+
* Defines the element.
|
|
874
|
+
*/
|
|
875
|
+
element: HTMLElement;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
export interface TransitionEvent extends Event {
|
|
879
|
+
/**
|
|
880
|
+
* Returns event name
|
|
881
|
+
*/
|
|
882
|
+
propertyName: string;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export interface EventArgs {
|
|
886
|
+
/**
|
|
887
|
+
* Illustrates whether the current action needs to be prevented or not.
|
|
888
|
+
*/
|
|
889
|
+
cancel?: boolean;
|
|
890
|
+
/**
|
|
891
|
+
* Defines the Sidebar model.
|
|
892
|
+
*/
|
|
893
|
+
model?: SidebarModel;
|
|
894
|
+
/**
|
|
895
|
+
* Defines the element.
|
|
896
|
+
*/
|
|
897
|
+
element: HTMLElement;
|
|
898
|
+
/**
|
|
899
|
+
* Defines the boolean that returns true when the Sidebar is closed by user interaction, otherwise returns false.
|
|
900
|
+
*/
|
|
901
|
+
isInteracted?: boolean;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Defines the original event arguments.
|
|
905
|
+
*/
|
|
906
|
+
event?: MouseEvent | Event;
|
|
907
|
+
}
|