@syncfusion/ej2-filemanager 30.1.37 → 30.1.39

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 (148) hide show
  1. package/dist/ej2-filemanager.min.js +2 -2
  2. package/dist/ej2-filemanager.umd.min.js +2 -2
  3. package/dist/ej2-filemanager.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-filemanager.es2015.js +8 -3
  5. package/dist/es6/ej2-filemanager.es2015.js.map +1 -1
  6. package/dist/es6/ej2-filemanager.es5.js +7 -2
  7. package/dist/es6/ej2-filemanager.es5.js.map +1 -1
  8. package/dist/global/ej2-filemanager.min.js +2 -2
  9. package/dist/global/ej2-filemanager.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/package.json +17 -52
  12. package/src/file-manager/common/utility.js +3 -0
  13. package/src/file-manager/layout/navigation-pane.js +4 -2
  14. package/styles/bds-lite.css +11 -12
  15. package/styles/bds.css +11 -12
  16. package/styles/bootstrap-dark-lite.css +11 -12
  17. package/styles/bootstrap-dark.css +11 -12
  18. package/styles/bootstrap-lite.css +11 -12
  19. package/styles/bootstrap.css +11 -12
  20. package/styles/bootstrap4-lite.css +11 -12
  21. package/styles/bootstrap4.css +11 -12
  22. package/styles/bootstrap5-dark-lite.css +11 -12
  23. package/styles/bootstrap5-dark.css +11 -12
  24. package/styles/bootstrap5-lite.css +11 -12
  25. package/styles/bootstrap5.3-lite.css +11 -12
  26. package/styles/bootstrap5.3.css +11 -12
  27. package/styles/bootstrap5.css +11 -12
  28. package/styles/fabric-dark-lite.css +11 -12
  29. package/styles/fabric-dark.css +11 -12
  30. package/styles/fabric-lite.css +11 -12
  31. package/styles/fabric.css +11 -12
  32. package/styles/file-manager/_layout.scss +7 -7
  33. package/styles/file-manager/bds.css +11 -12
  34. package/styles/file-manager/bootstrap-dark.css +11 -12
  35. package/styles/file-manager/bootstrap.css +11 -12
  36. package/styles/file-manager/bootstrap4.css +11 -12
  37. package/styles/file-manager/bootstrap5-dark.css +11 -12
  38. package/styles/file-manager/bootstrap5.3.css +11 -12
  39. package/styles/file-manager/bootstrap5.css +11 -12
  40. package/styles/file-manager/fabric-dark.css +11 -12
  41. package/styles/file-manager/fabric.css +11 -12
  42. package/styles/file-manager/fluent-dark.css +11 -12
  43. package/styles/file-manager/fluent.css +11 -12
  44. package/styles/file-manager/fluent2.css +11 -12
  45. package/styles/file-manager/highcontrast-light.css +11 -12
  46. package/styles/file-manager/highcontrast.css +11 -12
  47. package/styles/file-manager/material-dark.css +11 -12
  48. package/styles/file-manager/material.css +11 -12
  49. package/styles/file-manager/material3-dark.css +11 -12
  50. package/styles/file-manager/material3.css +11 -12
  51. package/styles/file-manager/tailwind-dark.css +11 -12
  52. package/styles/file-manager/tailwind.css +11 -12
  53. package/styles/file-manager/tailwind3.css +11 -12
  54. package/styles/fluent-dark-lite.css +11 -12
  55. package/styles/fluent-dark.css +11 -12
  56. package/styles/fluent-lite.css +11 -12
  57. package/styles/fluent.css +11 -12
  58. package/styles/fluent2-lite.css +11 -12
  59. package/styles/fluent2.css +11 -12
  60. package/styles/highcontrast-light-lite.css +11 -12
  61. package/styles/highcontrast-light.css +11 -12
  62. package/styles/highcontrast-lite.css +11 -12
  63. package/styles/highcontrast.css +11 -12
  64. package/styles/material-dark-lite.css +11 -12
  65. package/styles/material-dark.css +11 -12
  66. package/styles/material-lite.css +11 -12
  67. package/styles/material.css +11 -12
  68. package/styles/material3-dark-lite.css +11 -12
  69. package/styles/material3-dark.css +11 -12
  70. package/styles/material3-lite.css +11 -12
  71. package/styles/material3.css +11 -12
  72. package/styles/tailwind-dark-lite.css +11 -12
  73. package/styles/tailwind-dark.css +11 -12
  74. package/styles/tailwind-lite.css +11 -12
  75. package/styles/tailwind.css +11 -12
  76. package/styles/tailwind3-lite.css +11 -12
  77. package/styles/tailwind3.css +11 -12
  78. package/dist/ts/file-manager/actions/breadcrumb-bar.d.ts +0 -60
  79. package/dist/ts/file-manager/actions/breadcrumb-bar.ts +0 -423
  80. package/dist/ts/file-manager/actions/index.d.ts +0 -6
  81. package/dist/ts/file-manager/actions/index.ts +0 -6
  82. package/dist/ts/file-manager/actions/toolbar.d.ts +0 -54
  83. package/dist/ts/file-manager/actions/toolbar.ts +0 -609
  84. package/dist/ts/file-manager/actions/virtualization.d.ts +0 -93
  85. package/dist/ts/file-manager/actions/virtualization.ts +0 -324
  86. package/dist/ts/file-manager/base/classes.d.ts +0 -224
  87. package/dist/ts/file-manager/base/classes.ts +0 -225
  88. package/dist/ts/file-manager/base/constant.d.ts +0 -136
  89. package/dist/ts/file-manager/base/constant.ts +0 -137
  90. package/dist/ts/file-manager/base/file-manager-model.d.ts +0 -520
  91. package/dist/ts/file-manager/base/file-manager.d.ts +0 -867
  92. package/dist/ts/file-manager/base/file-manager.ts +0 -2061
  93. package/dist/ts/file-manager/base/index.d.ts +0 -8
  94. package/dist/ts/file-manager/base/index.ts +0 -8
  95. package/dist/ts/file-manager/base/interface.d.ts +0 -952
  96. package/dist/ts/file-manager/base/interface.ts +0 -931
  97. package/dist/ts/file-manager/common/index.d.ts +0 -5
  98. package/dist/ts/file-manager/common/index.ts +0 -5
  99. package/dist/ts/file-manager/common/operations.d.ts +0 -122
  100. package/dist/ts/file-manager/common/operations.ts +0 -1369
  101. package/dist/ts/file-manager/common/utility.d.ts +0 -644
  102. package/dist/ts/file-manager/common/utility.ts +0 -1728
  103. package/dist/ts/file-manager/index.d.ts +0 -9
  104. package/dist/ts/file-manager/index.ts +0 -9
  105. package/dist/ts/file-manager/layout/details-view.d.ts +0 -152
  106. package/dist/ts/file-manager/layout/details-view.ts +0 -1990
  107. package/dist/ts/file-manager/layout/index.d.ts +0 -6
  108. package/dist/ts/file-manager/layout/index.ts +0 -6
  109. package/dist/ts/file-manager/layout/large-icons-view.d.ts +0 -157
  110. package/dist/ts/file-manager/layout/large-icons-view.ts +0 -1684
  111. package/dist/ts/file-manager/layout/navigation-pane.d.ts +0 -104
  112. package/dist/ts/file-manager/layout/navigation-pane.ts +0 -919
  113. package/dist/ts/file-manager/models/ajax-settings-model.d.ts +0 -36
  114. package/dist/ts/file-manager/models/ajax-settings.d.ts +0 -30
  115. package/dist/ts/file-manager/models/ajax-settings.ts +0 -39
  116. package/dist/ts/file-manager/models/column-model.d.ts +0 -155
  117. package/dist/ts/file-manager/models/column.d.ts +0 -179
  118. package/dist/ts/file-manager/models/column.ts +0 -216
  119. package/dist/ts/file-manager/models/contextMenu-settings-model.d.ts +0 -36
  120. package/dist/ts/file-manager/models/contextMenu-settings.d.ts +0 -33
  121. package/dist/ts/file-manager/models/contextMenu-settings.ts +0 -44
  122. package/dist/ts/file-manager/models/default-locale.d.ts +0 -4
  123. package/dist/ts/file-manager/models/default-locale.ts +0 -101
  124. package/dist/ts/file-manager/models/details-view-settings-model.d.ts +0 -30
  125. package/dist/ts/file-manager/models/details-view-settings.d.ts +0 -31
  126. package/dist/ts/file-manager/models/details-view-settings.ts +0 -54
  127. package/dist/ts/file-manager/models/index.d.ts +0 -19
  128. package/dist/ts/file-manager/models/index.ts +0 -19
  129. package/dist/ts/file-manager/models/navigation-pane-settings-model.d.ts +0 -40
  130. package/dist/ts/file-manager/models/navigation-pane-settings.d.ts +0 -34
  131. package/dist/ts/file-manager/models/navigation-pane-settings.ts +0 -42
  132. package/dist/ts/file-manager/models/search-settings-model.d.ts +0 -42
  133. package/dist/ts/file-manager/models/search-settings.d.ts +0 -44
  134. package/dist/ts/file-manager/models/search-settings.ts +0 -53
  135. package/dist/ts/file-manager/models/toolbar-settings-model.d.ts +0 -197
  136. package/dist/ts/file-manager/models/toolbar-settings.d.ts +0 -174
  137. package/dist/ts/file-manager/models/toolbar-settings.ts +0 -198
  138. package/dist/ts/file-manager/models/upload-settings-model.d.ts +0 -70
  139. package/dist/ts/file-manager/models/upload-settings.d.ts +0 -61
  140. package/dist/ts/file-manager/models/upload-settings.ts +0 -75
  141. package/dist/ts/file-manager/pop-up/context-menu.d.ts +0 -64
  142. package/dist/ts/file-manager/pop-up/context-menu.ts +0 -693
  143. package/dist/ts/file-manager/pop-up/dialog.d.ts +0 -31
  144. package/dist/ts/file-manager/pop-up/dialog.ts +0 -1009
  145. package/dist/ts/file-manager/pop-up/index.d.ts +0 -5
  146. package/dist/ts/file-manager/pop-up/index.ts +0 -5
  147. package/dist/ts/index.d.ts +0 -4
  148. package/dist/ts/index.ts +0 -4
