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