@syncfusion/ej2-navigations 17.3.9-beta → 17.3.14-96615

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/.eslintrc.json +244 -0
  2. package/CHANGELOG.md +898 -800
  3. package/README.md +163 -163
  4. package/dist/ej2-navigations.umd.min.js +1 -10
  5. package/dist/ej2-navigations.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-navigations.es2015.js +325 -170
  7. package/dist/es6/ej2-navigations.es2015.js.map +1 -1
  8. package/dist/es6/ej2-navigations.es5.js +455 -300
  9. package/dist/es6/ej2-navigations.es5.js.map +1 -1
  10. package/dist/global/ej2-navigations.min.js +1 -10
  11. package/dist/global/ej2-navigations.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/accordion/accordion.ts +1312 -0
  14. package/dist/ts/common/h-scroll.ts +459 -0
  15. package/dist/ts/common/menu-base.ts +2131 -0
  16. package/dist/ts/common/v-scroll.ts +430 -0
  17. package/dist/ts/context-menu/context-menu.ts +119 -0
  18. package/dist/ts/menu/menu.ts +270 -0
  19. package/dist/ts/sidebar/sidebar.ts +817 -0
  20. package/dist/ts/tab/tab.ts +1761 -0
  21. package/dist/ts/toolbar/toolbar.ts +2076 -0
  22. package/dist/ts/treeview/treeview.ts +5050 -0
  23. package/helpers/e2e/index.js +3 -3
  24. package/license +10 -10
  25. package/package.json +135 -149
  26. package/src/accordion/accordion-model.d.ts +156 -156
  27. package/src/accordion/accordion.d.ts +1 -0
  28. package/src/accordion/accordion.js +40 -41
  29. package/src/common/h-scroll-model.d.ts +5 -5
  30. package/src/common/h-scroll.js +19 -20
  31. package/src/common/menu-base-model.d.ts +157 -157
  32. package/src/common/menu-base.d.ts +19 -0
  33. package/src/common/menu-base.js +94 -24
  34. package/src/common/v-scroll-model.d.ts +5 -5
  35. package/src/common/v-scroll.js +19 -19
  36. package/src/context-menu/context-menu-model.d.ts +15 -15
  37. package/src/context-menu/context-menu.js +19 -19
  38. package/src/menu/menu-model.d.ts +30 -30
  39. package/src/menu/menu.js +19 -19
  40. package/src/sidebar/sidebar-model.d.ts +136 -136
  41. package/src/sidebar/sidebar.js +19 -19
  42. package/src/tab/tab-model.d.ts +215 -215
  43. package/src/tab/tab.d.ts +3 -0
  44. package/src/tab/tab.js +117 -82
  45. package/src/toolbar/toolbar-model.d.ts +175 -175
  46. package/src/toolbar/toolbar.d.ts +1 -0
  47. package/src/toolbar/toolbar.js +30 -24
  48. package/src/treeview/treeview-model.d.ts +323 -323
  49. package/src/treeview/treeview.js +79 -33
  50. package/styles/accordion/_all.scss +2 -2
  51. package/styles/accordion/_bootstrap-dark-definition.scss +69 -69
  52. package/styles/accordion/_bootstrap-definition.scss +76 -76
  53. package/styles/accordion/_bootstrap4-definition.scss +82 -82
  54. package/styles/accordion/_fabric-dark-definition.scss +74 -74
  55. package/styles/accordion/_fabric-definition.scss +78 -78
  56. package/styles/accordion/_highcontrast-definition.scss +106 -106
  57. package/styles/accordion/_highcontrast-light-definition.scss +104 -104
  58. package/styles/accordion/_layout.scss +447 -447
  59. package/styles/accordion/_material-dark-definition.scss +75 -75
  60. package/styles/accordion/_material-definition.scss +72 -72
  61. package/styles/accordion/_theme.scss +479 -479
  62. package/styles/accordion/icons/_bootstrap-dark.scss +17 -17
  63. package/styles/accordion/icons/_bootstrap.scss +17 -17
  64. package/styles/accordion/icons/_bootstrap4.scss +17 -17
  65. package/styles/accordion/icons/_fabric-dark.scss +17 -17
  66. package/styles/accordion/icons/_fabric.scss +17 -17
  67. package/styles/accordion/icons/_highcontrast-light.scss +17 -17
  68. package/styles/accordion/icons/_highcontrast.scss +17 -17
  69. package/styles/accordion/icons/_material-dark.scss +17 -17
  70. package/styles/accordion/icons/_material.scss +17 -17
  71. package/styles/bootstrap-dark.css +7 -9
  72. package/styles/bootstrap.css +7 -9
  73. package/styles/bootstrap4.css +7 -9
  74. package/styles/bootstrap5-dark.css +0 -0
  75. package/styles/bootstrap5-dark.scss +0 -0
  76. package/styles/bootstrap5.css +0 -0
  77. package/styles/bootstrap5.scss +0 -0
  78. package/styles/context-menu/_all.scss +2 -2
  79. package/styles/context-menu/_bootstrap-dark-definition.scss +54 -54
  80. package/styles/context-menu/_bootstrap-definition.scss +52 -52
  81. package/styles/context-menu/_bootstrap4-definition.scss +52 -52
  82. package/styles/context-menu/_fabric-dark-definition.scss +54 -54
  83. package/styles/context-menu/_fabric-definition.scss +52 -52
  84. package/styles/context-menu/_highcontrast-definition.scss +52 -52
  85. package/styles/context-menu/_highcontrast-light-definition.scss +54 -54
  86. package/styles/context-menu/_layout-mixin.scss +175 -175
  87. package/styles/context-menu/_layout.scss +70 -70
  88. package/styles/context-menu/_material-dark-definition.scss +54 -54
  89. package/styles/context-menu/_material-definition.scss +52 -52
  90. package/styles/context-menu/_theme-mixin.scss +59 -59
  91. package/styles/context-menu/_theme.scss +36 -36
  92. package/styles/context-menu/bootstrap-dark.css +0 -1
  93. package/styles/context-menu/bootstrap.css +0 -1
  94. package/styles/context-menu/bootstrap4.css +0 -1
  95. package/styles/context-menu/fabric-dark.css +0 -1
  96. package/styles/context-menu/fabric.css +0 -1
  97. package/styles/context-menu/highcontrast-light.css +0 -1
  98. package/styles/context-menu/highcontrast.css +0 -1
  99. package/styles/context-menu/icons/_bootstrap-dark.scss +30 -30
  100. package/styles/context-menu/icons/_bootstrap.scss +30 -30
  101. package/styles/context-menu/icons/_bootstrap4.scss +30 -30
  102. package/styles/context-menu/icons/_fabric-dark.scss +30 -30
  103. package/styles/context-menu/icons/_fabric.scss +30 -30
  104. package/styles/context-menu/icons/_highcontrast-light.scss +30 -30
  105. package/styles/context-menu/icons/_highcontrast.scss +30 -30
  106. package/styles/context-menu/icons/_material-dark.scss +30 -30
  107. package/styles/context-menu/icons/_material.scss +30 -30
  108. package/styles/context-menu/material-dark.css +0 -1
  109. package/styles/context-menu/material.css +3 -4
  110. package/styles/fabric-dark.css +7 -9
  111. package/styles/fabric.css +7 -9
  112. package/styles/h-scroll/_all.scss +2 -2
  113. package/styles/h-scroll/_bootstrap-dark-definition.scss +49 -49
  114. package/styles/h-scroll/_bootstrap-definition.scss +50 -50
  115. package/styles/h-scroll/_bootstrap4-definition.scss +49 -49
  116. package/styles/h-scroll/_fabric-dark-definition.scss +50 -50
  117. package/styles/h-scroll/_fabric-definition.scss +48 -48
  118. package/styles/h-scroll/_highcontrast-definition.scss +52 -52
  119. package/styles/h-scroll/_highcontrast-light-definition.scss +54 -54
  120. package/styles/h-scroll/_layout.scss +198 -198
  121. package/styles/h-scroll/_material-dark-definition.scss +77 -77
  122. package/styles/h-scroll/_material-definition.scss +77 -77
  123. package/styles/h-scroll/_theme.scss +157 -157
  124. package/styles/h-scroll/icons/_bootstrap-dark.scss +49 -49
  125. package/styles/h-scroll/icons/_bootstrap.scss +49 -49
  126. package/styles/h-scroll/icons/_bootstrap4.scss +49 -49
  127. package/styles/h-scroll/icons/_fabric-dark.scss +49 -49
  128. package/styles/h-scroll/icons/_fabric.scss +49 -49
  129. package/styles/h-scroll/icons/_highcontrast-light.scss +49 -49
  130. package/styles/h-scroll/icons/_highcontrast.scss +49 -49
  131. package/styles/h-scroll/icons/_material-dark.scss +49 -49
  132. package/styles/h-scroll/icons/_material.scss +49 -49
  133. package/styles/highcontrast-light.css +7 -9
  134. package/styles/highcontrast.css +7 -9
  135. package/styles/material-dark.css +7 -9
  136. package/styles/material.css +21 -14
  137. package/styles/menu/_all.scss +2 -2
  138. package/styles/menu/_bootstrap-dark-definition.scss +63 -63
  139. package/styles/menu/_bootstrap-definition.scss +65 -65
  140. package/styles/menu/_bootstrap4-definition.scss +64 -64
  141. package/styles/menu/_fabric-dark-definition.scss +63 -63
  142. package/styles/menu/_fabric-definition.scss +64 -64
  143. package/styles/menu/_highcontrast-definition.scss +65 -65
  144. package/styles/menu/_highcontrast-light-definition.scss +61 -61
  145. package/styles/menu/_layout.scss +638 -638
  146. package/styles/menu/_material-dark-definition.scss +63 -63
  147. package/styles/menu/_material-definition.scss +64 -64
  148. package/styles/menu/_theme.scss +243 -243
  149. package/styles/menu/bootstrap-dark.css +0 -1
  150. package/styles/menu/bootstrap.css +0 -1
  151. package/styles/menu/bootstrap.scss +1 -0
  152. package/styles/menu/bootstrap4.css +0 -1
  153. package/styles/menu/fabric-dark.css +0 -1
  154. package/styles/menu/fabric.css +0 -1
  155. package/styles/menu/fabric.scss +1 -0
  156. package/styles/menu/highcontrast-light.css +0 -1
  157. package/styles/menu/highcontrast.css +0 -1
  158. package/styles/menu/highcontrast.scss +1 -0
  159. package/styles/menu/icons/_bootstrap-dark.scss +127 -127
  160. package/styles/menu/icons/_bootstrap.scss +127 -127
  161. package/styles/menu/icons/_bootstrap4.scss +127 -127
  162. package/styles/menu/icons/_fabric-dark.scss +127 -127
  163. package/styles/menu/icons/_fabric.scss +127 -127
  164. package/styles/menu/icons/_highcontrast-light.scss +127 -127
  165. package/styles/menu/icons/_highcontrast.scss +127 -127
  166. package/styles/menu/icons/_material-dark.scss +127 -127
  167. package/styles/menu/icons/_material.scss +127 -127
  168. package/styles/menu/material-dark.css +0 -1
  169. package/styles/menu/material.css +2 -3
  170. package/styles/menu/material.scss +1 -0
  171. package/styles/sidebar/_all.scss +3 -3
  172. package/styles/sidebar/_bootstrap-dark-definition.scss +4 -4
  173. package/styles/sidebar/_bootstrap-definition.scss +4 -4
  174. package/styles/sidebar/_bootstrap4-definition.scss +4 -4
  175. package/styles/sidebar/_fabric-dark-definition.scss +4 -4
  176. package/styles/sidebar/_fabric-definition.scss +6 -6
  177. package/styles/sidebar/_highcontrast-definition.scss +4 -4
  178. package/styles/sidebar/_highcontrast-light-definition.scss +4 -4
  179. package/styles/sidebar/_icons.scss +1 -1
  180. package/styles/sidebar/_material-dark-definition.scss +4 -4
  181. package/styles/sidebar/_material-definition.scss +6 -6
  182. package/styles/sidebar/_theme.scss +168 -168
  183. package/styles/sidebar/bootstrap-dark.css +0 -1
  184. package/styles/sidebar/bootstrap.css +0 -1
  185. package/styles/sidebar/bootstrap4.css +0 -1
  186. package/styles/sidebar/fabric-dark.css +0 -1
  187. package/styles/sidebar/fabric.css +0 -1
  188. package/styles/sidebar/highcontrast-light.css +0 -1
  189. package/styles/sidebar/highcontrast.css +0 -1
  190. package/styles/sidebar/material-dark.css +0 -1
  191. package/styles/sidebar/material.css +0 -1
  192. package/styles/tab/_all.scss +2 -2
  193. package/styles/tab/_bootstrap-dark-definition.scss +386 -386
  194. package/styles/tab/_bootstrap-definition.scss +396 -396
  195. package/styles/tab/_bootstrap4-definition.scss +401 -401
  196. package/styles/tab/_fabric-dark-definition.scss +394 -394
  197. package/styles/tab/_fabric-definition.scss +410 -410
  198. package/styles/tab/_highcontrast-definition.scss +434 -434
  199. package/styles/tab/_highcontrast-light-definition.scss +423 -423
  200. package/styles/tab/_icons.scss +43 -43
  201. package/styles/tab/_layout.scss +3528 -3521
  202. package/styles/tab/_material-dark-definition.scss +407 -407
  203. package/styles/tab/_material-definition.scss +416 -416
  204. package/styles/tab/_theme.scss +1751 -1751
  205. package/styles/tab/bootstrap-dark.css +7 -2
  206. package/styles/tab/bootstrap.css +7 -2
  207. package/styles/tab/bootstrap4.css +7 -2
  208. package/styles/tab/fabric-dark.css +7 -2
  209. package/styles/tab/fabric.css +7 -2
  210. package/styles/tab/highcontrast-light.css +7 -2
  211. package/styles/tab/highcontrast.css +7 -2
  212. package/styles/tab/icons/_bootstrap-dark.scss +132 -132
  213. package/styles/tab/icons/_bootstrap.scss +132 -132
  214. package/styles/tab/icons/_bootstrap4.scss +132 -132
  215. package/styles/tab/icons/_fabric-dark.scss +132 -132
  216. package/styles/tab/icons/_fabric.scss +132 -132
  217. package/styles/tab/icons/_highcontrast-light.scss +132 -132
  218. package/styles/tab/icons/_highcontrast.scss +132 -132
  219. package/styles/tab/icons/_material-dark.scss +132 -132
  220. package/styles/tab/icons/_material.scss +132 -132
  221. package/styles/tab/material-dark.css +7 -2
  222. package/styles/tab/material.css +7 -2
  223. package/styles/tailwind-dark.css +0 -0
  224. package/styles/tailwind-dark.scss +0 -0
  225. package/styles/tailwind.css +0 -0
  226. package/styles/tailwind.scss +0 -0
  227. package/styles/toolbar/_all.scss +2 -2
  228. package/styles/toolbar/_bootstrap-dark-definition.scss +135 -135
  229. package/styles/toolbar/_bootstrap-definition.scss +134 -134
  230. package/styles/toolbar/_bootstrap4-definition.scss +139 -139
  231. package/styles/toolbar/_fabric-dark-definition.scss +155 -155
  232. package/styles/toolbar/_fabric-definition.scss +139 -139
  233. package/styles/toolbar/_highcontrast-definition.scss +149 -149
  234. package/styles/toolbar/_highcontrast-light-definition.scss +164 -164
  235. package/styles/toolbar/_layout.scss +1460 -1460
  236. package/styles/toolbar/_material-dark-definition.scss +180 -180
  237. package/styles/toolbar/_material-definition.scss +164 -164
  238. package/styles/toolbar/_theme.scss +451 -451
  239. package/styles/toolbar/bootstrap-dark.css +0 -1
  240. package/styles/toolbar/bootstrap.css +0 -1
  241. package/styles/toolbar/bootstrap.scss +1 -0
  242. package/styles/toolbar/bootstrap4.css +0 -1
  243. package/styles/toolbar/fabric-dark.css +0 -1
  244. package/styles/toolbar/fabric.css +0 -1
  245. package/styles/toolbar/fabric.scss +1 -0
  246. package/styles/toolbar/highcontrast-light.css +0 -1
  247. package/styles/toolbar/highcontrast.css +0 -1
  248. package/styles/toolbar/highcontrast.scss +1 -0
  249. package/styles/toolbar/icons/_bootstrap-dark.scss +16 -16
  250. package/styles/toolbar/icons/_bootstrap.scss +16 -16
  251. package/styles/toolbar/icons/_bootstrap4.scss +16 -16
  252. package/styles/toolbar/icons/_fabric-dark.scss +16 -16
  253. package/styles/toolbar/icons/_fabric.scss +16 -16
  254. package/styles/toolbar/icons/_highcontrast-light.scss +16 -16
  255. package/styles/toolbar/icons/_highcontrast.scss +16 -16
  256. package/styles/toolbar/icons/_material-dark.scss +16 -16
  257. package/styles/toolbar/icons/_material.scss +16 -16
  258. package/styles/toolbar/material-dark.css +0 -1
  259. package/styles/toolbar/material.css +0 -1
  260. package/styles/toolbar/material.scss +1 -0
  261. package/styles/treeview/_all.scss +2 -2
  262. package/styles/treeview/_bootstrap-dark-definition.scss +131 -131
  263. package/styles/treeview/_bootstrap-definition.scss +127 -127
  264. package/styles/treeview/_bootstrap4-definition.scss +153 -153
  265. package/styles/treeview/_fabric-dark-definition.scss +130 -130
  266. package/styles/treeview/_fabric-definition.scss +126 -126
  267. package/styles/treeview/_highcontrast-definition.scss +132 -132
  268. package/styles/treeview/_highcontrast-light-definition.scss +137 -137
  269. package/styles/treeview/_layout.scss +551 -551
  270. package/styles/treeview/_material-dark-definition.scss +126 -126
  271. package/styles/treeview/_material-definition.scss +126 -126
  272. package/styles/treeview/_theme.scss +331 -331
  273. package/styles/treeview/bootstrap-dark.css +0 -3
  274. package/styles/treeview/bootstrap.css +0 -3
  275. package/styles/treeview/bootstrap4.css +0 -3
  276. package/styles/treeview/fabric-dark.css +0 -3
  277. package/styles/treeview/fabric.css +0 -3
  278. package/styles/treeview/highcontrast-light.css +0 -3
  279. package/styles/treeview/highcontrast.css +0 -3
  280. package/styles/treeview/icons/_bootstrap-dark.scss +39 -39
  281. package/styles/treeview/icons/_bootstrap.scss +39 -39
  282. package/styles/treeview/icons/_bootstrap4.scss +39 -39
  283. package/styles/treeview/icons/_fabric-dark.scss +43 -43
  284. package/styles/treeview/icons/_fabric.scss +43 -43
  285. package/styles/treeview/icons/_highcontrast-light.scss +43 -43
  286. package/styles/treeview/icons/_highcontrast.scss +43 -43
  287. package/styles/treeview/icons/_material-dark.scss +43 -43
  288. package/styles/treeview/icons/_material.scss +43 -43
  289. package/styles/treeview/material-dark.css +0 -3
  290. package/styles/treeview/material.css +9 -3
  291. package/styles/v-scroll/_all.scss +2 -2
  292. package/styles/v-scroll/_bootstrap-dark-definition.scss +50 -50
  293. package/styles/v-scroll/_bootstrap-definition.scss +49 -49
  294. package/styles/v-scroll/_bootstrap4-definition.scss +49 -49
  295. package/styles/v-scroll/_fabric-dark-definition.scss +51 -51
  296. package/styles/v-scroll/_fabric-definition.scss +50 -50
  297. package/styles/v-scroll/_highcontrast-definition.scss +51 -51
  298. package/styles/v-scroll/_highcontrast-light-definition.scss +52 -52
  299. package/styles/v-scroll/_layout.scss +162 -162
  300. package/styles/v-scroll/_material-dark-definition.scss +78 -78
  301. package/styles/v-scroll/_material-definition.scss +77 -77
  302. package/styles/v-scroll/_theme.scss +133 -133
  303. package/styles/v-scroll/icons/_bootstrap-dark.scss +26 -26
  304. package/styles/v-scroll/icons/_bootstrap.scss +26 -26
  305. package/styles/v-scroll/icons/_bootstrap4.scss +26 -26
  306. package/styles/v-scroll/icons/_fabric-dark.scss +26 -26
  307. package/styles/v-scroll/icons/_fabric.scss +26 -26
  308. package/styles/v-scroll/icons/_highcontrast-light.scss +26 -26
  309. package/styles/v-scroll/icons/_highcontrast.scss +26 -26
  310. package/styles/v-scroll/icons/_material-dark.scss +26 -26
  311. package/styles/v-scroll/icons/_material.scss +26 -26
  312. package/tslint.json +111 -0
  313. package/.gitlab/merge_request_templates/Bug.md +0 -63
  314. package/.gitlab/merge_request_templates/feature.md +0 -39