@@ -1,609 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { Toolbar as BaseToolbar, ItemModel, ClickEventArgs, MenuEventArgs, DisplayMode } from '@syncfusion/ej2-navigations';
3
- import { select, isNullOrUndefined as isNOU, closest, selectAll } from '@syncfusion/ej2-base';
4
- import { createDialog } from '../pop-up/dialog';
5
- import * as events from '../base/constant';
6
- import * as CLS from '../base/classes';
7
- import { IFileManager, NotifyArgs, ToolbarClickEventArgs, ToolbarCreateEventArgs } from '../base/interface';
8
- import { refresh, getPathObject, getLocaleText, getCssClass, sortbyClickHandler } from '../common/utility';
9
- import { createDeniedDialog, updateLayout } from '../common/utility';
10
- import { GetDetails } from '../common/operations';
11
- import { DropDownButton, ItemModel as SplitButtonItemModel } from '@syncfusion/ej2-splitbuttons';
12
- import { cutFiles, copyFiles, pasteHandler, hasEditAccess } from '../common/index';
13
- import { doDownload, createNewFolder, uploadItem } from '../common/index';
14
- import { ToolbarItem, ToolbarItemModel } from '../models';
15
-
16
- /**
17
- * Toolbar module
18
- */
19
- export class Toolbar {
20
-
21
- /* Internal variables */
22
- private parent: IFileManager;
23
- private items: ItemModel[];
24
- private buttonObj: DropDownButton;
25
- private layoutBtnObj: DropDownButton;
26
- private default: string[] = ['Delete', 'Rename', 'Download', 'Cut', 'Copy', 'Paste'];
27
- private single: string[] = ['Delete', 'Rename', 'Download', 'Cut', 'Copy'];
28
- private multiple: string[] = ['Delete', 'Download', 'Cut', 'Copy', 'Refresh'];
29
- private selection: string[] = ['NewFolder', 'Upload', 'SortBy', 'Refresh'];
30
-
31
- /* public variable */
32
- public toolbarObj: BaseToolbar;
33
-
34
- /**
35
- * Constructor for the Toolbar module
36
- *
37
- * @hidden
38
- * @param {IFileManager} parent - specifies the parent element.
39
- * @private
40
- */
41
- constructor(parent?: IFileManager) {
42
- this.parent = parent;
43
- this.render();
44
- this.addEventListener();
45
- }
46
-
47
- private render(): void {
48
- this.items = this.toolbarItemData(this.getItems(this.parent.toolbarSettings.items.map((item: string) => item.trim())));
49
- const eventArgs: ToolbarCreateEventArgs = { items: this.items };
50
- this.parent.trigger('toolbarCreate', eventArgs, (toolbarCreateArgs: ToolbarCreateEventArgs) => {
51
- this.items = toolbarCreateArgs.items;
52
- this.toolbarObj = new BaseToolbar({
53
- items: this.items,
54
- created: this.toolbarCreateHandler.bind(this),
55
- overflowMode: 'Popup',
56
- clicked: this.onClicked.bind(this),
57
- enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
58
- enableRtl: this.parent.enableRtl
59
- });
60
- this.toolbarObj.isStringTemplate = true;
61
- this.toolbarObj.root = this.parent.root ? this.parent.root : this.parent;
62
- this.toolbarObj.appendTo('#' + this.parent.element.id + CLS.TOOLBAR_ID);
63
- });
64
- }
65
-
66
- public getItemIndex(item: string): number {
67
- const itemId: string = this.getId(item);
68
- for (let i: number = 0; i < this.items.length; i++) {
69
- if (this.items[i as number].id === itemId) {
70
- return i;
71
- }
72
- }
73
- return -1;
74
- }
75
-
76
- private getItems(items: string[]): string[] {
77
- let currItems: string[] = items.slice();
78
- if (this.parent.isDevice && this.parent.allowMultiSelection) { currItems.push('SelectAll'); }
79
- if (this.parent.toolbarItems.length > 0) {
80
- currItems = this.parent.toolbarItems.map((item: ToolbarItem) => item.name);
81
- }
82
- return currItems;
83
- }
84
- /* istanbul ignore next */
85
- private onClicked(args: ClickEventArgs): void {
86
- if (isNOU(args.item) || !args.item.id) { return; }
87
- const tool: string = args.item.id.substr((this.parent.element.id + '_tb_').length);
88
- let details: Object[];
89
- if (tool === 'refresh' || tool === 'newfolder' || tool === 'upload') {
90
- details = [getPathObject(this.parent)];
91
- this.parent.itemData = details;
92
- } else {
93
- this.parent.notify(events.selectedData, {});
94
- details = this.parent.itemData;
95
- }
96
- const eventArgs: ToolbarClickEventArgs = { cancel: false, fileDetails: details, item: args.item };
97
- this.parent.trigger('toolbarClick', eventArgs, (toolbarClickArgs: ToolbarClickEventArgs) => {
98
- let sItems: string[];
99
- let target: Element;
100
- if (!toolbarClickArgs.cancel) {
101
- switch (tool) {
102
- case 'sortby':
103
- target = closest((args.originalEvent.target as Element), '.' + CLS.TB_ITEM);
104
- if (target && target.classList.contains('e-toolbar-popup')) {
105
- args.cancel = true;
106
- }
107
- break;
108
- case 'newfolder':
109
- createNewFolder(this.parent);
110
- break;
111
- case 'cut':
112
- cutFiles(this.parent);
113
- break;
114
- case 'copy':
115
- copyFiles(this.parent);
116
- break;
117
- case 'delete':
118
- for (let i: number = 0; i < details.length; i++) {
119
- if (!hasEditAccess(details[i as number])) {
120
- createDeniedDialog(this.parent, details[i as number], events.permissionEdit);
121
- return;
122
- }
123
- }
124
- createDialog(this.parent, 'Delete');
125
- break;
126
- case 'details':
127
- this.parent.notify(events.detailsInit, {});
128
- sItems = this.parent.selectedItems;
129
- if (this.parent.activeModule === 'navigationpane') {
130
- sItems = [];
131
- }
132
- GetDetails(this.parent, sItems, this.parent.path, 'details');
133
- break;
134
- case 'paste':
135
- this.parent.folderPath = '';
136
- pasteHandler(this.parent);
137
- break;
138
- case 'refresh':
139
- refresh(this.parent);
140
- break;
141
- case 'download':
142
- doDownload(this.parent);
143
- break;
144
- case 'rename':
145
- if (!hasEditAccess(details[0])) {
146
- createDeniedDialog(this.parent, details[0], events.permissionEdit);
147
- } else {
148
- this.parent.notify(events.renameInit, {});
149
- createDialog(this.parent, 'Rename');
150
- }
151
- break;
152
- case 'upload':
153
- uploadItem(this.parent);
154
- break;
155
- case 'selectall':
156
- this.parent.notify(events.selectAllInit, {});
157
- break;
158
- case 'selection':
159
- this.parent.notify(events.clearAllInit, {});
160
- break;
161
- }
162
- }
163
- });
164
- }
165
-
166
- private toolbarCreateHandler(): void {
167
- if (!isNOU(select('#' + this.getId('SortBy'), this.parent.element))) {
168
- const items: SplitButtonItemModel[] = [
169
- { id: this.getPupupId('name'), text: getLocaleText(this.parent, 'Name'),
170
- iconCss: this.parent.sortBy === 'name' ? CLS.TB_OPTION_DOT : '' },
171
- { id: this.getPupupId('size'), text: getLocaleText(this.parent, 'Size'),
172
- iconCss: this.parent.sortBy === 'size' ? CLS.TB_OPTION_DOT : '' },
173
- { id: this.getPupupId('date'), text: getLocaleText(this.parent, 'DateModified'),
174
- iconCss: this.parent.sortBy === '_fm_modified' ? CLS.TB_OPTION_DOT : '' },
175
- { separator: true },
176
- { id: this.getPupupId('ascending'), text: getLocaleText(this.parent, 'Ascending'),
177
- iconCss: this.parent.sortOrder === 'Ascending' ? CLS.TB_OPTION_TICK : '' },
178
- { id: this.getPupupId('descending'), text: getLocaleText(this.parent, 'Descending'),
179
- iconCss: this.parent.sortOrder === 'Descending' ? CLS.TB_OPTION_TICK : '' },
180
- { id: this.getPupupId('none'), text: getLocaleText(this.parent, 'None'),
181
- iconCss: this.parent.sortOrder === 'None' ? CLS.TB_OPTION_TICK : '' }
182
- ];
183
- this.buttonObj = new DropDownButton({
184
- items: items, cssClass: getCssClass(this.parent, CLS.ROOT_POPUP),
185
- select: sortbyClickHandler.bind(this, this.parent as IFileManager),
186
- enableHtmlSanitizer: this.parent.enableHtmlSanitizer,
187
- enableRtl: this.parent.enableRtl, iconCss: CLS.ICON_SHORTBY
188
- });
189
- this.buttonObj.isStringTemplate = true;
190
- this.buttonObj.appendTo('#' + this.getId('SortBy'));
191
- }
192
- if (!isNOU(select('#' + this.getId('View'), this.parent.element))) {
193
- const gridSpan: string = '<span class="' + CLS.ICON_GRID + ' ' + CLS.MENU_ICON + '"></span>';
194
- const largeIconSpan: string = '<span class="' + CLS.ICON_LARGE + ' ' + CLS.MENU_ICON + '"></span>';
195
- const layoutItems: SplitButtonItemModel[] = [
196
- {
197
- id: this.getPupupId('large'), text: getLocaleText(this.parent, 'View-LargeIcons'),
198
- iconCss: this.parent.view === 'Details' ? '' : CLS.TB_OPTION_TICK
199
- },
200
- {
201
- id: this.getPupupId('details'), text: getLocaleText(this.parent, 'View-Details'),
202
- iconCss: this.parent.view === 'Details' ? CLS.TB_OPTION_TICK : ''
203
- }
204
- ];
205
- this.layoutBtnObj = new DropDownButton({
206
- iconCss: this.parent.view === 'Details' ? CLS.ICON_GRID : CLS.ICON_LARGE,
207
- cssClass: getCssClass(this.parent, 'e-caret-hide ' + CLS.ROOT_POPUP),
208
- items: layoutItems, select: this.layoutChange.bind(this),
209
- enableRtl: this.parent.enableRtl,
210
- content: '<span class="e-tbar-btn-text">' + getLocaleText(this.parent, 'View') + '</span>',
211
- beforeItemRender: (args: MenuEventArgs) => {
212
- const tickIcon: string = args.item.iconCss;
213
- const viewText: boolean = args.item.text === getLocaleText(this.parent, 'View-LargeIcons');
214
- const iconClass: string = tickIcon ? ' e-menu-icon ' + tickIcon : '';
215
- args.element.innerHTML = '<span class="' + iconClass + '"></span>' + (viewText ? largeIconSpan : gridSpan) + args.item.text;
216
- const span: HTMLElement = args.element.firstChild as HTMLElement;
217
- if (span && span.className === '') {
218
- args.element.removeChild(span);
219
- }
220
- }
221
- });
222
- this.layoutBtnObj.isStringTemplate = true;
223
- this.layoutBtnObj.appendTo('#' + this.getId('View'));
224
- }
225
- this.hideItems(this.default, true);
226
- this.hideStatus();
227
- if ((this as any).parent.portals && (this.toolbarObj as any).portals) {
228
- (this as any).parent.portals = (this as any).parent.portals.concat((this.toolbarObj as any).portals);
229
- (this.parent as any)['renderReactTemplates']();
230
- }
231
- const btnElement: HTMLInputElement[] = (selectAll('.e-btn', this.toolbarObj.element) as HTMLInputElement[]);
232
- for (let btnCount: number = 0; btnCount < btnElement.length; btnCount++) {
233
- /* istanbul ignore next */
234
- btnElement[btnCount as number].onkeydown = (e: KeyboardEvent) => {
235
- if (e.keyCode === 13 && !(<HTMLElement>e.target).classList.contains('e-fe-popup')) {
236
- e.preventDefault();
237
- }
238
- };
239
- btnElement[btnCount as number].onkeyup = (e: KeyboardEvent) => {
240
- if (e.keyCode === 13 && !(<HTMLElement>e.target).classList.contains('e-fe-popup')) {
241
- btnElement[btnCount as number].click();
242
- }
243
- };
244
- }
245
- this.parent.refreshLayout();
246
- }
247
-
248
- private updateSortByButton(): void {
249
- if (this.buttonObj) {
250
- const items: SplitButtonItemModel[] = this.buttonObj.items;
251
- for (let itemCount: number = 0; itemCount < items.length; itemCount++) {
252
- if (items[itemCount as number].id === this.getPupupId('name')) {
253
- items[itemCount as number].iconCss = this.parent.sortBy === 'name' ? CLS.TB_OPTION_DOT : '';
254
- } else if (items[itemCount as number].id === this.getPupupId('size')) {
255
- items[itemCount as number].iconCss = this.parent.sortBy === 'size' ? CLS.TB_OPTION_DOT : '';
256
- } else if (items[itemCount as number].id === this.getPupupId('date')) {
257
- if (this.parent.sortBy === 'dateModified' || this.parent.sortBy === 'dateCreated') {
258
- items[itemCount as number].iconCss = this.parent.sortBy === this.parent.sortBy ? CLS.TB_OPTION_DOT : '';
259
- }
260
- else {
261
- items[itemCount as number].iconCss = this.parent.sortBy === '_fm_modified' ? CLS.TB_OPTION_DOT : '';
262
- }
263
- } else if (items[itemCount as number].id === this.getPupupId('ascending')) {
264
- items[itemCount as number].iconCss = this.parent.sortOrder === 'Ascending' ? CLS.TB_OPTION_TICK : '';
265
- } else if (items[itemCount as number].id === this.getPupupId('descending')) {
266
- items[itemCount as number].iconCss = this.parent.sortOrder === 'Descending' ? CLS.TB_OPTION_TICK : '';
267
- } else if (items[itemCount as number].id === this.getPupupId('none')) {
268
- items[itemCount as number].iconCss = this.parent.sortOrder === 'None' ? CLS.TB_OPTION_TICK : '';
269
- }
270
- }
271
- }
272
- }
273
-
274
- private getPupupId(id: string): string {
275
- return this.parent.element.id + '_ddl_' + id.toLowerCase();
276
- }
277
-
278
- private layoutChange(args: MenuEventArgs): void {
279
- if (this.parent.view === 'Details') {
280
- if (args.item.id === this.getPupupId('large')) {
281
- updateLayout(this.parent, 'LargeIcons');
282
- }
283
- } else {
284
- if (args.item.id === this.getPupupId('details')) {
285
- updateLayout(this.parent, 'Details');
286
- }
287
- }
288
- }
289
-
290
- private toolbarItemData(data: string[]): ItemModel[] {
291
- const items: ItemModel[] = [];
292
- let mode: DisplayMode = 'Both';
293
- if (this.parent.isMobile) {
294
- mode = 'Overflow';
295
- }
296
- for (let i: number = 0; i < data.length; i++) {
297
- let item: ItemModel;
298
- let propItem: ToolbarItemModel;
299
- if (this.parent.toolbarItems.length > 0) {
300
- propItem = this.getItemModel(this.parent.toolbarItems[parseInt(i.toString(), 10)]);
301
- }
302
- const itemId: string = this.getId(data[i as number]);
303
- const itemText: string = getLocaleText(this.parent, data[i as number]);
304
- const itemTooltip: string = getLocaleText(this.parent, 'Tooltip-' + data[i as number]);
305
- switch (data[i as number]) {
306
- case '|':
307
- item = { type: 'Separator' };
308
- break;
309
- case 'Upload':
310
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_UPLOAD, showTextOn: mode };
311
- break;
312
- case 'SortBy': {
313
- let spanElement: string = '<span class="e-tbar-btn-text e-tbar-ddb-text">' + itemText + '</span>';
314
- if (propItem && propItem.text) {
315
- spanElement = '<span class="e-tbar-btn-text e-tbar-ddb-text">' + propItem.text + '</span>';
316
- }
317
- item = {
318
- id: itemId, tooltipText: itemTooltip,
319
- template: '<button id="' + itemId + '" class="e-tbar-btn e-tbtn-txt" tabindex="-1">' + spanElement + '</button>'
320
- };
321
- break;
322
- }
323
- case 'Refresh':
324
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_REFRESH, showTextOn: mode };
325
- break;
326
- case 'Selection':
327
- item = {
328
- id: itemId, text: itemText, tooltipText: itemTooltip, suffixIcon: CLS.ICON_CLEAR, overflow: 'Show',
329
- align: 'Right'
330
- };
331
- break;
332
- case 'View': {
333
- let viewText: string;
334
- if (propItem && propItem.text) {
335
- viewText = propItem.text;
336
- } else {
337
- viewText = getLocaleText(this.parent, 'View');
338
- }
339
- item = {
340
- id: itemId, tooltipText: itemTooltip, prefixIcon: this.parent.view === 'Details' ? CLS.ICON_GRID : CLS.ICON_LARGE,
341
- overflow: 'Show', align: 'Right', text: itemText, showTextOn: 'Overflow',
342
- template: '<button id="' + itemId + '" class="e-tbar-btn e-tbtn-txt" tabindex="-1" aria-label=' +
343
- viewText + '></button>'
344
- };
345
- break;
346
- }
347
- case 'Details':
348
- item = {
349
- id: itemId, tooltipText: itemTooltip, prefixIcon: CLS.ICON_DETAILS, overflow: 'Show', align: 'Right',
350
- text: itemText, showTextOn: 'Overflow'
351
- };
352
- break;
353
- case 'NewFolder':
354
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_NEWFOLDER, showTextOn: mode };
355
- break;
356
- case 'Cut':
357
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_CUT, showTextOn: mode };
358
- break;
359
- case 'Copy':
360
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_COPY, showTextOn: mode };
361
- break;
362
- case 'Paste':
363
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_PASTE, showTextOn: mode };
364
- break;
365
- case 'Delete':
366
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_DELETE, showTextOn: mode };
367
- break;
368
- case 'Rename':
369
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_RENAME, showTextOn: mode };
370
- break;
371
- case 'Download':
372
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_DOWNLOAD, showTextOn: mode };
373
- break;
374
- case 'SelectAll':
375
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, prefixIcon: CLS.ICON_SELECTALL, showTextOn: mode };
376
- break;
377
- default:
378
- item = { id: itemId, text: itemText, tooltipText: itemTooltip, template: '' };
379
- break;
380
- }
381
- if (this.parent.toolbarItems.length > 0 && propItem) {
382
- const mergedItems: ToolbarItemModel = Object.assign({}, item, propItem);
383
- items.push(mergedItems);
384
- }
385
- else {
386
- items.push(item);
387
- }
388
- }
389
- return items;
390
- }
391
-
392
- private getItemModel(propItem: ToolbarItemModel): ToolbarItemModel {
393
- const item: ToolbarItemModel = {};
394
- if (propItem.id) {
395
- item.id = propItem.id;
396
- }
397
- if (propItem.text) {
398
- item.text = propItem.text;
399
- }
400
- if (propItem.tooltipText) {
401
- item.tooltipText = propItem.tooltipText;
402
- }
403
- if (propItem.prefixIcon) {
404
- item.prefixIcon = propItem.prefixIcon;
405
- }
406
- if (propItem.cssClass) {
407
- item.cssClass = propItem.cssClass;
408
- }
409
- if (propItem.showTextOn !== 'Both') {
410
- item.showTextOn = propItem.showTextOn;
411
- }
412
- if (propItem.template) {
413
- item.template = propItem.template;
414
- }
415
- if (propItem.disabled) {
416
- item.disabled = propItem.disabled;
417
- }
418
- if (propItem.width !== 'auto') {
419
- item.width = propItem.width;
420
- }
421
- if (propItem.suffixIcon) {
422
- item.suffixIcon = propItem.suffixIcon;
423
- }
424
- if (propItem.align !== 'Left') {
425
- item.align = propItem.align;
426
- }
427
- if (propItem.overflow !== 'None') {
428
- item.overflow = propItem.overflow;
429
- }
430
- if (propItem.htmlAttributes) {
431
- item.htmlAttributes = propItem.htmlAttributes;
432
- }
433
- if (propItem.type !== 'Button') {
434
- item.type = propItem.type;
435
- }
436
- if (propItem.visible !== true) {
437
- item.visible = propItem.visible;
438
- }
439
- if (propItem.showAlwaysInPopup) {
440
- item.showAlwaysInPopup = propItem.showAlwaysInPopup;
441
- }
442
- if (propItem.tabIndex !== -1) {
443
- item.tabIndex = propItem.tabIndex;
444
- }
445
- return item;
446
- }
447
-
448
- private getId(id: string): string {
449
- return this.parent.element.id + '_tb_' + id.toLowerCase();
450
- }
451
-
452
- private addEventListener(): void {
453
- this.parent.on(events.modelChanged, this.onPropertyChanged, this);
454
- this.parent.on(events.selectionChanged, this.onSelectionChanged, this);
455
- this.parent.on(events.layoutChange, this.onLayoutChange, this);
456
- this.parent.on(events.showPaste, this.showPaste, this);
457
- this.parent.on(events.hidePaste, this.hidePaste, this);
458
- this.parent.on(events.destroy, this.destroy, this);
459
- this.parent.on(events.sortByChange, this.updateSortByButton, this);
460
- }
461
-
462
- private reRenderToolbar(e: NotifyArgs): void {
463
- let itemsToProcess: string | string[] = [];
464
- if (this.parent.toolbarItems.length > 0) {
465
- itemsToProcess = this.parent.toolbarItems.map((item: ToolbarItem) => {
466
- return item.name;
467
- });
468
- } else if (e.newProp.toolbarSettings.items !== undefined) {
469
- itemsToProcess = e.newProp.toolbarSettings.items.map((item: string) => {
470
- return item.trim();
471
- });
472
- }
473
-
474
- if (itemsToProcess.length > 0) {
475
- this.items = this.toolbarItemData(this.getItems(itemsToProcess));
476
- const eventArgs: ToolbarCreateEventArgs = { items: this.items };
477
- this.parent.trigger('toolbarCreate', eventArgs, (toolbarCreateArgs: ToolbarCreateEventArgs) => {
478
- if (this.buttonObj) { this.buttonObj.destroy(); }
479
- if (this.layoutBtnObj) { this.layoutBtnObj.destroy(); }
480
- this.items = toolbarCreateArgs.items; this.toolbarObj.items = this.items;
481
- this.toolbarObj.dataBind();
482
- this.toolbarCreateHandler();
483
- });
484
- }
485
- }
486
-
487
- private onSelectionChanged(): void {
488
- this.hideStatus();
489
- this.hideItems(this.single, true);
490
- this.hideItems(this.selection, false);
491
- if (this.parent.selectedItems.length === 1) {
492
- this.hideItems(this.single, false);
493
- this.hideItems(this.selection, true);
494
- } else if (this.parent.selectedItems.length > 1) {
495
- this.hideItems(this.multiple, false);
496
- this.hideItems(this.selection, true);
497
- }
498
- const ele: Element = select('#' + this.getId('Selection'), this.toolbarObj.element);
499
- if (this.parent.selectedItems.length > 0 && ele && !this.parent.enableVirtualization) {
500
- let txt: string;
501
- if (this.parent.selectedItems.length === 1) {
502
- txt = this.parent.selectedItems.length + ' ' + getLocaleText(this.parent, 'Item-Selection');
503
- } else {
504
- txt = this.parent.selectedItems.length + ' ' + getLocaleText(this.parent, 'Items-Selection');
505
- }
506
- select('.e-tbar-btn-text', ele).textContent = txt;
507
- this.toolbarObj.hideItem(ele.parentElement, false);
508
- }
509
- }
510
-
511
- private hideItems(tools: string[], toHide: boolean): void {
512
- for (let i: number = 0; i < tools.length; i++) {
513
- const ele: Element = select('#' + this.getId(tools[i as number]), this.parent.element);
514
- if (ele) { this.toolbarObj.hideItem(ele.parentElement, toHide); }
515
- }
516
- }
517
-
518
- private hideStatus(): void {
519
- const ele: Element = select('#' + this.getId('Selection'), this.toolbarObj.element);
520
- if (ele) { this.toolbarObj.hideItem(ele.parentElement, true); }
521
- }
522
-
523
- private showPaste(): void {
524
- this.hideItems(['Paste'], false);
525
- }
526
-
527
- private hidePaste(): void {
528
- this.hideItems(['Paste'], true);
529
- }
530
-
531
- private onLayoutChange(): void {
532
- if (this.layoutBtnObj) {
533
- this.layoutBtnObj.iconCss = this.parent.view === 'Details' ? CLS.ICON_GRID : CLS.ICON_LARGE;
534
- const items: SplitButtonItemModel[] = this.layoutBtnObj.items;
535
- for (let itemCount: number = 0; itemCount < items.length; itemCount++) {
536
- if (items[itemCount as number].id === this.getPupupId('large')) {
537
- items[itemCount as number].iconCss = this.parent.view === 'LargeIcons' ? CLS.TB_OPTION_TICK : '';
538
- } else if (items[itemCount as number].id === this.getPupupId('details')) {
539
- items[itemCount as number].iconCss = this.parent.view === 'Details' ? CLS.TB_OPTION_TICK : '';
540
- }
541
- }
542
- }
543
- }
544
-
545
- private removeEventListener(): void {
546
- this.parent.off(events.modelChanged, this.onPropertyChanged);
547
- this.parent.off(events.selectionChanged, this.onSelectionChanged);
548
- this.parent.off(events.layoutChange, this.onLayoutChange);
549
- this.parent.off(events.showPaste, this.showPaste);
550
- this.parent.off(events.hidePaste, this.hidePaste);
551
- this.parent.off(events.destroy, this.destroy);
552
- this.parent.off(events.sortByChange, this.updateSortByButton);
553
- }
554
-
555
- /**
556
- * For internal use only - Get the module name.
557
- *
558
- * @returns {string} - returns module name.
559
- * @private
560
- */
561
- private getModuleName(): string {
562
- return 'toolbar';
563
- }
564
-
565
- private onPropertyChanged(e: NotifyArgs): void {
566
- if (e.module !== this.getModuleName() && e.module !== 'common') {
567
- /* istanbul ignore next */
568
- return;
569
- }
570
- for (const prop of Object.keys(e.newProp)) {
571
- switch (prop) {
572
- case 'cssClass':
573
- if (this.buttonObj) {
574
- this.buttonObj.cssClass = getCssClass(this.parent, CLS.ROOT_POPUP);
575
- }
576
- if (this.layoutBtnObj) {
577
- this.layoutBtnObj.cssClass = getCssClass(this.parent, 'e-caret-hide ' + CLS.ROOT_POPUP);
578
- }
579
- break;
580
- case 'height':
581
- case 'width':
582
- this.toolbarObj.refreshOverflow();
583
- break;
584
- case 'toolbarSettings':
585
- case 'toolbarItems':
586
- this.reRenderToolbar(e);
587
- break;
588
- }
589
- }
590
- }
591
-
592
- public destroy(): void {
593
- if (this.parent.isDestroyed) { return; }
594
- this.removeEventListener();
595
- if (this.buttonObj) { this.buttonObj.destroy(); }
596
- if (this.layoutBtnObj) { this.layoutBtnObj.destroy(); }
597
- this.toolbarObj.destroy();
598
- this.parent.refreshLayout();
599
- }
600
-
601
- public enableItems(items: string[], isEnable?: boolean): void {
602
- for (let i: number = 0; i < items.length; i++) {
603
- const ele: Element = select('#' + this.getId(items[i as number]), this.parent.element);
604
- if (ele) {
605
- this.toolbarObj.enableItems(ele.parentElement, isEnable);
606
- }
607
- }
608
- }
609
- }