@syncfusion/ej2-filemanager 20.1.52-10460 → 20.1.52-10461

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 (172) hide show
  1. package/CHANGELOG.md +412 -410
  2. package/README.md +69 -69
  3. package/dist/ej2-filemanager.min.js +1 -0
  4. package/dist/ej2-filemanager.umd.min.js +1 -10
  5. package/dist/ej2-filemanager.umd.min.js.map +1 -1
  6. package/dist/es6/ej2-filemanager.es2015.js +57 -54
  7. package/dist/es6/ej2-filemanager.es2015.js.map +1 -1
  8. package/dist/es6/ej2-filemanager.es5.js +174 -171
  9. package/dist/es6/ej2-filemanager.es5.js.map +1 -1
  10. package/dist/global/ej2-filemanager.min.js +1 -10
  11. package/dist/global/ej2-filemanager.min.js.map +1 -1
  12. package/dist/global/index.d.ts +0 -9
  13. package/dist/ts/file-manager/actions/breadcrumb-bar.ts +427 -0
  14. package/dist/ts/file-manager/actions/toolbar.ts +498 -0
  15. package/dist/ts/file-manager/base/classes.ts +225 -0
  16. package/dist/ts/file-manager/base/constant.ts +137 -0
  17. package/dist/ts/file-manager/base/file-manager.ts +1659 -0
  18. package/dist/ts/file-manager/base/interface.ts +652 -0
  19. package/dist/ts/file-manager/common/operations.ts +614 -0
  20. package/dist/ts/file-manager/common/utility.ts +1503 -0
  21. package/dist/ts/file-manager/layout/details-view.ts +1837 -0
  22. package/dist/ts/file-manager/layout/large-icons-view.ts +1587 -0
  23. package/dist/ts/file-manager/layout/navigation-pane.ts +879 -0
  24. package/dist/ts/file-manager/models/ajax-settings.ts +39 -0
  25. package/dist/ts/file-manager/models/column.ts +197 -0
  26. package/dist/ts/file-manager/models/contextMenu-settings.ts +44 -0
  27. package/dist/ts/file-manager/models/default-locale.ts +102 -0
  28. package/dist/ts/file-manager/models/details-view-settings.ts +48 -0
  29. package/dist/ts/file-manager/models/navigation-pane-settings.ts +42 -0
  30. package/dist/ts/file-manager/models/search-settings.ts +48 -0
  31. package/dist/ts/file-manager/models/toolbar-settings.ts +25 -0
  32. package/dist/ts/file-manager/models/upload-settings.ts +51 -0
  33. package/dist/ts/file-manager/pop-up/context-menu.ts +614 -0
  34. package/dist/ts/file-manager/pop-up/dialog.ts +996 -0
  35. package/helpers/e2e/filemanagerHelper.js +183 -166
  36. package/license +9 -9
  37. package/package.json +72 -72
  38. package/src/file-manager/base/file-manager-model.d.ts +329 -329
  39. package/src/file-manager/base/file-manager.js +19 -19
  40. package/src/file-manager/models/ajax-settings-model.d.ts +21 -21
  41. package/src/file-manager/models/ajax-settings.js +19 -19
  42. package/src/file-manager/models/column-model.d.ts +98 -98
  43. package/src/file-manager/models/column.js +19 -19
  44. package/src/file-manager/models/contextMenu-settings-model.d.ts +21 -21
  45. package/src/file-manager/models/contextMenu-settings.js +19 -19
  46. package/src/file-manager/models/details-view-settings-model.d.ts +19 -19
  47. package/src/file-manager/models/details-view-settings.js +19 -19
  48. package/src/file-manager/models/navigation-pane-settings-model.d.ts +25 -25
  49. package/src/file-manager/models/navigation-pane-settings.js +19 -19
  50. package/src/file-manager/models/search-settings-model.d.ts +26 -26
  51. package/src/file-manager/models/search-settings.js +19 -19
  52. package/src/file-manager/models/toolbar-settings-model.d.ts +11 -11
  53. package/src/file-manager/models/toolbar-settings.js +19 -19
  54. package/src/file-manager/models/upload-settings-model.d.ts +31 -31
  55. package/src/file-manager/models/upload-settings.js +19 -19
  56. package/src/file-manager/pop-up/context-menu.js +3 -0
  57. package/styles/compatibility/bootstrap.css +1 -0
  58. package/styles/compatibility/bootstrap.scss +12 -0
  59. package/styles/compatibility/bootstrap4.css +1 -0
  60. package/styles/compatibility/bootstrap4.scss +12 -0
  61. package/styles/compatibility/fabric.css +1 -0
  62. package/styles/compatibility/fabric.scss +12 -0
  63. package/styles/compatibility/highcontrast.css +1 -0
  64. package/styles/compatibility/highcontrast.scss +12 -0
  65. package/styles/compatibility/material.css +1 -0
  66. package/styles/compatibility/material.scss +12 -0
  67. package/styles/file-manager/_all.scss +2 -2
  68. package/styles/file-manager/_bds-definition.scss +236 -0
  69. package/styles/file-manager/_bigger.scss +759 -0
  70. package/styles/file-manager/_bootstrap-dark-definition.scss +244 -240
  71. package/styles/file-manager/_bootstrap-definition.scss +245 -241
  72. package/styles/file-manager/_bootstrap4-definition.scss +246 -242
  73. package/styles/file-manager/_bootstrap5-definition.scss +242 -237
  74. package/styles/file-manager/_bootstrap5.3-definition.scss +242 -0
  75. package/styles/file-manager/_fabric-dark-definition.scss +242 -238
  76. package/styles/file-manager/_fabric-definition.scss +244 -240
  77. package/styles/file-manager/_fluent-definition.scss +249 -246
  78. package/styles/file-manager/_fluent2-definition.scss +255 -0
  79. package/styles/file-manager/_fusionnew-definition.scss +241 -0
  80. package/styles/file-manager/_highcontrast-definition.scss +244 -240
  81. package/styles/file-manager/_highcontrast-light-definition.scss +244 -240
  82. package/styles/file-manager/_layout.scss +1252 -1815
  83. package/styles/file-manager/_material-dark-definition.scss +245 -240
  84. package/styles/file-manager/_material-definition.scss +245 -240
  85. package/styles/file-manager/_material3-definition.scss +235 -0
  86. package/styles/file-manager/_tailwind-definition.scss +236 -232
  87. package/styles/file-manager/_theme.scss +418 -397
  88. package/styles/file-manager/icons/_bds.scss +235 -0
  89. package/styles/file-manager/icons/_bootstrap-dark.scss +235 -235
  90. package/styles/file-manager/icons/_bootstrap.scss +235 -236
  91. package/styles/file-manager/icons/_bootstrap4.scss +235 -236
  92. package/styles/file-manager/icons/_bootstrap5.3.scss +235 -0
  93. package/styles/file-manager/icons/_bootstrap5.scss +235 -235
  94. package/styles/file-manager/icons/_fabric-dark.scss +229 -230
  95. package/styles/file-manager/icons/_fabric.scss +229 -230
  96. package/styles/file-manager/icons/_fluent.scss +235 -235
  97. package/styles/file-manager/icons/_fluent2.scss +235 -0
  98. package/styles/file-manager/icons/_fusionnew.scss +235 -0
  99. package/styles/file-manager/icons/_highcontrast-light.scss +235 -235
  100. package/styles/file-manager/icons/_highcontrast.scss +229 -229
  101. package/styles/file-manager/icons/_material-dark.scss +235 -235
  102. package/styles/file-manager/icons/_material.scss +235 -235
  103. package/styles/file-manager/icons/_material3.scss +235 -0
  104. package/styles/file-manager/icons/_tailwind.scss +235 -235
  105. package/.eslintrc.json +0 -244
  106. package/styles/bootstrap-dark.css +0 -1920
  107. package/styles/bootstrap-dark.scss +0 -1
  108. package/styles/bootstrap.css +0 -1899
  109. package/styles/bootstrap.scss +0 -1
  110. package/styles/bootstrap4.css +0 -1935
  111. package/styles/bootstrap4.scss +0 -1
  112. package/styles/bootstrap5-dark.css +0 -1982
  113. package/styles/bootstrap5-dark.scss +0 -1
  114. package/styles/bootstrap5.css +0 -1982
  115. package/styles/bootstrap5.scss +0 -1
  116. package/styles/fabric-dark.css +0 -1891
  117. package/styles/fabric-dark.scss +0 -1
  118. package/styles/fabric.css +0 -1891
  119. package/styles/fabric.scss +0 -1
  120. package/styles/file-manager/_bootstrap5-dark-definition.scss +0 -1
  121. package/styles/file-manager/_fluent-dark-definition.scss +0 -1
  122. package/styles/file-manager/_tailwind-dark-definition.scss +0 -1
  123. package/styles/file-manager/bootstrap-dark.css +0 -1920
  124. package/styles/file-manager/bootstrap-dark.scss +0 -16
  125. package/styles/file-manager/bootstrap.css +0 -1899
  126. package/styles/file-manager/bootstrap.scss +0 -16
  127. package/styles/file-manager/bootstrap4.css +0 -1935
  128. package/styles/file-manager/bootstrap4.scss +0 -16
  129. package/styles/file-manager/bootstrap5-dark.css +0 -1982
  130. package/styles/file-manager/bootstrap5-dark.scss +0 -16
  131. package/styles/file-manager/bootstrap5.css +0 -1982
  132. package/styles/file-manager/bootstrap5.scss +0 -16
  133. package/styles/file-manager/fabric-dark.css +0 -1891
  134. package/styles/file-manager/fabric-dark.scss +0 -16
  135. package/styles/file-manager/fabric.css +0 -1891
  136. package/styles/file-manager/fabric.scss +0 -16
  137. package/styles/file-manager/fluent-dark.css +0 -1901
  138. package/styles/file-manager/fluent-dark.scss +0 -16
  139. package/styles/file-manager/fluent.css +0 -1900
  140. package/styles/file-manager/fluent.scss +0 -16
  141. package/styles/file-manager/highcontrast-light.css +0 -1897
  142. package/styles/file-manager/highcontrast-light.scss +0 -16
  143. package/styles/file-manager/highcontrast.css +0 -1897
  144. package/styles/file-manager/highcontrast.scss +0 -16
  145. package/styles/file-manager/icons/_bootstrap5-dark.scss +0 -1
  146. package/styles/file-manager/icons/_fluent-dark.scss +0 -1
  147. package/styles/file-manager/icons/_tailwind-dark.scss +0 -1
  148. package/styles/file-manager/material-dark.css +0 -1945
  149. package/styles/file-manager/material-dark.scss +0 -16
  150. package/styles/file-manager/material.css +0 -1932
  151. package/styles/file-manager/material.scss +0 -16
  152. package/styles/file-manager/tailwind-dark.css +0 -1969
  153. package/styles/file-manager/tailwind-dark.scss +0 -16
  154. package/styles/file-manager/tailwind.css +0 -1969
  155. package/styles/file-manager/tailwind.scss +0 -16
  156. package/styles/fluent-dark.css +0 -1901
  157. package/styles/fluent-dark.scss +0 -1
  158. package/styles/fluent.css +0 -1900
  159. package/styles/fluent.scss +0 -1
  160. package/styles/highcontrast-light.css +0 -1897
  161. package/styles/highcontrast-light.scss +0 -1
  162. package/styles/highcontrast.css +0 -1897
  163. package/styles/highcontrast.scss +0 -1
  164. package/styles/material-dark.css +0 -1945
  165. package/styles/material-dark.scss +0 -1
  166. package/styles/material.css +0 -1932
  167. package/styles/material.scss +0 -1
  168. package/styles/tailwind-dark.css +0 -1969
  169. package/styles/tailwind-dark.scss +0 -1
  170. package/styles/tailwind.css +0 -1969
  171. package/styles/tailwind.scss +0 -1
  172. package/tslint.json +0 -111