@@ -0,0 +1,2076 @@
1
+ import { Component, EventHandler, Property, Event, EmitType, BaseEventArgs } from '@syncfusion/ej2-base';
2
+ import { addClass, removeClass, isVisible, closest, attributes, detach, classList, KeyboardEvents } from '@syncfusion/ej2-base';
3
+ import { selectAll, setStyleAttribute as setStyle, KeyboardEventArgs } from '@syncfusion/ej2-base';
4
+ import { isNullOrUndefined as isNOU, getUniqueID, formatUnit, Collection, compile as templateCompiler } from '@syncfusion/ej2-base';
5
+ import { INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Browser } from '@syncfusion/ej2-base';
6
+ import { updateBlazorTemplate, resetBlazorTemplate, isBlazor } 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
+ */
16
+ export type ItemType = 'Button' | 'Separator' | 'Input';
17
+ /**
18
+ * Specifies the options of where the text will be displayed in popup mode of the Toolbar.
19
+ */
20
+ export type DisplayMode = 'Both' | 'Overflow' | 'Toolbar';
21
+ /**
22
+ * Specifies the options of the Toolbar item display area when the Toolbar content overflows to available space.Applicable to `popup` mode.
23
+ */
24
+ export type OverflowOption = 'None' | 'Show' | 'Hide';
25
+ /**
26
+ * Specifies the options of Toolbar display mode. Display option is considered when Toolbar content exceeds the available space.
27
+ */
28
+ export type OverflowMode = 'Scrollable' | 'Popup' | 'MultiRow' | 'Extended';
29
+
30
+ type HTEle = HTMLElement;
31
+ type Str = string;
32
+ type ItmAlign = 'lefts' | 'centers' | 'rights';
33
+
34
+ export type ItemAlign = 'Left' | 'Center' | 'Right';
35
+
36
+ const CLS_VERTICAL: Str = 'e-vertical';
37
+ const CLS_ITEMS: Str = 'e-toolbar-items';
38
+ const CLS_ITEM: Str = 'e-toolbar-item';
39
+ const CLS_RTL: Str = 'e-rtl';
40
+ const CLS_SEPARATOR: Str = 'e-separator';
41
+ const CLS_POPUPICON: Str = 'e-popup-up-icon';
42
+ const CLS_POPUPDOWN: Str = 'e-popup-down-icon';
43
+ const CLS_POPUPOPEN: Str = 'e-popup-open';
44
+ const CLS_TEMPLATE: Str = 'e-template';
45
+ const CLS_DISABLE: Str = 'e-overlay';
46
+ const CLS_POPUPTEXT: Str = 'e-toolbar-text';
47
+ const CLS_TBARTEXT: Str = 'e-popup-text';
48
+ const CLS_TBAROVERFLOW: Str = 'e-overflow-show';
49
+ const CLS_POPOVERFLOW: Str = 'e-overflow-hide';
50
+ const CLS_TBARBTN: Str = 'e-tbar-btn';
51
+ const CLS_TBARNAV: Str = 'e-hor-nav';
52
+ const CLS_TBARSCRLNAV: Str = 'e-scroll-nav';
53
+ const CLS_TBARRIGHT: Str = 'e-toolbar-right';
54
+ const CLS_TBARLEFT: Str = 'e-toolbar-left';
55
+ const CLS_TBARCENTER: Str = 'e-toolbar-center';
56
+ const CLS_TBARPOS: Str = 'e-tbar-pos';
57
+ const CLS_HSCROLLCNT: Str = 'e-hscroll-content';
58
+ const CLS_VSCROLLCNT: Str = 'e-vscroll-content';
59
+ const CLS_POPUPNAV: Str = 'e-hor-nav';
60
+ const CLS_POPUPCLASS: Str = 'e-toolbar-pop';
61
+ const CLS_POPUP: Str = 'e-toolbar-popup';
62
+ const CLS_TBARBTNTEXT: Str = 'e-tbar-btn-text';
63
+ const CLS_TBARNAVACT: Str = 'e-nav-active';
64
+ const CLS_TBARIGNORE: Str = 'e-ignore';
65
+ const CLS_POPPRI: Str = 'e-popup-alone';
66
+ const CLS_HIDDEN: string = 'e-hidden';
67
+ const CLS_MULTIROW: string = 'e-toolbar-multirow';
68
+ const CLS_MULTIROWPOS: string = 'e-multirow-pos';
69
+ const CLS_MULTIROW_SEPARATOR: string = 'e-multirow-separator';
70
+ const CLS_EXTENDABLE_SEPARATOR: string = 'e-extended-separator';
71
+ const CLS_EXTEANDABLE_TOOLBAR: Str = 'e-extended-toolbar';
72
+ const CLS_EXTENDABLECLASS: Str = 'e-toolbar-extended';
73
+ const CLS_EXTENDPOPUP: Str = 'e-expended-nav';
74
+ const CLS_EXTENDEDPOPOPEN: Str = 'e-tbar-extended';
75
+
76
+ interface Template {
77
+ appendTo: Function;
78
+ }
79
+
80
+ interface ToolbarItemAlignIn {
81
+ lefts: HTMLElement[];
82
+ centers: HTMLElement[];
83
+ rights: HTMLElement[];
84
+ }
85
+ export interface ClickEventArgs extends BaseEventArgs {
86
+ /** Defines the current Toolbar Item Object. */
87
+ item: ItemModel;
88
+ /**
89
+ * Defines the current Event arguments.
90
+ * @blazorType MouseEventArgs
91
+ */
92
+ originalEvent: Event;
93
+ /** Defines the prevent action. */
94
+ cancel?: boolean;
95
+ }
96
+
97
+ export interface BeforeCreateArgs extends BaseEventArgs {
98
+ /** Enable or disable the popup collision. */
99
+ enableCollision: boolean;
100
+ /** Specifies the scrolling distance in scroller. */
101
+ scrollStep: number;
102
+ }
103
+
104
+ /**
105
+ * An item object that is used to configure Toolbar commands.
106
+ */
107
+ export class Item extends ChildProperty<Item> {
108
+ /**
109
+ * Specifies the unique ID to be used with button or input element of Toolbar items.
110
+ * @default ""
111
+ */
112
+ @Property('')
113
+ public id: string;
114
+ /**
115
+ * Specifies the text to be displayed on the Toolbar button.
116
+ * @default ""
117
+ */
118
+ @Property('')
119
+ public text: string;
120
+ /**
121
+ * Specifies the width of the Toolbar button commands.
122
+ * @default 'auto'
123
+ */
124
+ @Property('auto')
125
+ public width: number | string;
126
+ /**
127
+ * Defines single/multiple classes (separated by space) to be used for customization of commands.
128
+ * @default ""
129
+ */
130
+ @Property('')
131
+ public cssClass: string;
132
+ /**
133
+ * Defines the priority of items to display it in popup always.
134
+ * It allows to maintain toolbar item on popup always but it does not work for toolbar priority items.
135
+ * @default false
136
+ */
137
+ @Property(false)
138
+ public showAlwaysInPopup: boolean;
139
+ /**
140
+ * Defines single/multiple classes separated by space used to specify an icon for the button.
141
+ * The icon will be positioned before the text content if text is available, otherwise the icon alone will be rendered.
142
+ * @default ""
143
+ */
144
+ @Property('')
145
+ public prefixIcon: string;
146
+ /**
147
+ * Defines single/multiple classes separated by space used to specify an icon for the button.
148
+ * The icon will be positioned after the text content if text is available.
149
+ * @default ""
150
+ */
151
+ @Property('')
152
+ public suffixIcon: string;
153
+ /**
154
+ * Specifies the Toolbar command display area when an element's content is too large to fit available space.
155
+ * This is applicable only to `popup` mode. Possible values are:
156
+ * - Show: Always shows the item as the primary priority on the *Toolbar*.
157
+ * - Hide: Always shows the item as the secondary priority on the *popup*.
158
+ * - None: No priority for display, and as per normal order moves to popup when content exceeds.
159
+ * @default 'None'
160
+ */
161
+ @Property('None')
162
+ public overflow: OverflowOption;
163
+ /**
164
+ * Specifies the HTML element/element ID as a string that can be added as a Toolbar command.
165
+ * ```
166
+ * E.g - items: [{ template: '<input placeholder="Search"/>' },{ template: '#checkbox1' }]
167
+ * ```
168
+ * @default ""
169
+ */
170
+ @Property('')
171
+ public template: string | Object;
172
+ /**
173
+ * Specifies the types of command to be rendered in the Toolbar.
174
+ * Supported types are:
175
+ * - Button: Creates the Button control with its given properties like text, prefixIcon, etc.
176
+ * - Separator: Adds a horizontal line that separates the Toolbar commands.
177
+ * - Input: Creates an input element that is applicable to template rendering with Syncfusion controls like DropDownList,
178
+ * AutoComplete, etc.
179
+ * @default 'Button'
180
+ */
181
+ @Property('Button')
182
+ public type: ItemType;
183
+ /**
184
+ * Specifies where the button text will be displayed on *popup mode* of the Toolbar.
185
+ * Possible values are:
186
+ * - Toolbar: Text will be displayed on *Toolbar* only.
187
+ * - Overflow: Text will be displayed only when content overflows to *popup*.
188
+ * - Both: Text will be displayed on *popup* and *Toolbar*.
189
+ * @default 'Both'
190
+ */
191
+ @Property('Both')
192
+ public showTextOn: DisplayMode;
193
+ /**
194
+ * Defines htmlAttributes used to add custom attributes to Toolbar command.
195
+ * Supports HTML attributes such as style, class, etc.
196
+ * @default null
197
+ */
198
+ @Property(null)
199
+ public htmlAttributes: { [key: string]: string; };
200
+ /**
201
+ * Specifies the text to be displayed on the Toolbar button.
202
+ * @default ""
203
+ */
204
+ @Property('')
205
+ public tooltipText: string;
206
+ /**
207
+ * Specifies the location for aligning Toolbar items on the Toolbar. Each command will be aligned according to the `align` property.
208
+ * Possible values are:
209
+ * - Left: To align commands to the left side of the Toolbar.
210
+ * - Center: To align commands at the center of the Toolbar.
211
+ * - Right: To align commands to the right side of the Toolbar.
212
+ * ```html
213
+ * <div id="element"> </div>
214
+ * ```
215
+ * ```typescript
216
+ * let toolbar: Toolbar = new Toolbar({
217
+ * items: [
218
+ * { text: "Home" },
219
+ * { text: "My Home Page" , align: 'Center' },
220
+ * { text: "Search", align: 'Right' }
221
+ * { text: "Settings", align: 'Right' }
222
+ * ]
223
+ * });
224
+ * toolbar.appendTo('#element');
225
+ * ```
226
+ * @default "Left"
227
+ */
228
+ @Property('Left')
229
+ public align: ItemAlign;
230
+ /**
231
+ * Event triggers when `click` the toolbar item.
232
+ * @event
233
+ * @blazorProperty 'OnClick'
234
+ */
235
+ @Event()
236
+ public click: EmitType<ClickEventArgs>;
237
+ }
238
+ /**
239
+ * The Toolbar control contains a group of commands that are aligned horizontally.
240
+ * ```html
241
+ * <div id="toolbar"/>
242
+ * <script>
243
+ * var toolbarObj = new Toolbar();
244
+ * toolbarObj.appendTo("#toolbar");
245
+ * </script>
246
+ * ```
247
+ */
248
+ @NotifyPropertyChanges
249
+ export class Toolbar extends Component<HTMLElement> implements INotifyPropertyChanged {
250
+ private trgtEle: HTEle;
251
+ private ctrlTem: HTEle;
252
+
253
+ /** @hidden */
254
+ private popObj: Popup;
255
+ /** @hidden */
256
+ private tbarEle: HTMLElement[];
257
+ /** @hidden */
258
+ private tbarAlgEle: ToolbarItemAlignIn;
259
+ /** @hidden */
260
+ private tbarAlign: boolean;
261
+ /** @hidden */
262
+ private tbarEleMrgn: number;
263
+ /** @hidden */
264
+ private tbResize: boolean;
265
+ private offsetWid: number;
266
+ private keyModule: KeyboardEvents;
267
+ private scrollModule: HScroll | VScroll;
268
+ private activeEle: HTEle;
269
+ private popupPriCount: number;
270
+ private tbarItemsCol: ItemModel[];
271
+ private isVertical: boolean;
272
+ private tempId: string[];
273
+ private isExtendedOpen: boolean;
274
+ private resizeContext: EventListenerObject = this.resize.bind(this);
275
+
276
+ /**
277
+ * Contains the keyboard configuration of the Toolbar.
278
+ */
279
+ private keyConfigs: { [key: string]: Str } = {
280
+ moveLeft: 'leftarrow',
281
+ moveRight: 'rightarrow',
282
+ moveUp: 'uparrow',
283
+ moveDown: 'downarrow',
284
+ popupOpen: 'enter',
285
+ popupClose: 'escape',
286
+ tab: 'tab',
287
+ home: 'home',
288
+ end: 'end',
289
+ };
290
+ /**
291
+ * An array of items that is used to configure Toolbar commands.
292
+ * @default []
293
+ */
294
+ @Collection<ItemModel>([], Item)
295
+ public items: ItemModel[];
296
+ /**
297
+ * Specifies the width of the Toolbar in pixels/numbers/percentage. Number value is considered as pixels.
298
+ * @default 'auto'
299
+ */
300
+ @Property('auto')
301
+ public width: string | number;
302
+ /**
303
+ * Specifies the height of the Toolbar in pixels/number/percentage. Number value is considered as pixels.
304
+ * @default 'auto'
305
+ */
306
+ @Property('auto')
307
+ public height: string | number;
308
+ /**
309
+ * Specifies the Toolbar display mode when Toolbar content exceeds the viewing area.
310
+ * Possible modes are:
311
+ * - Scrollable: All the elements are displayed in a single line with horizontal scrolling enabled.
312
+ * - Popup: Prioritized elements are displayed on the Toolbar and the rest of elements are moved to the *popup*.
313
+ * - MultiRow: Displays the overflow toolbar items as an in-line of a toolbar.
314
+ * - Extended: Hide the overflowing toolbar items in the next row. Show the overflowing toolbar items when you click the expand icons.
315
+ * If the popup content overflows the height of the page, the rest of the elements will be hidden.
316
+ * @default 'Scrollable'
317
+ */
318
+ @Property('Scrollable')
319
+ public overflowMode: OverflowMode;
320
+ /**
321
+ * Specifies the scrolling distance in scroller.
322
+ * @default null
323
+ */
324
+ @Property()
325
+ public scrollStep: number;
326
+ /**
327
+ * Enable or disable the popup collision.
328
+ * @default true
329
+ */
330
+ @Property(true)
331
+ public enableCollision: boolean;
332
+ /**
333
+ * The event will be fired on clicking the Toolbar elements.
334
+ * @event
335
+ * @blazorProperty 'Clicked'
336
+ */
337
+ @Event()
338
+ public clicked: EmitType<ClickEventArgs>;
339
+ /**
340
+ * The event will be fired when the control is rendered.
341
+ * @event
342
+ * @blazorProperty 'Created'
343
+ */
344
+ @Event()
345
+ public created: EmitType<Event>;
346
+ /**
347
+ * The event will be fired when the control gets destroyed.
348
+ * @event
349
+ * @blazorProperty 'Destroyed'
350
+ */
351
+ @Event()
352
+ public destroyed: EmitType<Event>;
353
+ /**
354
+ * The event will be fired before the control is rendered on a page.
355
+ * @event
356
+ * @blazorProperty 'OnCreate'
357
+ * @deprecated
358
+ */
359
+ @Event()
360
+ public beforeCreate: EmitType<BeforeCreateArgs>;
361
+ /**
362
+ * Removes the control from the DOM and also removes all its related events.
363
+ * @returns void.
364
+ */
365
+ public destroy(): void {
366
+ let ele: HTEle = this.element;
367
+ super.destroy();
368
+ this.unwireEvents();
369
+ this.tempId.forEach((ele: Str): void => {
370
+ if (!isNOU(this.element.querySelector(ele))) {
371
+ (<HTEle>document.body.appendChild(this.element.querySelector(ele))).style.display = 'none'; }
372
+ });
373
+ while (ele.firstElementChild) {
374
+ ele.removeChild(ele.firstElementChild);
375
+ }
376
+ if (this.trgtEle) {
377
+ ele.appendChild(this.ctrlTem);
378
+ }
379
+ this.clearProperty();
380
+ this.popObj = null;
381
+ this.tbarAlign = null;
382
+ this.remove(this.element, 'e-toolpop');
383
+ ele.removeAttribute('style');
384
+ ['aria-disabled', 'aria-orientation', 'aria-haspopup', 'role'].forEach((attrb: string): void => {
385
+ this.element.removeAttribute(attrb);
386
+ });
387
+ }
388
+ /**
389
+ * Initialize the event handler
390
+ * @private
391
+ */
392
+ protected preRender(): void {
393
+ let eventArgs: BeforeCreateArgs = { enableCollision: this.enableCollision, scrollStep: this.scrollStep };
394
+ this.trigger('beforeCreate', eventArgs);
395
+ this.enableCollision = eventArgs.enableCollision;
396
+ this.scrollStep = eventArgs.scrollStep;
397
+ this.scrollModule = null;
398
+ this.popObj = null;
399
+ this.tempId = [];
400
+ this.tbarItemsCol = this.items;
401
+ this.isVertical = this.element.classList.contains(CLS_VERTICAL) ? true : false;
402
+ this.isExtendedOpen = false;
403
+ this.popupPriCount = 0;
404
+ if (this.enableRtl) {
405
+ this.add(this.element, CLS_RTL);
406
+ }
407
+ }
408
+ /**
409
+ * Initializes a new instance of the Toolbar class.
410
+ * @param options - Specifies Toolbar model properties as options.
411
+ * @param element - Specifies the element that is rendered as a Toolbar.
412
+ */
413
+ constructor(options?: ToolbarModel, element?: string | HTMLElement) {
414
+ super(options, <HTEle | Str>element);
415
+ }
416
+ private wireEvents(): void {
417
+ EventHandler.add(this.element, 'click', this.clickHandler, this);
418
+ window.addEventListener('resize', this.resizeContext);
419
+ this.keyModule = new KeyboardEvents(
420
+ this.element,
421
+ {
422
+ keyAction: this.keyActionHandler.bind(this),
423
+ keyConfigs: this.keyConfigs
424
+ });
425
+ EventHandler.add(this.element, 'keydown', this.docKeyDown, this);
426
+ this.element.setAttribute('tabIndex', '0');
427
+ }
428
+ private docKeyDown(e: KeyboardEvent): void {
429
+ if ((<HTEle>e.target).tagName === 'INPUT') { return; }
430
+ let popCheck: boolean = !isNOU(this.popObj) && isVisible(this.popObj.element) && this.overflowMode !== 'Extended';
431
+ if (e.keyCode === 9 && (<HTEle>e.target).classList.contains('e-hor-nav') === true && popCheck) {
432
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
433
+ }
434
+ let keyCheck: boolean = (e.keyCode === 40 || e.keyCode === 38 || e.keyCode === 35 || e.keyCode === 36);
435
+ if (keyCheck) {
436
+ e.preventDefault();
437
+ }
438
+ }
439
+ private unwireEvents(): void {
440
+ EventHandler.remove(this.element, 'click', this.clickHandler);
441
+ this.destroyScroll();
442
+ this.keyModule.destroy();
443
+ window.removeEventListener('resize', this.resizeContext);
444
+ EventHandler.remove(document, 'scroll', this.docEvent);
445
+ EventHandler.remove(this.element, 'keydown', this.docKeyDown);
446
+ EventHandler.remove(document, 'click', this.docEvent);
447
+ }
448
+ private clearProperty(): void {
449
+ this.tbarEle = [];
450
+ this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
451
+ }
452
+ private docEvent(e: Event): void {
453
+ let popEle: Element = closest(<Element>e.target, '.e-popup');
454
+ if (this.popObj && isVisible(this.popObj.element) && !popEle && this.overflowMode === 'Popup') {
455
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
456
+ }
457
+ }
458
+ private destroyScroll(): void {
459
+ if (this.scrollModule) {
460
+ if (this.tbarAlign) { this.add(this.scrollModule.element, CLS_TBARPOS); }
461
+ this.scrollModule.destroy(); this.scrollModule = null;
462
+ }
463
+ }
464
+ private destroyItems(): void {
465
+ [].slice.call(this.element.querySelectorAll('.' + CLS_ITEM)).forEach((el: HTEle) => {
466
+ detach(el);
467
+ });
468
+ let tbarItems: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
469
+ if (this.tbarAlign) {
470
+ [].slice.call(tbarItems.children).forEach((el: HTEle) => {
471
+ detach(el);
472
+ });
473
+ this.tbarAlign = false;
474
+ this.remove(tbarItems, CLS_TBARPOS);
475
+ }
476
+ this.clearProperty();
477
+ }
478
+ private destroyMode(): void {
479
+ if (this.scrollModule) {
480
+ this.remove(this.scrollModule.element, CLS_RTL);
481
+ this.destroyScroll();
482
+ }
483
+ this.remove(this.element, CLS_EXTENDEDPOPOPEN);
484
+ this.remove(this.element, CLS_EXTEANDABLE_TOOLBAR);
485
+ let tempEle: HTMLElement = this.element.querySelector('.e-toolbar-multirow');
486
+ if (tempEle) { this.remove(tempEle, CLS_MULTIROW); }
487
+ if (this.popObj) {
488
+ this.popupRefresh(this.popObj.element, true);
489
+ }
490
+ }
491
+ private add(ele: HTEle, val: Str): void {
492
+ ele.classList.add(val);
493
+ }
494
+ private remove(ele: HTEle, val: Str): void {
495
+ ele.classList.remove(val);
496
+ }
497
+ private elementFocus(ele: HTEle): void {
498
+ let fChild: HTEle = <HTEle>ele.firstElementChild;
499
+ if (fChild) {
500
+ fChild.focus();
501
+ this.activeEleSwitch(ele);
502
+ } else {
503
+ ele.focus();
504
+ }
505
+ }
506
+ private clstElement(tbrNavChk: Boolean, trgt: HTEle): HTEle {
507
+ let clst: HTEle;
508
+ if (tbrNavChk && this.popObj && isVisible(this.popObj.element)) {
509
+ clst = <HTEle>this.popObj.element.querySelector('.' + CLS_ITEM);
510
+ } else if (this.element === trgt || tbrNavChk) {
511
+ // tslint:disable-next-line:max-line-length
512
+ clst = <HTEle>this.element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_DISABLE + ' ):not(.' + CLS_SEPARATOR + ' ):not(.' + CLS_HIDDEN + ' )');
513
+ } else {
514
+ clst = <HTEle>closest(trgt, '.' + CLS_ITEM);
515
+ }
516
+ return clst;
517
+ }
518
+ private keyHandling(clst: HTEle, e: KeyboardEventArgs, trgt: HTEle, navChk: Boolean, scrollChk: Boolean): void {
519
+ let popObj: Popup = this.popObj;
520
+ let rootEle: HTEle = this.element;
521
+ let popAnimate: Object = { name: 'FadeOut', duration: 100 };
522
+ switch (e.action) {
523
+ case 'moveRight':
524
+ if (this.isVertical) { return; }
525
+ if (rootEle === trgt) {
526
+ this.elementFocus(clst);
527
+ } else if (!navChk) {
528
+ this.eleFocus(clst, 'next');
529
+ }
530
+ break;
531
+ case 'moveLeft':
532
+ if (this.isVertical) { return; }
533
+ if (!navChk) {
534
+ this.eleFocus(clst, 'previous');
535
+ }
536
+ break;
537
+ case 'home':
538
+ case 'end':
539
+ let ele: HTEle;
540
+ let nodes: NodeList;
541
+ if (clst) {
542
+ let popupCheck: HTEle = <HTEle>closest(clst, '.e-popup');
543
+ if (popupCheck) {
544
+ if (isVisible(this.popObj.element)) {
545
+ nodes = [].slice.call(popupCheck.children);
546
+ if (e.action === 'home') {
547
+ ele = <HTEle>nodes[0];
548
+ } else {
549
+ ele = <HTEle>nodes[nodes.length - 1];
550
+ }
551
+ }
552
+ } else {
553
+ nodes = this.element.querySelectorAll('.' + CLS_ITEMS + ' .' + CLS_ITEM);
554
+ if (e.action === 'home') {
555
+ ele = <HTEle>nodes[0];
556
+ } else {
557
+ ele = <HTEle>nodes[nodes.length - 1];
558
+ }
559
+ }
560
+ if (ele) {
561
+ this.elementFocus(ele);
562
+ }
563
+ }
564
+ break;
565
+ case 'moveUp':
566
+ case 'moveDown':
567
+ let value: Str = e.action === 'moveUp' ? 'previous' : 'next';
568
+ if (!this.isVertical) {
569
+ if (popObj && closest(trgt, '.e-popup')) {
570
+ let popEle: HTEle = popObj.element;
571
+ let popFrstEle: HTEle = popEle.firstElementChild as HTEle;
572
+ if ((value === 'previous' && popFrstEle === clst) || (value === 'next' && popEle.lastElementChild === clst)) {
573
+ return;
574
+ } else {
575
+ this.eleFocus(clst, value);
576
+ }
577
+ } else if (e.action === 'moveDown' && popObj && isVisible(popObj.element)) {
578
+ this.elementFocus(clst);
579
+ }
580
+ } else {
581
+ if (e.action === 'moveUp') {
582
+ this.eleFocus(clst, 'previous');
583
+ } else {
584
+ this.eleFocus(clst, 'next');
585
+ }
586
+ }
587
+ break;
588
+ case 'tab':
589
+ if (!scrollChk && !navChk) {
590
+ let ele: HTEle = (<HTEle>clst.firstElementChild);
591
+ if (rootEle === trgt) {
592
+ if (this.activeEle) {
593
+ this.activeEle.focus();
594
+ } else {
595
+ this.activeEleRemove(ele);
596
+ ele.focus();
597
+ }
598
+ this.element.removeAttribute('tabindex');
599
+ }
600
+ }
601
+ break;
602
+ case 'popupClose':
603
+ if (popObj && this.overflowMode !== 'Extended') {
604
+ popObj.hide(popAnimate);
605
+ }
606
+ break;
607
+ case 'popupOpen':
608
+ if (!navChk) { return; }
609
+ if (popObj && !isVisible(popObj.element)) {
610
+ popObj.element.style.top = rootEle.offsetHeight + 'px';
611
+ popObj.show({ name: 'FadeIn', duration: 100 });
612
+ } else {
613
+ popObj.hide(popAnimate);
614
+ }
615
+ break;
616
+ }
617
+ }
618
+ private keyActionHandler(e: KeyboardEventArgs): void {
619
+ let trgt: HTEle = <HTEle>e.target;
620
+ if (trgt.tagName === 'INPUT' || trgt.tagName === 'TEXTAREA' || this.element.classList.contains(CLS_DISABLE)) {
621
+ return;
622
+ }
623
+ e.preventDefault();
624
+ let clst: HTEle;
625
+ let tbrNavChk: boolean = trgt.classList.contains(CLS_TBARNAV);
626
+ let tbarScrollChk: boolean = trgt.classList.contains(CLS_TBARSCRLNAV);
627
+ clst = this.clstElement(tbrNavChk, trgt);
628
+ if (clst || tbarScrollChk) {
629
+ this.keyHandling(clst, e, trgt, tbrNavChk, tbarScrollChk);
630
+ }
631
+ }
632
+ /**
633
+ * Specifies the value to disable/enable the Toolbar component.
634
+ * When set to `true`, the component will be disabled.
635
+ * @param {boolean} value - Based on this Boolean value, Toolbar will be enabled (false) or disabled (true).
636
+ * @returns void.
637
+ */
638
+ public disable(value: boolean): void {
639
+ let rootEle: HTMLElement = this.element;
640
+ value ? rootEle.classList.add(CLS_DISABLE) : rootEle.classList.remove(CLS_DISABLE);
641
+ rootEle.setAttribute('tabindex', !value ? '0' : '-1');
642
+ if (this.activeEle) {
643
+ this.activeEle.setAttribute('tabindex', !value ? '0' : '-1'); }
644
+ if (this.scrollModule) {
645
+ this.scrollModule.disable(value); }
646
+ if (this.popObj) {
647
+ if (isVisible(this.popObj.element) && this.overflowMode !== 'Extended') {
648
+ this.popObj.hide(); }
649
+ rootEle.querySelector('#' + rootEle.id + '_nav').setAttribute('tabindex', !value ? '0' : '-1');
650
+ }
651
+ }
652
+ private eleContains(el: HTEle): string | boolean {
653
+ // tslint:disable-next-line:max-line-length
654
+ return el.classList.contains(CLS_SEPARATOR) || el.classList.contains(CLS_DISABLE) || el.getAttribute('disabled') || el.classList.contains(CLS_HIDDEN) || !isVisible(el);
655
+ // tslint:enable-next-line:max-line-length
656
+ }
657
+ private eleFocus(closest: HTEle, pos: Str): void {
658
+ let sib: HTEle = Object(closest)[pos + 'ElementSibling'];
659
+ if (sib) {
660
+ let skipEle: string | boolean = this.eleContains(sib);
661
+ if (skipEle) {
662
+ this.eleFocus(sib, pos); return;
663
+ }
664
+ this.elementFocus(sib);
665
+ } else if (this.tbarAlign) {
666
+ let elem: HTEle = Object(closest.parentElement)[pos + 'ElementSibling'] as HTEle;
667
+ if (!isNOU(elem) && elem.children.length === 0) {
668
+ elem = Object(elem)[pos + 'ElementSibling'] as HTEle;
669
+ }
670
+ if (!isNOU(elem) && elem.children.length > 0) {
671
+ if (pos === 'next') {
672
+ let el: HTEle = <HTEle>elem.querySelector('.' + CLS_ITEM);
673
+ if (this.eleContains(el)) {
674
+ this.eleFocus(el, pos);
675
+ } else {
676
+ (<HTEle>el.firstElementChild).focus();
677
+ this.activeEleSwitch(el);
678
+ }
679
+ } else {
680
+ let el: HTEle = <HTEle>elem.lastElementChild;
681
+ if (this.eleContains(el)) {
682
+ this.eleFocus(el, pos);
683
+ } else {
684
+ this.elementFocus(el);
685
+ }
686
+ }
687
+ }
688
+ }
689
+ }
690
+ private clickHandler(e: Event): void {
691
+ let trgt: HTEle = <HTEle>e.target;
692
+ let clsList: DOMTokenList = trgt.classList;
693
+ let ele: HTEle = this.element;
694
+ let isPopupElement: boolean = !isNOU(closest(trgt, '.' + CLS_POPUPCLASS));
695
+ let popupNav: HTEle = <HTEle>closest(trgt, ('.' + CLS_TBARNAV));
696
+ if (!popupNav) {
697
+ popupNav = trgt;
698
+ }
699
+ if (!ele.children[0].classList.contains('e-hscroll') && !ele.children[0].classList.contains('e-vscroll')
700
+ && (clsList.contains(CLS_TBARNAV))) {
701
+ clsList = trgt.querySelector('.e-icons').classList;
702
+ }
703
+ if (clsList.contains(CLS_POPUPICON) || clsList.contains(CLS_POPUPDOWN)) {
704
+ this.popupClickHandler(ele, popupNav, CLS_RTL);
705
+ }
706
+ let itemObj: ItemModel;
707
+ let clst: HTEle = <HTEle>closest(<Node>e.target, '.' + CLS_ITEM);
708
+ if ((isNOU(clst) || clst.classList.contains(CLS_DISABLE)) && !popupNav.classList.contains(CLS_TBARNAV)) {
709
+ return;
710
+ }
711
+ if (clst) {
712
+ itemObj = this.items[this.tbarEle.indexOf(clst)];
713
+ }
714
+ let eventArgs: ClickEventArgs = { originalEvent: e, item: itemObj };
715
+ if (itemObj && !isNOU(itemObj.click)) {
716
+ this.trigger('items[' + this.tbarEle.indexOf(clst) + '].click', eventArgs);
717
+ }
718
+ if (!eventArgs.cancel) {
719
+ this.trigger('clicked', eventArgs, (clickedArgs: ClickEventArgs) => {
720
+ if (!isNOU(this.popObj) && isPopupElement && !clickedArgs.cancel && this.overflowMode === 'Popup' &&
721
+ clickedArgs.item && clickedArgs.item.type !== 'Input') {
722
+ this.popObj.hide({ name: 'FadeOut', duration: 100 });
723
+ }
724
+ });
725
+ }
726
+ };
727
+ private popupClickHandler(ele: HTMLElement, popupNav: HTMLElement, CLS_RTL: Str): void {
728
+ let popObj: Popup = this.popObj;
729
+ if (isVisible(popObj.element)) {
730
+ popupNav.classList.remove(CLS_TBARNAVACT);
731
+ popObj.hide({ name: 'FadeOut', duration: 100 });
732
+ } else {
733
+ if (ele.classList.contains(CLS_RTL)) {
734
+ popObj.enableRtl = true;
735
+ popObj.position = { X: 'left', Y: 'top' };
736
+ }
737
+ if (popObj.offsetX === 0 && !ele.classList.contains(CLS_RTL)) {
738
+ popObj.enableRtl = false;
739
+ popObj.position = { X: 'right', Y: 'top' };
740
+ }
741
+ popObj.dataBind();
742
+ popObj.refreshPosition();
743
+ popObj.element.style.top = this.getElementOffsetY() + 'px';
744
+ if (this.overflowMode === 'Extended') { popObj.element.style.minHeight = '0px'; }
745
+ popupNav.classList.add(CLS_TBARNAVACT);
746
+ popObj.show({ name: 'FadeIn', duration: 100 });
747
+ }
748
+ }
749
+ /**
750
+ * To Initialize the control rendering
751
+ * @private
752
+ */
753
+ protected render(): void {
754
+ this.initialize();
755
+ this.renderControl();
756
+ this.separator();
757
+ this.refreshToolbarTemplate();
758
+ this.wireEvents();
759
+ if (isBlazor()) {
760
+ this.renderComplete();
761
+ }
762
+ }
763
+ private initialize(): void {
764
+ let width: Str = formatUnit(this.width);
765
+ let height: Str = formatUnit(this.height);
766
+ if (Browser.info.name !== 'msie' || this.height !== 'auto' || this.overflowMode === 'MultiRow') {
767
+ setStyle(this.element, { 'height': height });
768
+ }
769
+ setStyle(this.element, { 'width': width });
770
+ let ariaAttr: { [key: string]: Str } = {
771
+ 'role': 'toolbar', 'aria-disabled': 'false', 'aria-haspopup': 'false',
772
+ 'aria-orientation': !this.isVertical ? 'horizontal' : 'vertical',
773
+ };
774
+ attributes(this.element, ariaAttr);
775
+ }
776
+ private renderControl(): void {
777
+ this.trgtEle = (this.element.children.length > 0) ? <HTEle>this.element.querySelector('div') : null;
778
+ this.tbarAlgEle = { lefts: [], centers: [], rights: [] };
779
+ this.renderItems();
780
+ this.renderOverflowMode();
781
+ if (this.tbarAlign) { this.itemPositioning(); }
782
+ if (this.popObj && this.popObj.element.childElementCount > 1 && this.checkPopupRefresh(this.element, this.popObj.element)) {
783
+ this.popupRefresh(this.popObj.element, false);
784
+ }
785
+ }
786
+ /** @hidden */
787
+ public changeOrientation(): void {
788
+ let ele: HTEle = this.element;
789
+ if (this.isVertical) {
790
+ ele.classList.remove(CLS_VERTICAL);
791
+ this.isVertical = false;
792
+ if (this.height === 'auto' || this.height === '100%') {
793
+ ele.style.height = this.height; }
794
+ ele.setAttribute('aria-orientation', 'horizontal');
795
+ } else {
796
+ ele.classList.add(CLS_VERTICAL);
797
+ this.isVertical = true;
798
+ ele.setAttribute('aria-orientation', 'vertical');
799
+ setStyle(this.element, { 'height': formatUnit(this.height), 'width': formatUnit(this.width) });
800
+ }
801
+ this.destroyMode();
802
+ this.refreshOverflow();
803
+ }
804
+ private initScroll(element: HTEle, innerItems: NodeList): void {
805
+ if (!this.scrollModule && this.checkOverflow(element, <HTEle>innerItems[0])) {
806
+ if (this.tbarAlign) {
807
+ this.element.querySelector('.' + CLS_ITEMS + ' .' + CLS_TBARCENTER).removeAttribute('style');
808
+ }
809
+ if (this.isVertical) {
810
+ this.scrollModule = new VScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
811
+ } else {
812
+ this.scrollModule = new HScroll({ scrollStep: this.scrollStep, enableRtl: this.enableRtl }, <HTEle>innerItems[0]);
813
+ }
814
+ this.remove(this.scrollModule.element, CLS_TBARPOS);
815
+ setStyle(this.element, { overflow: 'hidden' });
816
+ }
817
+ }
818
+ private itemWidthCal(items: HTEle): number {
819
+ let width: number = 0;
820
+ let style: CSSStyleDeclaration;
821
+ [].slice.call(selectAll('.' + CLS_ITEM, items)).forEach((el: HTEle) => {
822
+ if (isVisible(el)) {
823
+ style = window.getComputedStyle(el);
824
+ width += this.isVertical ? el.offsetHeight : el.offsetWidth;
825
+ width += parseFloat(this.isVertical ? style.marginTop : style.marginRight);
826
+ width += parseFloat(this.isVertical ? style.marginBottom : style.marginLeft);
827
+ }
828
+ });
829
+ return width;
830
+ }
831
+ private getScrollCntEle(innerItem: HTEle): HTEle {
832
+ let trgClass: Str = (this.isVertical) ? '.e-vscroll-content' : '.e-hscroll-content';
833
+ return <HTEle>innerItem.querySelector(trgClass);
834
+ }
835
+ private checkOverflow(element: HTEle, innerItem: HTEle): boolean {
836
+ if (isNOU(element) || isNOU(innerItem) || !isVisible(element)) {
837
+ return false;
838
+ }
839
+ let eleWidth: number = this.isVertical ? element.offsetHeight : element.offsetWidth;
840
+ let itemWidth: number = this.isVertical ? innerItem.offsetHeight : innerItem.offsetWidth;
841
+ if (this.tbarAlign || this.scrollModule || (eleWidth === itemWidth)) {
842
+ itemWidth = this.itemWidthCal(this.scrollModule ? this.getScrollCntEle(innerItem) : innerItem);
843
+ }
844
+ let popNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
845
+ let scrollNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARSCRLNAV);
846
+ let navEleWidth: number = 0;
847
+ if (popNav) {
848
+ navEleWidth = this.isVertical ? popNav.offsetHeight : popNav.offsetWidth;
849
+ } else if (scrollNav) {
850
+ navEleWidth = this.isVertical ? (scrollNav.offsetHeight * (2)) : (scrollNav.offsetWidth * 2);
851
+ }
852
+ if (itemWidth > eleWidth - navEleWidth) {
853
+ return true;
854
+ } else { return false; }
855
+ }
856
+ /**
857
+ * Refresh the whole Toolbar component without re-rendering.
858
+ * - It is used to manually refresh the Toolbar overflow modes such as scrollable, popup, multi row, and extended.
859
+ * - It will refresh the Toolbar component after loading items dynamically.
860
+ * @returns void.
861
+ */
862
+ public refreshOverflow(): void {
863
+ this.resize();
864
+ }
865
+ private toolbarAlign(innerItems: HTEle): void {
866
+ if (this.tbarAlign) {
867
+ this.add(innerItems, CLS_TBARPOS);
868
+ this.itemPositioning();
869
+ }
870
+ }
871
+ private renderOverflowMode(): void {
872
+ let ele: HTEle = this.element;
873
+ let innerItems: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
874
+ let priorityCheck: boolean = this.popupPriCount > 0;
875
+ if (ele && ele.children.length > 0) {
876
+ this.offsetWid = ele.offsetWidth;
877
+ this.remove(this.element, 'e-toolpop');
878
+ if (Browser.info.name === 'msie' && this.height === 'auto') {
879
+ ele.style.height = '';
880
+ }
881
+ switch (this.overflowMode) {
882
+ case 'Scrollable':
883
+ if (isNOU(this.scrollModule)) {
884
+ this.initScroll(ele, [].slice.call(ele.getElementsByClassName(CLS_ITEMS)));
885
+ }
886
+ break;
887
+ case 'Popup':
888
+ this.add(this.element, 'e-toolpop');
889
+ if (this.tbarAlign) { this.removePositioning(); }
890
+ if (this.checkOverflow(ele, innerItems) || priorityCheck) {
891
+ this.setOverflowAttributes(ele);
892
+ }
893
+ this.toolbarAlign(innerItems);
894
+ break;
895
+ case 'MultiRow':
896
+ this.add(innerItems, CLS_MULTIROW);
897
+ if (this.checkOverflow(ele, innerItems) && this.tbarAlign) {
898
+ this.removePositioning();
899
+ this.add(innerItems, CLS_MULTIROWPOS);
900
+ }
901
+ if (ele.style.overflow === 'hidden') {
902
+ ele.style.overflow = '';
903
+ }
904
+ if (Browser.info.name === 'msie' || ele.style.height !== 'auto') {
905
+ ele.style.height = 'auto';
906
+ }
907
+ break;
908
+ case 'Extended':
909
+ this.add(this.element, CLS_EXTEANDABLE_TOOLBAR);
910
+ if (this.checkOverflow(ele, innerItems) || priorityCheck) {
911
+ if (this.tbarAlign) {
912
+ this.removePositioning();
913
+ }
914
+ this.setOverflowAttributes(ele);
915
+ }
916
+ this.toolbarAlign(innerItems);
917
+ }
918
+ }
919
+ }
920
+
921
+ private setOverflowAttributes(ele: HTMLElement): void {
922
+ this.createPopupEle(ele, [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, ele)));
923
+ this.element.querySelector('.' + CLS_TBARNAV).setAttribute('tabIndex', '0');
924
+ this.element.querySelector('.' + CLS_TBARNAV).setAttribute('role', 'list');
925
+ }
926
+
927
+ private separator(): void {
928
+ let element: HTEle = this.element;
929
+ let eleItem: HTEle[] = [].slice.call(element.querySelectorAll('.' + CLS_SEPARATOR));
930
+ let eleInlineItem: HTEle;
931
+ let multiVar: HTEle = element.querySelector('.' + CLS_MULTIROW_SEPARATOR) as HTEle;
932
+ let extendVar: HTEle = element.querySelector('.' + CLS_EXTENDABLE_SEPARATOR) as HTEle;
933
+ eleInlineItem = this.overflowMode === 'MultiRow' ? multiVar : extendVar;
934
+ if (eleInlineItem !== null) {
935
+ if (this.overflowMode === 'MultiRow') {
936
+ eleInlineItem.classList.remove(CLS_MULTIROW_SEPARATOR);
937
+ } else if (this.overflowMode === 'Extended') {
938
+ eleInlineItem.classList.remove(CLS_EXTENDABLE_SEPARATOR);
939
+ }
940
+ }
941
+ for (let i: number = 0; i <= eleItem.length - 1; i++) {
942
+ if (eleItem[i].offsetLeft < 30 && eleItem[i].offsetLeft !== 0) {
943
+ if (this.overflowMode === 'MultiRow') {
944
+ eleItem[i].classList.add(CLS_MULTIROW_SEPARATOR);
945
+ } else if (this.overflowMode === 'Extended') {
946
+ eleItem[i].classList.add(CLS_EXTENDABLE_SEPARATOR);
947
+ }
948
+ }
949
+ }
950
+ }
951
+
952
+ private createPopupEle(ele: HTMLElement, innerEle: HTMLElement[]): void {
953
+ let innerNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
954
+ let vertical: boolean = this.isVertical;
955
+ if (!innerNav) {
956
+ this.createPopupIcon(ele);
957
+ }
958
+ innerNav = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
959
+ let innerNavDom: number = (vertical ? innerNav.offsetHeight : innerNav.offsetWidth);
960
+ let eleWidth: number = ((vertical ? ele.offsetHeight : ele.offsetWidth) - (innerNavDom));
961
+ this.element.classList.remove('e-rtl');
962
+ setStyle(this.element, { direction: 'initial' });
963
+ this.checkPriority(ele, innerEle, eleWidth, true);
964
+ if (this.enableRtl) {
965
+ this.element.classList.add('e-rtl'); }
966
+ this.element.style.removeProperty('direction');
967
+ this.createPopup();
968
+ }
969
+ private pushingPoppedEle(tbarObj: Toolbar, popupPri: Element[], ele: HTEle, eleHeight: number, sepHeight: number): void {
970
+ let element: HTEle = tbarObj.element;
971
+ let nodes: HTEle[] = selectAll('.' + CLS_TBAROVERFLOW, ele);
972
+ let nodeIndex: number = 0;
973
+ let poppedEle: HTEle[] = [].slice.call(selectAll('.' + CLS_POPUP, element.querySelector('.' + CLS_ITEMS)));
974
+ let nodePri: number = 0;
975
+ poppedEle.forEach((el: HTEle, index: number) => {
976
+ nodes = selectAll('.' + CLS_TBAROVERFLOW, ele);
977
+ if (el.classList.contains(CLS_TBAROVERFLOW) && nodes.length > 0) {
978
+ if (tbarObj.tbResize && nodes.length > index) {
979
+ ele.insertBefore(el, nodes[index]); ++nodePri;
980
+ } else { ele.insertBefore(el, ele.children[nodes.length]); ++nodePri; }
981
+ } else if (el.classList.contains(CLS_TBAROVERFLOW)) {
982
+ ele.insertBefore(el, ele.firstChild); ++nodePri;
983
+ } else if (tbarObj.tbResize && el.classList.contains(CLS_POPOVERFLOW) && ele.children.length > 0 && nodes.length === 0) {
984
+ ele.insertBefore(el, ele.firstChild); ++nodePri;
985
+ } else if (el.classList.contains(CLS_POPOVERFLOW)) {
986
+ popupPri.push(el);
987
+ } else if (tbarObj.tbResize) {
988
+ ele.insertBefore(el, ele.childNodes[nodeIndex + nodePri]);
989
+ ++nodeIndex;
990
+ } else {
991
+ ele.appendChild(el);
992
+ }
993
+ if (el.classList.contains(CLS_SEPARATOR)) {
994
+ setStyle(el, { display: '', height: sepHeight + 'px' });
995
+ } else {
996
+ setStyle(el, { display: '', height: eleHeight + 'px' });
997
+ }
998
+ });
999
+ popupPri.forEach((el: Element) => {
1000
+ ele.appendChild(el);
1001
+ });
1002
+ let tbarEle: HTEle[] = selectAll('.' + CLS_ITEM, element.querySelector('.' + CLS_ITEMS));
1003
+ for (let i: number = tbarEle.length - 1; i >= 0; i--) {
1004
+ let tbarElement: HTEle = tbarEle[i];
1005
+ if (tbarElement.classList.contains(CLS_SEPARATOR) && this.overflowMode !== 'Extended') {
1006
+ setStyle(tbarElement, { display: 'none' });
1007
+ } else {
1008
+ break;
1009
+ }
1010
+ }
1011
+ }
1012
+ private createPopup(): void {
1013
+ let element: HTEle = this.element;
1014
+ let eleHeight: number;
1015
+ let eleItem: Element;
1016
+ let sepHeight: number;
1017
+ let sepItem: Element;
1018
+ if (this.overflowMode === 'Extended') {
1019
+ sepItem = element.querySelector('.' + CLS_SEPARATOR + ':not(.' + CLS_POPUP + ')');
1020
+ sepHeight = (element.style.height === 'auto' || element.style.height === '') ? null : (sepItem as HTEle).offsetHeight;
1021
+ }
1022
+ eleItem = element.querySelector('.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_POPUP + ')');
1023
+ eleHeight = (element.style.height === 'auto' || element.style.height === '') ? null : (eleItem && (eleItem as HTEle).offsetHeight);
1024
+ let ele: HTEle;
1025
+ let popupPri: Element[] = [];
1026
+ if (element.querySelector('#' + element.id + '_popup.' + CLS_POPUPCLASS)) {
1027
+ ele = <HTEle>element.querySelector('#' + element.id + '_popup.' + CLS_POPUPCLASS);
1028
+ } else {
1029
+ let extendEle: HTEle = this.createElement('div', {
1030
+ id: element.id + '_popup', className: CLS_POPUPCLASS + ' ' + CLS_EXTENDABLECLASS
1031
+ });
1032
+ let popupEle: HTEle = this.createElement('div', { id: element.id + '_popup', className: CLS_POPUPCLASS });
1033
+ ele = this.overflowMode === 'Extended' ? extendEle : popupEle;
1034
+ }
1035
+ this.pushingPoppedEle(this, popupPri, ele, eleHeight, sepHeight);
1036
+ this.popupInit(element, ele);
1037
+ }
1038
+ private getElementOffsetY(): number {
1039
+ return (this.overflowMode === 'Extended' && window.getComputedStyle(this.element).getPropertyValue('box-sizing') === 'border-box' ?
1040
+ this.element.clientHeight : this.element.offsetHeight);
1041
+ }
1042
+ private popupInit(element: HTEle, ele: HTEle): void {
1043
+ if (!this.popObj) {
1044
+ element.appendChild(ele);
1045
+ setStyle(this.element, { overflow: '' });
1046
+ let eleStyles: CSSStyleDeclaration = window.getComputedStyle(this.element);
1047
+ let popup: Popup = new Popup(null, {
1048
+ relateTo: this.element,
1049
+ offsetY: (this.isVertical) ? 0 : this.getElementOffsetY(),
1050
+ enableRtl: this.enableRtl,
1051
+ open: this.popupOpen.bind(this),
1052
+ close: this.popupClose.bind(this),
1053
+ collision: { Y: this.enableCollision ? 'flip' : 'none' },
1054
+ position: this.enableRtl ? { X: 'left', Y: 'top' } : { X: 'right', Y: 'top' }
1055
+ });
1056
+ popup.appendTo(ele);
1057
+ if (this.overflowMode === 'Extended') {
1058
+ popup.width = parseFloat(eleStyles.width) + ((parseFloat(eleStyles.borderRightWidth)) * 2);
1059
+ popup.offsetX = 0; }
1060
+ EventHandler.add(document, 'scroll', this.docEvent.bind(this));
1061
+ EventHandler.add(document, 'click ', this.docEvent.bind(this));
1062
+ popup.element.style.maxHeight = popup.element.offsetHeight + 'px';
1063
+ if (this.isVertical) { popup.element.style.visibility = 'hidden'; }
1064
+ if (this.isExtendedOpen) {
1065
+ let popupNav: HTEle = this.element.querySelector('.' + CLS_TBARNAV);
1066
+ popupNav.classList.add(CLS_TBARNAVACT);
1067
+ classList(popupNav.firstElementChild, [CLS_POPUPICON], [CLS_POPUPDOWN]);
1068
+ this.element.querySelector('.' + CLS_EXTENDABLECLASS).classList.add(CLS_POPUPOPEN);
1069
+ } else {
1070
+ popup.hide();
1071
+ }
1072
+ this.popObj = popup;
1073
+ this.element.setAttribute('aria-haspopup', 'true');
1074
+ } else {
1075
+ let popupEle: HTEle = this.popObj.element;
1076
+ setStyle(popupEle, { maxHeight: '', display: 'block' });
1077
+ setStyle(popupEle, { maxHeight: popupEle.offsetHeight + 'px', display: '' });
1078
+ }
1079
+ }
1080
+ private tbarPopupHandler(isOpen: boolean): void {
1081
+ if (this.overflowMode === 'Extended') {
1082
+ isOpen ? this.add(this.element, CLS_EXTENDEDPOPOPEN) : this.remove(this.element, CLS_EXTENDEDPOPOPEN);
1083
+ }
1084
+ }
1085
+ private popupOpen(e: Event): void {
1086
+ let popObj: Popup = this.popObj;
1087
+ if (!this.isVertical) {
1088
+ popObj.offsetY = this.getElementOffsetY();
1089
+ popObj.dataBind();
1090
+ }
1091
+ let popupEle: HTEle = this.popObj.element;
1092
+ let toolEle: HTEle = this.popObj.element.parentElement;
1093
+ let popupNav: HTEle = <HTEle>toolEle.querySelector('.' + CLS_TBARNAV);
1094
+ setStyle(popObj.element, { height: 'auto', maxHeight: '' });
1095
+ popObj.element.style.maxHeight = popObj.element.offsetHeight + 'px';
1096
+ if (this.overflowMode === 'Extended') { popObj.element.style.minHeight = ''; }
1097
+ let popupElePos: number = popupEle.offsetTop + popupEle.offsetHeight + calculatePosition(toolEle).top;
1098
+ let popIcon: Element = (popupNav.firstElementChild as Element);
1099
+ popupNav.classList.add(CLS_TBARNAVACT);
1100
+ classList(popIcon, [CLS_POPUPICON], [CLS_POPUPDOWN]);
1101
+ this.tbarPopupHandler(true);
1102
+ let scrollVal: number = isNOU(window.scrollY) ? 0 : window.scrollY;
1103
+ if (!this.isVertical && ((window.innerHeight + scrollVal) < popupElePos) && (this.element.offsetTop < popupEle.offsetHeight)) {
1104
+ let overflowHeight: number = (popupEle.offsetHeight - ((popupElePos - window.innerHeight - scrollVal) + 5));
1105
+ popObj.height = overflowHeight + 'px';
1106
+ for (let i: number = 0; i <= popupEle.childElementCount; i++) {
1107
+ let ele: HTEle = <HTEle>popupEle.children[i];
1108
+ if (ele.offsetTop + ele.offsetHeight > overflowHeight) {
1109
+ overflowHeight = ele.offsetTop;
1110
+ break;
1111
+ }
1112
+ }
1113
+ setStyle(popObj.element, { maxHeight: overflowHeight + 'px' });
1114
+ } else if (this.isVertical) {
1115
+ let tbEleData: ClientRect = this.element.getBoundingClientRect();
1116
+ setStyle(popObj.element, { maxHeight: (tbEleData.top + this.element.offsetHeight) + 'px', bottom: 0, visibility: '' });
1117
+ }
1118
+ }
1119
+
1120
+ private popupClose(e: Event): void {
1121
+ let element: HTEle = this.element;
1122
+ let popupNav: HTEle = <HTEle>element.querySelector('.' + CLS_TBARNAV);
1123
+ let popIcon: Element = (popupNav.firstElementChild as Element);
1124
+ popupNav.classList.remove(CLS_TBARNAVACT);
1125
+ classList(popIcon, [CLS_POPUPDOWN], [CLS_POPUPICON]);
1126
+ this.tbarPopupHandler(false);
1127
+ }
1128
+ private checkPriority(ele: HTEle, inEle: HTEle[], eleWidth: number, pre: boolean): void {
1129
+ let popPriority: boolean = this.popupPriCount > 0;
1130
+ let len: number = inEle.length;
1131
+ let eleWid: number = eleWidth;
1132
+ let eleOffset: number;
1133
+ let checkoffset: boolean;
1134
+ let sepCheck: number = 0; let itemCount: number = 0; let itemPopCount: number = 0;
1135
+ let checkClass: Function = (ele: HTEle, val: Str[]) => {
1136
+ let rVal: Boolean = false;
1137
+ val.forEach((cls: string) => {
1138
+ if (ele.classList.contains(cls)) {
1139
+ rVal = true;
1140
+ }
1141
+ });
1142
+ return rVal;
1143
+ };
1144
+ for (let i: number = len - 1; i >= 0; i--) {
1145
+ let mrgn: number;
1146
+ let compuStyle: CSSStyleDeclaration = window.getComputedStyle(inEle[i]);
1147
+ if (this.isVertical) {
1148
+ mrgn = parseFloat((compuStyle).marginTop);
1149
+ mrgn += parseFloat((compuStyle).marginBottom);
1150
+ } else {
1151
+ mrgn = parseFloat((compuStyle).marginRight);
1152
+ mrgn += parseFloat((compuStyle).marginLeft);
1153
+ }
1154
+ let fstEleCheck: Boolean = inEle[i] === this.tbarEle[0];
1155
+ if (fstEleCheck) { this.tbarEleMrgn = mrgn; }
1156
+ eleOffset = this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth;
1157
+ let eleWid: number = fstEleCheck ? (eleOffset + mrgn) : eleOffset;
1158
+ if (checkClass(inEle[i], [CLS_POPPRI]) && popPriority) {
1159
+ inEle[i].classList.add(CLS_POPUP);
1160
+ if (this.isVertical) {
1161
+ setStyle(inEle[i], { display: 'none', minHeight: eleWid + 'px' });
1162
+ } else {
1163
+ setStyle(inEle[i], { display: 'none', minWidth: eleWid + 'px' }); }
1164
+ itemPopCount++;
1165
+ }
1166
+ if (this.isVertical) {
1167
+ checkoffset = (inEle[i].offsetTop + inEle[i].offsetHeight + mrgn) > eleWidth;
1168
+ } else {
1169
+ checkoffset = (inEle[i].offsetLeft + inEle[i].offsetWidth + mrgn) > eleWidth; }
1170
+ if (checkoffset) {
1171
+ if (inEle[i].classList.contains(CLS_SEPARATOR)) {
1172
+ if (this.overflowMode === 'Extended') {
1173
+ if (itemCount === itemPopCount) {
1174
+ let sepEle: HTEle = (inEle[i] as HTEle);
1175
+ if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1176
+ inEle[i].classList.add(CLS_POPUP);
1177
+ itemPopCount++;
1178
+ }
1179
+ }
1180
+ itemCount++;
1181
+ } else if (this.overflowMode === 'Popup') {
1182
+ if (sepCheck > 0 && itemCount === itemPopCount) {
1183
+ let sepEle: HTEle = (inEle[i + itemCount + (sepCheck - 1)] as HTEle);
1184
+ if (checkClass(sepEle, [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1185
+ setStyle(sepEle, { display: 'none' });
1186
+ }
1187
+ }
1188
+ sepCheck++; itemCount = 0; itemPopCount = 0;
1189
+ }
1190
+ } else {
1191
+ itemCount++;
1192
+ }
1193
+ if (inEle[i].classList.contains(CLS_TBAROVERFLOW) && pre) {
1194
+ eleWidth -= (( this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth) + (mrgn));
1195
+ } else if (!checkClass(inEle[i], [CLS_SEPARATOR, CLS_TBARIGNORE])) {
1196
+ inEle[i].classList.add(CLS_POPUP);
1197
+ if (this.isVertical) {
1198
+ setStyle(inEle[i], { display: 'none', minHeight: eleWid + 'px' });
1199
+ } else {
1200
+ setStyle(inEle[i], { display: 'none', minWidth: eleWid + 'px' });
1201
+ }
1202
+ itemPopCount++;
1203
+ } else {
1204
+ eleWidth -= (( this.isVertical ? inEle[i].offsetHeight : inEle[i].offsetWidth) + (mrgn));
1205
+ }
1206
+ }
1207
+ }
1208
+ if (pre) {
1209
+ let popedEle: HTEle[] = selectAll('.' + CLS_ITEM + ':not(.' + CLS_POPUP + ')', this.element);
1210
+ this.checkPriority(ele, popedEle, eleWid, false);
1211
+ }
1212
+ }
1213
+
1214
+ private createPopupIcon(element: HTEle): void {
1215
+ let id: Str = element.id.concat('_nav');
1216
+ let className: Str = 'e-' + element.id.concat('_nav ' + CLS_POPUPNAV);
1217
+ className = this.overflowMode === 'Extended' ? className + ' ' + CLS_EXTENDPOPUP : className;
1218
+ let nav: HTEle = this.createElement('div', { id: id, className: className });
1219
+ if (Browser.info.name === 'msie' || Browser.info.name === 'edge') {
1220
+ nav.classList.add('e-ie-align');
1221
+ }
1222
+ let navItem: HTEle = this.createElement('div', { className: CLS_POPUPDOWN + ' e-icons' });
1223
+ nav.appendChild(navItem);
1224
+ nav.setAttribute('tabindex', '0');
1225
+ nav.setAttribute('role', 'list');
1226
+ element.appendChild(nav);
1227
+ }
1228
+
1229
+ private tbarPriRef(inEle: HTEle, indx: number, sepPri: number, el: HTEle, des: boolean, elWid: number, wid: number, ig: number): void {
1230
+ let ignoreCount: number = ig;
1231
+ let popEle: HTEle = this.popObj.element;
1232
+ let query: Str = '.' + CLS_ITEM + ':not(.' + CLS_SEPARATOR + '):not(.' + CLS_TBAROVERFLOW + ')';
1233
+ let priEleCnt: number = selectAll('.' + CLS_POPUP + ':not(.' + CLS_TBAROVERFLOW + ')', popEle).length;
1234
+ let checkClass: Function = (ele: HTEle, val: Str) => {
1235
+ return ele.classList.contains(val);
1236
+ };
1237
+ if (selectAll(query, inEle).length === 0) {
1238
+ let eleSep: HTEle = inEle.children[indx - (indx - sepPri) - 1] as HTEle;
1239
+ let ignoreCheck: Boolean = (!isNOU(eleSep) && checkClass(eleSep, CLS_TBARIGNORE));
1240
+ if ((!isNOU(eleSep) && checkClass(eleSep, CLS_SEPARATOR) && !isVisible(eleSep)) || ignoreCheck) {
1241
+ let sepDisplay: Str = 'none';
1242
+ eleSep.style.display = 'inherit';
1243
+ let eleSepWidth: number = eleSep.offsetWidth + (parseFloat(window.getComputedStyle(eleSep).marginRight) * 2);
1244
+ let prevSep: HTEle = eleSep.previousElementSibling as HTEle;
1245
+ if ((elWid + eleSepWidth) < wid || des) {
1246
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
1247
+ if (!isNOU(prevSep)) {
1248
+ prevSep.style.display = '';
1249
+ }
1250
+ } else {
1251
+ if (prevSep.classList.contains(CLS_SEPARATOR)) {
1252
+ prevSep.style.display = sepDisplay;
1253
+ }
1254
+ }
1255
+ eleSep.style.display = '';
1256
+ } else {
1257
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - (indx - sepPri)]);
1258
+ }
1259
+ } else {
1260
+ inEle.insertBefore(el, inEle.children[(indx + ignoreCount) - priEleCnt]);
1261
+ }
1262
+ }
1263
+
1264
+ private popupRefresh(popupEle: HTMLElement, destroy: boolean): void {
1265
+ let ele: HTEle = this.element;
1266
+ let isVer: boolean = this.isVertical;
1267
+ let popNav: HTEle = <HTEle>ele.querySelector('.' + CLS_TBARNAV);
1268
+ let innerEle: HTEle = <HTEle>ele.querySelector('.' + CLS_ITEMS);
1269
+ if (isNOU(popNav)) {
1270
+ return;
1271
+ }
1272
+ innerEle.removeAttribute('style');
1273
+ popupEle.style.display = 'block';
1274
+ let dimension: number;
1275
+ if (isVer) {
1276
+ dimension = ele.offsetHeight - (popNav.offsetHeight + innerEle.offsetHeight);
1277
+ } else {
1278
+ dimension = ele.offsetWidth - (popNav.offsetWidth + innerEle.offsetWidth); }
1279
+ let popupEleWidth: number = 0;
1280
+ [].slice.call(popupEle.children).forEach((el: HTMLElement): void => {
1281
+ popupEleWidth += this.popupEleWidth(el);
1282
+ setStyle(el, {'position': ''}); });
1283
+ if ((dimension + (isVer ? popNav.offsetHeight : popNav.offsetWidth)) > (popupEleWidth) && this.popupPriCount === 0 ) {
1284
+ destroy = true; }
1285
+ this.popupEleRefresh(dimension, popupEle, destroy);
1286
+ popupEle.style.display = '';
1287
+ if (popupEle.children.length === 0 && popNav && this.popObj) {
1288
+ detach(popNav);
1289
+ popNav = null;
1290
+ this.popObj.destroy();
1291
+ detach(this.popObj.element);
1292
+ this.popObj = null;
1293
+ ele.setAttribute('aria-haspopup', 'false');
1294
+ }
1295
+ }
1296
+ private ignoreEleFetch(index: number, innerEle: HTEle): number {
1297
+ let ignoreEle: HTEle[] = [].slice.call(innerEle.querySelectorAll('.' + CLS_TBARIGNORE));
1298
+ let ignoreInx: number[] = [];
1299
+ let count: number = 0;
1300
+ if (ignoreEle.length > 0) {
1301
+ ignoreEle.forEach((ele: HTEle): void => {
1302
+ ignoreInx.push([].slice.call(innerEle.children).indexOf(ele));
1303
+ });
1304
+ } else {
1305
+ return 0;
1306
+ }
1307
+ ignoreInx.forEach((val: number): void => {
1308
+ if (val <= index) { count++; }
1309
+ });
1310
+ return count;
1311
+ }
1312
+ private checkPopupRefresh(root: HTEle, popEle: HTEle): boolean {
1313
+ popEle.style.display = 'block';
1314
+ let elWid: number = this.popupEleWidth(<HTEle>popEle.firstElementChild);
1315
+ (<HTEle>popEle.firstElementChild).style.removeProperty('Position');
1316
+ let tbarWidth: number = root.offsetWidth - (<HTEle>root.querySelector('.' + CLS_TBARNAV)).offsetWidth;
1317
+ let tbarItemsWid: number = (<HTEle>root.querySelector('.' + CLS_ITEMS)).offsetWidth;
1318
+ popEle.style.removeProperty('display');
1319
+ if (tbarWidth > (elWid + tbarItemsWid)) {
1320
+ return true;
1321
+ }
1322
+ return false;
1323
+ }
1324
+ private popupEleWidth(el: HTEle): number {
1325
+ el.style.position = 'absolute';
1326
+ let elWidth: number = this.isVertical ? el.offsetHeight : el.offsetWidth;
1327
+ let btnText: HTEle = <HTEle>el.querySelector('.' + CLS_TBARBTNTEXT);
1328
+ if (el.classList.contains('e-tbtn-align') || el.classList.contains(CLS_TBARTEXT)) {
1329
+ let btn: HTEle = <HTEle>el.children[0];
1330
+ if (!isNOU(btnText) && el.classList.contains(CLS_TBARTEXT)) {
1331
+ btnText.style.display = 'none';
1332
+ } else if (!isNOU(btnText) && el.classList.contains(CLS_POPUPTEXT)) {
1333
+ btnText.style.display = 'block';
1334
+ }
1335
+ btn.style.minWidth = '0%';
1336
+ elWidth = parseFloat( !this.isVertical ? el.style.minWidth : el.style.minHeight);
1337
+ btn.style.minWidth = '';
1338
+ btn.style.minHeight = '';
1339
+ if (!isNOU(btnText)) {
1340
+ btnText.style.display = '';
1341
+ }
1342
+ }
1343
+ return elWidth;
1344
+ }
1345
+ private popupEleRefresh(width: number, popupEle: HTEle, destroy: boolean): void {
1346
+ let popPriority: boolean = this.popupPriCount > 0;
1347
+ let eleSplice: HTEle[] = this.tbarEle;
1348
+ let priEleCnt: number;
1349
+ let index: number;
1350
+ let checkOverflow: boolean;
1351
+ let innerEle: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
1352
+ let ignoreCount: number = 0;
1353
+ for (let el of [].slice.call(popupEle.children)) {
1354
+ if (el.classList.contains(CLS_POPPRI) && popPriority && !destroy) {
1355
+ continue;
1356
+ }
1357
+ let elWidth: number = this.popupEleWidth(el);
1358
+ if (el === this.tbarEle[0]) { elWidth += this.tbarEleMrgn; }
1359
+ el.style.position = '';
1360
+ if (elWidth < width || destroy) {
1361
+ setStyle(el, { minWidth: '', height: '', minHeight: '' });
1362
+ if (!el.classList.contains(CLS_POPOVERFLOW)) {
1363
+ el.classList.remove(CLS_POPUP);
1364
+ }
1365
+ index = this.tbarEle.indexOf(el);
1366
+ if (this.tbarAlign) {
1367
+ let pos: ItemAlign = this.items[index].align;
1368
+ index = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign].indexOf(el);
1369
+ eleSplice = this.tbarAlgEle[(pos + 's').toLowerCase() as ItmAlign];
1370
+ innerEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS + ' .' + 'e-toolbar-' + pos.toLowerCase());
1371
+ }
1372
+ let sepBeforePri: number = 0;
1373
+ if (this.overflowMode !== 'Extended') {
1374
+ eleSplice.slice(0, index).forEach((el: HTEle) => {
1375
+ if (el.classList.contains(CLS_TBAROVERFLOW) || el.classList.contains(CLS_SEPARATOR)) {
1376
+ if (el.classList.contains(CLS_SEPARATOR)) {
1377
+ el.style.display = '';
1378
+ width -= el.offsetWidth;
1379
+ }
1380
+ sepBeforePri++;
1381
+ }
1382
+ }); }
1383
+ ignoreCount = this.ignoreEleFetch(index, innerEle);
1384
+ if (el.classList.contains(CLS_TBAROVERFLOW)) {
1385
+ this.tbarPriRef(innerEle, index, sepBeforePri, el, destroy, elWidth, width, ignoreCount);
1386
+ width -= el.offsetWidth;
1387
+ } else if (index === 0) {
1388
+ innerEle.insertBefore(el, innerEle.firstChild);
1389
+ width -= el.offsetWidth;
1390
+ } else {
1391
+ priEleCnt = selectAll('.' + CLS_TBAROVERFLOW, this.popObj.element).length;
1392
+ innerEle.insertBefore(el, innerEle.children[(index + ignoreCount) - priEleCnt]);
1393
+ width -= el.offsetWidth;
1394
+ }
1395
+ el.style.height = '';
1396
+ } else {
1397
+ break;
1398
+ }
1399
+ }
1400
+ checkOverflow = this.checkOverflow(this.element, this.element.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
1401
+ if (checkOverflow && !destroy) {
1402
+ this.renderOverflowMode();
1403
+ }
1404
+ }
1405
+ private removePositioning(): void {
1406
+ let item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1407
+ if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) { return; }
1408
+ this.remove(item, CLS_TBARPOS);
1409
+ let innerItem: HTEle[] = [].slice.call(item.childNodes);
1410
+ innerItem[1].removeAttribute('style');
1411
+ innerItem[2].removeAttribute('style');
1412
+ }
1413
+ private refreshPositioning(): void {
1414
+ let item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1415
+ this.add(item, CLS_TBARPOS);
1416
+ this.itemPositioning();
1417
+ }
1418
+ private itemPositioning(): void {
1419
+ let item: HTEle = this.element.querySelector('.' + CLS_ITEMS) as HTEle;
1420
+ let margin: number;
1421
+ if (isNOU(item) || !item.classList.contains(CLS_TBARPOS)) { return; }
1422
+ let popupNav: HTEle = <HTEle>this.element.querySelector('.' + CLS_TBARNAV);
1423
+ let innerItem: HTEle[];
1424
+ if (this.scrollModule) {
1425
+ let trgClass: Str = (this.isVertical) ? CLS_VSCROLLCNT : CLS_HSCROLLCNT;
1426
+ innerItem = [].slice.call(item.querySelector('.' + trgClass).children);
1427
+ } else {
1428
+ innerItem = [].slice.call(item.childNodes);
1429
+ }
1430
+ if (this.isVertical) {
1431
+ margin = innerItem[0].offsetHeight + innerItem[2].offsetHeight;
1432
+ } else {
1433
+ margin = innerItem[0].offsetWidth + innerItem[2].offsetWidth; }
1434
+ let tbarWid: number = this.isVertical ? this.element.offsetHeight : this.element.offsetWidth;
1435
+ if (popupNav) {
1436
+ tbarWid -= (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth);
1437
+ let popWid: string = (this.isVertical ? popupNav.offsetHeight : popupNav.offsetWidth) + 'px';
1438
+ innerItem[2].removeAttribute('style');
1439
+ if (this.isVertical) {
1440
+ this.enableRtl ? innerItem[2].style.top = popWid : innerItem[2].style.bottom = popWid;
1441
+ } else {
1442
+ this.enableRtl ? innerItem[2].style.left = popWid : innerItem[2].style.right = popWid; }
1443
+ }
1444
+ if (tbarWid <= margin) { return; }
1445
+ let value: number = (((tbarWid - margin)) - (!this.isVertical ? innerItem[1].offsetWidth : innerItem[1].offsetHeight)) / 2;
1446
+ innerItem[1].removeAttribute('style');
1447
+ let mrgn: Str = ((!this.isVertical ? innerItem[0].offsetWidth : innerItem[0].offsetHeight) + value) + 'px';
1448
+ if (this.isVertical) {
1449
+ this.enableRtl ? innerItem[1].style.marginBottom = mrgn : innerItem[1].style.marginTop = mrgn;
1450
+ } else {
1451
+ this.enableRtl ? innerItem[1].style.marginRight = mrgn : innerItem[1].style.marginLeft = mrgn; }
1452
+ }
1453
+ private tbarItemAlign(item: ItemModel, itemEle: HTEle, pos: number): void {
1454
+ if (item.showAlwaysInPopup && item.overflow !== 'Show') { return; }
1455
+ let alignDiv: HTMLElement[] = [];
1456
+ alignDiv.push(this.createElement('div', { className: CLS_TBARLEFT }));
1457
+ alignDiv.push(this.createElement('div', { className: CLS_TBARCENTER }));
1458
+ alignDiv.push(this.createElement('div', { className: CLS_TBARRIGHT }));
1459
+ if (pos === 0 && item.align !== 'Left') {
1460
+ alignDiv.forEach((ele: HTEle) => {
1461
+ itemEle.appendChild(ele);
1462
+ });
1463
+ this.tbarAlign = true;
1464
+ this.add(itemEle, CLS_TBARPOS);
1465
+ } else if (item.align !== 'Left') {
1466
+ let alignEle: NodeList = itemEle.childNodes;
1467
+ let leftAlign: HTEle = alignDiv[0];
1468
+ [].slice.call(alignEle).forEach((el: HTEle) => {
1469
+ this.tbarAlgEle.lefts.push(el);
1470
+ leftAlign.appendChild(el);
1471
+ });
1472
+ itemEle.appendChild(leftAlign);
1473
+ itemEle.appendChild(alignDiv[1]);
1474
+ itemEle.appendChild(alignDiv[2]);
1475
+ this.tbarAlign = true;
1476
+ this.add(itemEle, CLS_TBARPOS);
1477
+ }
1478
+ }
1479
+ private ctrlTemplate(): void {
1480
+ this.ctrlTem = <HTEle>this.trgtEle.cloneNode(true);
1481
+ this.add(this.trgtEle, CLS_ITEMS);
1482
+ this.tbarEle = [];
1483
+ let innerEle: HTEle[] = [].slice.call(this.trgtEle.children);
1484
+ innerEle.forEach((ele: HTEle) => {
1485
+ if (ele.tagName === 'DIV') {
1486
+ this.tbarEle.push(ele);
1487
+ ele.setAttribute('aria-disabled', 'false');
1488
+ this.add(ele, CLS_ITEM);
1489
+ }
1490
+ });
1491
+ }
1492
+ private renderItems(): void {
1493
+ let ele: HTEle = this.element;
1494
+ let itemEleDom: HTEle;
1495
+ let innerItem: HTEle;
1496
+ let innerPos: HTEle;
1497
+ let items: Item[] = <Item[]>this.items;
1498
+ if (ele && ele.children.length > 0) {
1499
+ itemEleDom = <HTEle>ele.querySelector('.' + CLS_ITEMS);
1500
+ }
1501
+ if (this.trgtEle != null) {
1502
+ this.ctrlTemplate();
1503
+ } else if (ele && items.length > 0) {
1504
+ if (!itemEleDom) {
1505
+ itemEleDom = this.createElement('div', { className: CLS_ITEMS });
1506
+ }
1507
+ for (let i: number = 0; i < items.length; i++) {
1508
+ innerItem = this.renderSubComponent(items[i], i);
1509
+ if (this.tbarEle.indexOf(innerItem) === -1) {
1510
+ this.tbarEle.push(innerItem);
1511
+ }
1512
+ if (!this.tbarAlign) {
1513
+ this.tbarItemAlign(items[i], itemEleDom, i);
1514
+ }
1515
+ innerPos = <HTEle>itemEleDom.querySelector('.e-toolbar-' + items[i].align.toLowerCase());
1516
+ if (innerPos) {
1517
+ if (!(items[i].showAlwaysInPopup && items[i].overflow !== 'Show')) {
1518
+ this.tbarAlgEle[(items[i].align + 's').toLowerCase() as ItmAlign].push(innerItem);
1519
+ }
1520
+ innerPos.appendChild(innerItem);
1521
+ } else {
1522
+ itemEleDom.appendChild(innerItem);
1523
+ }
1524
+ }
1525
+ ele.appendChild(itemEleDom);
1526
+ }
1527
+ }
1528
+ private setAttr(attr: { [key: string]: Str; }, element: HTEle): void {
1529
+ let key: Object[] = Object.keys(attr);
1530
+ let keyVal: Str;
1531
+ for (let i: number = 0; i < key.length; i++) {
1532
+ keyVal = key[i] as Str;
1533
+ keyVal === 'class' ? this.add(element, attr[keyVal]) : element.setAttribute(keyVal, attr[keyVal]);
1534
+ }
1535
+ }
1536
+ /**
1537
+ * Enables or disables the specified Toolbar item.
1538
+ * @param {number|HTMLElement|NodeList} items - DOM element or an array of items to be enabled or disabled.
1539
+ * @param {boolean} isEnable - Boolean value that determines whether the command should be enabled or disabled.
1540
+ * By default, `isEnable` is set to true.
1541
+ * @returns void.
1542
+ */
1543
+ public enableItems(items: number | HTMLElement | NodeList, isEnable?: boolean): void {
1544
+ let elements: NodeList = <NodeList>items;
1545
+ let len: number = elements.length;
1546
+ let ele: HTEle | number;
1547
+ if (isNOU(isEnable)) {
1548
+ isEnable = true;
1549
+ }
1550
+ let enable: Function = (isEnable: Boolean, ele: HTEle) => {
1551
+ if (isEnable) {
1552
+ ele.classList.remove(CLS_DISABLE);
1553
+ ele.setAttribute('aria-disabled', 'false');
1554
+ } else {
1555
+ ele.classList.add(CLS_DISABLE);
1556
+ ele.setAttribute('aria-disabled', 'true');
1557
+ }
1558
+ };
1559
+ if (!isNOU(len) && len >= 1) {
1560
+ for (let a: number = 0, element: HTEle[] = [].slice.call(elements); a < len; a++) {
1561
+ let itemElement: HTEle = element[a];
1562
+ if (typeof (itemElement) === 'number') {
1563
+ ele = this.getElementByIndex(itemElement);
1564
+ if (isNOU(ele)) {
1565
+ return;
1566
+ } else {
1567
+ elements[a] = ele;
1568
+ }
1569
+ } else {
1570
+ ele = itemElement;
1571
+ }
1572
+ enable(isEnable, ele);
1573
+ }
1574
+ isEnable ? removeClass(elements, CLS_DISABLE) : addClass(elements, CLS_DISABLE);
1575
+ } else {
1576
+ if (typeof (elements) === 'number') {
1577
+ ele = this.getElementByIndex(elements);
1578
+ if (isNOU(ele)) {
1579
+ return;
1580
+ }
1581
+ } else {
1582
+ ele = <HTEle>items;
1583
+ }
1584
+ enable(isEnable, ele);
1585
+ }
1586
+ }
1587
+ private getElementByIndex(index: number): HTEle {
1588
+ if (this.tbarEle[index]) {
1589
+ return this.tbarEle[index];
1590
+ }
1591
+ return null;
1592
+ }
1593
+ /**
1594
+ * Adds new items to the Toolbar that accepts an array as Toolbar items.
1595
+ * @param {ItemsModel[]} items - DOM element or an array of items to be added to the Toolbar.
1596
+ * @param {number} index - Number value that determines where the command is to be added. By default, index is 0.
1597
+ * @returns void.
1598
+ */
1599
+ public addItems(items: ItemModel[], index?: number): void {
1600
+ let innerItems: HTEle[];
1601
+ this.extendedOpen();
1602
+ let itemsDiv: HTEle = <HTEle>this.element.querySelector('.' + CLS_ITEMS);
1603
+ if (isNOU(itemsDiv)) {
1604
+ this.itemsRerender(items);
1605
+ return;
1606
+ }
1607
+ let innerEle: HTEle;
1608
+ let itemAgn: Str = 'Left';
1609
+ if (isNOU(index)) {
1610
+ index = 0;
1611
+ }
1612
+ items.forEach((e: ItemModel) => {
1613
+ if (!isNOU(e.align) && e.align !== 'Left' && itemAgn === 'Left') {
1614
+ itemAgn = e.align;
1615
+ }
1616
+ });
1617
+ for (let item of items) {
1618
+ if (isNOU(item.type)) {
1619
+ item.type = 'Button';
1620
+ }
1621
+ innerItems = selectAll('.' + CLS_ITEM, this.element);
1622
+ item.align = <ItemAlign>itemAgn;
1623
+ innerEle = this.renderSubComponent(item, index);
1624
+ if (this.tbarEle.length >= index && innerItems.length >= 0) {
1625
+ if (isNOU(this.scrollModule)) {
1626
+ this.destroyMode(); }
1627
+ let algIndex: number = item.align[0] === 'L' ? 0 : item.align[0] === 'C' ? 1 : 2;
1628
+ let ele: Element;
1629
+ if (!this.tbarAlign && itemAgn !== 'Left') {
1630
+ this.tbarItemAlign(item, itemsDiv, 1);
1631
+ this.tbarAlign = true;
1632
+ ele = closest(innerItems[0], '.' + CLS_ITEMS).children[algIndex];
1633
+ ele.appendChild(innerEle);
1634
+ this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].push(innerEle);
1635
+ this.refreshPositioning();
1636
+ } else if (this.tbarAlign) {
1637
+ ele = closest(innerItems[0] , '.' + CLS_ITEMS).children[algIndex];
1638
+ ele.insertBefore(innerEle, ele.children[index]);
1639
+ this.tbarAlgEle[(item.align + 's').toLowerCase() as ItmAlign].splice(index, 0, innerEle);
1640
+ this.refreshPositioning();
1641
+ } else if (innerItems.length === 0) {
1642
+ innerItems = selectAll('.' + CLS_ITEMS, this.element);
1643
+ innerItems[0].appendChild(innerEle);
1644
+ } else {
1645
+ innerItems[0].parentNode.insertBefore(innerEle, innerItems[index]); }
1646
+ this.items.splice(index, 0, item);
1647
+ this.tbarEle.splice(index, 0, innerEle);
1648
+ index++;
1649
+ this.offsetWid = itemsDiv.offsetWidth;
1650
+ }
1651
+ }
1652
+ itemsDiv.style.width = '';
1653
+ this.renderOverflowMode();
1654
+ }
1655
+ /**
1656
+ * Removes the items from the Toolbar. Acceptable arguments are index of item/HTMLElement/node list.
1657
+ * @param {number|HTMLElement|NodeList|HTMLElement[]} args
1658
+ * Index or DOM element or an Array of item which is to be removed from the Toolbar.
1659
+ * @returns void.
1660
+ */
1661
+ public removeItems(args: number | HTMLElement | NodeList | Element | HTMLElement[]): void {
1662
+ let elements: NodeList = <NodeList>args;
1663
+ let index: number;
1664
+ let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
1665
+ if (typeof (elements) === 'number') {
1666
+ index = parseInt(args.toString(), 10);
1667
+ this.removeItemByIndex(index, innerItems);
1668
+ } else {
1669
+ if (elements && elements.length > 1) {
1670
+ for (let ele of [].slice.call(elements)) {
1671
+ index = this.tbarEle.indexOf(ele);
1672
+ this.removeItemByIndex(index, innerItems);
1673
+ innerItems = selectAll('.' + CLS_ITEM, this.element);
1674
+ }
1675
+ } else {
1676
+ let ele: HTEle = (elements && elements.length && elements.length === 1) ? <HTEle>elements[0] : <HTEle>args;
1677
+ index = innerItems.indexOf(ele);
1678
+ this.removeItemByIndex(index, innerItems);
1679
+ }
1680
+ }
1681
+ this.resize();
1682
+ }
1683
+ private removeItemByIndex(index: number, innerItems: HTEle[]): void {
1684
+ if (this.tbarEle[index] && innerItems[index]) {
1685
+ let eleIdx: number = this.tbarEle.indexOf(innerItems[index]);
1686
+ if (this.tbarAlign) {
1687
+ let indexAgn: number;
1688
+ indexAgn = this.tbarAlgEle[(this.items[eleIdx].align + 's').toLowerCase() as ItmAlign].indexOf(this.tbarEle[eleIdx]);
1689
+ this.tbarAlgEle[(this.items[eleIdx].align + 's').toLowerCase() as ItmAlign].splice(indexAgn, 1);
1690
+ }
1691
+ detach(innerItems[index]);
1692
+ this.items.splice(eleIdx, 1);
1693
+ this.tbarEle.splice(eleIdx, 1);
1694
+ }
1695
+ }
1696
+ private templateRender(templateProp: Object | Str, innerEle: HTEle, item: ItemModel, index: number): void {
1697
+ let itemType: Str = item.type;
1698
+ let eleObj: Template = <Template>templateProp;
1699
+ let isComponent: Boolean;
1700
+ if (typeof (templateProp) === 'object') {
1701
+ isComponent = typeof (eleObj.appendTo) === 'function';
1702
+ }
1703
+ if (typeof (templateProp) === 'string' || !isComponent) {
1704
+ let templateFn: Function;
1705
+ let val: Str = <Str>templateProp;
1706
+ val = (typeof (templateProp) === 'string') ? <Str>templateProp.trim() : <Str>templateProp;
1707
+ let e: Object;
1708
+ try {
1709
+ if (typeof (templateProp) === 'object' && !isNOU((templateProp as HTEle).tagName)) {
1710
+ innerEle.appendChild(templateProp as HTEle);
1711
+ } else if (document.querySelectorAll(val).length) {
1712
+ let ele: Element = document.querySelector(val);
1713
+ let tempStr: Str = ele.outerHTML.trim();
1714
+ innerEle.appendChild(ele);
1715
+ (<HTMLElement>ele).style.display = '';
1716
+ if (!isNOU(tempStr)) {
1717
+ this.tempId.push(val);
1718
+ }
1719
+ }
1720
+ } catch (e) {
1721
+ templateFn = templateCompiler(val);
1722
+ }
1723
+ let tempArray: HTEle[];
1724
+ if (!isNOU(templateFn)) {
1725
+ let toolbarTemplateID: string = this.element.id + index + '_template';
1726
+ tempArray = templateFn({}, this, 'template', toolbarTemplateID, this.isStringTemplate);
1727
+ }
1728
+ if (!isNOU(tempArray) && tempArray.length > 0) {
1729
+ [].slice.call(tempArray).forEach((ele: HTEle): void => {
1730
+ if (!isNOU(ele.tagName)) {
1731
+ ele.style.display = '';
1732
+ }
1733
+ innerEle.appendChild(ele);
1734
+ });
1735
+ }
1736
+ } else if (itemType === 'Input') {
1737
+ let ele: HTEle = this.createElement('input');
1738
+ item.id ? (ele.id = item.id) : (ele.id = getUniqueID('tbr-ipt'));
1739
+ innerEle.appendChild(ele);
1740
+ eleObj.appendTo(ele);
1741
+ }
1742
+ this.add(innerEle, CLS_TEMPLATE);
1743
+ this.tbarEle.push(innerEle);
1744
+ }
1745
+ private buttonRendering(item: ItemModel, innerEle: HTEle): HTEle {
1746
+ let dom: HTEle = this.createElement('button', { className: CLS_TBARBTN });
1747
+ dom.setAttribute('type', 'button');
1748
+ let textStr: Str = item.text;
1749
+ let iconCss: Str;
1750
+ let iconPos: Str;
1751
+ item.id ? (dom.id = item.id) : dom.id = getUniqueID('e-tbr-btn');
1752
+ let btnTxt: HTEle = this.createElement('span', { className: 'e-tbar-btn-text' });
1753
+ if (textStr) {
1754
+ btnTxt.innerHTML = textStr;
1755
+ dom.appendChild(btnTxt);
1756
+ dom.classList.add('e-tbtn-txt');
1757
+ } else {
1758
+ this.add(innerEle, 'e-tbtn-align');
1759
+ }
1760
+ if (item.prefixIcon || item.suffixIcon) {
1761
+ if ((item.prefixIcon && item.suffixIcon) || item.prefixIcon) {
1762
+ iconCss = item.prefixIcon + ' e-icons';
1763
+ iconPos = 'Left';
1764
+ } else {
1765
+ iconCss = item.suffixIcon + ' e-icons';
1766
+ iconPos = 'Right';
1767
+ }
1768
+ }
1769
+ let btnObj: Button = new Button({ iconCss: iconCss, iconPosition: <IconPosition>iconPos });
1770
+ btnObj.createElement = this.createElement;
1771
+ btnObj.appendTo( dom as HTMLButtonElement);
1772
+ if (item.width) {
1773
+ setStyle(dom, { 'width': formatUnit(item.width) });
1774
+ }
1775
+ return dom;
1776
+ }
1777
+ private renderSubComponent(item: ItemModel, index: number): HTEle {
1778
+ let innerEle: HTEle;
1779
+ let dom: HTEle;
1780
+ innerEle = this.createElement('div', { className: CLS_ITEM });
1781
+ innerEle.setAttribute('aria-disabled', 'false');
1782
+ if (!this.tbarEle) {
1783
+ this.tbarEle = [];
1784
+ }
1785
+ if (item.htmlAttributes) {
1786
+ this.setAttr(item.htmlAttributes, innerEle);
1787
+ }
1788
+ if (item.tooltipText) {
1789
+ let tempDom: HTEle = this.createElement('div', {innerHTML: item.tooltipText});
1790
+ innerEle.setAttribute('title', tempDom.textContent );
1791
+ }
1792
+ if (item.cssClass) {
1793
+ innerEle.className = innerEle.className + ' ' + item.cssClass;
1794
+ }
1795
+ if (item.template) {
1796
+ this.templateRender(item.template, innerEle, item, index);
1797
+ } else {
1798
+ switch (item.type) {
1799
+ case 'Button':
1800
+ dom = this.buttonRendering(item, innerEle);
1801
+ dom.setAttribute('tabindex', '-1');
1802
+ dom.setAttribute('aria-label', (item.text || item.tooltipText));
1803
+ innerEle.appendChild(dom);
1804
+ innerEle.addEventListener('click', this.itemClick.bind(this));
1805
+ break;
1806
+ case 'Separator':
1807
+ this.add(innerEle, CLS_SEPARATOR);
1808
+ break;
1809
+ }
1810
+ }
1811
+ if (item.showTextOn) {
1812
+ let sTxt: Str = item.showTextOn;
1813
+ if (sTxt === 'Toolbar') {
1814
+ this.add(innerEle, CLS_POPUPTEXT);
1815
+ this.add(innerEle, 'e-tbtn-align');
1816
+ } else if (sTxt === 'Overflow') {
1817
+ this.add(innerEle, CLS_TBARTEXT);
1818
+ }
1819
+ }
1820
+ if (item.overflow) {
1821
+ let overflow: Str = item.overflow;
1822
+ if (overflow === 'Show') {
1823
+ this.add(innerEle, CLS_TBAROVERFLOW);
1824
+ } else if (overflow === 'Hide') {
1825
+ if (!innerEle.classList.contains(CLS_SEPARATOR)) {
1826
+ this.add(innerEle, CLS_POPOVERFLOW);
1827
+ }
1828
+ }
1829
+ }
1830
+ if (item.overflow !== 'Show' && item.showAlwaysInPopup && !innerEle.classList.contains(CLS_SEPARATOR)) {
1831
+ this.add(innerEle, CLS_POPPRI);
1832
+ this.popupPriCount++;
1833
+ }
1834
+ return innerEle;
1835
+ }
1836
+
1837
+ private refreshToolbarTemplate(): void {
1838
+ let blazorContain: string[] = Object.keys(window) as string[];
1839
+ for (let a: number = 0, length: number = this.items.length; a < length; a++) {
1840
+ let item: ItemModel = this.items[a];
1841
+ if (item.template && blazorContain.indexOf('Blazor') > -1 && !this.isStringTemplate && (<string>item.template).indexOf('<div>Blazor') === 0) {
1842
+ resetBlazorTemplate(this.element.id + a + '_template', 'Template');
1843
+ updateBlazorTemplate(this.element.id + a + '_template', 'Template', item);
1844
+ }
1845
+ }
1846
+ }
1847
+
1848
+ private itemClick(e: Event): void {
1849
+ this.activeEleSwitch(<HTEle>e.currentTarget);
1850
+ }
1851
+ private activeEleSwitch(ele: HTEle): void {
1852
+ this.activeEleRemove(<HTEle>ele.firstElementChild);
1853
+ this.activeEle.focus();
1854
+ }
1855
+ private activeEleRemove(curEle: HTEle): void {
1856
+ if (!isNOU(this.activeEle)) {
1857
+ this.activeEle.setAttribute('tabindex', '-1');
1858
+ }
1859
+ this.activeEle = curEle;
1860
+ if (isNOU(this.trgtEle) && !(<HTEle>curEle.parentElement).classList.contains(CLS_TEMPLATE)) {
1861
+ curEle.removeAttribute('tabindex');
1862
+ } else {
1863
+ this.activeEle.setAttribute('tabindex', '0');
1864
+ }
1865
+ }
1866
+ protected getPersistData(): string {
1867
+ return this.addOnPersist([]);
1868
+ }
1869
+ /**
1870
+ * Returns the current module name.
1871
+ * @returns string
1872
+ * @private
1873
+ */
1874
+ protected getModuleName(): string {
1875
+ return 'toolbar';
1876
+ }
1877
+ private itemsRerender(newProp: ItemModel[]): void {
1878
+ this.items = this.tbarItemsCol;
1879
+ this.destroyMode();
1880
+ this.destroyItems();
1881
+ this.items = newProp;
1882
+ this.tbarItemsCol = this.items;
1883
+ this.renderItems();
1884
+ this.renderOverflowMode();
1885
+ }
1886
+ private resize(): void {
1887
+ let ele: HTEle = this.element;
1888
+ this.tbResize = true;
1889
+ if (this.tbarAlign) { this.itemPositioning(); }
1890
+ if (this.popObj && this.overflowMode === 'Popup') {
1891
+ this.popObj.hide();
1892
+ }
1893
+ let checkOverflow: boolean = this.checkOverflow(ele, ele.getElementsByClassName(CLS_ITEMS)[0] as HTEle);
1894
+ if (!checkOverflow) {
1895
+ this.destroyScroll();
1896
+ let multirowele: HTEle = ele.querySelector('.' + CLS_ITEMS);
1897
+ if (!isNOU(multirowele)) {
1898
+ this.remove(multirowele, CLS_MULTIROWPOS);
1899
+ if (this.tbarAlign) { this.add(multirowele, CLS_TBARPOS); }
1900
+ }
1901
+ }
1902
+ if (checkOverflow && this.scrollModule && (this.offsetWid === ele.offsetWidth)) { return; }
1903
+ if (this.offsetWid > ele.offsetWidth || checkOverflow) {
1904
+ this.renderOverflowMode();
1905
+ }
1906
+ if (this.popObj) {
1907
+ if (this.overflowMode === 'Extended') {
1908
+ let eleStyles: CSSStyleDeclaration = window.getComputedStyle(this.element);
1909
+ this.popObj.width = parseFloat(eleStyles.width) + ((parseFloat(eleStyles.borderRightWidth)) * 2); }
1910
+ if (this.tbarAlign) { this.removePositioning(); }
1911
+ this.popupRefresh(this.popObj.element, false);
1912
+ if (this.tbarAlign) { this.refreshPositioning(); }
1913
+ }
1914
+ this.offsetWid = ele.offsetWidth;
1915
+ this.tbResize = false;
1916
+ this.separator();
1917
+ }
1918
+
1919
+ private extendedOpen(): void {
1920
+ let sib: HTEle = this.element.querySelector('.' + CLS_EXTENDABLECLASS) as HTEle;
1921
+ if (this.overflowMode === 'Extended' && sib) {
1922
+ this.isExtendedOpen = sib.classList.contains(CLS_POPUPOPEN);
1923
+ }
1924
+ }
1925
+
1926
+ /**
1927
+ * Gets called when the model property changes.The data that describes the old and new values of the property that changed.
1928
+ * @param {ToolbarModel} newProp
1929
+ * @param {ToolbarModel} oldProp
1930
+ * @returns void
1931
+ * @private
1932
+ */
1933
+ public onPropertyChanged(newProp: ToolbarModel, oldProp: ToolbarModel): void {
1934
+ let tEle: HTEle = this.element;
1935
+ this.extendedOpen();
1936
+ for (let prop of Object.keys(newProp)) {
1937
+ switch (prop) {
1938
+ case 'items':
1939
+ if (!(newProp.items instanceof Array && oldProp.items instanceof Array)) {
1940
+ let changedProb: Object[] = Object.keys(newProp.items);
1941
+ for (let i: number = 0; i < changedProb.length; i++) {
1942
+ let index: number = parseInt(Object.keys(newProp.items)[i], 10);
1943
+ let property: Str = Object.keys(newProp.items[index])[0];
1944
+ let oldProperty: Str = Object(oldProp.items[index])[property];
1945
+ let newProperty: Str = Object(newProp.items[index])[property];
1946
+ if (this.tbarAlign || property === 'align') {
1947
+ this.refresh();
1948
+ this.trigger('created');
1949
+ break;
1950
+ }
1951
+ let popupPriCheck: Boolean = property === 'showAlwaysInPopup' && !newProperty;
1952
+ let booleanCheck: Boolean = property === 'overflow' && this.popupPriCount !== 0;
1953
+ if ((popupPriCheck) || (this.items[index].showAlwaysInPopup) && booleanCheck) {
1954
+ --this.popupPriCount;
1955
+ }
1956
+ if (isNOU(this.scrollModule)) {
1957
+ this.destroyMode(); }
1958
+ let itemCol: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEMS + ' .' + CLS_ITEM, tEle));
1959
+ detach(itemCol[index]);
1960
+ this.tbarEle.splice(index, 1);
1961
+ this.addItems([this.items[index]], index);
1962
+ this.items.splice(index, 1);
1963
+ if (this.items[index].template) {
1964
+ this.tbarEle.splice(this.items.length, 1);
1965
+ }
1966
+ }
1967
+ } else {
1968
+ this.itemsRerender(newProp.items);
1969
+ }
1970
+ break;
1971
+ case 'width':
1972
+ let wid: number = tEle.offsetWidth;
1973
+ setStyle(tEle, { 'width': formatUnit(newProp.width) });
1974
+ this.renderOverflowMode();
1975
+ if (this.popObj && wid < tEle.offsetWidth) {
1976
+ this.popupRefresh(this.popObj.element, false);
1977
+ }
1978
+ break;
1979
+ case 'height':
1980
+ setStyle(this.element, { 'height': formatUnit(newProp.height) });
1981
+ break;
1982
+ case 'overflowMode':
1983
+ this.destroyMode();
1984
+ this.renderOverflowMode();
1985
+ if (this.enableRtl) {
1986
+ this.add(tEle, CLS_RTL);
1987
+ }
1988
+ this.refreshOverflow();
1989
+ break;
1990
+ case 'enableRtl':
1991
+ newProp.enableRtl ? this.add(tEle, CLS_RTL) : this.remove(tEle, CLS_RTL);
1992
+ if (!isNOU(this.scrollModule)) {
1993
+ newProp.enableRtl ? this.add(this.scrollModule.element, CLS_RTL) : this.remove(this.scrollModule.element, CLS_RTL);
1994
+ }
1995
+ if (!isNOU(this.popObj)) {
1996
+ newProp.enableRtl ? this.add(this.popObj.element, CLS_RTL) : this.remove(this.popObj.element, CLS_RTL);
1997
+ }
1998
+ if (this.tbarAlign) { this.itemPositioning(); }
1999
+ break;
2000
+ case 'scrollStep':
2001
+ if (this.scrollModule) {
2002
+ this.scrollModule.scrollStep = this.scrollStep;
2003
+ }
2004
+ break;
2005
+ case 'enableCollision':
2006
+ if (this.popObj) {
2007
+ this.popObj.collision = { Y: this.enableCollision ? 'flip' : 'none' };
2008
+ }
2009
+ break;
2010
+ }
2011
+ }
2012
+ }
2013
+ /**
2014
+ * Shows or hides the Toolbar item that is in the specified index.
2015
+ * @param {number | HTMLElement} index - Index value of target item or DOM element of items to be hidden or shown.
2016
+ * @param {boolean} value - Based on this Boolean value, item will be hide (true) or show (false). By default, value is false.
2017
+ * @returns void.
2018
+ */
2019
+ public hideItem(index: number| HTMLElement | Element, value?: boolean): void {
2020
+ let isElement: boolean = (typeof (index) === 'object') ? true : false;
2021
+ let eleIndex: number = index as number;
2022
+ let initIndex: number;
2023
+ let ele: HTMLElement;
2024
+ let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2025
+ if (isElement) {
2026
+ ele = (index as HTMLElement);
2027
+ } else if (this.tbarEle[eleIndex]) {
2028
+ let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2029
+ ele = innerItems[eleIndex];
2030
+ }
2031
+ if (ele) {
2032
+ value ? ele.classList.add(CLS_HIDDEN) : ele.classList.remove(CLS_HIDDEN);
2033
+ if (value && isNOU(this.element.getAttribute('tabindex')) && !ele.classList.contains(CLS_SEPARATOR)) {
2034
+ if (isNOU(ele.firstElementChild.getAttribute('tabindex'))) {
2035
+ ele.firstElementChild.setAttribute('tabindex', '-1');
2036
+ let innerItems: HTEle[] = [].slice.call(selectAll('.' + CLS_ITEM, this.element));
2037
+ if (isElement) {
2038
+ eleIndex = innerItems.indexOf(ele);
2039
+ }
2040
+ let nextEle: HTEle = innerItems[++eleIndex];
2041
+ while (nextEle) {
2042
+ let skipEle: string | boolean = this.eleContains(nextEle);
2043
+ if (!skipEle) {
2044
+ nextEle.firstElementChild.removeAttribute('tabindex');
2045
+ break;
2046
+ }
2047
+ nextEle = innerItems[++eleIndex];
2048
+ }
2049
+ }
2050
+ } else if (isNOU(this.element.getAttribute('tabindex')) && !ele.classList.contains(CLS_SEPARATOR)) {
2051
+ initIndex = 0;
2052
+ let setFlag: boolean = false;
2053
+ let removeFlag: boolean = false;
2054
+ let initELe: HTEle = innerItems[initIndex];
2055
+ while (initELe) {
2056
+ if (!initELe.classList.contains(CLS_SEPARATOR)) {
2057
+ if (isNOU(initELe.firstElementChild.getAttribute('tabindex'))) {
2058
+ initELe.firstElementChild.setAttribute('tabindex', '-1');
2059
+ setFlag = true;
2060
+ } else {
2061
+ if (setFlag && removeFlag) { break; }
2062
+ let skipEle: string | boolean = this.eleContains(initELe);
2063
+ if (!skipEle) {
2064
+ initELe.firstElementChild.removeAttribute('tabindex');
2065
+ removeFlag = true;
2066
+ }
2067
+ initELe = innerItems[++initIndex];
2068
+ }
2069
+ } else {
2070
+ initELe = innerItems[++initIndex];
2071
+ }
2072
+ }
2073
+ }
2074
+ this.refreshOverflow(); }
2075
+ }
2076
+ }