@syncfusion/ej2-navigations 31.1.17 → 31.1.20
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/package.json +14 -67
- package/src/treeview/treeview.js +1 -0
- package/styles/bds-lite.css +7 -6
- package/styles/bds.css +7 -6
- package/styles/bootstrap-dark-lite.css +6 -3
- package/styles/bootstrap-dark.css +6 -3
- package/styles/bootstrap-lite.css +6 -3
- package/styles/bootstrap.css +6 -3
- package/styles/bootstrap4-lite.css +13 -9
- package/styles/bootstrap4.css +24 -13
- package/styles/bootstrap5-dark-lite.css +6 -5
- package/styles/bootstrap5-dark.css +16 -7
- package/styles/bootstrap5-lite.css +6 -5
- package/styles/bootstrap5.3-lite.css +23 -10
- package/styles/bootstrap5.3.css +34 -13
- package/styles/bootstrap5.css +16 -7
- package/styles/fabric-dark-lite.css +6 -3
- package/styles/fabric-dark.css +6 -3
- package/styles/fabric-lite.css +6 -3
- package/styles/fabric.css +6 -3
- package/styles/fluent-dark-lite.css +16 -12
- package/styles/fluent-dark.css +26 -15
- package/styles/fluent-lite.css +16 -12
- package/styles/fluent.css +26 -15
- package/styles/fluent2-lite.css +6 -4
- package/styles/fluent2.css +6 -4
- package/styles/highcontrast-light-lite.css +4 -4
- package/styles/highcontrast-light.css +4 -4
- package/styles/highcontrast-lite.css +14 -10
- package/styles/highcontrast.css +26 -13
- package/styles/material-dark-lite.css +19 -13
- package/styles/material-dark.css +39 -17
- package/styles/material-lite.css +19 -10
- package/styles/material.css +36 -13
- package/styles/material3-dark-lite.css +4 -4
- package/styles/material3-dark.css +5 -4
- package/styles/material3-lite.css +4 -4
- package/styles/material3.css +5 -4
- package/styles/menu/_bootstrap-dark-definition.scss +1 -0
- package/styles/menu/_bootstrap-definition.scss +1 -0
- package/styles/menu/_fluent-definition.scss +1 -1
- package/styles/menu/_fluent2-definition.scss +1 -1
- package/styles/menu/_layout.scss +7 -1
- package/styles/menu/bds.css +1 -0
- package/styles/menu/bootstrap-dark.css +1 -0
- package/styles/menu/bootstrap.css +1 -0
- package/styles/menu/bootstrap4.css +1 -0
- package/styles/menu/bootstrap5-dark.css +1 -0
- package/styles/menu/bootstrap5.3.css +1 -0
- package/styles/menu/bootstrap5.css +1 -0
- package/styles/menu/fabric-dark.css +1 -0
- package/styles/menu/fabric.css +1 -0
- package/styles/menu/fluent-dark.css +2 -1
- package/styles/menu/fluent.css +2 -1
- package/styles/menu/fluent2.css +2 -1
- package/styles/menu/highcontrast-light.css +1 -0
- package/styles/menu/highcontrast.css +1 -0
- package/styles/menu/material-dark.css +1 -0
- package/styles/menu/material.css +1 -0
- package/styles/menu/material3-dark.css +1 -0
- package/styles/menu/material3.css +1 -0
- package/styles/menu/tailwind-dark.css +1 -0
- package/styles/menu/tailwind.css +1 -0
- package/styles/menu/tailwind3.css +1 -0
- package/styles/tailwind-dark-lite.css +6 -5
- package/styles/tailwind-dark.css +6 -5
- package/styles/tailwind-lite.css +6 -5
- package/styles/tailwind.css +6 -5
- package/styles/tailwind3-lite.css +11 -5
- package/styles/tailwind3.css +18 -5
- package/styles/treeview/_bds-definition.scss +1 -1
- package/styles/treeview/_bigger.scss +91 -0
- package/styles/treeview/_bootstrap4-definition.scss +7 -7
- package/styles/treeview/_bootstrap5-definition.scss +2 -2
- package/styles/treeview/_bootstrap5.3-definition.scss +8 -8
- package/styles/treeview/_fluent-definition.scss +6 -6
- package/styles/treeview/_highcontrast-definition.scss +6 -6
- package/styles/treeview/_layout.scss +67 -16
- package/styles/treeview/_material-dark-definition.scss +7 -7
- package/styles/treeview/_material-definition.scss +6 -6
- package/styles/treeview/_tailwind3-definition.scss +1 -1
- package/styles/treeview/_theme.scss +7 -2
- package/styles/treeview/bds.css +6 -6
- package/styles/treeview/bootstrap-dark.css +5 -3
- package/styles/treeview/bootstrap.css +5 -3
- package/styles/treeview/bootstrap4.css +23 -13
- package/styles/treeview/bootstrap5-dark.css +15 -7
- package/styles/treeview/bootstrap5.3.css +33 -13
- package/styles/treeview/bootstrap5.css +15 -7
- package/styles/treeview/fabric-dark.css +5 -3
- package/styles/treeview/fabric.css +5 -3
- package/styles/treeview/fluent-dark.css +24 -14
- package/styles/treeview/fluent.css +24 -14
- package/styles/treeview/fluent2.css +4 -3
- package/styles/treeview/highcontrast-light.css +3 -4
- package/styles/treeview/highcontrast.css +25 -13
- package/styles/treeview/material-dark.css +38 -17
- package/styles/treeview/material.css +35 -13
- package/styles/treeview/material3-dark.css +4 -4
- package/styles/treeview/material3.css +4 -4
- package/styles/treeview/tailwind-dark.css +5 -5
- package/styles/treeview/tailwind.css +5 -5
- package/styles/treeview/tailwind3.css +17 -5
- package/dist/ts/accordion/accordion-model.d.ts +0 -285
- package/dist/ts/accordion/accordion.d.ts +0 -458
- package/dist/ts/accordion/accordion.ts +0 -1580
- package/dist/ts/accordion/index.d.ts +0 -5
- package/dist/ts/accordion/index.ts +0 -5
- package/dist/ts/appbar/appbar-model.d.ts +0 -76
- package/dist/ts/appbar/appbar.d.ts +0 -115
- package/dist/ts/appbar/appbar.ts +0 -281
- package/dist/ts/appbar/index.d.ts +0 -3
- package/dist/ts/appbar/index.ts +0 -3
- package/dist/ts/breadcrumb/breadcrumb-model.d.ts +0 -170
- package/dist/ts/breadcrumb/breadcrumb.d.ts +0 -297
- package/dist/ts/breadcrumb/breadcrumb.ts +0 -959
- package/dist/ts/breadcrumb/index.d.ts +0 -5
- package/dist/ts/breadcrumb/index.ts +0 -5
- package/dist/ts/carousel/carousel-model.d.ts +0 -282
- package/dist/ts/carousel/carousel.d.ts +0 -439
- package/dist/ts/carousel/carousel.ts +0 -1633
- package/dist/ts/carousel/index.d.ts +0 -3
- package/dist/ts/carousel/index.ts +0 -3
- package/dist/ts/common/h-scroll-model.d.ts +0 -16
- package/dist/ts/common/h-scroll.d.ts +0 -105
- package/dist/ts/common/h-scroll.ts +0 -481
- package/dist/ts/common/index.d.ts +0 -9
- package/dist/ts/common/index.ts +0 -10
- package/dist/ts/common/menu-base-model.d.ts +0 -308
- package/dist/ts/common/menu-base.d.ts +0 -558
- package/dist/ts/common/menu-base.ts +0 -2736
- package/dist/ts/common/menu-scroll.d.ts +0 -29
- package/dist/ts/common/menu-scroll.ts +0 -105
- package/dist/ts/common/v-scroll-model.d.ts +0 -16
- package/dist/ts/common/v-scroll.d.ts +0 -106
- package/dist/ts/common/v-scroll.ts +0 -454
- package/dist/ts/context-menu/context-menu-model.d.ts +0 -47
- package/dist/ts/context-menu/context-menu.d.ts +0 -102
- package/dist/ts/context-menu/context-menu.ts +0 -165
- package/dist/ts/context-menu/index.d.ts +0 -5
- package/dist/ts/context-menu/index.ts +0 -5
- package/dist/ts/index.d.ts +0 -16
- package/dist/ts/index.ts +0 -16
- package/dist/ts/menu/index.d.ts +0 -5
- package/dist/ts/menu/index.ts +0 -5
- package/dist/ts/menu/menu-model.d.ts +0 -70
- package/dist/ts/menu/menu.d.ts +0 -127
- package/dist/ts/menu/menu.ts +0 -313
- package/dist/ts/sidebar/index.d.ts +0 -5
- package/dist/ts/sidebar/index.ts +0 -5
- package/dist/ts/sidebar/sidebar-model.d.ts +0 -200
- package/dist/ts/sidebar/sidebar.d.ts +0 -336
- package/dist/ts/sidebar/sidebar.ts +0 -907
- package/dist/ts/stepper/index.d.ts +0 -3
- package/dist/ts/stepper/index.ts +0 -3
- package/dist/ts/stepper/stepper-model.d.ts +0 -159
- package/dist/ts/stepper/stepper.d.ts +0 -381
- package/dist/ts/stepper/stepper.ts +0 -1350
- package/dist/ts/stepper-base/index.d.ts +0 -5
- package/dist/ts/stepper-base/index.ts +0 -6
- package/dist/ts/stepper-base/stepper-base-model.d.ts +0 -124
- package/dist/ts/stepper-base/stepper-base.d.ts +0 -187
- package/dist/ts/stepper-base/stepper-base.ts +0 -290
- package/dist/ts/tab/index.d.ts +0 -5
- package/dist/ts/tab/index.ts +0 -5
- package/dist/ts/tab/tab-model.d.ts +0 -408
- package/dist/ts/tab/tab.d.ts +0 -715
- package/dist/ts/tab/tab.ts +0 -2842
- package/dist/ts/toolbar/index.d.ts +0 -5
- package/dist/ts/toolbar/index.ts +0 -5
- package/dist/ts/toolbar/toolbar-model.d.ts +0 -294
- package/dist/ts/toolbar/toolbar.d.ts +0 -541
- package/dist/ts/toolbar/toolbar.ts +0 -2646
- package/dist/ts/treeview/index.d.ts +0 -5
- package/dist/ts/treeview/index.ts +0 -5
- package/dist/ts/treeview/treeview-model.d.ts +0 -637
- package/dist/ts/treeview/treeview.d.ts +0 -1518
- package/dist/ts/treeview/treeview.ts +0 -6780
|
@@ -1,2646 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { Component, EventHandler, Property, Event, EmitType, BaseEventArgs } from '@syncfusion/ej2-base';
|
|
3
|
-
import { addClass, removeClass, isVisible, closest, attributes, detach, classList, KeyboardEvents } from '@syncfusion/ej2-base';
|
|
4
|
-
import { selectAll, setStyleAttribute as setStyle, KeyboardEventArgs, select } from '@syncfusion/ej2-base';
|
|
5
|
-
import { isNullOrUndefined as isNOU, getUniqueID, formatUnit, Collection, compile as templateCompiler } from '@syncfusion/ej2-base';
|
|
6
|
-
import { INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Browser, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
|
|
7
|
-
import { Popup } from '@syncfusion/ej2-popups';
|
|
8
|
-
import { calculatePosition } from '@syncfusion/ej2-popups';
|
|
9
|
-
import { Button, IconPosition } from '@syncfusion/ej2-buttons';
|
|
10
|
-
import { HScroll } from '../common/h-scroll';
|
|
11
|
-
import { VScroll } from '../common/v-scroll';
|
|
12
|
-
import { ToolbarModel, ItemModel } from './toolbar-model';
|
|
13
|
-
/**
|
|
14
|
-
* Specifies the options for supporting element types of Toolbar command.
|
|
15
|
-
* ```props
|
|
16
|
-
* Button :- Creates the Button control with its given properties like text, prefixIcon, etc.
|
|
17
|
-
* Separator :- Adds a horizontal line that separates the Toolbar commands.
|
|
18
|
-
* Input :- Creates an input element that is applicable to template rendering with Syncfusion controls like DropDownList, AutoComplete, etc.
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export type ItemType = 'Button' | 'Separator' | 'Input';
|
|
22
|
-
/**
|
|
23
|
-
* Specifies the options of where the text will be displayed in popup mode of the Toolbar.
|
|
24
|
-
* ```props
|
|
25
|
-
* Toolbar :- Text will be displayed on Toolbar only.
|
|
26
|
-
* Overflow :- Text will be displayed only when content overflows to popup.
|
|
27
|
-
* Both :- Text will be displayed on popup and Toolbar.
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export type DisplayMode = 'Both' | 'Overflow' | 'Toolbar';
|
|
31
|
-
/**
|
|
32
|
-
* Specifies the options of the Toolbar item display area when the Toolbar content overflows to available space.Applicable to `popup` mode.
|
|
33
|
-
* ```props
|
|
34
|
-
* Show :- Always shows the item as the primary priority on the *Toolbar*.
|
|
35
|
-
* Hide :- Always shows the item as the secondary priority on the *popup*.
|
|
36
|
-
* None :- No priority for display, and as per normal order moves to popup when content exceeds.
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export type OverflowOption = 'None' | 'Show' | 'Hide';
|
|
40
|
-
/**
|
|
41
|
-
* Specifies the options of Toolbar display mode. Display option is considered when Toolbar content exceeds the available space.
|
|
42
|
-
* ```props
|
|
43
|
-
* Scrollable :- All the elements are displayed in a single line with horizontal scrolling enabled.
|
|
44
|
-
* Popup :- Prioritized elements are displayed on the Toolbar and the rest of elements are moved to the popup.
|
|
45
|
-
* MultiRow :- Displays the overflow toolbar items as an in-line of a toolbar.
|
|
46
|
-
* Extended :- Hide the overflowing toolbar items in the next row. Show the overflowing toolbar items when you click the expand icons, if the popup content overflows the height of the page, the rest of the elements will be hidden.
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export type OverflowMode = 'Scrollable' |'Popup' | 'MultiRow' | 'Extended';
|
|
50
|
-
|
|
51
|
-
type HTEle = HTMLElement;
|
|
52
|
-
type Str = string;
|
|
53
|
-
type ItmAlign = 'lefts' | 'centers' | 'rights';
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Specifies the options for aligning the Toolbar items.
|
|
57
|
-
* ```props
|
|
58
|
-
* Left :- To align commands to the left side of the Toolbar.
|
|
59
|
-
* Center :- To align commands at the center of the Toolbar.
|
|
60
|
-
* Right :- To align commands to the right side of the Toolbar.
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export type ItemAlign = 'Left' | 'Center' | 'Right';
|
|
64
|
-
|
|
65
|
-
const CLS_VERTICAL: Str = 'e-vertical';
|
|
66
|
-
const CLS_ITEMS: Str = 'e-toolbar-items';
|
|
67
|
-
const CLS_ITEM: Str = 'e-toolbar-item';
|
|
68
|
-
const CLS_RTL: Str = 'e-rtl';
|
|
69
|
-
const CLS_SEPARATOR: Str = 'e-separator';
|
|
70
|
-
const CLS_POPUPICON: Str = 'e-popup-up-icon';
|
|
71
|
-
const CLS_POPUPDOWN: Str = 'e-popup-down-icon';
|
|
72
|
-
const CLS_POPUPOPEN: Str = 'e-popup-open';
|
|
73
|
-
const CLS_TEMPLATE: Str = 'e-template';
|
|
74
|
-
const CLS_DISABLE: Str = 'e-overlay';
|
|
75
|
-
const CLS_POPUPTEXT: Str = 'e-toolbar-text';
|
|
76
|
-
const CLS_TBARTEXT: Str = 'e-popup-text';
|
|
77
|
-
const CLS_TBAROVERFLOW: Str = 'e-overflow-show';
|
|
78
|
-
const CLS_POPOVERFLOW: Str = 'e-overflow-hide';
|
|
79
|
-
const CLS_TBARBTN: Str = 'e-tbar-btn';
|
|
80
|
-
const CLS_TBARNAV: Str = 'e-hor-nav';
|
|
81
|
-
const CLS_TBARSCRLNAV: Str = 'e-scroll-nav';
|
|
82
|
-
const CLS_TBARRIGHT: Str = 'e-toolbar-right';
|
|
83
|
-
const CLS_TBARLEFT: Str = 'e-toolbar-left';
|
|
84
|
-
const CLS_TBARCENTER: Str = 'e-toolbar-center';
|
|
85
|
-
const CLS_TBARPOS: Str = 'e-tbar-pos';
|
|
86
|
-
const CLS_HSCROLLCNT: Str = 'e-hscroll-content';
|
|
87
|
-
const CLS_VSCROLLCNT: Str = 'e-vscroll-content';
|
|
88
|
-
const CLS_HSCROLLBAR: Str = 'e-hscroll-bar';
|
|
89
|
-
const CLS_POPUPNAV: Str = 'e-hor-nav';
|
|
90
|
-
const CLS_POPUPCLASS: Str = 'e-toolbar-pop';
|
|
91
|
-
const CLS_POPUP: Str = 'e-toolbar-popup';
|
|
92
|
-
const CLS_TBARBTNTEXT: Str = 'e-tbar-btn-text';
|
|
93
|
-
const CLS_TBARNAVACT: Str = 'e-nav-active';
|
|
94
|
-
const CLS_TBARIGNORE: Str = 'e-ignore';
|
|
95
|
-
const CLS_POPPRI: Str = 'e-popup-alone';
|
|
96
|
-
const CLS_HIDDEN: string = 'e-hidden';
|
|
97
|
-
const CLS_MULTIROW: string = 'e-toolbar-multirow';
|
|
98
|
-
const CLS_MULTIROWPOS: string = 'e-multirow-pos';
|
|
99
|
-
const CLS_MULTIROW_SEPARATOR: string = 'e-multirow-separator';
|
|
100
|
-
const CLS_EXTENDABLE_SEPARATOR: string = 'e-extended-separator';
|
|
101
|
-
const CLS_EXTEANDABLE_TOOLBAR: Str = 'e-extended-toolbar';
|
|
102
|
-
const CLS_EXTENDABLECLASS: Str = 'e-toolbar-extended';
|
|
103
|
-
const CLS_EXTENDPOPUP: Str = 'e-expended-nav';
|
|
104
|
-
const CLS_EXTENDEDPOPOPEN: Str = 'e-tbar-extended';
|
|
105
|
-
|
|
106
|
-
interface Template {
|
|
107
|
-
appendTo: (elemnt: HTMLElement) => void
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface ToolbarItemAlignIn {
|
|
111
|
-
lefts: HTMLElement[]
|
|
112
|
-
centers: HTMLElement[]
|
|
113
|
-
rights: HTMLElement[]
|
|
114
|
-
}
|
|
115
|
-
/** An interface that holds options to control the toolbar clicked action. */
|
|
116
|
-
export interface ClickEventArgs extends BaseEventArgs {
|
|
117
|
-
/** Defines the current Toolbar Item Object. */
|
|
118
|
-
item: ItemModel
|
|
119
|
-
/**
|
|
120
|
-
* Defines the current Event arguments.
|
|
121
|
-
*/
|
|
122
|
-
originalEvent: Event
|
|
123
|
-
/** Defines the prevent action. */
|
|
124
|
-
cancel?: boolean
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** An interface that holds options to control before the toolbar create. */
|
|
128
|
-
export interface BeforeCreateArgs extends BaseEventArgs {
|
|
129
|
-
/** Enable or disable the popup collision. */
|
|
130
|
-
enableCollision: boolean
|
|
131
|
-
/** Specifies the scrolling distance in scroller. */
|
|
132
|
-
scrollStep: number
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** An interface that holds options to control keyDown event in the toolbar. */
|
|
136
|
-
export interface KeyDownEventArgs extends BaseEventArgs {
|
|
137
|
-
/** Defines the keyboard event arguments. */
|
|
138
|
-
originalEvent: KeyboardEventArgs;
|
|
139
|
-
/** Defines the prevent action. */
|
|
140
|
-
cancel?: boolean;
|
|
141
|
-
/** Defines the current Toolbar item. */
|
|
142
|
-
currentItem?: HTMLElement;
|
|
143
|
-
/** Defines the next Toolbar item. */
|
|
144
|
-
nextItem?: HTMLElement;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** @hidden */
|
|
148
|
-
interface EJ2Instance extends HTMLElement {
|
|
149
|
-
// eslint-disable-next-line camelcase
|
|
150
|
-
ej2_instances: Object[]
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* An item object that is used to configure Toolbar commands.
|
|
155
|
-
*/
|
|
156
|
-
export class Item extends ChildProperty<Item> {
|
|
157
|
-
/**
|
|
158
|
-
* Specifies the unique ID to be used with button or input element of Toolbar items.
|
|
159
|
-
*
|
|
160
|
-
* @default ""
|
|
161
|
-
*/
|
|
162
|
-
@Property('')
|
|
163
|
-
public id: string;
|
|
164
|
-
/**
|
|
165
|
-
* Specifies the text to be displayed on the Toolbar button.
|
|
166
|
-
*
|
|
167
|
-
* @default ""
|
|
168
|
-
*/
|
|
169
|
-
@Property('')
|
|
170
|
-
public text: string;
|
|
171
|
-
/**
|
|
172
|
-
* Specifies the width of the Toolbar button commands.
|
|
173
|
-
*
|
|
174
|
-
* @default 'auto'
|
|
175
|
-
*/
|
|
176
|
-
@Property('auto')
|
|
177
|
-
public width: number | string;
|
|
178
|
-
/**
|
|
179
|
-
* Defines single/multiple classes (separated by space) to be used for customization of commands.
|
|
180
|
-
*
|
|
181
|
-
* @default ""
|
|
182
|
-
*/
|
|
183
|
-
@Property('')
|
|
184
|
-
public cssClass: string;
|
|
185
|
-
/**
|
|
186
|
-
* Defines the priority of items to display it in popup always.
|
|
187
|
-
* It allows to maintain toolbar item on popup always but it does not work for toolbar priority items.
|
|
188
|
-
*
|
|
189
|
-
* @default false
|
|
190
|
-
*/
|
|
191
|
-
@Property(false)
|
|
192
|
-
public showAlwaysInPopup: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Specifies whether an item should be disabled or not.
|
|
195
|
-
*
|
|
196
|
-
* @default false
|
|
197
|
-
*/
|
|
198
|
-
@Property(false)
|
|
199
|
-
public disabled: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Defines single/multiple classes separated by space used to specify an icon for the button.
|
|
202
|
-
* The icon will be positioned before the text content if text is available, otherwise the icon alone will be rendered.
|
|
203
|
-
*
|
|
204
|
-
* @default ""
|
|
205
|
-
*/
|
|
206
|
-
@Property('')
|
|
207
|
-
public prefixIcon: string;
|
|
208
|
-
/**
|
|
209
|
-
* Defines single/multiple classes separated by space used to specify an icon for the button.
|
|
210
|
-
* The icon will be positioned after the text content if text is available.
|
|
211
|
-
*
|
|
212
|
-
* @default ""
|
|
213
|
-
*/
|
|
214
|
-
@Property('')
|
|
215
|
-
public suffixIcon: string;
|
|
216
|
-
/**
|
|
217
|
-
* Specifies whether an item should be hidden or not.
|
|
218
|
-
*
|
|
219
|
-
* @default true
|
|
220
|
-
*/
|
|
221
|
-
@Property(true)
|
|
222
|
-
public visible: boolean;
|
|
223
|
-
/**
|
|
224
|
-
* Specifies the Toolbar command display area when an element's content is too large to fit available space.
|
|
225
|
-
* This is applicable only to `popup` mode. The possible values for this property as follows
|
|
226
|
-
* * `Show`: Always shows the item as the primary priority on the *Toolbar*.
|
|
227
|
-
* * `Hide`: Always shows the item as the secondary priority on the *popup*.
|
|
228
|
-
* * `None`: No priority for display, and as per normal order moves to popup when content exceeds.
|
|
229
|
-
*
|
|
230
|
-
* @default 'None'
|
|
231
|
-
*/
|
|
232
|
-
@Property('None')
|
|
233
|
-
public overflow: OverflowOption;
|
|
234
|
-
/**
|
|
235
|
-
* Specifies the HTML element/element ID as a string that can be added as a Toolbar command.
|
|
236
|
-
* ```
|
|
237
|
-
* E.g - items: [{ template: '<input placeholder="Search"/>' },{ template: '#checkbox1' }]
|
|
238
|
-
* ```
|
|
239
|
-
*
|
|
240
|
-
* @default ""
|
|
241
|
-
* @angularType string | object
|
|
242
|
-
* @reactType string | function | JSX.Element
|
|
243
|
-
* @vueType string | function
|
|
244
|
-
* @aspType string
|
|
245
|
-
*/
|
|
246
|
-
@Property('')
|
|
247
|
-
public template: string | Object | Function;
|
|
248
|
-
/**
|
|
249
|
-
* Specifies the types of command to be rendered in the Toolbar.
|
|
250
|
-
* Supported types are:
|
|
251
|
-
* * `Button`: Creates the Button control with its given properties like text, prefixIcon, etc.
|
|
252
|
-
* * `Separator`: Adds a horizontal line that separates the Toolbar commands.
|
|
253
|
-
* * `Input`: Creates an input element that is applicable to template rendering with Syncfusion controls like DropDownList,
|
|
254
|
-
* AutoComplete, etc.
|
|
255
|
-
*
|
|
256
|
-
* @default 'Button'
|
|
257
|
-
*/
|
|
258
|
-
@Property('Button')
|
|
259
|
-
public type: ItemType;
|
|
260
|
-
/**
|
|
261
|
-
* Specifies where the button text will be displayed on *popup mode* of the Toolbar.
|
|
262
|
-
* The possible values for this property as follows
|
|
263
|
-
* * `Toolbar`: Text will be displayed on *Toolbar* only.
|
|
264
|
-
* * `Overflow`: Text will be displayed only when content overflows to *popup*.
|
|
265
|
-
* * `Both`: Text will be displayed on *popup* and *Toolbar*.
|
|
266
|
-
*
|
|
267
|
-
* @default 'Both'
|
|
268
|
-
*/
|
|
269
|
-
@Property('Both')
|
|
270
|
-
public showTextOn: DisplayMode;
|
|
271
|
-
/**
|
|
272
|
-
* Defines htmlAttributes used to add custom attributes to Toolbar command.
|
|
273
|
-
* Supports HTML attributes such as style, class, etc.
|
|
274
|
-
*
|
|
275
|
-
* @default null
|
|
276
|
-
*/
|
|
277
|
-
@Property(null)
|
|
278
|
-
public htmlAttributes: { [key: string]: string };
|
|
279
|
-
/**
|
|
280
|
-
* Specifies the text to be displayed on hovering the Toolbar button.
|
|
281
|
-
*
|
|
282
|
-
* @default ""
|
|
283
|
-
*/
|
|
284
|
-
@Property('')
|
|
285
|
-
public tooltipText: string;
|
|
286
|
-
/**
|
|
287
|
-
* Specifies the location for aligning Toolbar items on the Toolbar. Each command will be aligned according to the `align` property.
|
|
288
|
-
* The possible values for this property as follows
|
|
289
|
-
* * `Left`: To align commands to the left side of the Toolbar.
|
|
290
|
-
* * `Center`: To align commands at the center of the Toolbar.
|
|
291
|
-
* * `Right`: To align commands to the right side of the Toolbar.
|
|
292
|
-
* ```html
|
|
293
|
-
* <div id="element"> </div>
|
|
294
|
-
* ```
|
|
295
|
-
* ```typescript
|
|
296
|
-
* let toolbar: Toolbar = new Toolbar({
|
|
297
|
-
* items: [
|
|
298
|
-
* { text: "Home" },
|
|
299
|
-
* { text: "My Home Page" , align: 'Center' },
|
|
300
|
-
* { text: "Search", align: 'Right' }
|
|
301
|
-
* { text: "Settings", align: 'Right' }
|
|
302
|
-
* ]
|
|
303
|
-
* });
|
|
304
|
-
* toolbar.appendTo('#element');
|
|
305
|
-
* ```
|
|
306
|
-
*
|
|
307
|
-
* @default "Left"
|
|
308
|
-
* @aspPopulateDefaultValue
|
|
309
|
-
*/
|
|
310
|
-
@Property('Left')
|
|
311
|
-
public align: ItemAlign;
|
|
312
|
-
/**
|
|
313
|
-
* Event triggers when `click` the toolbar item.
|
|
314
|
-
*
|
|
315
|
-
* @event click
|
|
316
|
-
*/
|
|
317
|
-
@Event()
|
|
318
|
-
public click: EmitType<ClickEventArgs>;
|
|
319
|
-
/**
|
|
320
|
-
* Specifies the tab order of the Toolbar items. When positive values assigned, it allows to switch focus to the next/previous toolbar items with Tab/ShiftTab keys.
|
|
321
|
-
* By default, user can able to switch between items only via arrow keys.
|
|
322
|
-
* If the value is set to 0 for all tool bar items, then tab switches based on element order.
|
|
323
|
-
*
|
|
324
|
-
* @default -1
|
|
325
|
-
*/
|
|
326
|
-
@Property(-1)
|
|
327
|
-
public tabIndex: number;
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* The Toolbar control contains a group of commands that are aligned horizontally.
|
|
331
|
-
* ```html
|
|
332
|
-
* <div id="toolbar"/>
|
|
333
|
-
* <script>
|
|
334
|
-
* var toolbarObj = new Toolbar();
|
|
335
|
-
* toolbarObj.appendTo("#toolbar");
|
|
336
|
-
* </script>
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
@NotifyPropertyChanges
|
|
340
|
-
export class Toolbar extends Component<HTMLElement> implements INotifyPropertyChanged {
|
|
341
|
-
private trgtEle: HTEle;
|
|
342
|
-
private ctrlTem: HTEle;
|
|
343
|
-
private popObj: Popup;
|
|
344
|
-
private tbarEle: HTMLElement[];
|
|
345
|
-
private tbarAlgEle: ToolbarItemAlignIn;
|
|
346
|
-
private tbarAlign: boolean;
|
|
347
|
-
private tbarEleMrgn: number;
|
|
348
|
-
private tbResize: boolean;
|
|
349
|
-
private offsetWid: number;
|
|
350
|
-
private keyModule: KeyboardEvents;
|
|
351
|
-
private scrollModule: HScroll | VScroll;
|
|
352
|
-
private activeEle: HTEle;
|
|
353
|
-
private popupPriCount: number;
|
|
354
|
-
private tbarItemsCol: ItemModel[];
|
|
355
|
-
private isVertical: boolean;
|
|
356
|
-
private tempId: string[];
|
|
357
|
-
private isExtendedOpen: boolean;
|
|
358
|
-
private clickEvent: EventListenerOrEventListenerObject;
|
|
359
|
-
private scrollEvent: EventListenerOrEventListenerObject;
|
|
360
|
-
private resizeContext: EventListenerObject = this.resize.bind(this);
|
|
361
|
-
private orientationChangeContext: EventListenerObject = this.orientationChange.bind(this);
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Contains the keyboard configuration of the Toolbar.
|
|
365
|
-
*/
|
|
366
|
-
private keyConfigs: { [key: string]: Str } = {
|
|
367
|
-
moveLeft: 'leftarrow',
|
|
368
|
-
moveRight: 'rightarrow',
|
|
369
|
-
moveUp: 'uparrow',
|
|
370
|
-
moveDown: 'downarrow',
|
|
371
|
-
popupOpen: 'enter',
|
|
372
|
-
popupClose: 'escape',
|
|
373
|
-
tab: 'tab',
|
|
374
|
-
home: 'home',
|
|
375
|
-
end: 'end'
|
|
376
|
-
};
|
|
377
|
-
/**
|
|
378
|
-
* An array of items that is used to configure Toolbar commands.
|
|
379
|
-
*
|
|
380
|
-
* @default []
|
|
381
|
-
*/
|
|
382
|
-
@Collection<ItemModel>([], Item)
|
|
383
|
-
public items: ItemModel[];
|
|
384
|
-
/**
|
|
385
|
-
* Specifies the width of the Toolbar in pixels/numbers/percentage. Number value is considered as pixels.
|
|
386
|
-
*
|
|
387
|
-
* @default 'auto'
|
|
388
|
-
*/
|
|
389
|
-
@Property('auto')
|
|
390
|
-
public width: string | number;
|
|
391
|
-
/**
|
|
392
|
-
* Specifies the height of the Toolbar in pixels/number/percentage. Number value is considered as pixels.
|
|
393
|
-
*
|
|
394
|
-
* @default 'auto'
|
|
395
|
-
*/
|
|
396
|
-
@Property('auto')
|
|
397
|
-
public height: string | number;
|
|
398
|
-
/**
|
|
399
|
-
* Sets the CSS classes to root element of the Tab that helps to customize component styles.
|
|
400
|
-
*
|
|
401
|
-
* @default ''
|
|
402
|
-
*/
|
|
403
|
-
@Property('')
|
|
404
|
-
public cssClass: string;
|
|
405
|
-
/**
|
|
406
|
-
* Specifies the Toolbar display mode when Toolbar content exceeds the viewing area.
|
|
407
|
-
* The possible values for this property as follows
|
|
408
|
-
* - Scrollable: All the elements are displayed in a single line with horizontal scrolling enabled.
|
|
409
|
-
* - Popup: Prioritized elements are displayed on the Toolbar and the rest of elements are moved to the *popup*.
|
|
410
|
-
* - MultiRow: Displays the overflow toolbar items as an in-line of a toolbar.
|
|
411
|
-
* - Extended: Hide the overflowing toolbar items in the next row. Show the overflowing toolbar items when you click the expand icons.
|
|
412
|
-
* If the popup content overflows the height of the page, the rest of the elements will be hidden.
|
|
413
|
-
*
|
|
414
|
-
* @default 'Scrollable'
|
|
415
|
-
*/
|
|
416
|
-
@Property('Scrollable')
|
|
417
|
-
public overflowMode: OverflowMode;
|
|
418
|
-
/**
|
|
419
|
-
* Specifies the scrolling distance in scroller.
|
|
420
|
-
*
|
|
421
|
-
* {% codeBlock src='toolbar/scrollStep/index.md' %}{% endcodeBlock %}
|
|
422
|
-
*
|
|
423
|
-
* @default null
|
|
424
|
-
*/
|
|
425
|
-
@Property()
|
|
426
|
-
public scrollStep: number;
|
|
427
|
-
/**
|
|
428
|
-
* Enable or disable the popup collision.
|
|
429
|
-
*
|
|
430
|
-
* @default true
|
|
431
|
-
*/
|
|
432
|
-
@Property(true)
|
|
433
|
-
public enableCollision: boolean;
|
|
434
|
-
/**
|
|
435
|
-
* Defines whether to allow the cross-scripting site or not.
|
|
436
|
-
*
|
|
437
|
-
* @default true
|
|
438
|
-
*/
|
|
439
|
-
@Property(true)
|
|
440
|
-
public enableHtmlSanitizer: boolean;
|
|
441
|
-
/**
|
|
442
|
-
* When this property is set to true, it allows the keyboard interaction in toolbar.
|
|
443
|
-
*
|
|
444
|
-
* @default true
|
|
445
|
-
*/
|
|
446
|
-
@Property(true)
|
|
447
|
-
public allowKeyboard: boolean;
|
|
448
|
-
|
|
449
|
-
/**
|
|
450
|
-
* The event will be fired on clicking the Toolbar elements.
|
|
451
|
-
*
|
|
452
|
-
* @event clicked
|
|
453
|
-
*/
|
|
454
|
-
@Event()
|
|
455
|
-
public clicked: EmitType<ClickEventArgs>;
|
|
456
|
-
/**
|
|
457
|
-
* The event will be fired when the control is rendered.
|
|
458
|
-
*
|
|
459
|
-
* @event created
|
|
460
|
-
*/
|
|
461
|
-
@Event()
|
|
462
|
-
public created: EmitType<Event>;
|
|
463
|
-
/**
|
|
464
|
-
* The event will be fired when the control gets destroyed.
|
|
465
|
-
*
|
|
466
|
-
* @event destroyed
|
|
467
|
-
*/
|
|
468
|
-
@Event()
|
|
469
|
-
public destroyed: EmitType<Event>;
|
|
470
|
-
/**
|
|
471
|
-
* The event will be fired before the control is rendered on a page.
|
|
472
|
-
*
|
|
473
|
-
* @event beforeCreate
|
|
474
|
-
*/
|
|
475
|
-
@Event()
|
|
476
|
-
public beforeCreate: EmitType<BeforeCreateArgs>;
|
|
477
|
-
/**
|
|
478
|
-
* The event will be fired when the keyboard interaction occurs on the Toolbar.
|
|
479
|
-
*
|
|
480
|
-
* @event keyDown
|
|
481
|
-
*/
|
|
482
|
-
@Event()
|
|
483
|
-
public keyDown: EmitType<KeyDownEventArgs>;
|
|
484
|
-
/**
|
|
485
|
-
* Removes the control from the DOM and also removes all its related events.
|
|
486
|
-
*
|
|
487
|
-
* @returns {void}.
|
|
488
|
-
*/
|
|
489
|
-
public destroy(): void {
|
|
490
|
-
if ((this as any).isReact || (this as any).isAngular) {
|
|
491
|
-
this.clearTemplate();
|
|
492
|
-
}
|
|
493
|
-
const btnItems: NodeList = this.element.querySelectorAll('.e-control.e-btn');
|
|
494
|
-
[].slice.call(btnItems).forEach((el: EJ2Instance) => {
|
|
495
|
-
if (!isNOU(el) && !isNOU(el.ej2_instances) && !isNOU(el.ej2_instances[0]) && !((el.ej2_instances[0] as Button).isDestroyed)) {
|
|
496
|
-
(el.ej2_instances[0] as Button).destroy();
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
this.unwireEvents();
|
|
500
|
-
this.tempId.forEach((ele: Str): void => {
|
|
501
|
-
if (!isNOU(this.element.querySelector(ele))) {
|
|
502
|
-
(<HTEle>document.body.appendChild(this.element.querySelector(ele))).style.display = 'none';
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
this.destroyItems();
|
|
506
|
-
while (this.element.lastElementChild) {
|
|
507
|
-
this.element.removeChild(this.element.lastElementChild);
|
|
508
|
-
}
|
|
509
|
-
if (this.trgtEle) {
|
|
510
|
-
this.element.appendChild(this.ctrlTem);
|
|
511
|
-
this.trgtEle = null;
|
|
512
|
-
this.ctrlTem = null;
|
|
513
|
-
}
|
|
514
|
-
if (this.popObj) {
|
|
515
|
-
this.popObj.destroy();
|
|
516
|
-
detach(this.popObj.element);
|
|
517
|
-
}
|
|
518
|
-
if (this.activeEle) {
|
|
519
|
-
this.activeEle = null;
|
|
520
|
-
}
|
|
521
|
-
this.popObj = null;
|
|
522
|
-
this.tbarAlign = null;
|
|
523
|
-
this.tbarItemsCol = [];
|
|
524
|
-
this.remove(this.element, 'e-toolpop');
|
|
525
|
-
if (this.cssClass) {
|
|
526
|
-
removeClass([this.element], this.cssClass.split(' '));
|
|
527
|
-
}
|
|
528
|
-
this.element.removeAttribute('style');
|
|
529
|
-
['aria-disabled', 'aria-orientation', 'role'].forEach((attrb: string): void =>
|
|
530
|
-
this.element.removeAttribute(attrb));
|
|
531
|
-
super.destroy();
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Initialize the event handler
|
|
535
|
-
*
|
|
536
|
-
* @private
|
|
537
|
-
* @returns {void}
|
|
538
|
-
*/
|
|
539
|
-
protected preRender(): void {
|
|
540
|
-
const eventArgs: BeforeCreateArgs = { enableCollision: this.enableCollision, scrollStep: this.scrollStep };
|
|
541
|
-
this.trigger('beforeCreate', eventArgs);
|
|
542
|
-
this.enableCollision = eventArgs.enableCollision;
|
|
543
|
-
this.scrollStep = eventArgs.scrollStep;
|
|
544
|
-
this.scrollModule = null;
|
|
545
|
-
this.popObj = null;
|
|
546
|
-
this.tempId = [];
|
|
547
|
-
this.tbarItemsCol = this.items;
|
|
548
|
-
this.isVertical = this.element.classList.contains(CLS_VERTICAL) ? true : false;
|
|
549
|
-
this.isExtendedOpen = false;
|
|
550
|
-
this.popupPriCount = 0;
|
|
551
|
-
if (this.enableRtl) {
|
|
552
|
-
this.add(this.element, CLS_RTL);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* Initializes a new instance of the Toolbar class.
|
|
557
|
-
*
|
|
558
|
-
* @param {ToolbarModel} options - Specifies Toolbar model properties as options.
|
|
559
|
-
* @param { string | HTMLElement} element - Specifies the element that is rendered as a Toolbar.
|
|
560
|
-
*/
|
|
561
|
-
public constructor(options?: ToolbarModel, element?: string | HTMLElement) {
|
|
562
|
-
super(options, <HTEle | Str>element);
|
|
563
|
-
}
|
|
564
|
-
private wireEvents(): void {
|
|
565
|
-
EventHandler.add(this.element, 'click', this.clickHandler, this);
|
|
566
|
-
window.addEventListener('resize', this.resizeContext);
|
|
567
|
-
window.addEventListener('orientationchange', this.orientationChangeContext);
|
|
568
|
-
if (this.allowKeyboard) {
|
|
569
|
-
this.wireKeyboardEvent();
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
private wireKeyboardEvent(): void {
|
|
573
|
-
this.keyModule = new KeyboardEvents(this.element, {
|
|
574
|
-
keyAction: this.keyActionHandler.bind(this),
|
|
575
|
-
keyConfigs: this.keyConfigs
|
|
576
|
-
});
|
|
577
|
-
EventHandler.add(this.element, 'keydown', this.docKeyDown, this);
|
|
578
|
-
this.updateTabIndex('0');
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
private updateTabIndex(tabIndex: string): void {
|
|
582
|
-
const ele: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_DISABLE + ' ):not(.' + CLS_SEPARATOR + ' ):not(.' + CLS_HIDDEN + ' )');
|
|
583
|
-
if (!isNOU(ele) && !isNOU(ele.firstElementChild)) {
|
|
584
|
-
const dataTabIndex: string = ele.firstElementChild.getAttribute('data-tabindex');
|
|
585
|
-
if (dataTabIndex && dataTabIndex === '-1' && ele.firstElementChild.tagName !== 'INPUT') {
|
|
586
|
-
ele.firstElementChild.setAttribute('tabindex', tabIndex);
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
private unwireKeyboardEvent(): void {
|
|
592
|
-
if (this.keyModule) {
|
|
593
|
-
EventHandler.remove(this.element, 'keydown', this.docKeyDown);
|
|
594
|
-
this.keyModule.destroy();
|
|
595
|
-
this.keyModule = null;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
private docKeyDown(e: KeyboardEvent): void {
|
|
599
|
-
if ((<HTEle>e.target).tagName === 'INPUT') {
|
|
600
|
-
return;
|
|
601
|
-
}
|
|
602
|
-
const popCheck: boolean = !isNOU(this.popObj) && isVisible(this.popObj.element) && this.overflowMode !== 'Extended';
|
|
603
|
-
if (e.keyCode === 9 && (<HTEle>e.target).classList.contains('e-hor-nav') === true && popCheck) {
|
|
604
|
-
this.popObj.hide({ name: 'FadeOut', duration: 100 });
|
|
605
|
-
}
|
|
606
|
-
const keyCheck: boolean = (e.keyCode === 40 || e.keyCode === 38 || e.keyCode === 35 || e.keyCode === 36);
|
|
607
|
-
if (keyCheck) {
|
|
608
|
-
e.preventDefault();
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
private unwireEvents(): void {
|
|
612
|
-
EventHandler.remove(this.element, 'click', this.clickHandler);
|
|
613
|
-
this.destroyScroll();
|
|
614
|
-
this.unwireKeyboardEvent();
|
|
615
|
-
window.removeEventListener('resize', this.resizeContext);
|
|
616
|
-
window.removeEventListener('orientationchange', this.orientationChangeContext);
|
|
617
|
-
document.removeEventListener('scroll', this.clickEvent);
|
|
618
|
-
document.removeEventListener('click', this.scrollEvent);
|
|
619
|
-
this.scrollEvent = null;
|
|
620
|
-
this.clickEvent = null;
|
|
621
|
-
}
|
|
622
|
-
private clearProperty(): void {
|
|
623
|
-
this.tbarEle = [];
|
|
624
|
-
this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
|
|
625
|
-
}
|
|
626
|
-
private docEvent(e: Event): void {
|
|
627
|
-
const popEle: Element = closest(<Element>e.target, '.e-popup');
|
|
628
|
-
if (this.popObj && isVisible(this.popObj.element) && !popEle && this.overflowMode === 'Popup') {
|
|
629
|
-
this.popObj.hide({ name: 'FadeOut', duration: 100 });
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
private destroyScroll(): void {
|
|
633
|
-
if (this.scrollModule) {
|
|
634
|
-
if (this.tbarAlign) {
|
|
635
|
-
this.add(this.scrollModule.element, CLS_TBARPOS);
|
|
636
|
-
}
|
|
637
|
-
this.scrollModule.destroy(); this.scrollModule = null;
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
private destroyItems(): void {
|
|
641
|
-
if (this.element) {
|
|
642
|
-
[].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el: HTEle) => { detach(el); });
|
|
643
|
-
}
|
|
644
|
-
if (this.tbarAlign) {
|
|
645
|
-
const tbarItems: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
|
|
646
|
-
if (tbarItems) {
|
|
647
|
-
if (tbarItems.children) {
|
|
648
|
-
[].slice.call(tbarItems.children).forEach((el: HTEle) => {
|
|
649
|
-
detach(el);
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
this.remove(tbarItems, CLS_TBARPOS);
|
|
653
|
-
}
|
|
654
|
-
this.tbarAlign = false;
|
|
655
|
-
}
|
|
656
|
-
this.clearProperty();
|
|
657
|
-
}
|
|
658
|
-
private destroyMode(): void {
|
|
659
|
-
if (this.scrollModule) {
|
|
660
|
-
this.remove(this.scrollModule.element, CLS_RTL);
|
|
661
|
-
this.destroyScroll();
|
|
662
|
-
}
|
|
663
|
-
this.remove(this.element, CLS_EXTENDEDPOPOPEN);
|
|
664
|
-
this.remove(this.element, CLS_EXTEANDABLE_TOOLBAR);
|
|
665
|
-
const tempEle: HTMLElement = this.element.querySelector('.e-toolbar-multirow');
|
|
666
|
-
if (tempEle) {
|
|
667
|
-
this.remove(tempEle, CLS_MULTIROW);
|
|
668
|
-
}
|
|
669
|
-
if (this.popObj) {
|
|
670
|
-
this.popupRefresh(this.popObj.element, true);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
private add(ele: HTEle, val: Str): void {
|
|
674
|
-
ele.classList.add(val);
|
|
675
|
-
}
|
|
676
|
-
private remove(ele: HTEle, val: Str): void {
|
|
677
|
-
ele.classList.remove(val);
|
|
678
|
-
}
|
|
679
|
-
private elementFocus(ele: HTEle): void {
|
|
680
|
-
const fChild: HTEle = <HTEle>ele.firstElementChild;
|
|
681
|
-
if (fChild) {
|
|
682
|
-
fChild.focus();
|
|
683
|
-
this.activeEleSwitch(ele);
|
|
684
|
-
} else {
|
|
685
|
-
ele.focus();
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
private clstElement(tbrNavChk: boolean, trgt: HTEle): HTEle {
|
|
689
|
-
let clst: HTEle;
|
|
690
|
-
if (tbrNavChk && this.popObj && isVisible(this.popObj.element)) {
|
|
691
|
-
clst = <HTEle>this.popObj.element.querySelector('.' + CLS_ITEM);
|
|
692
|
-
} else if (this.element === trgt || tbrNavChk) {
|
|
693
|
-
clst = <HTEle>this.element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_DISABLE + ' ):not(.' + CLS_SEPARATOR + ' ):not(.' + CLS_HIDDEN + ' )');
|
|
694
|
-
} else {
|
|
695
|
-
clst = <HTEle>closest(trgt, '.' + CLS_ITEM);
|
|
696
|
-
}
|
|
697
|
-
return clst;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
private getNextFocusableItem(currentItem: HTEle, action: string): HTMLElement {
|
|
701
|
-
const selector: string = `.${CLS_ITEM}:not(.${CLS_DISABLE}):not(.${CLS_SEPARATOR}):not(.${CLS_HIDDEN})`;
|
|
702
|
-
const items: HTMLElement[] = Array.from(this.element.querySelectorAll(selector));
|
|
703
|
-
const currentIndex: number = items.indexOf(currentItem);
|
|
704
|
-
if (currentIndex < 0) {
|
|
705
|
-
return null;
|
|
706
|
-
}
|
|
707
|
-
let nextIndex: number;
|
|
708
|
-
switch (action) {
|
|
709
|
-
case 'moveRight':
|
|
710
|
-
case 'moveDown':
|
|
711
|
-
case 'tab':
|
|
712
|
-
nextIndex = (currentIndex + 1) % items.length;
|
|
713
|
-
break;
|
|
714
|
-
case 'moveLeft':
|
|
715
|
-
case 'moveUp':
|
|
716
|
-
nextIndex = (currentIndex - 1 + items.length) % items.length;
|
|
717
|
-
break;
|
|
718
|
-
case 'home':
|
|
719
|
-
nextIndex = 0;
|
|
720
|
-
break;
|
|
721
|
-
case 'end':
|
|
722
|
-
nextIndex = items.length - 1;
|
|
723
|
-
break;
|
|
724
|
-
default:
|
|
725
|
-
nextIndex = currentIndex;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
if (nextIndex >= 0 && nextIndex < items.length) {
|
|
729
|
-
return items[parseInt(nextIndex.toString(), 10)];
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
return null;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
private keyHandling(clst: HTEle, e: KeyboardEventArgs, trgt: HTEle, navChk: boolean, scrollChk: boolean): void {
|
|
736
|
-
const popObj: Popup = this.popObj;
|
|
737
|
-
const rootEle: HTEle = this.element;
|
|
738
|
-
const popAnimate: Object = { name: 'FadeOut', duration: 100 };
|
|
739
|
-
const value: Str = e.action === 'moveUp' ? 'previous' : 'next';
|
|
740
|
-
let ele: HTEle;
|
|
741
|
-
let nodes: NodeList;
|
|
742
|
-
switch (e.action) {
|
|
743
|
-
case 'moveRight':
|
|
744
|
-
if (this.isVertical) {
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
if (rootEle === trgt) {
|
|
748
|
-
this.elementFocus(clst);
|
|
749
|
-
} else if (!navChk) {
|
|
750
|
-
this.eleFocus(clst, 'next');
|
|
751
|
-
}
|
|
752
|
-
break;
|
|
753
|
-
case 'moveLeft':
|
|
754
|
-
if (this.isVertical) {
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
if (!navChk) {
|
|
758
|
-
this.eleFocus(clst, 'previous');
|
|
759
|
-
}
|
|
760
|
-
break;
|
|
761
|
-
case 'home':
|
|
762
|
-
case 'end':
|
|
763
|
-
if (clst) {
|
|
764
|
-
let popupCheck: HTEle = <HTEle>closest(clst, '.e-popup');
|
|
765
|
-
const extendedPopup: HTEle = this.element.querySelector('.' + CLS_EXTENDABLECLASS);
|
|
766
|
-
if (this.overflowMode === 'Extended' && extendedPopup && extendedPopup.classList.contains('e-popup-open')) {
|
|
767
|
-
popupCheck = e.action === 'end' ? extendedPopup : null;
|
|
768
|
-
}
|
|
769
|
-
if (popupCheck) {
|
|
770
|
-
if (isVisible(this.popObj.element)) {
|
|
771
|
-
nodes = [].slice.call(popupCheck.children);
|
|
772
|
-
if (e.action === 'home') {
|
|
773
|
-
ele = this.focusFirstVisibleEle(nodes);
|
|
774
|
-
} else {
|
|
775
|
-
ele = this.focusLastVisibleEle(nodes);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
} else {
|
|
779
|
-
nodes = this.element.querySelectorAll('.' + CLS_ITEMS + ' .' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + ')');
|
|
780
|
-
if (e.action === 'home') {
|
|
781
|
-
ele = this.focusFirstVisibleEle(nodes);
|
|
782
|
-
} else {
|
|
783
|
-
ele = this.focusLastVisibleEle(nodes);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
if (ele) {
|
|
787
|
-
this.elementFocus(ele);
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
break;
|
|
791
|
-
case 'moveUp':
|
|
792
|
-
case 'moveDown':
|
|
793
|
-
if (!this.isVertical) {
|
|
794
|
-
if (popObj && closest(trgt, '.e-popup')) {
|
|
795
|
-
const popEle: HTEle = popObj.element;
|
|
796
|
-
if ((value === 'previous' && popEle.firstElementChild === clst)) {
|
|
797
|
-
const lastVisibleEle: HTMLElement = this.focusLastVisibleEle([].slice.call(popEle.children));
|
|
798
|
-
if (lastVisibleEle) {
|
|
799
|
-
this.elementFocus(lastVisibleEle);
|
|
800
|
-
}
|
|
801
|
-
} else if (value === 'next' && popEle.lastElementChild === clst) {
|
|
802
|
-
const firstVisibleEle: HTMLElement = this.focusFirstVisibleEle([].slice.call(popEle.children));
|
|
803
|
-
if (firstVisibleEle) {
|
|
804
|
-
this.elementFocus(firstVisibleEle);
|
|
805
|
-
}
|
|
806
|
-
} else {
|
|
807
|
-
this.eleFocus(clst, value);
|
|
808
|
-
}
|
|
809
|
-
} else if (e.action === 'moveDown' && popObj && isVisible(popObj.element)) {
|
|
810
|
-
const skipEle: string | boolean = this.eleContains(clst);
|
|
811
|
-
if (skipEle) {
|
|
812
|
-
this.eleFocus(clst, value);
|
|
813
|
-
} else {
|
|
814
|
-
this.elementFocus(clst);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
} else {
|
|
818
|
-
if (e.action === 'moveUp') {
|
|
819
|
-
this.eleFocus(clst, 'previous');
|
|
820
|
-
} else {
|
|
821
|
-
this.eleFocus(clst, 'next');
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
break;
|
|
825
|
-
case 'tab':
|
|
826
|
-
if (!scrollChk && !navChk) {
|
|
827
|
-
const ele: HTEle = (<HTEle>clst.firstElementChild);
|
|
828
|
-
if (rootEle === trgt) {
|
|
829
|
-
if (this.activeEle) {
|
|
830
|
-
this.activeEle.focus();
|
|
831
|
-
} else {
|
|
832
|
-
this.activeEleRemove(ele);
|
|
833
|
-
ele.focus();
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
break;
|
|
838
|
-
case 'popupClose':
|
|
839
|
-
if (popObj && this.overflowMode !== 'Extended') {
|
|
840
|
-
popObj.hide(popAnimate);
|
|
841
|
-
}
|
|
842
|
-
break;
|
|
843
|
-
case 'popupOpen':
|
|
844
|
-
if (!navChk) {
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
if (popObj && !isVisible(popObj.element)) {
|
|
848
|
-
popObj.element.style.top = rootEle.offsetHeight + 'px';
|
|
849
|
-
popObj.show({ name: 'FadeIn', duration: 100 });
|
|
850
|
-
} else {
|
|
851
|
-
popObj.hide(popAnimate);
|
|
852
|
-
}
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
private keyActionHandler(e: KeyboardEventArgs): void {
|
|
857
|
-
const trgt: HTEle = <HTEle>e.target;
|
|
858
|
-
if ((e.action === 'home' || e.action === 'end' || e.action === 'moveRight' || e.action === 'moveLeft' || e.action === 'moveUp' || e.action === 'moveDown')
|
|
859
|
-
&& (trgt.tagName === 'INPUT' || trgt.tagName === 'TEXTAREA' || this.element.classList.contains(CLS_DISABLE))) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
e.preventDefault();
|
|
863
|
-
const tbrNavChk: boolean = trgt.classList.contains(CLS_TBARNAV);
|
|
864
|
-
const tbarScrollChk: boolean = trgt.classList.contains(CLS_TBARSCRLNAV);
|
|
865
|
-
const clst: HTEle = this.clstElement(tbrNavChk, trgt);
|
|
866
|
-
if (clst || tbarScrollChk) {
|
|
867
|
-
const currentItem: HTMLElement = clst;
|
|
868
|
-
const nextItem: HTMLElement = this.getNextFocusableItem(currentItem, e.action);
|
|
869
|
-
const keyDownEventArgs: KeyDownEventArgs = {
|
|
870
|
-
originalEvent: e,
|
|
871
|
-
currentItem: currentItem,
|
|
872
|
-
nextItem: nextItem,
|
|
873
|
-
cancel: false
|
|
874
|
-
};
|
|
875
|
-
this.trigger('keyDown', keyDownEventArgs, (keyDownArgs: KeyDownEventArgs) => {
|
|
876
|
-
if (!keyDownArgs.cancel) {
|
|
877
|
-
this.keyHandling(clst, e, trgt, tbrNavChk, tbarScrollChk);
|
|
878
|
-
}
|
|
879
|
-
});
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* Specifies the value to disable/enable the Toolbar component.
|
|
884
|
-
* When set to `true`, the component will be disabled.
|
|
885
|
-
*
|
|
886
|
-
* @param {boolean} value - Based on this Boolean value, Toolbar will be enabled (false) or disabled (true).
|
|
887
|
-
* @returns {void}.
|
|
888
|
-
*/
|
|
889
|
-
public disable(value: boolean): void {
|
|
890
|
-
const rootEle: HTMLElement = this.element;
|
|
891
|
-
if (value) {
|
|
892
|
-
rootEle.classList.add(CLS_DISABLE);
|
|
893
|
-
} else {
|
|
894
|
-
rootEle.classList.remove(CLS_DISABLE);
|
|
895
|
-
}
|
|
896
|
-
if (this.activeEle) {
|
|
897
|
-
this.activeEle.setAttribute('tabindex', this.activeEle.getAttribute('data-tabindex'));
|
|
898
|
-
}
|
|
899
|
-
if (this.scrollModule) {
|
|
900
|
-
this.scrollModule.disable(value);
|
|
901
|
-
}
|
|
902
|
-
if (this.popObj) {
|
|
903
|
-
if (isVisible(this.popObj.element) && this.overflowMode !== 'Extended') {
|
|
904
|
-
this.popObj.hide();
|
|
905
|
-
}
|
|
906
|
-
rootEle.querySelector('#' + rootEle.id + '_nav').setAttribute('tabindex', !value ? '0' : '-1');
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
private eleContains(el: HTEle): string | boolean {
|
|
910
|
-
return el.classList.contains(CLS_SEPARATOR) || el.classList.contains(CLS_DISABLE) || el.getAttribute('disabled') || el.classList.contains(CLS_HIDDEN) || !isVisible(el) || !el.classList.contains(CLS_ITEM);
|
|
911
|
-
}
|
|
912
|
-
private focusFirstVisibleEle(nodes: NodeList): HTMLElement {
|
|
913
|
-
let element: HTMLElement;
|
|
914
|
-
let index: number = 0;
|
|
915
|
-
while (index < nodes.length) {
|
|
916
|
-
const ele: HTMLElement = nodes[parseInt(index.toString(), 10)] as HTMLElement;
|
|
917
|
-
if (!ele.classList.contains(CLS_SEPARATOR) && !ele.classList.contains(CLS_HIDDEN) && !ele.classList.contains(CLS_DISABLE)) {
|
|
918
|
-
return ele;
|
|
919
|
-
}
|
|
920
|
-
index++;
|
|
921
|
-
}
|
|
922
|
-
return element;
|
|
923
|
-
}
|
|
924
|
-
private focusLastVisibleEle(nodes: NodeList): HTMLElement {
|
|
925
|
-
let element: HTMLElement;
|
|
926
|
-
let index: number = nodes.length - 1;
|
|
927
|
-
while (index >= 0) {
|
|
928
|
-
const ele: HTMLElement = nodes[parseInt(index.toString(), 10)] as HTMLElement;
|
|
929
|
-
if (!ele.classList.contains(CLS_SEPARATOR) && !ele.classList.contains(CLS_HIDDEN) && !ele.classList.contains(CLS_DISABLE)) {
|
|
930
|
-
return ele;
|
|
931
|
-
}
|
|
932
|
-
index--;
|
|
933
|
-
}
|
|
934
|
-
return element;
|
|
935
|
-
}
|
|
936
|
-
private eleFocus(closest: HTEle, pos: Str): void {
|
|
937
|
-
const sib: HTEle = Object(closest)[pos + 'ElementSibling'];
|
|
938
|
-
if (sib) {
|
|
939
|
-
const skipEle: string | boolean = this.eleContains(sib);
|
|
940
|
-
if (skipEle) {
|
|
941
|
-
this.eleFocus(sib, pos); return;
|
|
942
|
-
}
|
|
943
|
-
this.elementFocus(sib);
|
|
944
|
-
} else if (this.tbarAlign) {
|
|
945
|
-
let elem: HTEle = Object(closest.parentElement)[pos + 'ElementSibling'] as HTEle;
|
|
946
|
-
if (!isNOU(elem) && elem.children.length === 0) {
|
|
947
|
-
elem = Object(elem)[pos + 'ElementSibling'] as HTEle;
|
|
948
|
-
}
|
|
949
|
-
if (!isNOU(elem) && elem.children.length > 0) {
|
|
950
|
-
if (pos === 'next') {
|
|
951
|
-
const el: HTEle = <HTEle>elem.querySelector('.' + CLS_ITEM);
|
|
952
|
-
if (this.eleContains(el)) {
|
|
953
|
-
this.eleFocus(el, pos);
|
|
954
|
-
} else {
|
|
955
|
-
(<HTEle>el.firstElementChild).focus();
|
|
956
|
-
this.activeEleSwitch(el);
|
|
957
|
-
}
|
|
958
|
-
} else {
|
|
959
|
-
const el: HTEle = <HTEle>elem.lastElementChild;
|
|
960
|
-
if (this.eleContains(el)) {
|
|
961
|
-
this.eleFocus(el, pos);
|
|
962
|
-
} else {
|
|
963
|
-
this.elementFocus(el);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
} else if (!isNOU(closest)) {
|
|
968
|
-
const tbrItems: NodeList = this.element.querySelectorAll('.' + CLS_ITEMS + ' .' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + ')' + ':not(.' + CLS_DISABLE + ')' + ':not(.' + CLS_HIDDEN + ')');
|
|
969
|
-
if (pos === 'next' && tbrItems) {
|
|
970
|
-
this.elementFocus(tbrItems[0] as HTMLElement);
|
|
971
|
-
} else if (pos === 'previous' && tbrItems) {
|
|
972
|
-
this.elementFocus(tbrItems[tbrItems.length - 1] as HTMLElement);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
private clickHandler(e: Event): void {
|
|
977
|
-
const trgt: HTEle = <HTEle>e.target;
|
|
978
|
-
const ele: HTEle = this.element;
|
|
979
|
-
const isPopupElement: boolean = !isNOU(closest(trgt, '.' + CLS_POPUPCLASS));
|
|
980
|
-
let clsList: DOMTokenList = trgt.classList;
|
|
981
|
-
let popupNav: HTEle = <HTEle>closest(trgt, ('.' + CLS_TBARNAV));
|
|
982
|
-
if (!popupNav) {
|
|
983
|
-
popupNav = trgt;
|
|
984
|
-
}
|
|
985
|
-
if (!ele.children[0].classList.contains('e-hscroll') && !ele.children[0].classList.contains('e-vscroll')
|
|
986
|
-
&& (clsList.contains(CLS_TBARNAV))) {
|
|
987
|
-
clsList = trgt.querySelector('.e-icons').classList;
|
|
988
|
-
}
|
|
989
|
-
if (clsList.contains(CLS_POPUPICON) || clsList.contains(CLS_POPUPDOWN)) {
|
|
990
|
-
this.popupClickHandler(ele, popupNav, CLS_RTL);
|
|
991
|
-
}
|
|
992
|
-
let itemObj: ItemModel;
|
|
993
|
-
const clst: HTEle = <HTEle>closest(<Node>e.target, '.' + CLS_ITEM);
|
|
994
|
-
if ((isNOU(clst) || clst.classList.contains(CLS_DISABLE)) && !popupNav.classList.contains(CLS_TBARNAV)) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
if (clst) {
|
|
998
|
-
const tempItem: ItemModel = this.items[this.tbarEle.indexOf(clst)];
|
|
999
|
-
itemObj = tempItem;
|
|
1000
|
-
}
|
|
1001
|
-
const eventArgs: ClickEventArgs = { originalEvent: e, item: itemObj };
|
|
1002
|
-
const isClickBinded: boolean = itemObj && !isNOU(itemObj.click) && typeof itemObj.click == 'object' ?
|
|
1003
|
-
!isNOU((itemObj as any).click.observers) && (itemObj as any).click.observers.length > 0 :
|
|
1004
|
-
!isNOU(itemObj) && !isNOU(itemObj.click);
|
|
1005
|
-
if (isClickBinded) {
|
|
1006
|
-
this.trigger('items[' + this.tbarEle.indexOf(clst) + '].click', eventArgs);
|
|
1007
|
-
}
|
|
1008
|
-
if (!eventArgs.cancel) {
|
|
1009
|
-
this.trigger('clicked', eventArgs, (clickedArgs: ClickEventArgs) => {
|
|
1010
|
-
if (!isNOU(this.popObj) && isPopupElement && !clickedArgs.cancel && this.overflowMode === 'Popup' &&
|
|
1011
|
-
clickedArgs.item && clickedArgs.item.type !== 'Input') {
|
|
1012
|
-
this.popObj.hide({ name: 'FadeOut', duration: 100 });
|
|
1013
|
-
}
|
|
1014
|
-
});
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
private popupClickHandler(ele: HTMLElement, popupNav: HTMLElement, CLS_RTL: Str): void {
|
|
1019
|
-
const popObj: Popup = this.popObj;
|
|
1020
|
-
if (isVisible(popObj.element)) {
|
|
1021
|
-
popupNav.classList.remove(CLS_TBARNAVACT);
|
|
1022
|
-
popObj.hide({ name: 'FadeOut', duration: 100 });
|
|
1023
|
-
} else {
|
|
1024
|
-
if (ele.classList.contains(CLS_RTL)) {
|
|
1025
|
-
popObj.enableRtl = true;
|
|
1026
|
-
popObj.position = { X: 'left', Y: 'top' };
|
|
1027
|
-
}
|
|
1028
|
-
if (popObj.offsetX === 0 && !ele.classList.contains(CLS_RTL)) {
|
|
1029
|
-
popObj.enableRtl = false;
|
|
1030
|
-
popObj.position = { X: 'right', Y: 'top' };
|
|
1031
|
-
}
|
|
1032
|
-
if (this.overflowMode === 'Extended') {
|
|
1033
|
-
popObj.element.style.minHeight = '0px';
|
|
1034
|
-
popObj.width = this.getToolbarPopupWidth(this.element);
|
|
1035
|
-
}
|
|
1036
|
-
popObj.dataBind();
|
|
1037
|
-
popObj.refreshPosition();
|
|
1038
|
-
popObj.element.style.top = this.getElementOffsetY() + 'px';
|
|
1039
|
-
popupNav.classList.add(CLS_TBARNAVACT);
|
|
1040
|
-
popObj.show({ name: 'FadeIn', duration: 100 });
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
private getToolbarPopupWidth(ele: HTMLElement): number {
|
|
1045
|
-
const eleStyles: CSSStyleDeclaration = window.getComputedStyle(ele);
|
|
1046
|
-
return parseFloat(eleStyles.width) + ((parseFloat(eleStyles.borderRightWidth)) * 2);
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
/**
|
|
1050
|
-
* To Initialize the control rendering
|
|
1051
|
-
*
|
|
1052
|
-
* @private
|
|
1053
|
-
* @returns {void}
|
|
1054
|
-
*/
|
|
1055
|
-
protected render(): void {
|
|
1056
|
-
this.initialize();
|
|
1057
|
-
this.clickEvent = this.docEvent.bind(this);
|
|
1058
|
-
this.scrollEvent = this.docEvent.bind(this);
|
|
1059
|
-
this.renderControl();
|
|
1060
|
-
this.wireEvents();
|
|
1061
|
-
this.renderComplete();
|
|
1062
|
-
if ((this as any).isReact && (this as Record<string, any>).portals && (this as Record<string, any>).portals.length > 0) {
|
|
1063
|
-
this.renderReactTemplates(() => {
|
|
1064
|
-
this.refreshOverflow();
|
|
1065
|
-
});
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
private initialize(): void {
|
|
1069
|
-
const width: Str = formatUnit(this.width);
|
|
1070
|
-
const height: Str = formatUnit(this.height);
|
|
1071
|
-
if (Browser.info.name !== 'msie' || this.height !== 'auto' || this.overflowMode === 'MultiRow') {
|
|
1072
|
-
setStyle(this.element, { 'height': height });
|
|
1073
|
-
}
|
|
1074
|
-
setStyle(this.element, { 'width': width });
|
|
1075
|
-
const ariaAttr: { [key: string]: Str } = {
|
|
1076
|
-
'role': 'toolbar', 'aria-disabled': 'false',
|
|
1077
|
-
'aria-orientation': !this.isVertical ? 'horizontal' : 'vertical'
|
|
1078
|
-
};
|
|
1079
|
-
attributes(this.element, ariaAttr);
|
|
1080
|
-
if (this.cssClass) {
|
|
1081
|
-
addClass([this.element], this.cssClass.split(' '));
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
private renderControl(): void {
|
|
1085
|
-
const ele: HTEle = this.element;
|
|
1086
|
-
this.trgtEle = (ele.children.length > 0) ? <HTEle>ele.querySelector('div') : null;
|
|
1087
|
-
this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
|
|
1088
|
-
this.renderItems();
|
|
1089
|
-
this.renderLayout();
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
private renderLayout(): void {
|
|
1093
|
-
this.renderOverflowMode();
|
|
1094
|
-
if (this.tbarAlign) {
|
|
1095
|
-
this.itemPositioning();
|
|
1096
|
-
}
|
|
1097
|
-
if (this.popObj && this.popObj.element.childElementCount > 1 && this.checkPopupRefresh(this.element, this.popObj.element)) {
|
|
1098
|
-
this.popupRefresh(this.popObj.element, false);
|
|
1099
|
-
}
|
|
1100
|
-
this.separator();
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
private itemsAlign(items: ItemModel[], itemEleDom: HTEle): void {
|
|
1104
|
-
let innerItem: HTEle;
|
|
1105
|
-
let innerPos: HTEle;
|
|
1106
|
-
if (!this.tbarEle) {
|
|
1107
|
-
this.tbarEle = [];
|
|
1108
|
-
}
|
|
1109
|
-
for (let i: number = 0; i < items.length; i++) {
|
|
1110
|
-
innerItem = this.renderSubComponent(items[parseInt(i.toString(), 10)], i);
|
|
1111
|
-
if (this.tbarEle.indexOf(innerItem) === -1) {
|
|
1112
|
-
this.tbarEle.push(innerItem);
|
|
1113
|
-
}
|
|
1114
|
-
if (!this.tbarAlign) {
|
|
1115
|
-
this.tbarItemAlign(items[parseInt(i.toString(), 10)], itemEleDom, i);
|
|
1116
|
-
}
|
|
1117
|
-
innerPos = <HTEle>itemEleDom.querySelector('.e-toolbar-' + items[parseInt(i.toString(), 10)].align.toLowerCase());
|
|
1118
|
-
if (innerPos) {
|
|
1119
|
-
if (!(items[parseInt(i.toString(), 10)].showAlwaysInPopup && items[parseInt(i.toString(), 10)].overflow !== 'Show')) {
|
|
1120
|
-
this.tbarAlgEle[(items[parseInt(i.toString(), 10)].align + 's').toLowerCase() as ItmAlign].push(innerItem);
|
|
1121
|
-
}
|
|
1122
|
-
innerPos.appendChild(innerItem);
|
|
1123
|
-
} else {
|
|
1124
|
-
itemEleDom.appendChild(innerItem);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
if ((this as any).isReact) {
|
|
1128
|
-
const portals: string = 'portals';
|
|
1129
|
-
this.notify('render-react-toolbar-template', (this as any)[`${portals}`]);
|
|
1130
|
-
this.renderReactTemplates();
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
/**
|
|
1135
|
-
* @hidden
|
|
1136
|
-
* @returns {void}
|
|
1137
|
-
*/
|
|
1138
|
-
public changeOrientation(): void {
|
|
1139
|
-
const ele: HTEle = this.element;
|
|
1140
|
-
if (this.isVertical) {
|
|
1141
|
-
ele.classList.remove(CLS_VERTICAL);
|
|
1142
|
-
this.isVertical = false;
|
|
1143
|
-
if (this.height === 'auto' || this.height === '100%') {
|
|
1144
|
-
ele.style.height = this.height;
|
|
1145
|
-
}
|
|
1146
|
-
ele.setAttribute('aria-orientation', 'horizontal');
|
|
1147
|
-
} else {
|
|
1148
|
-
ele.classList.add(CLS_VERTICAL);
|
|
1149
|
-
this.isVertical = true;
|
|
1150
|
-
ele.setAttribute('aria-orientation', 'vertical');
|
|
1151
|
-
setStyle(this.element, { 'height': formatUnit(this.height), 'width': formatUnit(this.width) });
|
|
1152
|
-
}
|
|
1153
|
-
this.destroyMode();
|
|
1154
|
-
this.refreshOverflow();
|
|
1155
|
-
}
|
|
1156
|
-
private initScroll(element: HTEle, innerItems: NodeList): void {
|
|
1157
|
-
if (!this.scrollModule && this.checkOverflow(element, <HTEle>innerItems[0])) {
|
|
1158
|
-
if (this.tbarAlign) {
|
|
1159
|
-
this.element.querySelector('.' + CLS_ITEMS + ' .' + CLS_TBARCENTER).removeAttribute('style');
|
|
1160
|
-
}
|
|
1161
|
-
if (this.isVertical) {
|
|
1162
|
-
this.scrollModule = new VScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
|
|
1163
|
-
} else {
|
|
1164
|
-
this.scrollModule = new HScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
|
|
1165
|
-
}
|
|
1166
|
-
if (this.cssClass) {
|
|
1167
|
-
addClass([<HTEle>innerItems[0]], this.cssClass.split(' '));
|
|
1168
|
-
}
|
|
1169
|
-
const scrollEle: Element = this.scrollModule.element.querySelector('.' + CLS_HSCROLLBAR + ', .' + 'e-vscroll-bar');
|
|
1170
|
-
if (scrollEle) {
|
|
1171
|
-
scrollEle.removeAttribute('tabindex');
|
|
1172
|
-
}
|
|
1173
|
-
this.remove(this.scrollModule.element, CLS_TBARPOS);
|
|
1174
|
-
setStyle(this.element, { overflow: 'hidden' });
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
private itemWidthCal(items: HTEle): number {
|
|
1178
|
-
let width: number = 0;
|
|
1179
|
-
let style: CSSStyleDeclaration;
|
|
1180
|
-
[].slice.call(selectAll('.' + CLS_ITEM, items)).forEach((el: HTEle) => {
|
|
1181
|
-
if (isVisible(el)) {
|
|
1182
|
-
style = window.getComputedStyle(el);
|
|
1183
|
-
width += this.isVertical ? el.offsetHeight : el.offsetWidth;
|
|
1184
|
-
width += parseFloat(this.isVertical ? style.marginTop : style.marginRight);
|
|
1185
|
-
width += parseFloat(this.isVertical ? style.marginBottom : style.marginLeft);
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
return width;
|
|
1189
|
-
}
|
|
1190
|
-
private getScrollCntEle(innerItem: HTEle): HTEle {
|
|
1191
|
-
const trgClass: Str = (this.isVertical) ? '.e-vscroll-content' : '.e-hscroll-content';
|
|
1192
|
-
return <HTEle>innerItem.querySelector(trgClass);
|
|
1193
|
-
}
|
|
1194
|
-
private checkOverflow(element: HTEle, innerItem: HTEle): boolean {
|
|
1195
|
-
if (isNOU(element) || isNOU(innerItem) || !isVisible(element)) {
|
|
1196
|
-
return false;
|
|
1197
|
-
}
|
|
1198
|
-
const eleWidth: number = this.isVertical ? element.offsetHeight : element.offsetWidth;
|
|
1199
|
-
let itemWidth: number = this.isVertical ? innerItem.offsetHeight : innerItem.offsetWidth;
|
|
1200
|
-
if (this.tbarAlign || this.scrollModule || (eleWidth === itemWidth)) {
|
|
1201
|
-
itemWidth = this.itemWidthCal(this.scrollModule ? this.getScrollCntEle(innerItem) : innerItem);
|
|
1202
|
-
}
|
|
1203
|
-
const popNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
|
|
1204
|
-
const scrollNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARSCRLNAV);
|
|
1205
|
-
let navEleWidth: number = 0;
|
|
1206
|
-
if (popNav) {
|
|
1207
|
-
navEleWidth = this.isVertical ? popNav.offsetHeight : popNav.offsetWidth;
|
|
1208
|
-
} else if (scrollNav) {
|
|
1209
|
-
navEleWidth = this.isVertical ? (scrollNav.offsetHeight * (2)) : (scrollNav.offsetWidth * 2);
|
|
1210
|
-
}
|
|
1211
|
-
if (eleWidth >= itemWidth && scrollNav) {
|
|
1212
|
-
return false;
|
|
1213
|
-
}
|
|
1214
|
-
else if (itemWidth > eleWidth - navEleWidth) {
|
|
1215
|
-
return true;
|
|
1216
|
-
} else {
|
|
1217
|
-
return false;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Refresh the whole Toolbar component without re-rendering.
|
|
1222
|
-
* - It is used to manually refresh the Toolbar overflow modes such as scrollable, popup, multi row, and extended.
|
|
1223
|
-
* - It will refresh the Toolbar component after loading items dynamically.
|
|
1224
|
-
*
|
|
1225
|
-
* @returns {void}.
|
|
1226
|
-
*/
|
|
1227
|
-
public refreshOverflow(): void {
|
|
1228
|
-
this.resize();
|
|
1229
|
-
}
|
|
1230
|
-
private toolbarAlign(innerItems: HTEle): void {
|
|
1231
|
-
if (this.tbarAlign) {
|
|
1232
|
-
this.add(innerItems, CLS_TBARPOS);
|
|
1233
|
-
this.itemPositioning();
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
private renderOverflowMode(): void {
|
|
1237
|
-
const ele: HTEle = this.element;
|
|
1238
|
-
const innerItems: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
|
|
1239
|
-
const priorityCheck: boolean = this.popupPriCount > 0;
|
|
1240
|
-
if (ele && ele.children.length > 0) {
|
|
1241
|
-
this.offsetWid = ele.offsetWidth;
|
|
1242
|
-
this.remove(this.element, 'e-toolpop');
|
|
1243
|
-
if (Browser.info.name === 'msie' && this.height === 'auto') {
|
|
1244
|
-
ele.style.height = '';
|
|
1245
|
-
}
|
|
1246
|
-
switch (this.overflowMode) {
|
|
1247
|
-
case 'Scrollable':
|
|
1248
|
-
if (isNOU(this.scrollModule)) {
|
|
1249
|
-
this.initScroll(ele, [].slice.call(ele.getElementsByClassName(CLS_ITEMS)));
|
|
1250
|
-
}
|
|
1251
|
-
break;
|
|
1252
|
-
case 'Popup':
|
|
1253
|
-
this.add(this.element, 'e-toolpop');
|
|
1254
|
-
if (this.tbarAlign) {
|
|
1255
|
-
this.removePositioning();
|
|
1256
|
-
}
|
|
1257
|
-
if (this.checkOverflow(ele, innerItems) || priorityCheck) {
|
|
1258
|
-
this.setOverflowAttributes(ele);
|
|
1259
|
-
}
|
|
1260
|
-
this.toolbarAlign(innerItems);
|
|
1261
|
-
break;
|
|
1262
|
-
case 'MultiRow':
|
|
1263
|
-
this.add(innerItems, CLS_MULTIROW);
|
|
1264
|
-
if (this.checkOverflow(ele, innerItems) && this.tbarAlign) {
|
|
1265
|
-
this.removePositioning();
|
|
1266
|
-
this.add(innerItems, CLS_MULTIROWPOS);
|
|
1267
|
-
}
|
|
1268
|
-
if (ele.style.overflow === 'hidden') {
|
|
1269
|
-
ele.style.overflow = '';
|
|
1270
|
-
}
|
|
1271
|
-
if (Browser.info.name === 'msie' || ele.style.height !== 'auto') {
|
|
1272
|
-
ele.style.height = 'auto';
|
|
1273
|
-
}
|
|
1274
|
-
break;
|
|
1275
|
-
case 'Extended':
|
|
1276
|
-
this.add(this.element, CLS_EXTEANDABLE_TOOLBAR);
|
|
1277
|
-
if (this.checkOverflow(ele, innerItems) || priorityCheck) {
|
|
1278
|
-
if (this.tbarAlign) {
|
|
1279
|
-
this.removePositioning();
|
|
1280
|
-
}
|
|
1281
|
-
this.setOverflowAttributes(ele);
|
|
1282
|
-
}
|
|
1283
|
-
this.toolbarAlign(innerItems);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
private setOverflowAttributes(ele: HTMLElement): void {
|
|
1289
|
-
this.createPopupEle(ele, [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, ele)));
|
|
1290
|
-
const ariaAttr: { [key: string]: Str } = {
|
|
1291
|
-
'tabindex': '0', 'role': 'button', 'aria-haspopup' : 'true',
|
|
1292
|
-
'aria-label': 'overflow'
|
|
1293
|
-
};
|
|
1294
|
-
attributes(this.element.querySelector('.' + CLS_TBARNAV), ariaAttr);
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
private separator(): void {
|
|
1298
|
-
const element: HTEle = this.element;
|
|
1299
|
-
const eleItem: HTEle[] = [].slice.call(element.querySelectorAll('.' + CLS_SEPARATOR));
|
|
1300
|
-
const multiVar: HTEle = element.querySelector('.' + CLS_MULTIROW_SEPARATOR) as HTEle;
|
|
1301
|
-
const extendVar: HTEle = element.querySelector('.' + CLS_EXTENDABLE_SEPARATOR) as HTEle;
|
|
1302
|
-
const eleInlineItem: HTEle = this.overflowMode === 'MultiRow' ? multiVar : extendVar;
|
|
1303
|
-
if (eleInlineItem !== null) {
|
|
1304
|
-
if (this.overflowMode === 'MultiRow') {
|
|
1305
|
-
eleInlineItem.classList.remove(CLS_MULTIROW_SEPARATOR);
|
|
1306
|
-
} else if (this.overflowMode === 'Extended') {
|
|
1307
|
-
eleInlineItem.classList.remove(CLS_EXTENDABLE_SEPARATOR);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
for (let i: number = 0; i <= eleItem.length - 1; i++) {
|
|
1311
|
-
if (eleItem[parseInt(i.toString(), 10)].offsetLeft < 30 && eleItem[parseInt(i.toString(), 10)].offsetLeft !== 0) {
|
|
1312
|
-
if (this.overflowMode === 'MultiRow') {
|
|
1313
|
-
eleItem[parseInt(i.toString(), 10)].classList.add(CLS_MULTIROW_SEPARATOR);
|
|
1314
|
-
} else if (this.overflowMode === 'Extended') {
|
|
1315
|
-
eleItem[parseInt(i.toString(), 10)].classList.add(CLS_EXTENDABLE_SEPARATOR);
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
private createPopupEle(ele: HTMLElement, innerEle: HTMLElement[]): void {
|
|
1322
|
-
let innerNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
|
|
1323
|
-
const vertical: boolean = this.isVertical;
|
|
1324
|
-
if (!innerNav) {
|
|
1325
|
-
this.createPopupIcon(ele);
|
|
1326
|
-
}
|
|
1327
|
-
innerNav = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
|
|
1328
|
-
const innerNavDom: number = (vertical ? innerNav.offsetHeight : innerNav.offsetWidth);
|
|
1329
|
-
const eleWidth: number = ((vertical ? ele.offsetHeight : ele.offsetWidth) - (innerNavDom));
|
|
1330
|
-
this.element.classList.remove('e-rtl');
|
|
1331
|
-
setStyle(this.element, { direction: 'initial' });
|
|
1332
|
-
this.checkPriority(ele, innerEle, eleWidth, true);
|
|
1333
|
-
if (this.enableRtl) {
|
|
1334
|
-
this.element.classList.add('e-rtl');
|
|
1335
|
-
}
|
|
1336
|
-
this.element.style.removeProperty('direction');
|
|
1337
|
-
this.createPopup();
|
|
1338
|
-
}
|
|
1339
|
-
private pushingPoppedEle(tbarObj: Toolbar, popupPri: Element[], ele: HTEle, eleHeight: number, sepHeight: number): void {
|
|
1340
|
-
const element: HTEle = tbarObj.element;
|
|
1341
|
-
const poppedEle: HTEle[] = [].slice.call(selectAll('.' + CLS_POPUP, element.querySelector('.' + CLS_ITEMS)));
|
|
1342
|
-
let nodes: HTEle[] = selectAll('.' + CLS_TBAROVERFLOW, ele);
|
|
1343
|
-
let nodeIndex: number = 0;
|
|
1344
|
-
let nodePri: number = 0;
|
|
1345
|
-
poppedEle.forEach((el: HTEle, index: number) => {
|
|
1346
|
-
nodes = selectAll('.' + CLS_TBAROVERFLOW, ele);
|
|
1347
|
-
if (el.classList.contains(CLS_TBAROVERFLOW) && nodes.length > 0) {
|
|
1348
|
-
if (tbarObj.tbResize && nodes.length > index) {
|
|
1349
|
-
ele.insertBefore(el, nodes[parseInt(index.toString(), 10)]); ++nodePri;
|
|
1350
|
-
} else {
|
|
1351
|
-
ele.insertBefore(el, ele.children[nodes.length]); ++nodePri;
|
|
1352
|
-
}
|
|
1353
|
-
} else if (el.classList.contains(CLS_TBAROVERFLOW)) {
|
|
1354
|
-
ele.insertBefore(el, ele.firstChild); ++nodePri;
|
|
1355
|
-
} else if (tbarObj.tbResize && el.classList.contains(CLS_POPOVERFLOW) && ele.children.length > 0 && nodes.length === 0) {
|
|
1356
|
-
ele.insertBefore(el, ele.firstChild); ++nodePri;
|
|
1357
|
-
} else if (el.classList.contains(CLS_POPOVERFLOW)) {
|
|
1358
|
-
popupPri.push(el);
|
|
1359
|
-
} else if (tbarObj.tbResize) {
|
|
1360
|
-
ele.insertBefore(el, ele.childNodes[nodeIndex + nodePri]);
|
|
1361
|
-
++nodeIndex;
|
|
1362
|
-
} else {
|
|
1363
|
-
ele.appendChild(el);
|
|
1364
|
-
}
|
|
1365
|
-
if (el.classList.contains(CLS_SEPARATOR)) {
|
|
1366
|
-
setStyle(el, { display: '', height: sepHeight + 'px' });
|
|
1367
|
-
} else {
|
|
1368
|
-
setStyle(el, { display: '', height: eleHeight + 'px' });
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
popupPri.forEach((el: Element) => {
|
|
1372
|
-
ele.appendChild(el);
|
|
1373
|
-
});
|
|
1374
|
-
const tbarEle: HTEle[] = selectAll('.' + CLS_ITEM, element.querySelector('.' + CLS_ITEMS));
|
|
1375
|
-
for (let i: number = tbarEle.length - 1; i >= 0; i--) {
|
|
1376
|
-
const tbarElement: HTEle = tbarEle[parseInt(i.toString(), 10)];
|
|
1377
|
-
if (tbarElement.classList.contains(CLS_SEPARATOR) && this.overflowMode !== 'Extended') {
|
|
1378
|
-
setStyle(tbarElement, { display: 'none' });
|
|
1379
|
-
} else {
|
|
1380
|
-
break;
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
private createPopup(): void {
|
|
1385
|
-
const element: HTEle = this.element;
|
|
1386
|
-
let sepHeight: number;
|
|
1387
|
-
let sepItem: Element;
|
|
1388
|
-
if (this.overflowMode === 'Extended') {
|
|
1389
|
-
sepItem = element.querySelector('.' + CLS_SEPARATOR);
|
|
1390
|
-
sepHeight =
|
|
1391
|
-
(element.style.height === 'auto' || element.style.height === '') ? null : (sepItem && (sepItem as HTEle).offsetHeight);
|
|
1392
|
-
}
|
|
1393
|
-
const eleItem: Element = element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_POPUP + ')');
|
|
1394
|
-
const eleHeight: number =
|
|
1395
|
-
(element.style.height === 'auto' || element.style.height === '') ? null : (eleItem && (eleItem as HTEle).offsetHeight);
|
|
1396
|
-
let ele: HTEle;
|
|
1397
|
-
const popupPri: Element[] = [];
|
|
1398
|
-
if (select('#' + element.id + '_popup.' + CLS_POPUPCLASS, element)) {
|
|
1399
|
-
ele = <HTEle>select('#' + element.id + '_popup.' + CLS_POPUPCLASS, element);
|
|
1400
|
-
} else {
|
|
1401
|
-
const extendEle: HTEle = this.createElement('div', {
|
|
1402
|
-
id: element.id + '_popup', className: CLS_POPUPCLASS + ' ' + CLS_EXTENDABLECLASS
|
|
1403
|
-
});
|
|
1404
|
-
const popupEle: HTEle = this.createElement('div', { id: element.id + '_popup', className: CLS_POPUPCLASS });
|
|
1405
|
-
ele = this.overflowMode === 'Extended' ? extendEle : popupEle;
|
|
1406
|
-
}
|
|
1407
|
-
this.pushingPoppedEle(this, popupPri, ele, eleHeight, sepHeight);
|
|
1408
|
-
this.popupInit(element, ele);
|
|
1409
|
-
}
|
|
1410
|
-
private getElementOffsetY(): number {
|
|
1411
|
-
return (this.overflowMode === 'Extended' && window.getComputedStyle(this.element).getPropertyValue('box-sizing') === 'border-box' ?
|
|
1412
|
-
this.element.clientHeight : this.element.offsetHeight);
|
|
1413
|
-
}
|
|
1414
|
-
private popupInit(element: HTEle, ele: HTEle): void {
|
|
1415
|
-
if (!this.popObj) {
|
|
1416
|
-
element.appendChild(ele);
|
|
1417
|
-
if (this.cssClass) {
|
|
1418
|
-
addClass([ele], this.cssClass.split(' '));
|
|
1419
|
-
}
|
|
1420
|
-
setStyle(this.element, { overflow: '' });
|
|
1421
|
-
const popup: Popup = new Popup(null, {
|
|
1422
|
-
relateTo: this.element,
|
|
1423
|
-
offsetY: (this.isVertical) ? 0 : this.getElementOffsetY(),
|
|
1424
|
-
enableRtl: this.enableRtl,
|
|
1425
|
-
open: this.popupOpen.bind(this),
|
|
1426
|
-
close: this.popupClose.bind(this),
|
|
1427
|
-
collision: { Y: this.enableCollision ? 'flip' : 'none' },
|
|
1428
|
-
position: this.enableRtl ? { X: 'left', Y: 'top' } : { X: 'right', Y: 'top' }
|
|
1429
|
-
});
|
|
1430
|
-
if (this.overflowMode === 'Extended') {
|
|
1431
|
-
popup.width = this.getToolbarPopupWidth(this.element);
|
|
1432
|
-
popup.offsetX = 0;
|
|
1433
|
-
}
|
|
1434
|
-
popup.appendTo(ele);
|
|
1435
|
-
document.addEventListener('scroll', this.clickEvent);
|
|
1436
|
-
document.addEventListener('click', this.scrollEvent);
|
|
1437
|
-
if (this.overflowMode !== 'Extended') {
|
|
1438
|
-
popup.element.style.maxHeight = popup.element.offsetHeight + 'px';
|
|
1439
|
-
}
|
|
1440
|
-
if (this.isVertical) {
|
|
1441
|
-
popup.element.style.visibility = 'hidden';
|
|
1442
|
-
}
|
|
1443
|
-
if (this.isExtendedOpen) {
|
|
1444
|
-
const popupNav: HTEle = this.element.querySelector('.' + CLS_TBARNAV);
|
|
1445
|
-
popupNav.classList.add(CLS_TBARNAVACT);
|
|
1446
|
-
classList(popupNav.firstElementChild, [CLS_POPUPICON], [CLS_POPUPDOWN]);
|
|
1447
|
-
this.element.querySelector('.' + CLS_EXTENDABLECLASS).classList.add(CLS_POPUPOPEN);
|
|
1448
|
-
} else {
|
|
1449
|
-
popup.hide();
|
|
1450
|
-
}
|
|
1451
|
-
this.popObj = popup;
|
|
1452
|
-
} else if (this.overflowMode !== 'Extended') {
|
|
1453
|
-
const popupEle: HTEle = this.popObj.element;
|
|
1454
|
-
setStyle(popupEle, { maxHeight: '', display: 'block' });
|
|
1455
|
-
setStyle(popupEle, { maxHeight: popupEle.offsetHeight + 'px', display: '' });
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
private tbarPopupHandler(isOpen: boolean): void {
|
|
1459
|
-
if (this.overflowMode === 'Extended') {
|
|
1460
|
-
if (isOpen) {
|
|
1461
|
-
this.add(this.element, CLS_EXTENDEDPOPOPEN);
|
|
1462
|
-
} else {
|
|
1463
|
-
this.remove(this.element, CLS_EXTENDEDPOPOPEN);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1468
|
-
private popupOpen(e: Event): void {
|
|
1469
|
-
const popObj: Popup = this.popObj;
|
|
1470
|
-
if (!this.isVertical) {
|
|
1471
|
-
popObj.offsetY = this.getElementOffsetY();
|
|
1472
|
-
popObj.dataBind();
|
|
1473
|
-
}
|
|
1474
|
-
const popupEle: HTEle = this.popObj.element;
|
|
1475
|
-
const toolEle: HTEle = this.popObj.element.parentElement;
|
|
1476
|
-
const popupNav: HTEle = <HTEle>toolEle.querySelector('.' + CLS_TBARNAV);
|
|
1477
|
-
popupNav.setAttribute('aria-expanded', 'true');
|
|
1478
|
-
if (this.overflowMode === 'Extended') {
|
|
1479
|
-
popObj.element.style.minHeight = '';
|
|
1480
|
-
} else {
|
|
1481
|
-
setStyle(popObj.element, { height: 'auto', maxHeight: '' });
|
|
1482
|
-
popObj.element.style.maxHeight = popObj.element.offsetHeight + 'px';
|
|
1483
|
-
}
|
|
1484
|
-
const popupElePos: number = popupEle.offsetTop + popupEle.offsetHeight + calculatePosition(toolEle).top;
|
|
1485
|
-
const popIcon: Element = (popupNav.firstElementChild as Element);
|
|
1486
|
-
popupNav.classList.add(CLS_TBARNAVACT);
|
|
1487
|
-
classList(popIcon, [CLS_POPUPICON], [CLS_POPUPDOWN]);
|
|
1488
|
-
this.tbarPopupHandler(true);
|
|
1489
|
-
const scrollVal: number = isNOU(window.scrollY) ? 0 : window.scrollY;
|
|
1490
|
-
if (!this.isVertical && ((window.innerHeight + scrollVal) < popupElePos) && (this.element.offsetTop < popupEle.offsetHeight)) {
|
|
1491
|
-
let overflowHeight: number = (popupEle.offsetHeight - ((popupElePos - window.innerHeight - scrollVal) + 5));
|
|
1492
|
-
popObj.height = overflowHeight + 'px';
|
|
1493
|
-
for (let i: number = 0; i <= popupEle.childElementCount; i++) {
|
|
1494
|
-
const ele: HTEle = <HTEle>popupEle.children[parseInt(i.toString(), 10)];
|
|
1495
|
-
if (ele.offsetTop + ele.offsetHeight > overflowHeight) {
|
|
1496
|
-
overflowHeight = ele.offsetTop;
|
|
1497
|
-
break;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
if (this.overflowMode !== 'Extended') {
|
|
1501
|
-
setStyle(popObj.element, { maxHeight: overflowHeight + 'px' });
|
|
1502
|
-
}
|
|
1503
|
-
} else if (this.isVertical && this.overflowMode !== 'Extended') {
|
|
1504
|
-
const tbEleData: ClientRect = this.element.getBoundingClientRect();
|
|
1505
|
-
setStyle(popObj.element, { maxHeight: (tbEleData.top + this.element.offsetHeight) + 'px', bottom: 0, visibility: '' });
|
|
1506
|
-
}
|
|
1507
|
-
if (popObj) {
|
|
1508
|
-
const popupOffset: ClientRect = popupEle.getBoundingClientRect();
|
|
1509
|
-
if (popupOffset.right > document.documentElement.clientWidth && popupOffset.width > toolEle.getBoundingClientRect().width) {
|
|
1510
|
-
popObj.collision = { Y: 'none' };
|
|
1511
|
-
popObj.dataBind();
|
|
1512
|
-
}
|
|
1513
|
-
popObj.refreshPosition();
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1518
|
-
private popupClose(e: Event): void {
|
|
1519
|
-
const element: HTEle = this.element;
|
|
1520
|
-
const popupNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
|
|
1521
|
-
popupNav.setAttribute('aria-expanded', 'false');
|
|
1522
|
-
const popIcon: Element = (popupNav.firstElementChild as Element);
|
|
1523
|
-
popupNav.classList.remove(CLS_TBARNAVACT);
|
|
1524
|
-
classList(popIcon, [CLS_POPUPDOWN], [CLS_POPUPICON]);
|
|
1525
|
-
this.tbarPopupHandler(false);
|
|
1526
|
-
}
|
|
1527
|
-
private checkPriority(ele: HTEle, inEle: HTEle[], eleWidth: number, pre: boolean): void {
|
|
1528
|
-
const popPriority: boolean = this.popupPriCount > 0;
|
|
1529
|
-
const len: number = inEle.length;
|
|
1530
|
-
const eleWid: number = eleWidth;
|
|
1531
|
-
let eleOffset: number;
|
|
1532
|
-
let checkoffset: boolean;
|
|
1533
|
-
let sepCheck: number = 0; let itemCount: number = 0; let itemPopCount: number = 0;
|
|
1534
|
-
const checkClass: (ele: HTEle, val: Str[]) => boolean = (ele: HTEle, val: Str[]) => {
|
|
1535
|
-
let rVal: boolean = false;
|
|
1536
|
-
val.forEach((cls: string) => {
|
|
1537
|
-
if (ele.classList.contains(cls)) {
|
|
1538
|
-
rVal = true;
|
|
1539
|
-
}
|
|
1540
|
-
});
|
|
1541
|
-
return rVal;
|
|
1542
|
-
};
|
|
1543
|
-
for (let i: number = len - 1; i >= 0; i--) {
|
|
1544
|
-
let mrgn: number;
|
|
1545
|
-
const compuStyle: CSSStyleDeclaration = window.getComputedStyle(inEle[parseInt(i.toString(), 10)]);
|
|
1546
|
-
if (this.isVertical) {
|
|
1547
|
-
mrgn = parseFloat((compuStyle).marginTop);
|
|
1548
|
-
mrgn += parseFloat((compuStyle).marginBottom);
|
|
1549
|
-
} else {
|
|
1550
|
-
mrgn = parseFloat((compuStyle).marginRight);
|
|
1551
|
-
mrgn += parseFloat((compuStyle).marginLeft);
|
|
1552
|
-
}
|
|
1553
|
-
const fstEleCheck: boolean = inEle[parseInt(i.toString(), 10)] === this.tbarEle[0];
|
|
1554
|
-
if (fstEleCheck) {
|
|
1555
|
-
this.tbarEleMrgn = mrgn;
|
|
1556
|
-
}
|
|
1557
|
-
eleOffset = this.isVertical ? inEle[parseInt(i.toString(), 10)].offsetHeight : inEle[parseInt(i.toString(), 10)].offsetWidth;
|
|
1558
|
-
const eleWid: number = fstEleCheck ? (eleOffset + mrgn) : eleOffset;
|
|
1559
|
-
if (checkClass(inEle[parseInt(i.toString(), 10)], [CLS_POPPRI]) && popPriority) {
|
|
1560
|
-
inEle[parseInt(i.toString(), 10)].classList.add(CLS_POPUP);
|
|
1561
|
-
if (this.isVertical) {
|
|
1562
|
-
setStyle(inEle[parseInt(i.toString(), 10)], { display: 'none', minHeight: eleWid + 'px' });
|
|
1563
|
-
} else {
|
|
1564
|
-
setStyle(inEle[parseInt(i.toString(), 10)], { display: 'none', minWidth: eleWid + 'px' });
|
|
1565
|
-
}
|
|
1566
|
-
itemPopCount++;
|
|
1567
|
-
}
|
|
1568
|
-
if (this.isVertical) {
|
|
1569
|
-
checkoffset =
|
|
1570
|
-
(inEle[parseInt(i.toString(), 10)].offsetTop + inEle[parseInt(i.toString(), 10)].offsetHeight + mrgn) > eleWidth;
|
|
1571
|
-
} else {
|
|
1572
|
-
checkoffset =
|
|
1573
|
-
(inEle[parseInt(i.toString(), 10)].offsetLeft + inEle[parseInt(i.toString(), 10)].offsetWidth + mrgn) > eleWidth;
|
|
1574
|
-
}
|
|
1575
|
-
if (checkoffset) {
|
|
1576
|
-
if (inEle[parseInt(i.toString(), 10)].classList.contains(CLS_SEPARATOR)) {
|
|
1577
|
-
if (this.overflowMode === 'Extended') {
|
|
1578
|
-
const sepEle: HTEle = (inEle[parseInt(i.toString(), 10)] as HTEle);
|
|
1579
|
-
if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
|
|
1580
|
-
inEle[parseInt(i.toString(), 10)].classList.add(CLS_POPUP);
|
|
1581
|
-
itemPopCount++;
|
|
1582
|
-
}
|
|
1583
|
-
itemCount++;
|
|
1584
|
-
} else if (this.overflowMode === 'Popup') {
|
|
1585
|
-
if (sepCheck > 0 && itemCount === itemPopCount) {
|
|
1586
|
-
const sepEle: HTEle = (inEle[i + itemCount + (sepCheck - 1)] as HTEle);
|
|
1587
|
-
if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
|
|
1588
|
-
setStyle(sepEle, { display: 'none' });
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
sepCheck++; itemCount = 0; itemPopCount = 0;
|
|
1592
|
-
}
|
|
1593
|
-
} else {
|
|
1594
|
-
itemCount++;
|
|
1595
|
-
}
|
|
1596
|
-
if (inEle[parseInt(i.toString(), 10)].classList.contains(CLS_TBAROVERFLOW) && pre) {
|
|
1597
|
-
eleWidth -= ((this.isVertical ? inEle[parseInt(i.toString(), 10)].offsetHeight :
|
|
1598
|
-
inEle[parseInt(i.toString(), 10)].offsetWidth) + (mrgn));
|
|
1599
|
-
} else if (!checkClass(inEle[parseInt(i.toString(), 10)], [CLS_SEPARATOR, CLS_TBARIGNORE])) {
|
|
1600
|
-
inEle[parseInt(i.toString(), 10)].classList.add(CLS_POPUP);
|
|
1601
|
-
if (this.isVertical) {
|
|
1602
|
-
setStyle(inEle[parseInt(i.toString(), 10)], { display: 'none', minHeight: eleWid + 'px' });
|
|
1603
|
-
} else {
|
|
1604
|
-
setStyle(inEle[parseInt(i.toString(), 10)], { display: 'none', minWidth: eleWid + 'px' });
|
|
1605
|
-
}
|
|
1606
|
-
itemPopCount++;
|
|
1607
|
-
} else {
|
|
1608
|
-
eleWidth -= ((this.isVertical ? inEle[parseInt(i.toString(), 10)].offsetHeight :
|
|
1609
|
-
inEle[parseInt(i.toString(), 10)].offsetWidth) + (mrgn));
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
}
|
|
1613
|
-
if (pre) {
|
|
1614
|
-
const popedEle: HTEle[] = selectAll('.' + CLS_ITEM + ':not(.' + CLS_POPUP + ')', this.element);
|
|
1615
|
-
this.checkPriority(ele, popedEle, eleWid, false);
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
private createPopupIcon(element: HTEle): void {
|
|
1620
|
-
const id: Str = element.id.concat('_nav');
|
|
1621
|
-
let className: Str = 'e-' + element.id.concat('_nav ' + CLS_POPUPNAV);
|
|
1622
|
-
className = this.overflowMode === 'Extended' ? className + ' ' + CLS_EXTENDPOPUP : className;
|
|
1623
|
-
const nav: HTEle = this.createElement('div', { id: id, className: className });
|
|
1624
|
-
if (Browser.info.name === 'msie' || Browser.info.name === 'edge') {
|
|
1625
|
-
nav.classList.add('e-ie-align');
|
|
1626
|
-
}
|
|
1627
|
-
const navItem: HTEle = this.createElement('div', { className: CLS_POPUPDOWN + ' e-icons' });
|
|
1628
|
-
nav.appendChild(navItem);
|
|
1629
|
-
nav.setAttribute('tabindex', '0');
|
|
1630
|
-
nav.setAttribute('role', 'button');
|
|
1631
|
-
element.appendChild(nav);
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
// eslint-disable-next-line max-len
|
|
1635
|
-
private tbarPriRef(inEle: HTEle, indx: number, sepPri: number, el: HTEle, des: boolean, elWid: number, wid: number, ig: number, eleStyles: Record<string, any>): void {
|
|
1636
|
-
const ignoreCount: number = ig;
|
|
1637
|
-
const popEle: HTEle = this.popObj.element;
|
|
1638
|
-
const query: Str = '.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_TBAROVERFLOW + ')';
|
|
1639
|
-
const priEleCnt: number = selectAll('.' + CLS_POPUP + ':not(.' + CLS_TBAROVERFLOW + ')', popEle).length;
|
|
1640
|
-
const checkClass: (ele: HTEle, val: Str) => boolean = (ele: HTEle, val: Str) => {
|
|
1641
|
-
return ele.classList.contains(val);
|
|
1642
|
-
};
|
|
1643
|
-
if (selectAll(query, inEle).length === 0) {
|
|
1644
|
-
const eleSep: HTEle = inEle.children[indx - (indx - sepPri) - 1] as HTEle;
|
|
1645
|
-
const ignoreCheck: boolean = (!isNOU(eleSep) && checkClass(eleSep, CLS_TBARIGNORE));
|
|
1646
|
-
if ((!isNOU(eleSep) && checkClass(eleSep, CLS_SEPARATOR) && !isVisible(eleSep)) || ignoreCheck) {
|
|
1647
|
-
eleSep.style.display = 'unset';
|
|
1648
|
-
const eleSepWidth: number = eleSep.offsetWidth + (parseFloat(window.getComputedStyle(eleSep).marginRight) * 2);
|
|
1649
|
-
const prevSep: HTEle = eleSep.previousElementSibling as HTEle;
|
|
1650
|
-
if ((elWid + eleSepWidth) < wid || des) {
|
|
1651
|
-
inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
|
|
1652
|
-
if (!isNOU(prevSep)) {
|
|
1653
|
-
prevSep.style.display = '';
|
|
1654
|
-
}
|
|
1655
|
-
} else {
|
|
1656
|
-
setStyle(el, eleStyles);
|
|
1657
|
-
if (prevSep.classList.contains(CLS_SEPARATOR)) {
|
|
1658
|
-
prevSep.style.display = 'none';
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
eleSep.style.display = '';
|
|
1662
|
-
} else {
|
|
1663
|
-
inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
|
|
1664
|
-
}
|
|
1665
|
-
} else {
|
|
1666
|
-
inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - priEleCnt]);
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
|
|
1670
|
-
private popupRefresh(popupEle: HTMLElement, destroy: boolean): void {
|
|
1671
|
-
const ele: HTEle = this.element;
|
|
1672
|
-
const isVer: boolean = this.isVertical;
|
|
1673
|
-
const innerEle: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
|
|
1674
|
-
let popNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
|
|
1675
|
-
if (isNOU(popNav)) {
|
|
1676
|
-
return;
|
|
1677
|
-
}
|
|
1678
|
-
innerEle.removeAttribute('style');
|
|
1679
|
-
popupEle.style.display = 'block';
|
|
1680
|
-
let dimension: number;
|
|
1681
|
-
if (isVer) {
|
|
1682
|
-
dimension = ele.offsetHeight - (popNav.offsetHeight + innerEle.offsetHeight);
|
|
1683
|
-
} else {
|
|
1684
|
-
dimension = ele.offsetWidth - (popNav.offsetWidth + innerEle.offsetWidth);
|
|
1685
|
-
}
|
|
1686
|
-
let popupEleWidth: number = 0;
|
|
1687
|
-
[].slice.call(popupEle.children).forEach((el: HTMLElement): void => {
|
|
1688
|
-
popupEleWidth += this.popupEleWidth(el);
|
|
1689
|
-
setStyle(el, { 'position': '' });
|
|
1690
|
-
});
|
|
1691
|
-
if ((dimension + (isVer ? popNav.offsetHeight : popNav.offsetWidth)) > (popupEleWidth) && this.popupPriCount === 0) {
|
|
1692
|
-
destroy = true;
|
|
1693
|
-
}
|
|
1694
|
-
this.popupEleRefresh(dimension, popupEle, destroy);
|
|
1695
|
-
popupEle.style.display = '';
|
|
1696
|
-
if (popupEle.children.length === 0 && popNav && this.popObj) {
|
|
1697
|
-
detach(popNav);
|
|
1698
|
-
popNav = null;
|
|
1699
|
-
this.popObj.destroy();
|
|
1700
|
-
detach(this.popObj.element);
|
|
1701
|
-
this.popObj = null;
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
private ignoreEleFetch(index: number, innerEle: HTEle): number {
|
|
1705
|
-
const ignoreEle: HTEle[] = [].slice.call(innerEle.querySelectorAll('.' + CLS_TBARIGNORE));
|
|
1706
|
-
const ignoreInx: number[] = [];
|
|
1707
|
-
let count: number = 0;
|
|
1708
|
-
if (ignoreEle.length > 0) {
|
|
1709
|
-
ignoreEle.forEach((ele: HTEle): void => {
|
|
1710
|
-
ignoreInx.push([].slice.call(innerEle.children).indexOf(ele));
|
|
1711
|
-
});
|
|
1712
|
-
} else {
|
|
1713
|
-
return 0;
|
|
1714
|
-
}
|
|
1715
|
-
ignoreInx.forEach((val: number): void => {
|
|
1716
|
-
if (val <= index) {
|
|
1717
|
-
count++;
|
|
1718
|
-
}
|
|
1719
|
-
});
|
|
1720
|
-
return count;
|
|
1721
|
-
}
|
|
1722
|
-
private checkPopupRefresh(root: HTEle, popEle: HTEle): boolean {
|
|
1723
|
-
popEle.style.display = 'block';
|
|
1724
|
-
const elWid: number = this.popupEleWidth(<HTEle>popEle.firstElementChild);
|
|
1725
|
-
(<HTEle>popEle.firstElementChild).style.removeProperty('Position');
|
|
1726
|
-
const tbarWidth: number = root.offsetWidth - (<HTEle>root.querySelector('.' + CLS_TBARNAV)).offsetWidth;
|
|
1727
|
-
const tbarItemsWid: number = (<HTEle>root.querySelector('.' + CLS_ITEMS)).offsetWidth;
|
|
1728
|
-
popEle.style.removeProperty('display');
|
|
1729
|
-
if (tbarWidth > (elWid + tbarItemsWid)) {
|
|
1730
|
-
return true;
|
|
1731
|
-
}
|
|
1732
|
-
return false;
|
|
1733
|
-
}
|
|
1734
|
-
private popupEleWidth(el: HTEle): number {
|
|
1735
|
-
el.style.position = 'absolute';
|
|
1736
|
-
const style: CSSStyleDeclaration = window.getComputedStyle(el);
|
|
1737
|
-
let elWidth: number = this.isVertical
|
|
1738
|
-
? el.offsetHeight
|
|
1739
|
-
: el.offsetWidth + parseFloat(style.marginLeft) + parseFloat(style.marginRight);
|
|
1740
|
-
const btnText: HTEle = <HTEle>el.querySelector('.' + CLS_TBARBTNTEXT);
|
|
1741
|
-
if (el.classList.contains('e-tbtn-align') || el.classList.contains(CLS_TBARTEXT)) {
|
|
1742
|
-
const btn: HTEle = <HTEle>el.children[0];
|
|
1743
|
-
if (!isNOU(btnText) && el.classList.contains(CLS_TBARTEXT)) {
|
|
1744
|
-
btnText.style.display = 'none';
|
|
1745
|
-
} else if (!isNOU(btnText) && el.classList.contains(CLS_POPUPTEXT)) {
|
|
1746
|
-
btnText.style.display = 'block';
|
|
1747
|
-
}
|
|
1748
|
-
btn.style.minWidth = '0%';
|
|
1749
|
-
elWidth = parseFloat(!this.isVertical ? el.style.minWidth : el.style.minHeight);
|
|
1750
|
-
btn.style.minWidth = '';
|
|
1751
|
-
btn.style.minHeight = '';
|
|
1752
|
-
if (!isNOU(btnText)) {
|
|
1753
|
-
btnText.style.display = '';
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
return elWidth;
|
|
1757
|
-
}
|
|
1758
|
-
private popupEleRefresh(width: number, popupEle: HTEle, destroy: boolean): void {
|
|
1759
|
-
const popPriority: boolean = this.popupPriCount > 0;
|
|
1760
|
-
let eleSplice: HTEle[] = this.tbarEle;
|
|
1761
|
-
let priEleCnt: number;
|
|
1762
|
-
let index: number;
|
|
1763
|
-
let innerEle: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
|
|
1764
|
-
let ignoreCount: number = 0;
|
|
1765
|
-
for (const el of [].slice.call(popupEle.children)) {
|
|
1766
|
-
if (el.classList.contains(CLS_POPPRI) && popPriority && !destroy) {
|
|
1767
|
-
continue;
|
|
1768
|
-
}
|
|
1769
|
-
let elWidth: number = this.popupEleWidth(el);
|
|
1770
|
-
if (el === this.tbarEle[0]) {
|
|
1771
|
-
elWidth += this.tbarEleMrgn;
|
|
1772
|
-
}
|
|
1773
|
-
el.style.position = '';
|
|
1774
|
-
if (elWidth < width || destroy) {
|
|
1775
|
-
const inlineStyles: Record<string, any> = {
|
|
1776
|
-
minWidth: el.style.minWidth, height: el.style.height,
|
|
1777
|
-
minHeight: el.style.minHeight
|
|
1778
|
-
};
|
|
1779
|
-
setStyle(el, { minWidth: '', height: '', minHeight: '' });
|
|
1780
|
-
if (!el.classList.contains(CLS_POPOVERFLOW)) {
|
|
1781
|
-
el.classList.remove(CLS_POPUP);
|
|
1782
|
-
}
|
|
1783
|
-
index = this.tbarEle.indexOf(el);
|
|
1784
|
-
if (this.tbarAlign) {
|
|
1785
|
-
const pos: ItemAlign = this.items[parseInt(index.toString(), 10)].align;
|
|
1786
|
-
index = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign].indexOf(el);
|
|
1787
|
-
eleSplice = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign];
|
|
1788
|
-
innerEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS + ' .' + 'e-toolbar-' + pos.toLowerCase());
|
|
1789
|
-
}
|
|
1790
|
-
let sepBeforePri: number = 0;
|
|
1791
|
-
if (this.overflowMode !== 'Extended') {
|
|
1792
|
-
eleSplice.slice(0, index).forEach((el: HTEle) => {
|
|
1793
|
-
if (el.classList.contains(CLS_TBAROVERFLOW) || el.classList.contains(CLS_SEPARATOR)) {
|
|
1794
|
-
if (el.classList.contains(CLS_SEPARATOR)) {
|
|
1795
|
-
el.style.display = '';
|
|
1796
|
-
width -= el.offsetWidth;
|
|
1797
|
-
}
|
|
1798
|
-
sepBeforePri++;
|
|
1799
|
-
}
|
|
1800
|
-
});
|
|
1801
|
-
}
|
|
1802
|
-
ignoreCount = this.ignoreEleFetch(index, innerEle);
|
|
1803
|
-
if (el.classList.contains(CLS_TBAROVERFLOW)) {
|
|
1804
|
-
this.tbarPriRef(innerEle, index, sepBeforePri, el, destroy, elWidth, width, ignoreCount, inlineStyles);
|
|
1805
|
-
width -= el.offsetWidth;
|
|
1806
|
-
} else if (index === 0) {
|
|
1807
|
-
innerEle.insertBefore(el, innerEle.firstChild);
|
|
1808
|
-
width -= el.offsetWidth;
|
|
1809
|
-
} else {
|
|
1810
|
-
priEleCnt = selectAll('.' + CLS_TBAROVERFLOW, this.popObj.element).length;
|
|
1811
|
-
innerEle.insertBefore(el, innerEle.children[(index + ignoreCount) - priEleCnt]);
|
|
1812
|
-
width -= el.offsetWidth;
|
|
1813
|
-
}
|
|
1814
|
-
el.style.height = '';
|
|
1815
|
-
} else {
|
|
1816
|
-
break;
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
const checkOverflow: boolean = this.checkOverflow(this.element, this.element.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
|
|
1820
|
-
if (checkOverflow && !destroy) {
|
|
1821
|
-
this.renderOverflowMode();
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
private removePositioning(): void {
|
|
1825
|
-
const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
|
|
1826
|
-
if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) {
|
|
1827
|
-
return;
|
|
1828
|
-
}
|
|
1829
|
-
this.remove(item, CLS_TBARPOS);
|
|
1830
|
-
const innerItem: HTEle[] = [].slice.call(item.childNodes);
|
|
1831
|
-
innerItem[1].removeAttribute('style');
|
|
1832
|
-
innerItem[2].removeAttribute('style');
|
|
1833
|
-
}
|
|
1834
|
-
private refreshPositioning(): void {
|
|
1835
|
-
const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
|
|
1836
|
-
this.add(item, CLS_TBARPOS);
|
|
1837
|
-
this.itemPositioning();
|
|
1838
|
-
}
|
|
1839
|
-
private itemPositioning(): void {
|
|
1840
|
-
const item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
|
|
1841
|
-
let margin: number;
|
|
1842
|
-
if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) {
|
|
1843
|
-
return;
|
|
1844
|
-
}
|
|
1845
|
-
const popupNav: HTEle = <HTEle>this.element.querySelector('.' + CLS_TBARNAV);
|
|
1846
|
-
let innerItem: HTEle[];
|
|
1847
|
-
if (this.scrollModule) {
|
|
1848
|
-
const trgClass: Str = (this.isVertical) ? CLS_VSCROLLCNT : CLS_HSCROLLCNT;
|
|
1849
|
-
innerItem = [].slice.call(item.querySelector('.' + trgClass).children);
|
|
1850
|
-
} else {
|
|
1851
|
-
innerItem = [].slice.call(item.childNodes);
|
|
1852
|
-
}
|
|
1853
|
-
if (this.isVertical) {
|
|
1854
|
-
margin = innerItem[0].offsetHeight + innerItem[2].offsetHeight;
|
|
1855
|
-
} else {
|
|
1856
|
-
margin = innerItem[0].offsetWidth + innerItem[2].offsetWidth;
|
|
1857
|
-
}
|
|
1858
|
-
let tbarWid: number = this.isVertical ? this.element.offsetHeight : this.element.offsetWidth;
|
|
1859
|
-
if (popupNav) {
|
|
1860
|
-
tbarWid -= (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth);
|
|
1861
|
-
const popWid: string = (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth) + 'px';
|
|
1862
|
-
innerItem[2].removeAttribute('style');
|
|
1863
|
-
if (this.isVertical) {
|
|
1864
|
-
if (this.enableRtl) {
|
|
1865
|
-
innerItem[2].style.top = popWid;
|
|
1866
|
-
} else {
|
|
1867
|
-
innerItem[2].style.bottom = popWid;
|
|
1868
|
-
}
|
|
1869
|
-
} else {
|
|
1870
|
-
if (this.enableRtl) {
|
|
1871
|
-
innerItem[2].style.left = popWid;
|
|
1872
|
-
} else {
|
|
1873
|
-
innerItem[2].style.right = popWid;
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
if (tbarWid <= margin) {
|
|
1878
|
-
return;
|
|
1879
|
-
}
|
|
1880
|
-
const value: number = (((tbarWid - margin)) - (!this.isVertical ? innerItem[1].offsetWidth : innerItem[1].offsetHeight)) / 2;
|
|
1881
|
-
innerItem[1].removeAttribute('style');
|
|
1882
|
-
const mrgn: Str = ((!this.isVertical ? innerItem[0].offsetWidth : innerItem[0].offsetHeight) + value) + 'px';
|
|
1883
|
-
if (this.isVertical) {
|
|
1884
|
-
if (this.enableRtl) {
|
|
1885
|
-
innerItem[1].style.marginBottom = mrgn;
|
|
1886
|
-
} else {
|
|
1887
|
-
innerItem[1].style.marginTop = mrgn;
|
|
1888
|
-
}
|
|
1889
|
-
} else {
|
|
1890
|
-
if (this.enableRtl) {
|
|
1891
|
-
innerItem[1].style.marginRight = mrgn;
|
|
1892
|
-
} else {
|
|
1893
|
-
innerItem[1].style.marginLeft = mrgn;
|
|
1894
|
-
}
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
private tbarItemAlign(item: ItemModel, itemEle: HTEle, pos: number): void {
|
|
1898
|
-
if (item.showAlwaysInPopup && item.overflow !== 'Show') {
|
|
1899
|
-
return;
|
|
1900
|
-
}
|
|
1901
|
-
const alignDiv: HTMLElement[] = [];
|
|
1902
|
-
alignDiv.push(this.createElement('div', { className: CLS_TBARLEFT, attrs: { role: 'group' } }));
|
|
1903
|
-
alignDiv.push(this.createElement('div', { className: CLS_TBARCENTER , attrs: { role: 'group' } }));
|
|
1904
|
-
alignDiv.push(this.createElement('div', { className: CLS_TBARRIGHT, attrs: { role: 'group' } }));
|
|
1905
|
-
if (pos === 0 && item.align !== 'Left') {
|
|
1906
|
-
alignDiv.forEach((ele: HTEle) => {
|
|
1907
|
-
itemEle.appendChild(ele);
|
|
1908
|
-
});
|
|
1909
|
-
this.tbarAlign = true;
|
|
1910
|
-
this.add(itemEle, CLS_TBARPOS);
|
|
1911
|
-
} else if (item.align !== 'Left') {
|
|
1912
|
-
const alignEle: NodeList = itemEle.childNodes;
|
|
1913
|
-
const leftAlign: HTEle = alignDiv[0];
|
|
1914
|
-
[].slice.call(alignEle).forEach((el: HTEle) => {
|
|
1915
|
-
this.tbarAlgEle.lefts.push(el);
|
|
1916
|
-
leftAlign.appendChild(el);
|
|
1917
|
-
});
|
|
1918
|
-
itemEle.appendChild(leftAlign);
|
|
1919
|
-
itemEle.appendChild(alignDiv[1]);
|
|
1920
|
-
itemEle.appendChild(alignDiv[2]);
|
|
1921
|
-
this.tbarAlign = true;
|
|
1922
|
-
this.add(itemEle, CLS_TBARPOS);
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
private ctrlTemplate(): void {
|
|
1926
|
-
this.ctrlTem = <HTEle>this.trgtEle.cloneNode(true);
|
|
1927
|
-
this.add(this.trgtEle, CLS_ITEMS);
|
|
1928
|
-
this.tbarEle = [];
|
|
1929
|
-
const innerEle: HTEle[] = [].slice.call(this.trgtEle.children);
|
|
1930
|
-
innerEle.forEach((ele: HTEle) => {
|
|
1931
|
-
if (ele.tagName === 'DIV') {
|
|
1932
|
-
this.tbarEle.push(ele);
|
|
1933
|
-
if (!isNOU(ele.firstElementChild)) {
|
|
1934
|
-
ele.firstElementChild.setAttribute('aria-disabled', 'false');
|
|
1935
|
-
}
|
|
1936
|
-
this.add(ele, CLS_ITEM);
|
|
1937
|
-
}
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
private renderItems(): void {
|
|
1941
|
-
const ele: HTEle = this.element;
|
|
1942
|
-
const items: Item[] = <Item[]>this.items;
|
|
1943
|
-
if (this.trgtEle != null) {
|
|
1944
|
-
this.ctrlTemplate();
|
|
1945
|
-
} else if (ele && items.length > 0) {
|
|
1946
|
-
let itemEleDom: HTEle;
|
|
1947
|
-
if (ele && ele.children.length > 0) {
|
|
1948
|
-
itemEleDom = <HTEle>ele.querySelector('.' + CLS_ITEMS);
|
|
1949
|
-
}
|
|
1950
|
-
if (!itemEleDom) {
|
|
1951
|
-
itemEleDom = this.createElement('div', { className: CLS_ITEMS });
|
|
1952
|
-
}
|
|
1953
|
-
this.itemsAlign(items, itemEleDom);
|
|
1954
|
-
ele.appendChild(itemEleDom);
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
private setAttr(attr: { [key: string]: Str }, element: HTEle): void {
|
|
1958
|
-
const key: Object[] = Object.keys(attr);
|
|
1959
|
-
let keyVal: Str;
|
|
1960
|
-
for (let i: number = 0; i < key.length; i++) {
|
|
1961
|
-
keyVal = key[parseInt(i.toString(), 10)] as Str;
|
|
1962
|
-
if (keyVal === 'class') {
|
|
1963
|
-
this.add(element, attr[`${keyVal}`]);
|
|
1964
|
-
} else {
|
|
1965
|
-
element.setAttribute(keyVal, attr[`${keyVal}`]);
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
/**
|
|
1970
|
-
* Enables or disables the specified Toolbar item.
|
|
1971
|
-
*
|
|
1972
|
-
* @param {number|HTMLElement|NodeList} items - DOM element or an array of items to be enabled or disabled.
|
|
1973
|
-
* @param {boolean} isEnable - Boolean value that determines whether the command should be enabled or disabled.
|
|
1974
|
-
* By default, `isEnable` is set to true.
|
|
1975
|
-
* @returns {void}.
|
|
1976
|
-
*/
|
|
1977
|
-
public enableItems(items: number | HTMLElement | NodeList, isEnable?: boolean): void {
|
|
1978
|
-
const elements: NodeList = <NodeList>items;
|
|
1979
|
-
const len: number = elements.length;
|
|
1980
|
-
let ele: HTEle | number;
|
|
1981
|
-
if (isNOU(isEnable)) {
|
|
1982
|
-
isEnable = true;
|
|
1983
|
-
}
|
|
1984
|
-
const enable: (isEnable: boolean, ele: HTEle) => void = (isEnable: boolean, ele: HTEle) => {
|
|
1985
|
-
if (isEnable) {
|
|
1986
|
-
ele.classList.remove(CLS_DISABLE);
|
|
1987
|
-
if (!isNOU(ele.firstElementChild)) {
|
|
1988
|
-
ele.firstElementChild.setAttribute('aria-disabled', 'false');
|
|
1989
|
-
this.updateTabIndex('0');
|
|
1990
|
-
}
|
|
1991
|
-
} else {
|
|
1992
|
-
ele.classList.add(CLS_DISABLE);
|
|
1993
|
-
if (!isNOU(ele.firstElementChild)) {
|
|
1994
|
-
ele.firstElementChild.setAttribute('aria-disabled', 'true');
|
|
1995
|
-
ele.firstElementChild.setAttribute('tabindex', '-1');
|
|
1996
|
-
this.updateTabIndex('0');
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
};
|
|
2000
|
-
if (!isNOU(len) && len >= 1) {
|
|
2001
|
-
for (let a: number = 0, element: HTEle[] = [].slice.call(elements); a < len; a++) {
|
|
2002
|
-
const itemElement: HTEle = element[parseInt(a.toString(), 10)];
|
|
2003
|
-
if (typeof (itemElement) === 'number') {
|
|
2004
|
-
ele = this.getElementByIndex(itemElement);
|
|
2005
|
-
if (isNOU(ele)) {
|
|
2006
|
-
return;
|
|
2007
|
-
} else {
|
|
2008
|
-
elements[parseInt(a.toString(), 10)] = ele;
|
|
2009
|
-
}
|
|
2010
|
-
} else {
|
|
2011
|
-
ele = itemElement;
|
|
2012
|
-
}
|
|
2013
|
-
enable(isEnable, ele);
|
|
2014
|
-
}
|
|
2015
|
-
if (isEnable) {
|
|
2016
|
-
removeClass(elements, CLS_DISABLE);
|
|
2017
|
-
} else {
|
|
2018
|
-
addClass(elements, CLS_DISABLE);
|
|
2019
|
-
}
|
|
2020
|
-
} else {
|
|
2021
|
-
if (typeof (elements) === 'number') {
|
|
2022
|
-
ele = this.getElementByIndex(elements);
|
|
2023
|
-
if (isNOU(ele)) {
|
|
2024
|
-
return;
|
|
2025
|
-
}
|
|
2026
|
-
} else {
|
|
2027
|
-
ele = <HTEle>items;
|
|
2028
|
-
}
|
|
2029
|
-
enable(isEnable, ele);
|
|
2030
|
-
}
|
|
2031
|
-
}
|
|
2032
|
-
private getElementByIndex(index: number): HTEle {
|
|
2033
|
-
if (this.tbarEle[parseInt(index.toString(), 10)]) {
|
|
2034
|
-
return this.tbarEle[parseInt(index.toString(), 10)];
|
|
2035
|
-
}
|
|
2036
|
-
return null;
|
|
2037
|
-
}
|
|
2038
|
-
/**
|
|
2039
|
-
* Adds new items to the Toolbar that accepts an array as Toolbar items.
|
|
2040
|
-
*
|
|
2041
|
-
* @param {ItemModel[]} items - DOM element or an array of items to be added to the Toolbar.
|
|
2042
|
-
* @param {number} index - Number value that determines where the command is to be added. By default, index is 0.
|
|
2043
|
-
* @returns {void}.
|
|
2044
|
-
*/
|
|
2045
|
-
public addItems(items: ItemModel[], index?: number): void {
|
|
2046
|
-
let innerItems: HTEle[];
|
|
2047
|
-
this.extendedOpen();
|
|
2048
|
-
const itemsDiv: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
|
|
2049
|
-
if (isNOU(itemsDiv)) {
|
|
2050
|
-
this.itemsRerender(items);
|
|
2051
|
-
return;
|
|
2052
|
-
}
|
|
2053
|
-
let innerEle: HTEle;
|
|
2054
|
-
let itemAgn: Str = 'Left';
|
|
2055
|
-
if (isNOU(index)) {
|
|
2056
|
-
index = 0;
|
|
2057
|
-
}
|
|
2058
|
-
items.forEach((e: ItemModel) => {
|
|
2059
|
-
if (!isNOU(e.align) && e.align !== 'Left' && itemAgn === 'Left') {
|
|
2060
|
-
itemAgn = e.align;
|
|
2061
|
-
}
|
|
2062
|
-
});
|
|
2063
|
-
for (const item of items) {
|
|
2064
|
-
if (isNOU(item.type)) {
|
|
2065
|
-
item.type = 'Button';
|
|
2066
|
-
}
|
|
2067
|
-
innerItems = selectAll('.' + CLS_ITEM, this.element);
|
|
2068
|
-
item.align = <ItemAlign>itemAgn;
|
|
2069
|
-
innerEle = this.renderSubComponent(item, index);
|
|
2070
|
-
if (this.tbarEle.length >= index && innerItems.length >= 0) {
|
|
2071
|
-
if (isNOU(this.scrollModule)) {
|
|
2072
|
-
this.destroyMode();
|
|
2073
|
-
}
|
|
2074
|
-
const algIndex: number = item.align[0] === 'L' ? 0 : item.align[0] === 'C' ? 1 : 2;
|
|
2075
|
-
let ele: Element;
|
|
2076
|
-
if (!this.tbarAlign && itemAgn !== 'Left') {
|
|
2077
|
-
this.tbarItemAlign(item, itemsDiv, 1);
|
|
2078
|
-
this.tbarAlign = true;
|
|
2079
|
-
ele = closest(innerItems[0], '.' + CLS_ITEMS).children[parseInt(algIndex.toString(), 10)];
|
|
2080
|
-
ele.appendChild(innerEle);
|
|
2081
|
-
this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].push(innerEle);
|
|
2082
|
-
this.refreshPositioning();
|
|
2083
|
-
} else if (this.tbarAlign) {
|
|
2084
|
-
ele = closest(innerItems[0], '.' + CLS_ITEMS).children[parseInt(algIndex.toString(), 10)];
|
|
2085
|
-
ele.insertBefore(innerEle, ele.children[parseInt(index.toString(), 10)]);
|
|
2086
|
-
this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].splice(index, 0, innerEle);
|
|
2087
|
-
this.refreshPositioning();
|
|
2088
|
-
} else if (innerItems.length === 0) {
|
|
2089
|
-
innerItems = selectAll('.' + CLS_ITEMS, this.element);
|
|
2090
|
-
innerItems[0].appendChild(innerEle);
|
|
2091
|
-
} else {
|
|
2092
|
-
innerItems[0].parentNode.insertBefore(innerEle, innerItems[parseInt(index.toString(), 10)]);
|
|
2093
|
-
}
|
|
2094
|
-
this.items.splice(index, 0, item);
|
|
2095
|
-
if (item.template) {
|
|
2096
|
-
this.tbarEle.splice(this.tbarEle.length - 1, 1);
|
|
2097
|
-
}
|
|
2098
|
-
this.tbarEle.splice(index, 0, innerEle);
|
|
2099
|
-
index++;
|
|
2100
|
-
this.offsetWid = itemsDiv.offsetWidth;
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
itemsDiv.style.width = '';
|
|
2104
|
-
this.renderOverflowMode();
|
|
2105
|
-
if ((this as any).isReact) {
|
|
2106
|
-
this.renderReactTemplates();
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
/**
|
|
2110
|
-
* Removes the items from the Toolbar. Acceptable arguments are index of item/HTMLElement/node list.
|
|
2111
|
-
*
|
|
2112
|
-
* @param {number|HTMLElement|NodeList|HTMLElement[]} args
|
|
2113
|
-
* Index or DOM element or an Array of item which is to be removed from the Toolbar.
|
|
2114
|
-
* @returns {void}.
|
|
2115
|
-
*/
|
|
2116
|
-
public removeItems(args: number | HTMLElement | NodeList | Element | HTMLElement[]): void {
|
|
2117
|
-
const elements: NodeList = <NodeList>args;
|
|
2118
|
-
let index: number;
|
|
2119
|
-
let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
|
|
2120
|
-
if (typeof (elements) === 'number') {
|
|
2121
|
-
index = parseInt(args.toString(), 10);
|
|
2122
|
-
this.removeItemByIndex(index, innerItems);
|
|
2123
|
-
} else {
|
|
2124
|
-
if (elements && elements.length > 1) {
|
|
2125
|
-
for (const ele of [].slice.call(elements)) {
|
|
2126
|
-
index = this.tbarEle.indexOf(ele);
|
|
2127
|
-
this.removeItemByIndex(index, innerItems);
|
|
2128
|
-
innerItems = selectAll('.' + CLS_ITEM, this.element);
|
|
2129
|
-
}
|
|
2130
|
-
} else {
|
|
2131
|
-
const ele: HTEle = (elements && elements.length && elements.length === 1) ? <HTEle>elements[0] : <HTEle>args;
|
|
2132
|
-
index = innerItems.indexOf(ele);
|
|
2133
|
-
this.removeItemByIndex(index, innerItems);
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2136
|
-
this.resize();
|
|
2137
|
-
}
|
|
2138
|
-
private removeItemByIndex(index: number, innerItems: HTEle[]): void {
|
|
2139
|
-
if (this.tbarEle[parseInt(index.toString(), 10)] && innerItems[parseInt(index.toString(), 10)]) {
|
|
2140
|
-
const eleIdx: number = this.tbarEle.indexOf(innerItems[parseInt(index.toString(), 10)]);
|
|
2141
|
-
if (this.tbarAlign) {
|
|
2142
|
-
const indexAgn: number =
|
|
2143
|
-
this.tbarAlgEle[(this.items[parseInt(eleIdx.toString(), 10)].align + 's').toLowerCase() as ItmAlign].indexOf(this.tbarEle[parseInt(eleIdx.toString(), 10)]);
|
|
2144
|
-
this.tbarAlgEle[(this.items[parseInt(eleIdx.toString(), 10)].align + 's').toLowerCase() as ItmAlign].splice(parseInt(indexAgn.toString(), 10), 1);
|
|
2145
|
-
}
|
|
2146
|
-
if ((this as any).isReact) {
|
|
2147
|
-
this.clearToolbarTemplate(innerItems[parseInt(index.toString(), 10)]);
|
|
2148
|
-
}
|
|
2149
|
-
const btnItem: EJ2Instance = innerItems[parseInt(index.toString(), 10)].querySelector('.e-control.e-btn');
|
|
2150
|
-
if (!isNOU(btnItem) && !isNOU(btnItem.ej2_instances[0]) && !((btnItem.ej2_instances[0] as Button).isDestroyed)) {
|
|
2151
|
-
(btnItem.ej2_instances[0] as Button).destroy();
|
|
2152
|
-
}
|
|
2153
|
-
detach(innerItems[parseInt(index.toString(), 10)]);
|
|
2154
|
-
this.items.splice(eleIdx, 1);
|
|
2155
|
-
this.tbarEle.splice(eleIdx, 1);
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
private templateRender(templateProp: Object | Str, innerEle: HTEle, item: ItemModel, index: number): void {
|
|
2159
|
-
const itemType: Str = item.type;
|
|
2160
|
-
const eleObj: Template = <Template>templateProp;
|
|
2161
|
-
let isComponent: boolean;
|
|
2162
|
-
if (typeof (templateProp) === 'object') {
|
|
2163
|
-
isComponent = typeof (eleObj.appendTo) === 'function';
|
|
2164
|
-
}
|
|
2165
|
-
if (typeof (templateProp) === 'string' || !isComponent) {
|
|
2166
|
-
let templateFn: Function;
|
|
2167
|
-
let val: Str = <Str>templateProp;
|
|
2168
|
-
const regEx: RegExp = new RegExp(/<(?=.*? .*?\/ ?>|br|hr|input|!--|wbr)[a-z]+.*?>|<([a-z]+).*?<\/\1>/i);
|
|
2169
|
-
val = (typeof (templateProp) === 'string') ? <Str>templateProp.trim() : <Str>templateProp;
|
|
2170
|
-
try {
|
|
2171
|
-
if (typeof (templateProp) === 'object' && !isNOU((templateProp as HTEle).tagName)) {
|
|
2172
|
-
innerEle.appendChild(templateProp as HTEle);
|
|
2173
|
-
} else if (typeof (templateProp) === 'string' && regEx.test(val)) {
|
|
2174
|
-
innerEle.innerHTML = val;
|
|
2175
|
-
} else if (document.querySelectorAll(val).length) {
|
|
2176
|
-
const ele: Element = document.querySelector(val);
|
|
2177
|
-
const tempStr: Str = ele.outerHTML.trim();
|
|
2178
|
-
innerEle.appendChild(ele);
|
|
2179
|
-
(<HTMLElement>ele).style.display = '';
|
|
2180
|
-
if (!isNOU(tempStr)) {
|
|
2181
|
-
this.tempId.push(val);
|
|
2182
|
-
}
|
|
2183
|
-
} else {
|
|
2184
|
-
templateFn = templateCompiler(val);
|
|
2185
|
-
}
|
|
2186
|
-
} catch (e) {
|
|
2187
|
-
templateFn = templateCompiler(val);
|
|
2188
|
-
}
|
|
2189
|
-
let tempArray: HTEle[];
|
|
2190
|
-
if (!isNOU(templateFn)) {
|
|
2191
|
-
const toolbarTemplateID: string = this.element.id + index + '_template';
|
|
2192
|
-
tempArray = templateFn({}, this, 'template', toolbarTemplateID, this.isStringTemplate, undefined, undefined, this.root);
|
|
2193
|
-
}
|
|
2194
|
-
if (!isNOU(tempArray) && tempArray.length > 0) {
|
|
2195
|
-
[].slice.call(tempArray).forEach((ele: HTEle): void => {
|
|
2196
|
-
if (!isNOU(ele.tagName)) {
|
|
2197
|
-
ele.style.display = '';
|
|
2198
|
-
}
|
|
2199
|
-
innerEle.appendChild(ele);
|
|
2200
|
-
});
|
|
2201
|
-
}
|
|
2202
|
-
} else if (itemType === 'Input') {
|
|
2203
|
-
const ele: HTEle = this.createElement('input');
|
|
2204
|
-
if (item.id) {
|
|
2205
|
-
ele.id = item.id;
|
|
2206
|
-
} else {
|
|
2207
|
-
ele.id = getUniqueID('tbr-ipt');
|
|
2208
|
-
}
|
|
2209
|
-
innerEle.appendChild(ele);
|
|
2210
|
-
eleObj.appendTo(ele);
|
|
2211
|
-
}
|
|
2212
|
-
this.add(innerEle, CLS_TEMPLATE);
|
|
2213
|
-
const firstChild: HTMLElement = innerEle.firstElementChild as HTMLElement;
|
|
2214
|
-
if (!isNOU(firstChild)) {
|
|
2215
|
-
firstChild.setAttribute('tabindex', isNOU(firstChild.getAttribute('tabIndex')) ? '-1' : this.getDataTabindex(firstChild));
|
|
2216
|
-
firstChild.setAttribute('data-tabindex', isNOU(firstChild.getAttribute('tabIndex')) ? '-1' : this.getDataTabindex(firstChild));
|
|
2217
|
-
}
|
|
2218
|
-
this.tbarEle.push(innerEle);
|
|
2219
|
-
}
|
|
2220
|
-
private buttonRendering(item: ItemModel, innerEle: HTEle): HTEle {
|
|
2221
|
-
const dom: HTEle = this.createElement('button', { className: CLS_TBARBTN });
|
|
2222
|
-
dom.setAttribute('type', 'button');
|
|
2223
|
-
const textStr: Str = item.text;
|
|
2224
|
-
let iconCss: Str;
|
|
2225
|
-
let iconPos: Str;
|
|
2226
|
-
if (item.id) {
|
|
2227
|
-
dom.id = item.id;
|
|
2228
|
-
} else {
|
|
2229
|
-
dom.id = getUniqueID('e-tbr-btn');
|
|
2230
|
-
}
|
|
2231
|
-
const btnTxt: HTEle = this.createElement('span', { className: 'e-tbar-btn-text' });
|
|
2232
|
-
if (textStr) {
|
|
2233
|
-
btnTxt.innerHTML = this.enableHtmlSanitizer ? SanitizeHtmlHelper.sanitize(textStr) : textStr;
|
|
2234
|
-
dom.appendChild(btnTxt);
|
|
2235
|
-
dom.classList.add('e-tbtn-txt');
|
|
2236
|
-
} else {
|
|
2237
|
-
this.add(innerEle, 'e-tbtn-align');
|
|
2238
|
-
}
|
|
2239
|
-
if (item.prefixIcon || item.suffixIcon) {
|
|
2240
|
-
if ((item.prefixIcon && item.suffixIcon) || item.prefixIcon) {
|
|
2241
|
-
iconCss = item.prefixIcon + ' e-icons';
|
|
2242
|
-
iconPos = 'Left';
|
|
2243
|
-
} else {
|
|
2244
|
-
iconCss = item.suffixIcon + ' e-icons';
|
|
2245
|
-
iconPos = 'Right';
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
const btnObj: Button = new Button({ iconCss: iconCss, iconPosition: <IconPosition>iconPos });
|
|
2249
|
-
btnObj.createElement = this.createElement;
|
|
2250
|
-
btnObj.appendTo(dom as HTMLButtonElement);
|
|
2251
|
-
if (item.width) {
|
|
2252
|
-
setStyle(dom, { 'width': formatUnit(item.width) });
|
|
2253
|
-
}
|
|
2254
|
-
return dom;
|
|
2255
|
-
}
|
|
2256
|
-
private renderSubComponent(item: ItemModel, index: number): HTEle {
|
|
2257
|
-
let dom: HTEle;
|
|
2258
|
-
const innerEle: HTEle = this.createElement('div', { className: CLS_ITEM });
|
|
2259
|
-
const tempDom: HTEle = this.createElement('div', {
|
|
2260
|
-
innerHTML: this.enableHtmlSanitizer && !isNOU(item.tooltipText) ?
|
|
2261
|
-
SanitizeHtmlHelper.sanitize(item.tooltipText) : item.tooltipText
|
|
2262
|
-
});
|
|
2263
|
-
if (!this.tbarEle) {
|
|
2264
|
-
this.tbarEle = [];
|
|
2265
|
-
}
|
|
2266
|
-
if (item.htmlAttributes) {
|
|
2267
|
-
this.setAttr(item.htmlAttributes, innerEle);
|
|
2268
|
-
}
|
|
2269
|
-
if (item.tooltipText) {
|
|
2270
|
-
innerEle.setAttribute('title', tempDom.textContent);
|
|
2271
|
-
}
|
|
2272
|
-
if (item.cssClass) {
|
|
2273
|
-
innerEle.className = innerEle.className + ' ' + item.cssClass;
|
|
2274
|
-
}
|
|
2275
|
-
if (item.template) {
|
|
2276
|
-
this.templateRender(item.template, innerEle, item, index);
|
|
2277
|
-
} else {
|
|
2278
|
-
switch (item.type) {
|
|
2279
|
-
case 'Button':
|
|
2280
|
-
dom = this.buttonRendering(item, innerEle);
|
|
2281
|
-
dom.setAttribute('tabindex', isNOU(item.tabIndex) ? '-1' : item.tabIndex.toString());
|
|
2282
|
-
dom.setAttribute('data-tabindex', isNOU(item.tabIndex) ? '-1' : item.tabIndex.toString());
|
|
2283
|
-
dom.setAttribute('aria-label', (item.text || item.tooltipText));
|
|
2284
|
-
dom.setAttribute('aria-disabled', 'false');
|
|
2285
|
-
innerEle.appendChild(dom);
|
|
2286
|
-
innerEle.addEventListener('click', this.itemClick.bind(this));
|
|
2287
|
-
break;
|
|
2288
|
-
case 'Separator':
|
|
2289
|
-
this.add(innerEle, CLS_SEPARATOR);
|
|
2290
|
-
break;
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
if (item.showTextOn) {
|
|
2294
|
-
const sTxt: Str = item.showTextOn;
|
|
2295
|
-
if (sTxt === 'Toolbar') {
|
|
2296
|
-
this.add(innerEle, CLS_POPUPTEXT);
|
|
2297
|
-
this.add(innerEle, 'e-tbtn-align');
|
|
2298
|
-
} else if (sTxt === 'Overflow') {
|
|
2299
|
-
this.add(innerEle, CLS_TBARTEXT);
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
if (item.overflow) {
|
|
2303
|
-
const overflow: Str = item.overflow;
|
|
2304
|
-
if (overflow === 'Show') {
|
|
2305
|
-
this.add(innerEle, CLS_TBAROVERFLOW);
|
|
2306
|
-
} else if (overflow === 'Hide') {
|
|
2307
|
-
if (!innerEle.classList.contains(CLS_SEPARATOR)) {
|
|
2308
|
-
this.add(innerEle, CLS_POPOVERFLOW);
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
if (item.overflow !== 'Show' && item.showAlwaysInPopup && !innerEle.classList.contains(CLS_SEPARATOR)) {
|
|
2313
|
-
this.add(innerEle, CLS_POPPRI);
|
|
2314
|
-
this.popupPriCount++;
|
|
2315
|
-
}
|
|
2316
|
-
if (item.disabled) {
|
|
2317
|
-
this.add(innerEle, CLS_DISABLE);
|
|
2318
|
-
}
|
|
2319
|
-
if (item.visible === false) {
|
|
2320
|
-
this.add(innerEle, CLS_HIDDEN);
|
|
2321
|
-
}
|
|
2322
|
-
return innerEle;
|
|
2323
|
-
}
|
|
2324
|
-
|
|
2325
|
-
private getDataTabindex(ele: HTEle): string {
|
|
2326
|
-
return isNOU(ele.getAttribute('data-tabindex')) ? '-1' : ele.getAttribute('data-tabindex');
|
|
2327
|
-
}
|
|
2328
|
-
private itemClick(e: Event): void {
|
|
2329
|
-
this.activeEleSwitch(<HTEle>e.currentTarget);
|
|
2330
|
-
}
|
|
2331
|
-
private activeEleSwitch(ele: HTEle): void {
|
|
2332
|
-
this.activeEleRemove(<HTEle>ele.firstElementChild);
|
|
2333
|
-
this.activeEle.focus();
|
|
2334
|
-
}
|
|
2335
|
-
private activeEleRemove(curEle: HTEle): void {
|
|
2336
|
-
let previousEle: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_DISABLE + ' ):not(.' + CLS_SEPARATOR + ' ):not(.' + CLS_HIDDEN + ' )');
|
|
2337
|
-
if (!isNOU(this.activeEle)) {
|
|
2338
|
-
this.activeEle.setAttribute('tabindex', this.getDataTabindex(this.activeEle));
|
|
2339
|
-
if (previousEle) {
|
|
2340
|
-
previousEle.removeAttribute('tabindex');
|
|
2341
|
-
}
|
|
2342
|
-
previousEle = this.activeEle;
|
|
2343
|
-
}
|
|
2344
|
-
this.activeEle = curEle;
|
|
2345
|
-
if (this.getDataTabindex(this.activeEle) === '-1') {
|
|
2346
|
-
if (isNOU(this.trgtEle) && !(<HTEle>curEle.parentElement).classList.contains(CLS_TEMPLATE)) {
|
|
2347
|
-
if (!isNOU(this.element.querySelector('.e-hor-nav')) && this.element.querySelector('.e-hor-nav').classList.contains('e-nav-active')) {
|
|
2348
|
-
this.updateTabIndex('0');
|
|
2349
|
-
const tabindexValue: string = this.getDataTabindex(previousEle) === '-1' ? '0' : this.getDataTabindex(previousEle);
|
|
2350
|
-
previousEle.setAttribute('tabindex', tabindexValue);
|
|
2351
|
-
}
|
|
2352
|
-
else {
|
|
2353
|
-
this.updateTabIndex('-1');
|
|
2354
|
-
}
|
|
2355
|
-
curEle.removeAttribute('tabindex');
|
|
2356
|
-
} else {
|
|
2357
|
-
const tabIndex: number = parseInt(this.getDataTabindex(this.activeEle), 10) + 1;
|
|
2358
|
-
this.activeEle.setAttribute('tabindex', tabIndex.toString());
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
protected getPersistData(): string {
|
|
2363
|
-
return this.addOnPersist([]);
|
|
2364
|
-
}
|
|
2365
|
-
/**
|
|
2366
|
-
* Returns the current module name.
|
|
2367
|
-
*
|
|
2368
|
-
* @returns {string} - Returns the module name as string.
|
|
2369
|
-
* @private
|
|
2370
|
-
*/
|
|
2371
|
-
protected getModuleName(): string {
|
|
2372
|
-
return 'toolbar';
|
|
2373
|
-
}
|
|
2374
|
-
private itemsRerender(newProp: ItemModel[]): void {
|
|
2375
|
-
this.items = this.tbarItemsCol;
|
|
2376
|
-
if ((this as any).isReact || (this as any).isAngular) {
|
|
2377
|
-
this.clearTemplate();
|
|
2378
|
-
}
|
|
2379
|
-
this.destroyMode();
|
|
2380
|
-
this.destroyItems();
|
|
2381
|
-
this.items = newProp;
|
|
2382
|
-
this.tbarItemsCol = this.items;
|
|
2383
|
-
this.renderItems();
|
|
2384
|
-
this.renderOverflowMode();
|
|
2385
|
-
if ((this as any).isReact) {
|
|
2386
|
-
this.renderReactTemplates();
|
|
2387
|
-
}
|
|
2388
|
-
}
|
|
2389
|
-
private resize(): void {
|
|
2390
|
-
const ele: HTEle = this.element;
|
|
2391
|
-
this.tbResize = true;
|
|
2392
|
-
if (this.tbarAlign) {
|
|
2393
|
-
this.itemPositioning();
|
|
2394
|
-
}
|
|
2395
|
-
if (this.popObj && this.overflowMode === 'Popup') {
|
|
2396
|
-
this.popObj.hide();
|
|
2397
|
-
}
|
|
2398
|
-
const checkOverflow: boolean = this.checkOverflow(ele, ele.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
|
|
2399
|
-
if (!checkOverflow) {
|
|
2400
|
-
this.destroyScroll();
|
|
2401
|
-
const multirowele: HTEle = ele.querySelector('.' + CLS_ITEMS);
|
|
2402
|
-
if (!isNOU(multirowele)) {
|
|
2403
|
-
this.remove(multirowele, CLS_MULTIROWPOS);
|
|
2404
|
-
if (this.tbarAlign) {
|
|
2405
|
-
this.add(multirowele, CLS_TBARPOS);
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
if (checkOverflow && this.scrollModule && (this.offsetWid === ele.offsetWidth)) {
|
|
2410
|
-
return;
|
|
2411
|
-
}
|
|
2412
|
-
if (this.offsetWid > ele.offsetWidth || checkOverflow) {
|
|
2413
|
-
this.renderOverflowMode();
|
|
2414
|
-
}
|
|
2415
|
-
if (this.popObj) {
|
|
2416
|
-
if (this.overflowMode === 'Extended') {
|
|
2417
|
-
this.popObj.width = this.getToolbarPopupWidth(this.element);
|
|
2418
|
-
}
|
|
2419
|
-
if (this.tbarAlign) {
|
|
2420
|
-
this.removePositioning();
|
|
2421
|
-
}
|
|
2422
|
-
this.popupRefresh(this.popObj.element, false);
|
|
2423
|
-
if (this.tbarAlign) {
|
|
2424
|
-
this.refreshPositioning();
|
|
2425
|
-
}
|
|
2426
|
-
}
|
|
2427
|
-
if (this.element.querySelector('.' + CLS_HSCROLLBAR)) {
|
|
2428
|
-
this.scrollStep = (this.element.querySelector('.' + CLS_HSCROLLBAR) as HTMLElement).offsetWidth;
|
|
2429
|
-
}
|
|
2430
|
-
this.offsetWid = ele.offsetWidth;
|
|
2431
|
-
this.tbResize = false;
|
|
2432
|
-
this.separator();
|
|
2433
|
-
}
|
|
2434
|
-
|
|
2435
|
-
private orientationChange(): void {
|
|
2436
|
-
setTimeout(() => {
|
|
2437
|
-
this.resize();
|
|
2438
|
-
}, 500);
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
private extendedOpen(): void {
|
|
2442
|
-
const sib: HTEle = this.element.querySelector('.' + CLS_EXTENDABLECLASS) as HTEle;
|
|
2443
|
-
if (this.overflowMode === 'Extended' && sib) {
|
|
2444
|
-
this.isExtendedOpen = sib.classList.contains(CLS_POPUPOPEN);
|
|
2445
|
-
}
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
private updateHideEleTabIndex(ele: HTMLElement, isHidden: boolean, isElement: boolean, eleIndex: number, innerItems: HTEle[]): void {
|
|
2449
|
-
if (isElement) {
|
|
2450
|
-
eleIndex = innerItems.indexOf(ele);
|
|
2451
|
-
}
|
|
2452
|
-
let nextEle: HTEle = innerItems[++eleIndex];
|
|
2453
|
-
while (nextEle) {
|
|
2454
|
-
const skipEle: string | boolean = this.eleContains(nextEle);
|
|
2455
|
-
if (!skipEle) {
|
|
2456
|
-
const dataTabIndex: string = nextEle.firstElementChild.getAttribute('data-tabindex');
|
|
2457
|
-
if (isHidden && dataTabIndex === '-1') {
|
|
2458
|
-
nextEle.firstElementChild.setAttribute('tabindex', '0');
|
|
2459
|
-
} else if (dataTabIndex !== nextEle.firstElementChild.getAttribute('tabindex')) {
|
|
2460
|
-
nextEle.firstElementChild.setAttribute('tabindex', dataTabIndex);
|
|
2461
|
-
}
|
|
2462
|
-
break;
|
|
2463
|
-
}
|
|
2464
|
-
nextEle = innerItems[++eleIndex];
|
|
2465
|
-
}
|
|
2466
|
-
}
|
|
2467
|
-
|
|
2468
|
-
private clearToolbarTemplate(templateEle: HTMLElement): void {
|
|
2469
|
-
if ((this as Record<string, any>).registeredTemplate && (this as Record<string, any>).registeredTemplate[`${'template'}`]) {
|
|
2470
|
-
const registeredTemplates: Record<string, any> = (this as Record<string, any>).registeredTemplate;
|
|
2471
|
-
for (let index: number = 0; index < registeredTemplates[`${'template'}`].length; index++) {
|
|
2472
|
-
const registeredItem: any = registeredTemplates[`${'template'}`][parseInt(index.toString(), 10)].rootNodes[0] as any;
|
|
2473
|
-
const closestItem: Element = closest(registeredItem, '.' + CLS_ITEM);
|
|
2474
|
-
if (!isNOU(closestItem) && closestItem === templateEle) {
|
|
2475
|
-
this.clearTemplate(['template'], [registeredTemplates[`${'template'}`][parseInt(index.toString(), 10)]]);
|
|
2476
|
-
break;
|
|
2477
|
-
}
|
|
2478
|
-
}
|
|
2479
|
-
} else if ((this as Record<string, any>).portals && (this as Record<string, any>).portals.length > 0) {
|
|
2480
|
-
const portals: Record<string, any>[] = (this as Record<string, any>).portals;
|
|
2481
|
-
for (let index: number = 0; index < portals.length; index++) {
|
|
2482
|
-
const portalItem: Record<string, any> = portals[parseInt(index.toString(), 10)];
|
|
2483
|
-
const closestItem: Element = closest(portalItem.containerInfo, '.' + CLS_ITEM);
|
|
2484
|
-
if (!isNOU(closestItem) && closestItem === templateEle) {
|
|
2485
|
-
this.clearTemplate(['template'], index);
|
|
2486
|
-
break;
|
|
2487
|
-
}
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
|
|
2492
|
-
/**
|
|
2493
|
-
* Gets called when the model property changes.The data that describes the old and new values of the property that changed.
|
|
2494
|
-
*
|
|
2495
|
-
* @param {ToolbarModel} newProp - It contains new value of the data.
|
|
2496
|
-
* @param {ToolbarModel} oldProp - It contains old value of the data.
|
|
2497
|
-
* @returns {void}
|
|
2498
|
-
* @private
|
|
2499
|
-
*/
|
|
2500
|
-
public onPropertyChanged(newProp: ToolbarModel, oldProp: ToolbarModel): void {
|
|
2501
|
-
const tEle: HTEle = this.element;
|
|
2502
|
-
this.extendedOpen();
|
|
2503
|
-
for (const prop of Object.keys(newProp)) {
|
|
2504
|
-
switch (prop) {
|
|
2505
|
-
case 'items':
|
|
2506
|
-
if (!(newProp.items instanceof Array && oldProp.items instanceof Array)) {
|
|
2507
|
-
const changedProb: Object[] = Object.keys(newProp.items);
|
|
2508
|
-
for (let i: number = 0; i < changedProb.length; i++) {
|
|
2509
|
-
const index: number = parseInt(Object.keys(newProp.items)[parseInt(i.toString(), 10)], 10);
|
|
2510
|
-
const property: Str = Object.keys(newProp.items[parseInt(index.toString(), 10)])[0];
|
|
2511
|
-
const newProperty: Str = Object(newProp.items[parseInt(index.toString(), 10)])[`${property}`];
|
|
2512
|
-
if (this.tbarAlign || property === 'align') {
|
|
2513
|
-
this.refresh();
|
|
2514
|
-
this.trigger('created');
|
|
2515
|
-
break;
|
|
2516
|
-
}
|
|
2517
|
-
const popupPriCheck: boolean = property === 'showAlwaysInPopup' && !newProperty;
|
|
2518
|
-
const booleanCheck: boolean = property === 'overflow' && this.popupPriCount !== 0;
|
|
2519
|
-
if ((popupPriCheck) || (this.items[parseInt(index.toString(), 10)].showAlwaysInPopup) && booleanCheck) {
|
|
2520
|
-
--this.popupPriCount;
|
|
2521
|
-
}
|
|
2522
|
-
if (isNOU(this.scrollModule)) {
|
|
2523
|
-
this.destroyMode();
|
|
2524
|
-
}
|
|
2525
|
-
const itemCol: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, tEle));
|
|
2526
|
-
if ((this as any).isReact && this.items[parseInt(index.toString(), 10)].template) {
|
|
2527
|
-
this.clearToolbarTemplate(itemCol[parseInt(index.toString(), 10)]);
|
|
2528
|
-
}
|
|
2529
|
-
detach(itemCol[parseInt(index.toString(), 10)]);
|
|
2530
|
-
this.tbarEle.splice(index, 1);
|
|
2531
|
-
this.addItems([this.items[parseInt(index.toString(), 10)]], index);
|
|
2532
|
-
this.items.splice(index, 1);
|
|
2533
|
-
if (this.items[parseInt(index.toString(), 10)].template) {
|
|
2534
|
-
this.tbarEle.splice(this.items.length, 1);
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
} else {
|
|
2538
|
-
this.itemsRerender(newProp.items);
|
|
2539
|
-
}
|
|
2540
|
-
break;
|
|
2541
|
-
case 'width':
|
|
2542
|
-
setStyle(tEle, { 'width': formatUnit(newProp.width) });
|
|
2543
|
-
this.refreshOverflow();
|
|
2544
|
-
break;
|
|
2545
|
-
case 'height':
|
|
2546
|
-
setStyle(this.element, { 'height': formatUnit(newProp.height) });
|
|
2547
|
-
break;
|
|
2548
|
-
case 'overflowMode':
|
|
2549
|
-
this.destroyMode();
|
|
2550
|
-
this.renderOverflowMode();
|
|
2551
|
-
if (this.enableRtl) {
|
|
2552
|
-
this.add(tEle, CLS_RTL);
|
|
2553
|
-
}
|
|
2554
|
-
this.refreshOverflow();
|
|
2555
|
-
break;
|
|
2556
|
-
case 'enableRtl':
|
|
2557
|
-
if (newProp.enableRtl) {
|
|
2558
|
-
this.add(tEle, CLS_RTL);
|
|
2559
|
-
} else {
|
|
2560
|
-
this.remove(tEle, CLS_RTL);
|
|
2561
|
-
}
|
|
2562
|
-
if (!isNOU(this.scrollModule)) {
|
|
2563
|
-
if (newProp.enableRtl) {
|
|
2564
|
-
this.add(this.scrollModule.element, CLS_RTL);
|
|
2565
|
-
} else {
|
|
2566
|
-
this.remove(this.scrollModule.element, CLS_RTL);
|
|
2567
|
-
}
|
|
2568
|
-
}
|
|
2569
|
-
if (!isNOU(this.popObj)) {
|
|
2570
|
-
if (newProp.enableRtl) {
|
|
2571
|
-
this.add(this.popObj.element, CLS_RTL);
|
|
2572
|
-
} else {
|
|
2573
|
-
this.remove(this.popObj.element, CLS_RTL);
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
if (this.tbarAlign) {
|
|
2577
|
-
this.itemPositioning();
|
|
2578
|
-
}
|
|
2579
|
-
break;
|
|
2580
|
-
case 'scrollStep':
|
|
2581
|
-
if (this.scrollModule) {
|
|
2582
|
-
this.scrollModule.scrollStep = this.scrollStep;
|
|
2583
|
-
}
|
|
2584
|
-
break;
|
|
2585
|
-
case 'enableCollision':
|
|
2586
|
-
if (this.popObj) {
|
|
2587
|
-
this.popObj.collision = { Y: this.enableCollision ? 'flip' : 'none' };
|
|
2588
|
-
}
|
|
2589
|
-
break;
|
|
2590
|
-
case 'cssClass':
|
|
2591
|
-
if (oldProp.cssClass) {
|
|
2592
|
-
removeClass([this.element], oldProp.cssClass.split(' '));
|
|
2593
|
-
}
|
|
2594
|
-
if (newProp.cssClass) {
|
|
2595
|
-
addClass([this.element], newProp.cssClass.split(' '));
|
|
2596
|
-
}
|
|
2597
|
-
break;
|
|
2598
|
-
case 'allowKeyboard':
|
|
2599
|
-
this.unwireKeyboardEvent();
|
|
2600
|
-
if (newProp.allowKeyboard) {
|
|
2601
|
-
this.wireKeyboardEvent();
|
|
2602
|
-
}
|
|
2603
|
-
break;
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
/**
|
|
2608
|
-
* Shows or hides the Toolbar item that is in the specified index.
|
|
2609
|
-
*
|
|
2610
|
-
* @param {number | HTMLElement} index - Index value of target item or DOM element of items to be hidden or shown.
|
|
2611
|
-
* @param {boolean} value - Based on this Boolean value, item will be hide (true) or show (false). By default, value is false.
|
|
2612
|
-
* @returns {void}.
|
|
2613
|
-
*/
|
|
2614
|
-
public hideItem(index: number | HTMLElement | Element, value?: boolean): void {
|
|
2615
|
-
const isElement: boolean = (typeof (index) === 'object') ? true : false;
|
|
2616
|
-
const eleIndex: number = index as number;
|
|
2617
|
-
let ele: HTMLElement;
|
|
2618
|
-
if (!isElement && isNOU(eleIndex)) {
|
|
2619
|
-
return;
|
|
2620
|
-
}
|
|
2621
|
-
const innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
|
|
2622
|
-
if (isElement) {
|
|
2623
|
-
ele = (index as HTMLElement);
|
|
2624
|
-
} else if (this.tbarEle[parseInt(eleIndex.toString(), 10)]) {
|
|
2625
|
-
const innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
|
|
2626
|
-
ele = innerItems[parseInt(eleIndex.toString(), 10)];
|
|
2627
|
-
}
|
|
2628
|
-
if (ele) {
|
|
2629
|
-
if (value) {
|
|
2630
|
-
ele.classList.add(CLS_HIDDEN);
|
|
2631
|
-
if (!ele.classList.contains(CLS_SEPARATOR)) {
|
|
2632
|
-
if (isNOU(ele.firstElementChild.getAttribute('tabindex')) ||
|
|
2633
|
-
ele.firstElementChild.getAttribute('tabindex') !== '-1') {
|
|
2634
|
-
this.updateHideEleTabIndex(ele, value, isElement, eleIndex, innerItems);
|
|
2635
|
-
}
|
|
2636
|
-
}
|
|
2637
|
-
} else {
|
|
2638
|
-
ele.classList.remove(CLS_HIDDEN);
|
|
2639
|
-
if (!ele.classList.contains(CLS_SEPARATOR)) {
|
|
2640
|
-
this.updateHideEleTabIndex(ele, value, isElement, eleIndex, innerItems);
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
this.refreshOverflow();
|
|
2644
|
-
}
|
|
2645
|
-
}
|
|
2646
|
-
}
|