@@ -0,0 +1,1587 @@
1
+ import { ListBase, ListBaseOptions, ItemCreatedArgs } from '@syncfusion/ej2-lists';
2
+ import { createElement, select, selectAll, EventHandler, KeyboardEvents, closest, DragEventArgs, Draggable } from '@syncfusion/ej2-base';
3
+ import { isNullOrUndefined as isNOU, addClass, removeClass, Touch, TapEventArgs, isVisible } from '@syncfusion/ej2-base';
4
+ import { TouchEventArgs, MouseEventArgs, KeyboardEventArgs, getValue, setValue, remove } from '@syncfusion/ej2-base';
5
+ import { IFileManager, FileOpenEventArgs, FileLoadEventArgs } from '../base/interface';
6
+ import { FileSelectEventArgs, NotifyArgs, FileSelectionEventArgs } from '../base/interface';
7
+ import { DataManager, Query } from '@syncfusion/ej2-data';
8
+ import { hideSpinner, showSpinner } from '@syncfusion/ej2-popups';
9
+ import * as events from '../base/constant';
10
+ import { ReadArgs, MouseArgs } from '../../index';
11
+ import * as CLS from '../base/classes';
12
+ import { createCheckBox } from '@syncfusion/ej2-buttons';
13
+ import { read, GetDetails, Delete } from '../common/operations';
14
+ import { doRename, getAccessClass, getPathObject, getFullPath, getDirectoryPath, rename, doDownload, getItemName } from '../common/index';
15
+ import { removeBlur, cutFiles, copyFiles, addBlur, openSearchFolder, removeActive, pasteHandler } from '../common/index';
16
+ import { createVirtualDragElement, dragStopHandler, dragStartHandler, draggingHandler, getModule } from '../common/index';
17
+ import { updateRenamingData, doDeleteFiles, doDownloadFiles } from '../common/index';
18
+ import { openAction, fileType, refresh, getImageUrl, getSortedData, createDeniedDialog, updateLayout } from '../common/utility';
19
+ import { createEmptyElement, hasReadAccess, hasEditAccess } from '../common/utility';
20
+ import { createDialog, createImageDialog } from '../pop-up/dialog';
21
+
22
+ /**
23
+ * LargeIconsView module
24
+ */
25
+ export class LargeIconsView {
26
+
27
+ /* Internal variables */
28
+ private parent: IFileManager;
29
+ public element: HTMLElement;
30
+ public listObj: ListBaseOptions;
31
+ private keyboardModule: KeyboardEvents;
32
+ private keyboardDownModule: KeyboardEvents;
33
+ private keyConfigs: { [key: string]: string };
34
+ private isInteraction: boolean = true;
35
+ private itemList: HTMLElement[];
36
+ // specifies the current view items in large icon
37
+ // eslint-disable-next-line
38
+ public items: Object[];
39
+ private clickObj: Touch;
40
+ private perRow: number;
41
+ private startItem: Element;
42
+ private multiSelect: boolean;
43
+ public listElements: HTMLElement;
44
+ public uploadOperation: boolean = false;
45
+ private count: number = 0;
46
+ private isRendered: boolean = true;
47
+ private tapCount: number = 0;
48
+ private tapEvent: TapEventArgs;
49
+ private isPasteOperation: boolean = false;
50
+ private dragObj: Draggable;
51
+ private isInteracted: boolean = true;
52
+
53
+ /**
54
+ * Constructor for the LargeIcons module.
55
+ *
56
+ * @param {IFileManager} parent - specifies the parent element.
57
+ * @hidden
58
+ */
59
+ constructor(parent?: IFileManager) {
60
+ this.parent = parent;
61
+ this.element = <HTMLElement>select('#' + this.parent.element.id + CLS.LARGEICON_ID, this.parent.element);
62
+ addClass([this.element], CLS.LARGE_ICONS);
63
+ this.addEventListener();
64
+ this.keyConfigs = {
65
+ end: 'end',
66
+ home: 'home',
67
+ tab: 'tab',
68
+ moveDown: 'downarrow',
69
+ moveLeft: 'leftarrow',
70
+ moveRight: 'rightarrow',
71
+ moveUp: 'uparrow',
72
+ ctrlEnd: 'ctrl+end',
73
+ ctrlHome: 'ctrl+home',
74
+ ctrlDown: 'ctrl+downarrow',
75
+ ctrlLeft: 'ctrl+leftarrow',
76
+ ctrlRight: 'ctrl+rightarrow',
77
+ ctrlUp: 'ctrl+uparrow',
78
+ shiftEnd: 'shift+end',
79
+ shiftHome: 'shift+home',
80
+ shiftDown: 'shift+downarrow',
81
+ shiftLeft: 'shift+leftarrow',
82
+ shiftRight: 'shift+rightarrow',
83
+ shiftUp: 'shift+uparrow',
84
+ csEnd: 'ctrl+shift+end',
85
+ csHome: 'ctrl+shift+home',
86
+ csDown: 'ctrl+shift+downarrow',
87
+ csLeft: 'ctrl+shift+leftarrow',
88
+ csRight: 'ctrl+shift+rightarrow',
89
+ csUp: 'ctrl+shift+uparrow',
90
+ space: 'space',
91
+ ctrlSpace: 'ctrl+space',
92
+ shiftSpace: 'shift+space',
93
+ csSpace: 'ctrl+shift+space',
94
+ ctrlA: 'ctrl+a',
95
+ enter: 'enter',
96
+ altEnter: 'alt+enter',
97
+ esc: 'escape',
98
+ del: 'delete',
99
+ ctrlX: 'ctrl+x',
100
+ ctrlC: 'ctrl+c',
101
+ ctrlV: 'ctrl+v',
102
+ f2: 'f2',
103
+ shiftdel: 'shift+delete',
104
+ back: 'backspace',
105
+ ctrlD: 'ctrl+d'
106
+ };
107
+ }
108
+
109
+ private render(args: ReadArgs): void {
110
+ this.parent.visitedItem = null;
111
+ this.startItem = null;
112
+ showSpinner(this.parent.element);
113
+ if (this.parent.view === 'LargeIcons') {
114
+ this.resetMultiSelect();
115
+ this.element.setAttribute('tabindex', '0');
116
+ if (this.listObj) {
117
+ this.unWireEvents();
118
+ this.removeEventListener();
119
+ }
120
+ this.parent.notify(events.hideLayout, {});
121
+ const iconsView: Element = select('#' + this.parent.element.id + CLS.LARGEICON_ID, this.parent.element);
122
+ const ul: HTMLUListElement = select('ul', iconsView) as HTMLUListElement;
123
+ if (ul) {
124
+ remove(ul);
125
+ }
126
+ this.listObj = {
127
+ ariaAttributes: {
128
+ itemRole: 'option', listRole: 'listbox', itemText: '',
129
+ groupItemRole: 'group', wrapperRole: ''
130
+ },
131
+ showIcon: true,
132
+ fields: { text: 'name', iconCss: '_fm_icon', imageUrl: '_fm_imageUrl', htmlAttributes: '_fm_htmlAttr' },
133
+ sortOrder: this.parent.sortOrder,
134
+ itemCreated: this.onItemCreated.bind(this),
135
+ enableHtmlSanitizer: this.parent.enableHtmlSanitizer
136
+ };
137
+ this.items = [];
138
+ this.items = this.renderList(args);
139
+ this.items = getSortedData(this.parent, this.items);
140
+ // eslint-disable-next-line
141
+ this.listElements = ListBase.createListFromJson(createElement, <{ [key: string]: Object; }[]>this.items, this.listObj);
142
+ this.itemList = Array.prototype.slice.call(selectAll('.' + CLS.LIST_ITEM, this.listElements));
143
+ this.element.appendChild(this.listElements);
144
+ this.preventImgDrag();
145
+ this.createDragObj();
146
+ iconsView.classList.remove(CLS.DISPLAY_NONE);
147
+ if (this.itemList.length === 0) {
148
+ const emptyList: Element = this.element.querySelector('.' + CLS.LIST_PARENT);
149
+ this.element.removeChild(emptyList);
150
+ createEmptyElement(this.parent, this.element, args);
151
+ } else if (this.itemList.length !== 0 && this.element.querySelector('.' + CLS.EMPTY)) {
152
+ this.element.removeChild(this.element.querySelector('.' + CLS.EMPTY));
153
+ }
154
+ if (this.isPasteOperation === true) {
155
+ this.selectItems(this.parent.pasteNodes);
156
+ this.isPasteOperation = false;
157
+ }
158
+ /* istanbul ignore next */
159
+ if (this.uploadOperation === true) {
160
+ this.selectItems(this.parent.uploadItem);
161
+ this.parent.setProperties({ selectedItems: [] }, true);
162
+ this.count++;
163
+ if (this.count === this.parent.uploadItem.length) {
164
+ this.uploadOperation = false;
165
+ this.parent.uploadItem = [];
166
+ }
167
+ }
168
+ const activeEle: NodeListOf<Element> = this.element.querySelectorAll('.' + CLS.ACTIVE);
169
+ if (activeEle.length !== 0) {
170
+ this.parent.activeModule = 'largeiconsview';
171
+ }
172
+ for (let i: number = 0; i < activeEle.length; i++) {
173
+ activeEle[i].setAttribute('aria-selected', 'true');
174
+ }
175
+ this.adjustHeight();
176
+ this.element.style.maxHeight = '100%';
177
+ this.getItemCount();
178
+ this.addEventListener();
179
+ this.wireEvents();
180
+ this.isRendered = true;
181
+ hideSpinner(this.parent.element);
182
+ if (this.parent.selectedItems.length) { this.checkItem(); }
183
+ }
184
+ }
185
+ private preventImgDrag(): void {
186
+ let i: number = 0;
187
+ while (i < this.itemList.length) {
188
+ if (this.itemList[i].querySelector('img')) {
189
+ /* istanbul ignore next */
190
+ this.itemList[i].ondragstart = () => { return false; };
191
+ }
192
+ i++;
193
+ }
194
+ }
195
+
196
+ private createDragObj(): void {
197
+ if (!this.parent.isMobile && this.listObj) {
198
+ if (this.parent.allowDragAndDrop) {
199
+ if (this.dragObj) { this.dragObj.destroy(); }
200
+ this.dragObj = new Draggable(this.listElements, {
201
+ enableTailMode: true,
202
+ distance: 5,
203
+ enableAutoScroll: true,
204
+ dragTarget: '.' + CLS.LARGE_ICON,
205
+ helper: this.dragHelper.bind(this),
206
+ cursorAt: this.parent.dragCursorPosition,
207
+ dragArea: this.parent.element,
208
+ dragStop: dragStopHandler.bind(this, this.parent),
209
+ drag: draggingHandler.bind(this, this.parent),
210
+ clone: true,
211
+ dragStart: (args: DragEventArgs) => {
212
+ dragStartHandler(this.parent, args, this.dragObj);
213
+ }
214
+ });
215
+ } else if (this.dragObj && !this.parent.allowDragAndDrop) {
216
+ this.dragObj.destroy();
217
+ }
218
+ }
219
+ }
220
+
221
+ public dragHelper(args: { element: HTMLElement, sender: MouseEvent & TouchEvent }): HTMLElement {
222
+ const dragTarget: Element = <Element>args.sender.target;
223
+ const dragLi: Element = closest(dragTarget, '.e-list-item');
224
+ if (!dragLi) { return null; }
225
+ if (dragLi && !dragLi.classList.contains('e-active')) {
226
+ this.setFocus(dragLi);
227
+ }
228
+ const activeEle: NodeListOf<Element> = this.element.querySelectorAll('.' + CLS.ACTIVE);
229
+ this.parent.activeElements = [];
230
+ this.parent.dragData = [];
231
+ for (let i: number = 0; i < activeEle.length; i++) {
232
+ // eslint-disable-next-line
233
+ this.parent.dragData.push(<{ [key: string]: Object; }>this.getItemObject(activeEle[i]));
234
+ this.parent.activeElements.push(activeEle[i]);
235
+ }
236
+ getModule(this.parent, dragLi);
237
+ this.parent.dragPath = this.parent.path;
238
+ createVirtualDragElement(this.parent);
239
+ return this.parent.virtualDragElement;
240
+ }
241
+
242
+ private onDropInit(args: DragEventArgs): void {
243
+ if (this.parent.targetModule === this.getModuleName()) {
244
+ const dropLi: Element = closest(args.target, '.e-list-item');
245
+ // eslint-disable-next-line
246
+ const cwdData: Object = getValue(this.parent.pathId[this.parent.pathId.length - 1], this.parent.feParent);
247
+ if (dropLi) {
248
+ // eslint-disable-next-line
249
+ const info: { [key: string]: Object; } = <{ [key: string]: Object; }>this.getItemObject(dropLi);
250
+ this.parent.dropPath = info.isFile ? this.parent.path : getFullPath(this.parent, info, this.parent.path);
251
+ this.parent.dropData = info.isFile ? cwdData : info;
252
+ } else {
253
+ this.parent.dropPath = this.parent.path;
254
+ this.parent.dropData = cwdData;
255
+ }
256
+ }
257
+ }
258
+
259
+ /**
260
+ * For internal use only - Get the module name.
261
+ *
262
+ * @returns {string} - returns the module name.
263
+ * @private
264
+ */
265
+ private getModuleName(): string {
266
+ return 'largeiconsview';
267
+ }
268
+
269
+ private adjustHeight(): void {
270
+ const pane: HTMLElement = <HTMLElement>select('#' + this.parent.element.id + CLS.CONTENT_ID, this.parent.element);
271
+ const bar: HTMLElement = <HTMLElement>select('#' + this.parent.element.id + CLS.BREADCRUMBBAR_ID, this.parent.element);
272
+ this.element.style.height = (pane.offsetHeight - bar.offsetHeight) + 'px';
273
+ }
274
+
275
+ private onItemCreated(args: ItemCreatedArgs): void {
276
+ args.item.removeAttribute('aria-level');
277
+ if (!this.parent.showFileExtension && getValue('isFile', args.curData)) {
278
+ const textEle: Element = args.item.querySelector('.' + CLS.LIST_TEXT);
279
+ const txt: string = getValue('name', args.curData);
280
+ const type: string = getValue('type', args.curData);
281
+ textEle.innerHTML = txt.substr(0, txt.length - type.length);
282
+ }
283
+ this.renderCheckbox(args);
284
+ const eventArgs: FileLoadEventArgs = {
285
+ element: args.item,
286
+ fileDetails: args.curData,
287
+ module: 'LargeIconsView'
288
+ };
289
+ this.parent.trigger('fileLoad', eventArgs);
290
+ }
291
+
292
+ private renderCheckbox(args: ItemCreatedArgs): void {
293
+ if (!this.parent.allowMultiSelection) { return; }
294
+ const checkElement: Element = createCheckBox(createElement, false, {
295
+ checked: false,
296
+ cssClass: 'e-small'
297
+ });
298
+ checkElement.setAttribute('role', 'checkbox');
299
+ checkElement.setAttribute('aria-checked', 'false');
300
+ args.item.firstElementChild.insertBefore(checkElement, args.item.firstElementChild.childNodes[0]);
301
+ }
302
+
303
+ private onLayoutChange(args: ReadArgs): void {
304
+ if (this.parent.view === 'LargeIcons') {
305
+ this.destroy();
306
+ this.render(args);
307
+ /* istanbul ignore next */
308
+ if (getValue('name', args) === 'layout-change' && this.parent.fileAction === 'move' &&
309
+ this.parent.isCut && this.parent.selectedNodes && this.parent.selectedNodes.length !== 0) {
310
+ const indexes: number[] = this.getIndexes(this.parent.selectedNodes);
311
+ let length: number = 0;
312
+ while (length < indexes.length) {
313
+ addBlur(this.itemList[indexes[length]]);
314
+ length++;
315
+ }
316
+ }
317
+ const activeEle: NodeListOf<Element> = this.element.querySelectorAll('.' + CLS.ACTIVE);
318
+ if (activeEle.length !== 0) {
319
+ this.element.focus();
320
+ }
321
+ this.checkItem();
322
+ this.parent.isLayoutChange = false;
323
+ } else {
324
+ this.element.setAttribute('tabindex', '-1');
325
+ }
326
+ }
327
+
328
+ private checkItem(): void {
329
+ const checkEle: NodeListOf<Element> = this.element.querySelectorAll('.' + CLS.ACTIVE);
330
+ if (checkEle) {
331
+ let checkLength: number = 0;
332
+ while (checkLength < checkEle.length) {
333
+ this.checkState(checkEle[checkLength], true);
334
+ checkLength++;
335
+ }
336
+ }
337
+ }
338
+
339
+ // eslint-disable-next-line
340
+ private renderList(args?: ReadArgs): Object[] {
341
+ let i: number = 0;
342
+ // eslint-disable-next-line
343
+ const items: Object[] = JSON.parse(JSON.stringify(args.files));
344
+ while (i < items.length) {
345
+ const icon: string = fileType(items[i]);
346
+ const name: string = getValue('name', items[i]);
347
+ const selected: string = getItemName(this.parent, items[i]);
348
+ let className: string = ((this.parent.selectedItems &&
349
+ this.parent.selectedItems.indexOf(selected) !== -1)) ?
350
+ CLS.LARGE_ICON + ' e-active' : CLS.LARGE_ICON;
351
+ if (!hasEditAccess(items[i])) {
352
+ className += ' ' + getAccessClass(items[i]);
353
+ }
354
+ if (icon === CLS.ICON_IMAGE && this.parent.showThumbnail && hasReadAccess(items[i])) {
355
+ const imgUrl: string = getImageUrl(this.parent, items[i]);
356
+ setValue('_fm_imageUrl', imgUrl, items[i]);
357
+ setValue('_fm_imageAttr', { alt: name }, items[i]);
358
+ } else {
359
+ setValue('_fm_icon', icon, items[i]);
360
+ }
361
+ setValue('_fm_htmlAttr', { class: className, title: name }, items[i]);
362
+ i++;
363
+ }
364
+ return items;
365
+ }
366
+
367
+ private onFinalizeEnd(args: ReadArgs): void {
368
+ this.render(args);
369
+ }
370
+
371
+ private onCreateEnd(args: ReadArgs): void {
372
+ if (this.parent.view !== 'LargeIcons') { return; }
373
+ this.onLayoutChange(args);
374
+ this.clearSelect();
375
+ this.selectItems([getValue(this.parent.hasId ? 'id' : 'name', this.parent.createdItem)]);
376
+ this.parent.createdItem = null;
377
+ this.parent.largeiconsviewModule.element.focus();
378
+ }
379
+
380
+ private onSelectedData(): void {
381
+ if (this.parent.activeModule === 'largeiconsview') {
382
+ this.updateSelectedData();
383
+ }
384
+ }
385
+
386
+ private onDeleteInit(): void {
387
+ if (this.parent.activeModule === 'largeiconsview') {
388
+ Delete(this.parent, this.parent.selectedItems, this.parent.path, 'delete');
389
+ }
390
+ }
391
+
392
+ /* istanbul ignore next */
393
+ private onDeleteEnd(args: ReadArgs): void {
394
+ if (this.parent.view !== 'LargeIcons') { return; }
395
+ this.onLayoutChange(args);
396
+ this.parent.setProperties({ selectedItems: [] }, true);
397
+ this.clearSelect();
398
+ }
399
+
400
+ private onRefreshEnd(args: ReadArgs): void {
401
+ if (this.parent.view !== 'LargeIcons') { return; }
402
+ this.onLayoutChange(args);
403
+ }
404
+
405
+ private onRenameInit(): void {
406
+ if (this.parent.activeModule === 'largeiconsview' && this.parent.selectedItems.length === 1) {
407
+ this.updateRenameData();
408
+ }
409
+ }
410
+
411
+ private onPathChanged(args: ReadArgs): void {
412
+ this.parent.isCut = false;
413
+ /* istanbul ignore next */
414
+ if (this.parent.breadcrumbbarModule.searchObj.element.value === '') {
415
+ this.parent.searchedItems = [];
416
+ }
417
+ if (this.parent.view === 'LargeIcons') {
418
+ removeBlur(this.parent);
419
+ this.parent.setProperties({ selectedItems: [] }, true);
420
+ this.onLayoutChange(args);
421
+ if (this.parent.renamedItem) {
422
+ this.clearSelect();
423
+ this.addSelection(this.parent.renamedItem);
424
+ this.parent.renamedItem = null;
425
+ }
426
+ }
427
+ }
428
+
429
+ private onOpenInit(args: NotifyArgs): void {
430
+ if (this.parent.activeModule === 'largeiconsview') {
431
+ this.doOpenAction(args.target);
432
+ }
433
+ }
434
+
435
+ private onHideLayout(): void {
436
+ if (this.parent.view !== 'LargeIcons' && this.element) {
437
+ this.element.classList.add(CLS.DISPLAY_NONE);
438
+ }
439
+ }
440
+
441
+ private onSelectAllInit(): void {
442
+ if (this.parent.view === 'LargeIcons') {
443
+ this.startItem = this.getFirstItem();
444
+ const lastItem: Element = this.getLastItem();
445
+ const eveArgs: KeyboardEventArgs = { ctrlKey: true, shiftKey: true } as KeyboardEventArgs;
446
+ this.doSelection(lastItem, eveArgs);
447
+ this.isInteraction = true;
448
+ this.isInteracted = true;
449
+ }
450
+ }
451
+
452
+ private onClearAllInit(): void {
453
+ if (this.parent.view === 'LargeIcons') {
454
+ this.clearSelection();
455
+ this.isInteraction = true;
456
+ this.isInteracted = true;
457
+ }
458
+ }
459
+
460
+ private onBeforeRequest(): void {
461
+ this.isRendered = false;
462
+ }
463
+
464
+ private onAfterRequest(): void {
465
+ this.isRendered = true;
466
+ }
467
+
468
+ /* istanbul ignore next */
469
+ private onSearch(args: ReadArgs): void {
470
+ if (this.parent.view === 'LargeIcons') {
471
+ this.parent.setProperties({ selectedItems: [] }, true);
472
+ this.parent.notify(events.selectionChanged, {});
473
+ this.parent.searchedItems = args.files;
474
+ this.onLayoutChange(args);
475
+ }
476
+ }
477
+
478
+ private onLayoutRefresh(): void {
479
+ if (this.parent.view !== 'LargeIcons') { return; }
480
+ this.adjustHeight();
481
+ }
482
+
483
+ private onUpdateSelectionData(): void {
484
+ if (this.parent.view !== 'LargeIcons') { return; }
485
+ this.updateSelectedData();
486
+ }
487
+
488
+ private onPathColumn(): void {
489
+ if (this.parent.view === 'LargeIcons' && !isNOU(this.listObj) &&
490
+ this.parent.breadcrumbbarModule.searchObj.element.value === '' && !this.parent.isFiltered
491
+ && this.parent.sortBy === 'filterPath') {
492
+ this.parent.sortBy = 'name';
493
+ this.parent.notify(events.sortByChange, {});
494
+
495
+ }
496
+ }
497
+
498
+ private removeEventListener(): void {
499
+ if (this.parent.isDestroyed) { return; }
500
+ this.parent.off(events.pathColumn, this.onPathColumn);
501
+ this.parent.off(events.finalizeEnd, this.onFinalizeEnd);
502
+ this.parent.off(events.createEnd, this.onCreateEnd);
503
+ this.parent.off(events.selectedData, this.onSelectedData);
504
+ this.parent.off(events.deleteInit, this.onDeleteInit);
505
+ this.parent.off(events.deleteEnd, this.onDeleteEnd);
506
+ this.parent.off(events.refreshEnd, this.onRefreshEnd);
507
+ this.parent.off(events.pathChanged, this.onPathChanged);
508
+ this.parent.off(events.layoutChange, this.onLayoutChange);
509
+ this.parent.off(events.search, this.onSearch);
510
+ this.parent.off(events.openInit, this.onOpenInit);
511
+ this.parent.off(events.openEnd, this.onPathChanged);
512
+ this.parent.off(events.modelChanged, this.onPropertyChanged);
513
+ this.parent.off(events.methodCall, this.onMethodCall);
514
+ this.parent.off(events.actionFailure, this.onActionFailure);
515
+ this.parent.off(events.renameInit, this.onRenameInit);
516
+ this.parent.off(events.renameEnd, this.onPathChanged);
517
+ this.parent.off(events.hideLayout, this.onHideLayout);
518
+ this.parent.off(events.selectAllInit, this.onSelectAllInit);
519
+ this.parent.off(events.clearAllInit, this.onClearAllInit);
520
+ this.parent.off(events.menuItemData, this.onMenuItemData);
521
+ this.parent.off(events.beforeRequest, this.onBeforeRequest);
522
+ this.parent.off(events.afterRequest, this.onAfterRequest);
523
+ this.parent.off(events.splitterResize, this.splitterResizeHandler);
524
+ this.parent.off(events.resizeEnd, this.resizeHandler);
525
+ this.parent.off(events.pasteInit, this.onpasteInit);
526
+ this.parent.off(events.pasteEnd, this.onpasteEnd);
527
+ this.parent.off(events.cutCopyInit, this.oncutCopyInit);
528
+ this.parent.off(events.dropInit, this.onDropInit);
529
+ this.parent.off(events.detailsInit, this.onDetailsInit);
530
+ this.parent.off(events.layoutRefresh, this.onLayoutRefresh);
531
+ this.parent.off(events.dropPath, this.onDropPath);
532
+ this.parent.off(events.updateSelectionData, this.onUpdateSelectionData);
533
+ this.parent.off(events.filterEnd, this.onPathChanged);
534
+ }
535
+
536
+ private addEventListener(): void {
537
+ this.parent.on(events.pathColumn, this.onPathColumn, this);
538
+ this.parent.on(events.finalizeEnd, this.onFinalizeEnd, this);
539
+ this.parent.on(events.createEnd, this.onCreateEnd, this);
540
+ this.parent.on(events.refreshEnd, this.onRefreshEnd, this);
541
+ this.parent.on(events.selectedData, this.onSelectedData, this);
542
+ this.parent.on(events.pathChanged, this.onPathChanged, this);
543
+ this.parent.on(events.deleteInit, this.onDeleteInit, this);
544
+ this.parent.on(events.pasteInit, this.onpasteInit, this);
545
+ this.parent.on(events.deleteEnd, this.onDeleteEnd, this);
546
+ this.parent.on(events.layoutChange, this.onLayoutChange, this);
547
+ this.parent.on(events.search, this.onSearch, this);
548
+ this.parent.on(events.openInit, this.onOpenInit, this);
549
+ this.parent.on(events.renameInit, this.onRenameInit, this);
550
+ this.parent.on(events.renameEnd, this.onPathChanged, this);
551
+ this.parent.on(events.openEnd, this.onPathChanged, this);
552
+ this.parent.on(events.modelChanged, this.onPropertyChanged, this);
553
+ this.parent.on(events.methodCall, this.onMethodCall, this);
554
+ this.parent.on(events.actionFailure, this.onActionFailure, this);
555
+ this.parent.on(events.hideLayout, this.onHideLayout, this);
556
+ this.parent.on(events.selectAllInit, this.onSelectAllInit, this);
557
+ this.parent.on(events.clearAllInit, this.onClearAllInit, this);
558
+ this.parent.on(events.menuItemData, this.onMenuItemData, this);
559
+ this.parent.on(events.beforeRequest, this.onBeforeRequest, this);
560
+ this.parent.on(events.afterRequest, this.onAfterRequest, this);
561
+ this.parent.on(events.dropInit, this.onDropInit, this);
562
+ this.parent.on(events.detailsInit, this.onDetailsInit, this);
563
+ this.parent.on(events.splitterResize, this.splitterResizeHandler, this);
564
+ this.parent.on(events.resizeEnd, this.resizeHandler, this);
565
+ this.parent.on(events.pasteEnd, this.onpasteEnd, this);
566
+ this.parent.on(events.cutCopyInit, this.oncutCopyInit, this);
567
+ this.parent.on(events.layoutRefresh, this.onLayoutRefresh, this);
568
+ this.parent.on(events.dropPath, this.onDropPath, this);
569
+ this.parent.on(events.updateSelectionData, this.onUpdateSelectionData, this);
570
+ this.parent.on(events.filterEnd, this.onPathChanged, this);
571
+ }
572
+
573
+ private onActionFailure(): void { this.isInteraction = true; this.isInteracted = true; }
574
+
575
+ // eslint-disable-next-line
576
+ private onMenuItemData(args: { [key: string]: Object; }): void {
577
+ if (this.parent.activeModule === this.getModuleName()) {
578
+ const ele: Element = closest(<Element>args.target, 'li');
579
+ this.parent.itemData = [this.getItemObject(ele)];
580
+ }
581
+ }
582
+
583
+ private onDetailsInit(): void {
584
+ if (this.parent.activeModule === this.getModuleName()) {
585
+ if (this.parent.selectedItems.length !== 0) {
586
+ this.updateSelectedData();
587
+ } else {
588
+ this.parent.itemData = [getValue(this.parent.pathId[this.parent.pathId.length - 1], this.parent.feParent)];
589
+ }
590
+ }
591
+ }
592
+
593
+ private onpasteInit(): void {
594
+ if (this.parent.activeModule === this.getModuleName()) {
595
+ this.parent.itemData = (this.parent.folderPath === '') ? [getPathObject(this.parent)] :
596
+ [this.getItemObject(select('.e-active', this.element))];
597
+ }
598
+ }
599
+
600
+ private oncutCopyInit(): void {
601
+ if (this.parent.activeModule === this.getModuleName()) {
602
+ const activeEle: NodeListOf<Element> = this.element.querySelectorAll('.' + CLS.ACTIVE);
603
+ this.parent.activeRecords = [];
604
+ this.parent.activeElements = [];
605
+ for (let i: number = 0; i < activeEle.length; i++) {
606
+ this.parent.activeElements.push(activeEle[i]);
607
+ this.parent.activeRecords.push(this.getItemObject(activeEle[i]));
608
+ }
609
+ }
610
+ }
611
+
612
+ private onpasteEnd(args: ReadArgs): void {
613
+ if (this.parent.view === 'LargeIcons') {
614
+ this.isPasteOperation = true;
615
+ if (this.parent.path === this.parent.destinationPath || this.parent.path === getDirectoryPath(this.parent, args)) {
616
+ this.onPathChanged(args);
617
+ }
618
+ }
619
+ }
620
+
621
+ private onDropPath(args: ReadArgs): void {
622
+ if (this.parent.view === 'LargeIcons') {
623
+ this.isPasteOperation = true;
624
+ this.onPathChanged(args);
625
+ }
626
+ }
627
+
628
+ private onPropertyChanged(e: NotifyArgs): void {
629
+ let currentSelected: string[];
630
+ if (e.module !== this.getModuleName() && e.module !== 'common') {
631
+ return;
632
+ }
633
+ for (const prop of Object.keys(e.newProp)) {
634
+ switch (prop) {
635
+ case 'allowDragAndDrop':
636
+ this.createDragObj();
637
+ break;
638
+ case 'height':
639
+ this.adjustHeight();
640
+ break;
641
+ case 'selectedItems':
642
+ this.isInteraction = false;
643
+ this.isInteracted = false;
644
+ currentSelected = isNOU(this.parent.selectedItems) ? [] : this.parent.selectedItems.slice(0);
645
+ currentSelected = this.parent.allowMultiSelection ? currentSelected :
646
+ currentSelected.slice(currentSelected.length - 1);
647
+ this.parent.setProperties({ selectedItems: [] }, true);
648
+ this.onClearAllInit();
649
+ if (currentSelected.length) {
650
+ this.selectItems(currentSelected);
651
+ }
652
+ this.parent.setProperties({ selectedItems: this.parent.selectedItems }, true);
653
+ this.isInteraction = true;
654
+ this.isInteracted = true;
655
+ break;
656
+ case 'showThumbnail':
657
+ refresh(this.parent);
658
+ break;
659
+ case 'showFileExtension':
660
+ read(this.parent, events.pathChanged, this.parent.path);
661
+ break;
662
+ case 'showHiddenItems':
663
+ read(this.parent, events.pathChanged, this.parent.path);
664
+ break;
665
+ case 'allowMultiSelection':
666
+ if (this.parent.view !== 'LargeIcons') { break; }
667
+ refresh(this.parent);
668
+ break;
669
+ case 'view':
670
+ updateLayout(this.parent, 'LargeIcons');
671
+ break;
672
+ }
673
+ }
674
+ }
675
+
676
+ public destroy(): void {
677
+ if (this.parent.isDestroyed) { return; }
678
+ this.removeEventListener();
679
+ if (this.listObj) {
680
+ this.unWireEvents();
681
+ }
682
+ }
683
+
684
+ private wireEvents(): void {
685
+ this.wireClickEvent(true);
686
+ this.keyboardModule = new KeyboardEvents(
687
+ this.element,
688
+ {
689
+ keyAction: this.keyActionHandler.bind(this),
690
+ keyConfigs: this.keyConfigs,
691
+ eventName: 'keyup'
692
+ }
693
+ );
694
+ this.keyboardDownModule = new KeyboardEvents(
695
+ this.element,
696
+ {
697
+ keyAction: this.keydownActionHandler.bind(this),
698
+ keyConfigs: this.keyConfigs,
699
+ eventName: 'keydown'
700
+ }
701
+ );
702
+ EventHandler.add(this.element, 'mouseover', this.onMouseOver, this);
703
+ }
704
+
705
+ private unWireEvents(): void {
706
+ this.wireClickEvent(false);
707
+ EventHandler.remove(this.element, 'mouseover', this.onMouseOver);
708
+ this.keyboardModule.destroy();
709
+ this.keyboardDownModule.destroy();
710
+ }
711
+
712
+ /* istanbul ignore next */
713
+ private onMouseOver(e: MouseArgs): void {
714
+ const targetEle: Element = closest(e.target, '.e-list-item');
715
+ removeBlur(this.parent, 'hover');
716
+ if (targetEle !== null) {
717
+ targetEle.classList.add(CLS.HOVER);
718
+ }
719
+ }
720
+
721
+ private wireClickEvent(toBind: boolean): void {
722
+ if (toBind) {
723
+ // eslint-disable-next-line
724
+ const proxy: LargeIconsView = this;
725
+ this.clickObj = new Touch(this.element, {
726
+ tap: (eve: TapEventArgs) => {
727
+ eve.originalEvent.preventDefault();
728
+ if (proxy.parent.isDevice) {
729
+ proxy.tapCount = eve.tapCount;
730
+ proxy.tapEvent = eve;
731
+ setTimeout(
732
+ () => {
733
+ if (proxy.tapCount > 0) {
734
+ proxy.doTapAction(proxy.tapEvent);
735
+ }
736
+ proxy.tapCount = 0;
737
+ },
738
+ 350);
739
+ } else {
740
+ if (eve.tapCount === 2 && eve.originalEvent.which !== 3) {
741
+ proxy.dblClickHandler(eve);
742
+ } else {
743
+ proxy.clickHandler(eve);
744
+ }
745
+ }
746
+ },
747
+ tapHold: (e: TapEventArgs) => {
748
+ if (proxy.parent.isDevice) {
749
+ proxy.multiSelect = proxy.parent.allowMultiSelection ? true : false;
750
+ if (proxy.parent.allowMultiSelection) {
751
+ addClass([proxy.parent.element], CLS.MULTI_SELECT);
752
+ }
753
+ proxy.clickHandler(e);
754
+ }
755
+ }
756
+ });
757
+ } else {
758
+ if (this.clickObj) {
759
+ this.clickObj.destroy();
760
+ }
761
+ }
762
+ }
763
+
764
+ private doTapAction(eve: TapEventArgs): void {
765
+ const target: Element = <Element>eve.originalEvent.target;
766
+ const item: Element = closest(target, '.' + CLS.LIST_ITEM);
767
+ if (this.multiSelect || target.classList.contains(CLS.LIST_PARENT) || isNOU(item)) {
768
+ this.clickHandler(eve);
769
+ } else {
770
+ this.parent.isFile = false;
771
+ this.updateType(item);
772
+ if (!this.parent.isFile) {
773
+ this.dblClickHandler(eve);
774
+ } else if (eve.tapCount === 2) {
775
+ this.clickHandler(eve);
776
+ this.dblClickHandler(eve);
777
+ } else {
778
+ this.clickHandler(eve);
779
+ }
780
+ }
781
+ }
782
+
783
+ private clickHandler(e: TapEventArgs): void {
784
+ const target: Element = <Element>e.originalEvent.target;
785
+ removeBlur(this.parent, 'hover');
786
+ this.doSelection(target, e.originalEvent);
787
+ this.parent.activeModule = 'largeiconsview';
788
+ }
789
+ /**
790
+ *
791
+ * @param {Element} target - specifies the target element.
792
+ * @param {TouchEventArgs | MouseEventArgs | KeyboardEventArgs} e - specifies event arguements.
793
+ * @returns {void}
794
+ * @hidden
795
+ */
796
+ public doSelection(target: Element, e: TouchEventArgs | MouseEventArgs | KeyboardEventArgs): void {
797
+ const item: Element = closest(target, '.' + CLS.LIST_ITEM);
798
+ const cList: DOMTokenList = target.classList;
799
+ this.parent.isFile = false;
800
+ let action: string = 'select';
801
+ if (e.which === 3 && !isNOU(item) && item.classList.contains(CLS.ACTIVE)) {
802
+ this.updateType(item);
803
+ return;
804
+ } else if (!isNOU(item)) {
805
+ if (this.parent.allowMultiSelection && item.classList.contains(CLS.ACTIVE)
806
+ && (e.ctrlKey || target.classList.contains(CLS.CHECK))) {
807
+ action = 'unselect';
808
+ }
809
+ const fileSelectionArgs: FileSelectionEventArgs = this.triggerSelection(action, item);
810
+ if (fileSelectionArgs.cancel !== true) {
811
+ if ((!this.parent.allowMultiSelection || (!this.multiSelect && (e && !e.ctrlKey)))
812
+ && !cList.contains(CLS.FRAME)) {
813
+ this.updateType(item);
814
+ this.clearSelect();
815
+ }
816
+ if (this.parent.allowMultiSelection && e.shiftKey) {
817
+ if (!(e && e.ctrlKey)) { this.clearSelect(); }
818
+ if (!this.startItem) {
819
+ this.startItem = item;
820
+ }
821
+ const startIndex: number = this.itemList.indexOf(<HTMLElement>this.startItem);
822
+ const endIndex: number = this.itemList.indexOf(<HTMLElement>item);
823
+ if (startIndex > endIndex) {
824
+ for (let i: number = startIndex; i >= endIndex; i--) {
825
+ this.addActive(this.itemList[i]);
826
+ }
827
+ } else {
828
+ for (let i: number = startIndex; i <= endIndex; i++) {
829
+ this.addActive(this.itemList[i]);
830
+ }
831
+ }
832
+ this.addFocus(this.itemList[endIndex]);
833
+ } else {
834
+ this.startItem = item;
835
+ if (this.parent.allowMultiSelection && item.classList.contains(CLS.ACTIVE)) {
836
+ this.removeActive(item);
837
+ } else {
838
+ this.addActive(item);
839
+ }
840
+ this.addFocus(item);
841
+ }
842
+ if (this.parent.selectedItems.length === 0) {
843
+ this.resetMultiSelect();
844
+ }
845
+ this.parent.notify(events.selectionChanged, {});
846
+ this.triggerSelect(action, item);
847
+ }
848
+ } else {
849
+ this.clearSelection();
850
+ }
851
+ if (!isNOU(item)) {
852
+ this.updateType(item);
853
+ }
854
+ }
855
+
856
+ private dblClickHandler(e: TapEventArgs): void {
857
+ this.parent.activeModule = 'largeiconsview';
858
+ const target: Element = <Element>e.originalEvent.target;
859
+ this.doOpenAction(target);
860
+ }
861
+
862
+ private clearSelection(): void {
863
+ this.clearSelect();
864
+ this.resetMultiSelect();
865
+ this.parent.notify(events.selectionChanged, {});
866
+ }
867
+
868
+ private resetMultiSelect(): void {
869
+ this.multiSelect = false;
870
+ removeClass([this.parent.element], CLS.MULTI_SELECT);
871
+ }
872
+
873
+ private doOpenAction(target: Element): void {
874
+ if (isNOU(target)) { return; }
875
+ const item: Element = closest(target, '.' + CLS.LIST_ITEM);
876
+ this.parent.isFile = false;
877
+ if (!isNOU(item)) {
878
+ this.updateType(item);
879
+ // eslint-disable-next-line
880
+ const details: Object = this.getItemObject(item);
881
+ if (!hasReadAccess(details)) {
882
+ createDeniedDialog(this.parent, details, events.permissionRead);
883
+ return;
884
+ }
885
+ const eventArgs: FileOpenEventArgs = { cancel: false, fileDetails: details, module: 'LargeIconsView' };
886
+ this.parent.trigger('fileOpen', eventArgs, (fileOpenArgs: FileOpenEventArgs) => {
887
+ if (!fileOpenArgs.cancel) {
888
+ const text: string = getValue('name', details);
889
+ if (!this.parent.isFile) {
890
+ const val: string = this.parent.breadcrumbbarModule.searchObj.element.value;
891
+ if (val === '' && !this.parent.isFiltered) {
892
+ const id: string = getValue('id', details);
893
+ const newPath: string = this.parent.path + (isNOU(id) ? text : id) + '/';
894
+ this.parent.setProperties({ path: newPath }, true);
895
+ this.parent.pathNames.push(text);
896
+ this.parent.pathId.push(getValue('_fm_id', details));
897
+ this.parent.itemData = [details];
898
+ openAction(this.parent);
899
+ } else {
900
+ openSearchFolder(this.parent, details);
901
+ }
902
+ this.parent.isFiltered = false;
903
+ this.parent.setProperties({ selectedItems: [] }, true);
904
+ } else {
905
+ const icon: string = fileType(details);
906
+ if (icon === CLS.ICON_IMAGE) {
907
+ const imgUrl: string = getImageUrl(this.parent, details);
908
+ createImageDialog(this.parent, text, imgUrl);
909
+ }
910
+ }
911
+ }
912
+ });
913
+ }
914
+ }
915
+
916
+ private updateType(item: Element): void {
917
+ const folder: Element = select('.' + CLS.FOLDER, item);
918
+ this.parent.isFile = isNOU(folder) ? true : false;
919
+ }
920
+
921
+ /* istanbul ignore next */
922
+ // eslint:disable-next-line
923
+ private keydownActionHandler(e: KeyboardEventArgs): void {
924
+ if (!this.isRendered) { return; }
925
+ switch (e.action) {
926
+ case 'end':
927
+ case 'home':
928
+ case 'moveDown':
929
+ case 'moveLeft':
930
+ case 'moveRight':
931
+ case 'moveUp':
932
+ case 'ctrlEnd':
933
+ case 'shiftEnd':
934
+ case 'csEnd':
935
+ case 'ctrlHome':
936
+ case 'shiftHome':
937
+ case 'csHome':
938
+ case 'ctrlDown':
939
+ case 'shiftDown':
940
+ case 'csDown':
941
+ case 'ctrlLeft':
942
+ case 'shiftLeft':
943
+ case 'csLeft':
944
+ case 'ctrlRight':
945
+ case 'shiftRight':
946
+ case 'csRight':
947
+ case 'space':
948
+ case 'ctrlSpace':
949
+ case 'shiftSpace':
950
+ case 'csSpace':
951
+ case 'ctrlA':
952
+ case 'enter':
953
+ case 'altEnter':
954
+ case 'esc':
955
+ case 'del':
956
+ case 'shiftdel':
957
+ case 'ctrlC':
958
+ case 'ctrlV':
959
+ case 'ctrlX':
960
+ case 'f2':
961
+ case 'ctrlD':
962
+ e.preventDefault();
963
+ break;
964
+ default:
965
+ break;
966
+ }
967
+ }
968
+
969
+ /* istanbul ignore next */
970
+ // eslint:disable-next-line
971
+ private keyActionHandler(e: KeyboardEventArgs): void {
972
+ if (!this.isRendered) { return; }
973
+ const fItem: Element = this.getFocusedItem();
974
+ const firstItem: Element = this.getFirstItem();
975
+ const lastItem: Element = this.getLastItem();
976
+ switch (e.action) {
977
+ case 'end':
978
+ this.navigateItem(lastItem);
979
+ break;
980
+ case 'home':
981
+ this.navigateItem(firstItem);
982
+ break;
983
+ case 'tab':
984
+ if (!isNOU(fItem)) {
985
+ this.addFocus(fItem);
986
+ } else if (!isNOU(firstItem)) {
987
+ this.addFocus(firstItem);
988
+ }
989
+ break;
990
+ case 'moveDown':
991
+ this.navigateDown(fItem, true);
992
+ break;
993
+ case 'moveLeft':
994
+ this.navigateRight(fItem, false);
995
+ break;
996
+ case 'moveRight':
997
+ this.navigateRight(fItem, true);
998
+ break;
999
+ case 'moveUp':
1000
+ this.navigateDown(fItem, false);
1001
+ break;
1002
+ case 'ctrlEnd':
1003
+ case 'shiftEnd':
1004
+ case 'csEnd':
1005
+ this.csEndKey(lastItem, e);
1006
+ break;
1007
+ case 'ctrlHome':
1008
+ case 'shiftHome':
1009
+ case 'csHome':
1010
+ this.csHomeKey(firstItem, e);
1011
+ break;
1012
+ case 'ctrlDown':
1013
+ case 'shiftDown':
1014
+ case 'csDown':
1015
+ this.csDownKey(fItem, e);
1016
+ break;
1017
+ case 'ctrlLeft':
1018
+ case 'shiftLeft':
1019
+ case 'csLeft':
1020
+ this.csLeftKey(fItem, e);
1021
+ break;
1022
+ case 'ctrlRight':
1023
+ case 'shiftRight':
1024
+ case 'csRight':
1025
+ this.csRightKey(fItem, e);
1026
+ break;
1027
+ case 'ctrlUp':
1028
+ case 'shiftUp':
1029
+ case 'csUp':
1030
+ this.csUpKey(fItem, e);
1031
+ break;
1032
+ case 'space':
1033
+ this.spaceKey(fItem);
1034
+ break;
1035
+ case 'ctrlSpace':
1036
+ case 'shiftSpace':
1037
+ case 'csSpace':
1038
+ if (!isNOU(fItem)) { this.doSelection(fItem, e); }
1039
+ break;
1040
+ case 'ctrlA':
1041
+ this.ctrlAKey(firstItem, lastItem);
1042
+ break;
1043
+ case 'enter':
1044
+ this.doOpenAction(this.parent.visitedItem ? this.parent.visitedItem : this.getVisitedItem());
1045
+ break;
1046
+ case 'altEnter':
1047
+ this.parent.notify(events.detailsInit, {});
1048
+ GetDetails(this.parent, this.parent.selectedItems, this.parent.path, 'details');
1049
+ break;
1050
+ case 'esc':
1051
+ removeActive(this.parent);
1052
+ break;
1053
+ case 'del':
1054
+ case 'shiftdel':
1055
+ this.performDelete();
1056
+ break;
1057
+ case 'ctrlC':
1058
+ copyFiles(this.parent);
1059
+ break;
1060
+ case 'ctrlV':
1061
+ this.parent.folderPath = '';
1062
+ pasteHandler(this.parent);
1063
+ break;
1064
+ case 'ctrlX':
1065
+ cutFiles(this.parent);
1066
+ break;
1067
+ case 'f2':
1068
+ this.performRename();
1069
+ break;
1070
+ case 'ctrlD':
1071
+ this.doDownload();
1072
+ break;
1073
+ }
1074
+ }
1075
+
1076
+ private doDownload(): void {
1077
+ this.updateSelectedData();
1078
+ doDownload(this.parent);
1079
+ }
1080
+
1081
+ private performDelete(): void {
1082
+ if (this.parent.selectedItems && this.parent.selectedItems.length > 0) {
1083
+ this.updateSelectedData();
1084
+ // eslint-disable-next-line
1085
+ const data: Object[] = this.parent.itemData;
1086
+ for (let i: number = 0; i < data.length; i++) {
1087
+ if (!hasEditAccess(data[i])) {
1088
+ createDeniedDialog(this.parent, data[i], events.permissionEdit);
1089
+ return;
1090
+ }
1091
+ }
1092
+ createDialog(this.parent, 'Delete');
1093
+ }
1094
+ }
1095
+
1096
+ private performRename(): void {
1097
+ if (this.parent.selectedItems.length === 1) {
1098
+ this.updateRenameData();
1099
+ doRename(this.parent);
1100
+ }
1101
+ }
1102
+
1103
+ private updateRenameData(): void {
1104
+ const item: Element = select('.' + CLS.LIST_ITEM + '.' + CLS.ACTIVE, this.element);
1105
+ // eslint-disable-next-line
1106
+ const data: Object = this.getItemObject(item);
1107
+ updateRenamingData(this.parent, data);
1108
+ }
1109
+
1110
+ private getVisitedItem(): Element {
1111
+ const item: string = this.parent.selectedItems[this.parent.selectedItems.length - 1];
1112
+ const indexes: number[] = this.getIndexes([item], this.parent.hasId);
1113
+ return this.itemList[indexes[0]];
1114
+ }
1115
+
1116
+ private getFocusedItem(): Element {
1117
+ return select('.' + CLS.LIST_ITEM + '.' + CLS.FOCUS, this.element);
1118
+ }
1119
+
1120
+ private getActiveItem(): Element {
1121
+ return select('.' + CLS.LIST_ITEM + '.' + CLS.ACTIVE, this.element);
1122
+ }
1123
+
1124
+ private getFirstItem(): Element {
1125
+ return this.itemList[0];
1126
+ }
1127
+
1128
+ private getLastItem(): Element {
1129
+ return this.itemList[this.itemList.length - 1];
1130
+ }
1131
+
1132
+ private navigateItem(item: Element): void {
1133
+ this.setFocus(item);
1134
+ }
1135
+
1136
+ private navigateDown(fItem: Element, isTowards: boolean): void {
1137
+ const nItem: Element = this.getNextItem(fItem, isTowards, this.perRow);
1138
+ this.setFocus(nItem);
1139
+ }
1140
+
1141
+ private navigateRight(fItem: Element, isTowards: boolean): void {
1142
+ const nItem: Element = this.getNextItem(fItem, isTowards);
1143
+ this.setFocus(nItem);
1144
+ }
1145
+
1146
+ private getNextItem(li: Element, isTowards: boolean, perRow?: number): Element {
1147
+ if (isNOU(li)) { return this.getFocusedItem() || this.getActiveItem() || this.getFirstItem(); }
1148
+ let index: number = this.itemList.indexOf(<HTMLElement>li);
1149
+ let nextItem: Element;
1150
+ do {
1151
+ if (isTowards) {
1152
+ index = perRow ? index + perRow : index + 1;
1153
+ } else {
1154
+ index = perRow ? index - perRow : index - 1;
1155
+ }
1156
+ nextItem = this.itemList[index];
1157
+ if (isNOU(nextItem)) {
1158
+ return li;
1159
+ }
1160
+ }
1161
+ while (!isVisible(nextItem));
1162
+ return nextItem;
1163
+ }
1164
+
1165
+ private setFocus(nextItem: Element): void {
1166
+ if (!isNOU(nextItem)) {
1167
+ const fileSelectionArgs: FileSelectionEventArgs = this.triggerSelection('select', nextItem);
1168
+ if (fileSelectionArgs.cancel !== true) {
1169
+ this.startItem = nextItem;
1170
+ this.clearSelect();
1171
+ this.addActive(nextItem);
1172
+ this.addFocus(nextItem);
1173
+ this.parent.notify(events.selectionChanged, {});
1174
+ this.triggerSelect('select', nextItem);
1175
+ }
1176
+ }
1177
+ }
1178
+
1179
+ private spaceKey(fItem: Element): void {
1180
+ if (!isNOU(fItem) && !fItem.classList.contains(CLS.ACTIVE)) {
1181
+ const fileSelectionArgs: FileSelectionEventArgs = this.triggerSelection('select', fItem);
1182
+ if (fileSelectionArgs.cancel !== true) {
1183
+ this.addActive(fItem);
1184
+ this.parent.notify(events.selectionChanged, {});
1185
+ this.triggerSelect('select', fItem);
1186
+ }
1187
+ }
1188
+ }
1189
+
1190
+ private ctrlAKey(firstItem: Element, lastItem: Element): void {
1191
+ if (this.parent.allowMultiSelection && !isNOU(firstItem)) {
1192
+ this.startItem = firstItem;
1193
+ const eveArgs: KeyboardEventArgs = { ctrlKey: true, shiftKey: true } as KeyboardEventArgs;
1194
+ const liParent: HTMLElement = this.element.querySelector('.' + CLS.LIST_PARENT);
1195
+ const liScrPos: number = liParent.scrollTop;
1196
+ const getCurFocusedItem: Element = this.getFocusedItem();
1197
+ this.doSelection(lastItem, eveArgs);
1198
+ liParent.scrollTop = liScrPos;
1199
+ if (!isNOU(getCurFocusedItem)) {
1200
+ this.addFocus(getCurFocusedItem);
1201
+ }
1202
+ }
1203
+ }
1204
+
1205
+ private csEndKey(lastItem: Element, e: KeyboardEventArgs): void {
1206
+ if (!this.parent.allowMultiSelection) {
1207
+ this.navigateItem(lastItem);
1208
+ } else if (!isNOU(lastItem)) {
1209
+ if (e.action === 'ctrlEnd') { this.addFocus(lastItem); } else { this.doSelection(lastItem, e); }
1210
+ }
1211
+ }
1212
+
1213
+ private csHomeKey(firstItem: Element, e: KeyboardEventArgs): void {
1214
+ if (!this.parent.allowMultiSelection) {
1215
+ this.navigateItem(firstItem);
1216
+ } else if (!isNOU(firstItem)) {
1217
+ if (e.action === 'ctrlHome') {
1218
+ this.addFocus(firstItem);
1219
+ } else{
1220
+ this.doSelection(firstItem, e);
1221
+ }
1222
+ }
1223
+ }
1224
+
1225
+ private csDownKey(fItem: Element, e: KeyboardEventArgs): void {
1226
+ if (!this.parent.allowMultiSelection) {
1227
+ this.navigateDown(fItem, true);
1228
+ } else {
1229
+ const dItem: Element = this.getNextItem(fItem, true, this.perRow);
1230
+ if (!isNOU(dItem)) {
1231
+ if (e.action === 'ctrlDown') {
1232
+ this.addFocus(dItem);
1233
+ } else {
1234
+ this.doSelection(dItem, e);
1235
+ }
1236
+ }
1237
+ }
1238
+ }
1239
+
1240
+ private csLeftKey(fItem: Element, e: KeyboardEventArgs): void {
1241
+ if (!this.parent.allowMultiSelection) {
1242
+ this.navigateRight(fItem, false);
1243
+ } else {
1244
+ const lItem: Element = this.getNextItem(fItem, false);
1245
+ if (!isNOU(lItem)) {
1246
+ if (e.action === 'ctrlLeft') {
1247
+ this.addFocus(lItem);
1248
+ } else {
1249
+ this.doSelection(lItem, e);
1250
+ }
1251
+ }
1252
+ }
1253
+ }
1254
+
1255
+ private csRightKey(fItem: Element, e: KeyboardEventArgs): void {
1256
+ if (!this.parent.allowMultiSelection) {
1257
+ this.navigateRight(fItem, true);
1258
+ } else {
1259
+ const rItem: Element = this.getNextItem(fItem, true);
1260
+ if (!isNOU(rItem)) {
1261
+ if (e.action === 'ctrlRight'){
1262
+ this.addFocus(rItem);
1263
+ } else{
1264
+ this.doSelection(rItem, e);
1265
+ }
1266
+ }
1267
+ }
1268
+ }
1269
+
1270
+ private csUpKey(fItem: Element, e: KeyboardEventArgs): void {
1271
+ if (!this.parent.allowMultiSelection) {
1272
+ this.navigateDown(fItem, false);
1273
+ } else {
1274
+ const uItem: Element = this.getNextItem(fItem, false, this.perRow);
1275
+ if (!isNOU(uItem)) {
1276
+ if (e.action === 'ctrlUp') {
1277
+ this.addFocus(uItem);
1278
+ } else{
1279
+ this.doSelection(uItem, e);
1280
+ }
1281
+ }
1282
+ }
1283
+ }
1284
+
1285
+ private addActive(nextItem: Element): void {
1286
+ if (!isNOU(nextItem)) {
1287
+ if (!nextItem.classList.contains(CLS.ACTIVE)) {
1288
+ this.parent.selectedItems.push(this.getDataName(nextItem));
1289
+ this.parent.setProperties({ selectedItems: this.parent.selectedItems }, true);
1290
+ addClass([nextItem], [CLS.ACTIVE]);
1291
+ nextItem.setAttribute('aria-selected', 'true');
1292
+ this.checkState(nextItem, true);
1293
+ }
1294
+ this.parent.visitedItem = nextItem;
1295
+ }
1296
+ }
1297
+
1298
+ private removeActive(preItem: Element): void {
1299
+ if (!isNOU(preItem)) {
1300
+ removeClass([preItem], [CLS.ACTIVE]);
1301
+ if (this.parent.allowMultiSelection) {
1302
+ preItem.setAttribute('aria-selected', 'false');
1303
+ } else {
1304
+ preItem.removeAttribute('aria-selected');
1305
+ }
1306
+ this.checkState(preItem, false);
1307
+ const index: number = this.parent.selectedItems.indexOf(this.getDataName(preItem));
1308
+ if (index > -1) {
1309
+ this.parent.selectedItems.splice(index, 1);
1310
+ this.parent.setProperties({ selectedItems: this.parent.selectedItems }, true);
1311
+ }
1312
+ this.parent.visitedItem = null;
1313
+ }
1314
+ }
1315
+
1316
+ private getDataName(item: Element): string {
1317
+ // eslint-disable-next-line
1318
+ const data: Object = this.getItemObject(item);
1319
+ return getItemName(this.parent, data);
1320
+ }
1321
+
1322
+ private addFocus(item: Element): void {
1323
+ this.element.setAttribute('tabindex', '-1');
1324
+ const fItem: Element = this.getFocusedItem();
1325
+ if (fItem) {
1326
+ fItem.removeAttribute('tabindex');
1327
+ removeClass([fItem], [CLS.FOCUS]);
1328
+ }
1329
+ addClass([item], [CLS.FOCUS]);
1330
+ item.setAttribute('tabindex', '0');
1331
+ (item as HTMLElement).focus();
1332
+ }
1333
+
1334
+ private checkState(item: Element, toCheck: boolean): void {
1335
+ if (!this.parent.allowMultiSelection) { return; }
1336
+ const checkEle: Element = select('.' + CLS.FRAME, item);
1337
+ if (isNOU(checkEle)) { return; }
1338
+ if (toCheck) {
1339
+ if (!checkEle.classList.contains(CLS.CHECK)) {
1340
+ addClass([checkEle], CLS.CHECK);
1341
+ closest(checkEle, '.' + CLS.CB_WRAP).setAttribute('aria-checked', 'true');
1342
+ }
1343
+ } else {
1344
+ if (checkEle.classList.contains(CLS.CHECK)) {
1345
+ removeClass([checkEle], CLS.CHECK);
1346
+ closest(checkEle, '.' + CLS.CB_WRAP).setAttribute('aria-checked', 'false');
1347
+ }
1348
+ }
1349
+ }
1350
+
1351
+ private clearSelect(): void {
1352
+ const eles: Element[] = Array.prototype.slice.call(selectAll('.' + CLS.ACTIVE, this.listElements));
1353
+ let fileSelectionArgs: FileSelectionEventArgs;
1354
+ if (eles.length !== 0) {
1355
+ fileSelectionArgs = this.triggerSelection('unselect', eles[0]);
1356
+ if (fileSelectionArgs.cancel !== true) {
1357
+ for (let i: number = 0, len: number = eles.length; i < len; i++) {
1358
+ this.removeActive(eles[i]);
1359
+ }
1360
+ }
1361
+ this.triggerSelect('unselect', eles[0]);
1362
+ }
1363
+ }
1364
+
1365
+ private resizeHandler(): void {
1366
+ this.getItemCount();
1367
+ if (!isNOU(this.listObj)) {
1368
+ this.adjustHeight();
1369
+ }
1370
+ }
1371
+
1372
+ private splitterResizeHandler(): void {
1373
+ this.getItemCount();
1374
+ }
1375
+
1376
+ private getItemCount(): void {
1377
+ let perRow: number = 1;
1378
+ if (this.itemList) {
1379
+ for (let i: number = 0, len: number = this.itemList.length - 1; i < len; i++) {
1380
+ if (this.itemList[i].getBoundingClientRect().top === this.itemList[i + 1].getBoundingClientRect().top) {
1381
+ perRow++;
1382
+ } else {
1383
+ break;
1384
+ }
1385
+ }
1386
+ }
1387
+ this.perRow = perRow;
1388
+ }
1389
+ private triggerSelection(action: string, item: Element): FileSelectionEventArgs {
1390
+ // eslint-disable-next-line
1391
+ const data: Object = this.getItemObject(item);
1392
+ const eventArgs: FileSelectionEventArgs = {
1393
+ action: action, fileDetails: data, isInteracted: this.isInteraction, cancel: false, target: item
1394
+ };
1395
+ this.parent.trigger('fileSelection', eventArgs);
1396
+ this.isInteraction = true;
1397
+ return eventArgs;
1398
+ }
1399
+
1400
+ private triggerSelect(action: string, item: Element): void {
1401
+ // eslint-disable-next-line
1402
+ const data: Object = this.getItemObject(item);
1403
+ this.parent.visitedData = data;
1404
+ const eventArgs: FileSelectEventArgs = { action: action, fileDetails: data, isInteracted: this.isInteracted };
1405
+ this.parent.trigger('fileSelect', eventArgs);
1406
+ this.isInteracted = true;
1407
+ }
1408
+
1409
+ private selectItems(items: string[]): void {
1410
+ const indexes: number[] = this.getIndexes(items, this.parent.hasId);
1411
+ for (let j: number = 0, len: number = indexes.length; j < len; j++) {
1412
+ const eveArgs: KeyboardEventArgs = { ctrlKey: true, shiftKey: false } as KeyboardEventArgs;
1413
+ this.doSelection(this.itemList[indexes[j]], eveArgs);
1414
+ }
1415
+ }
1416
+
1417
+ private getIndexes(items: string[], byId?: boolean): number[] {
1418
+ const indexes: number[] = [];
1419
+ const filter: string = byId ? 'id' : 'name';
1420
+ for (let i: number = 0, len: number = this.items.length; i < len; i++) {
1421
+ if (items.indexOf(getValue(filter, this.items[i])) !== -1) {
1422
+ indexes.push(i);
1423
+ }
1424
+ }
1425
+ return indexes;
1426
+ }
1427
+
1428
+ // eslint-disable-next-line
1429
+ private getItemObject(item: Element): Object {
1430
+ const index: number = this.itemList.indexOf(<HTMLElement>item);
1431
+ return this.items[index];
1432
+ }
1433
+
1434
+ // eslint-disable-next-line
1435
+ private addSelection(data: Object): void {
1436
+ // eslint-disable-next-line
1437
+ let resultData: Object[] = [];
1438
+ if (this.parent.hasId) {
1439
+ resultData = new DataManager(this.items).
1440
+ executeLocal(new Query().where('id', 'equal', this.parent.renamedId, false));
1441
+ } else {
1442
+ // eslint-disable-next-line
1443
+ const newData: Object[] = new DataManager(this.items).
1444
+ executeLocal(new Query().where('name', 'equal', getValue('name', data), false));
1445
+ if (newData.length > 0) {
1446
+ resultData = new DataManager(newData).
1447
+ executeLocal(new Query().where('filterPath', 'equal', this.parent.filterPath, false));
1448
+ }
1449
+ }
1450
+ if (resultData.length > 0) {
1451
+ const index: number = this.items.indexOf(resultData[0]);
1452
+ const eveArgs: KeyboardEventArgs = { ctrlKey: true, shiftKey: false } as KeyboardEventArgs;
1453
+ this.doSelection(this.itemList[index], eveArgs);
1454
+ }
1455
+ }
1456
+
1457
+ private updateSelectedData(): void {
1458
+ // eslint-disable-next-line
1459
+ const data: object[] = [];
1460
+ const items: Element[] = selectAll('.' + CLS.LIST_ITEM + '.' + CLS.ACTIVE, this.element);
1461
+ for (let i: number = 0; i < items.length; i++) {
1462
+ data[i] = this.getItemObject(items[i]);
1463
+ }
1464
+ this.parent.itemData = data;
1465
+ }
1466
+
1467
+ // eslint-disable-next-line
1468
+ private onMethodCall(args: Object): void {
1469
+ if (this.parent.view !== 'LargeIcons') { return; }
1470
+ const action: string = getValue('action', args);
1471
+ switch (action) {
1472
+ case 'deleteFiles':
1473
+ this.deleteFiles(getValue('ids', args));
1474
+ break;
1475
+ case 'downloadFiles':
1476
+ this.downloadFiles(getValue('ids', args));
1477
+ break;
1478
+ case 'openFile':
1479
+ this.openFile(getValue('id', args));
1480
+ break;
1481
+ case 'renameFile':
1482
+ this.isInteraction = false;
1483
+ this.isInteracted = false;
1484
+ this.renameFile(getValue('id', args), getValue('newName', args));
1485
+ break;
1486
+ case 'createFolder':
1487
+ this.isInteraction = false;
1488
+ this.isInteracted = false;
1489
+ break;
1490
+ case 'clearSelection':
1491
+ this.isInteraction = false;
1492
+ this.isInteracted = false;
1493
+ this.onClearAllInit();
1494
+ break;
1495
+ case 'selectAll':
1496
+ this.isInteraction = false;
1497
+ this.isInteracted = false;
1498
+ this.onSelectAllInit();
1499
+ break;
1500
+ }
1501
+ }
1502
+
1503
+ private getItemsIndex(items: string[]): number[] {
1504
+ const indexes: number[] = [];
1505
+ const isFilter: boolean = (this.parent.breadcrumbbarModule.searchObj.element.value !== '' || this.parent.isFiltered) ? true : false;
1506
+ const filterName: string = this.parent.hasId ? 'id' : 'name';
1507
+ if (this.parent.hasId || !isFilter) {
1508
+ for (let i: number = 0, len: number = this.items.length; i < len; i++) {
1509
+ if (items.indexOf(getValue(filterName, this.items[i])) !== -1) {
1510
+ indexes.push(i);
1511
+ }
1512
+ }
1513
+ } else {
1514
+ for (let i: number = 0, len: number = this.items.length; i < len; i++) {
1515
+ const name: string = getValue('filterPath', this.items[i]) + getValue('name', this.items[i]);
1516
+ if ((items.indexOf(name) !== -1) || (items.indexOf(getValue(filterName, this.items[i])) !== -1)) {
1517
+ indexes.push(i);
1518
+ }
1519
+ }
1520
+ }
1521
+ return indexes;
1522
+ }
1523
+
1524
+ private deleteFiles(ids: string[]): void {
1525
+ this.parent.activeModule = 'largeiconsview';
1526
+ if (isNOU(ids)) {
1527
+ this.performDelete();
1528
+ return;
1529
+ }
1530
+ const indexes: number[] = this.getItemsIndex(ids);
1531
+ if (indexes.length === 0) { return; }
1532
+ // eslint-disable-next-line
1533
+ const data: Object[] = [];
1534
+ const newIds: string[] = [];
1535
+ for (let i: number = 0; i < indexes.length; i++) {
1536
+ data[i] = this.items[indexes[i]];
1537
+ newIds[i] = getItemName(this.parent, data[i]);
1538
+ }
1539
+ doDeleteFiles(this.parent, data, newIds);
1540
+ }
1541
+
1542
+ private downloadFiles(ids: string[]): void {
1543
+ if (isNOU(ids)) {
1544
+ this.doDownload();
1545
+ return;
1546
+ }
1547
+ const index: number[] = this.getItemsIndex(ids);
1548
+ if (index.length === 0) { return; }
1549
+ // eslint-disable-next-line
1550
+ const data: Object[] = [];
1551
+ const newIds: string[] = [];
1552
+ for (let i: number = 0; i < index.length; i++) {
1553
+ data[i] = this.items[index[i]];
1554
+ newIds[i] = getItemName(this.parent, data[i]);
1555
+ }
1556
+ doDownloadFiles(this.parent, data, newIds);
1557
+ }
1558
+
1559
+ private openFile(id: string): void {
1560
+ if (isNOU(id)) { return; }
1561
+ const indexes: number[] = this.getItemsIndex([id]);
1562
+ if (indexes.length > 0) {
1563
+ this.doOpenAction(this.itemList[indexes[0]]);
1564
+ }
1565
+ }
1566
+
1567
+ private renameFile(id: string, name: string): void {
1568
+ this.parent.activeModule = 'largeiconsview';
1569
+ if (isNOU(id)) {
1570
+ this.performRename();
1571
+ return;
1572
+ }
1573
+ const indexes: number[] = this.getItemsIndex([id]);
1574
+ if (indexes.length > 0) {
1575
+ updateRenamingData(this.parent, this.items[indexes[0]]);
1576
+ if (isNOU(name)) {
1577
+ doRename(this.parent);
1578
+ } else {
1579
+ if (!hasEditAccess(this.parent.itemData[0])) {
1580
+ createDeniedDialog(this.parent, this.parent.itemData[0], events.permissionEdit);
1581
+ } else {
1582
+ rename(this.parent, this.parent.path, name);
1583
+ }
1584
+ }
1585
+ }
1586
+ }
1587
+ }