@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,1503 @@
1
+ import { IFileManager, ReadArgs, SortOrder, SearchArgs, FileDragEventArgs, BeforeImageLoadEventArgs } from '../base/interface';
2
+ import * as CLS from '../base/classes';
3
+ import * as events from '../base/constant';
4
+ import { read, paste, Search, filter, Download, Delete } from '../common/operations';
5
+ import { getValue, setValue, isNullOrUndefined as isNOU, matches, select, createElement, Draggable } from '@syncfusion/ej2-base';
6
+ import { closest, DragEventArgs, detach } from '@syncfusion/ej2-base';
7
+ import { DataManager, Query } from '@syncfusion/ej2-data';
8
+ import { MenuEventArgs } from '@syncfusion/ej2-navigations';
9
+ import { createDialog } from '../pop-up/dialog';
10
+
11
+ /**
12
+ * Utility file for common actions
13
+ *
14
+ * @param {HTMLLIElement} node - specifies the node.
15
+ * @param {Object} data - specifies the data.
16
+ * @param {IFileManager} instance - specifies the control instance.
17
+ * @returns {void}
18
+ * @private
19
+ */
20
+ // eslint-disable-next-line
21
+ export function updatePath(node: HTMLLIElement, data: Object, instance: IFileManager): void {
22
+ const text: string = getValue('name', data);
23
+ const id: string = node.getAttribute('data-id');
24
+ const newText: string = isNOU(id) ? text : id;
25
+ instance.setProperties({ path: getPath(node, newText, instance.hasId) }, true);
26
+ instance.pathId = getPathId(node);
27
+ instance.pathNames = getPathNames(node, text);
28
+ }
29
+ /**
30
+ * Functions for get path in FileManager
31
+ *
32
+ * @param {Element | Node} element - specifies the element.
33
+ * @param {string} text - specifies the text.
34
+ * @param {boolean} hasId - specifies the id.
35
+ * @returns {string} returns the path.
36
+ * @private
37
+ */
38
+ export function getPath(element: Element | Node, text: string, hasId: boolean): string {
39
+ const matched: string[] = getParents(<Element>element, text, false, hasId);
40
+ let path: string = hasId ? '' : '/';
41
+ const len: number = matched.length - (hasId ? 1 : 2);
42
+ for (let i: number = len; i >= 0; i--) {
43
+ path += matched[i] + '/';
44
+ }
45
+ return path;
46
+ }
47
+
48
+ /**
49
+ * Functions for get path id in FileManager
50
+ *
51
+ * @param {Element} node - specifies the node element.
52
+ * @returns {string[]} returns the path ids.
53
+ * @private
54
+ */
55
+ export function getPathId(node: Element): string[] {
56
+ const matched: string[] = getParents(node, node.getAttribute('data-uid'), true);
57
+ const ids: string[] = [];
58
+ for (let i: number = matched.length - 1; i >= 0; i--) {
59
+ ids.push(matched[i]);
60
+ }
61
+ return ids;
62
+ }
63
+
64
+ /**
65
+ * Functions for get path names in FileManager
66
+ *
67
+ * @param {Element} element - specifies the node element.
68
+ * @param {string} text - specifies the text.
69
+ * @returns {string[]} returns the path names.
70
+ * @private
71
+ */
72
+ export function getPathNames(element: Element, text: string): string[] {
73
+ const matched: string[] = getParents(element, text, false);
74
+ const names: string[] = [];
75
+ for (let i: number = matched.length - 1; i >= 0; i--) {
76
+ names.push(matched[i]);
77
+ }
78
+ return names;
79
+ }
80
+
81
+ /**
82
+ * Functions for get path id in FileManager
83
+ *
84
+ * @param {Element} element - specifies the node element.
85
+ * @param {string} text - specifies the text.
86
+ * @param {boolean} isId - specifies the id.
87
+ * @param {boolean} hasId - checks the id exists.
88
+ * @returns {string[]} returns parent element.
89
+ * @private
90
+ */
91
+ export function getParents(element: Element, text: string, isId: boolean, hasId?: boolean): string[] {
92
+ const matched: string[] = [text];
93
+ let el: Element = <Element>element.parentNode;
94
+ while (!isNOU(el)) {
95
+ if (matches(el, '.' + CLS.LIST_ITEM)) {
96
+ const parentText: string = isId ? el.getAttribute('data-uid') : (hasId ? el.getAttribute('data-id') :
97
+ select('.' + CLS.LIST_TEXT, el).textContent);
98
+ matched.push(parentText);
99
+ }
100
+ el = <Element>el.parentNode;
101
+ if (el.classList.contains(CLS.TREE_VIEW)) {
102
+ break;
103
+ }
104
+ }
105
+ return matched;
106
+ }
107
+ /**
108
+ * Functions for generate path
109
+ *
110
+ * @param {IFileManager} parent - specifies the parent element.
111
+ * @returns {void}
112
+ * @private
113
+ */
114
+ export function generatePath(parent: IFileManager): void {
115
+ const key: string = parent.hasId ? 'id' : 'name';
116
+ let newPath: string = parent.hasId ? '' : '/';
117
+ let i: number = parent.hasId ? 0 : 1;
118
+ for (i; i < parent.pathId.length; i++) {
119
+ // eslint-disable-next-line
120
+ const data: Object = getValue(parent.pathId[i], parent.feParent);
121
+ newPath += getValue(key, data) + '/';
122
+ }
123
+ parent.setProperties({ path: newPath }, true);
124
+ }
125
+
126
+ /**
127
+ * Functions for remove active element
128
+ *
129
+ * @param {IFileManager} parent - specifies the parent element.
130
+ * @returns {void}
131
+ * @private
132
+ */
133
+ export function removeActive(parent: IFileManager): void {
134
+ if (parent.isCut) {
135
+ removeBlur(parent);
136
+ parent.selectedNodes = [];
137
+ parent.actionRecords = [];
138
+ parent.enablePaste = false;
139
+ parent.notify(events.hidePaste, {});
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Selects active element in File Manager
145
+ *
146
+ * @param {string} action - specifies the action.
147
+ * @param {IFileManager} parent - specifies the parent element.
148
+ * @returns {boolean} - returns active element.
149
+ * @private
150
+ */
151
+ export function activeElement(action: string, parent: IFileManager): boolean {
152
+ parent.isSearchCut = false;
153
+ parent.actionRecords = [];
154
+ parent.activeElements = [];
155
+ parent.notify(events.cutCopyInit, {});
156
+ if (parent.activeElements.length === 0) { return false; }
157
+ removeBlur(parent);
158
+ const blurEle: Element[] = parent.activeElements;
159
+ if (parent.activeModule !== 'navigationpane') {
160
+ parent.targetPath = parent.path;
161
+ } else {
162
+ parent.targetPath = getParentPath(parent.path);
163
+ }
164
+ let i: number = 0;
165
+ if (blurEle) {
166
+ getModule(parent, blurEle[0]);
167
+ if (action === 'cut') {
168
+ while (i < blurEle.length) {
169
+ addBlur(blurEle[i]);
170
+ i++;
171
+ }
172
+ }
173
+ }
174
+ i = 0;
175
+ parent.selectedNodes = [];
176
+ parent.enablePaste = true;
177
+ parent.notify(events.showPaste, {});
178
+ while (i < parent.activeRecords.length) {
179
+ parent.actionRecords.push(parent.activeRecords[i]);
180
+ parent.selectedNodes.push(getValue('name', parent.activeRecords[i]));
181
+ i++;
182
+ }
183
+ if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) &&
184
+ parent.activeModule !== 'navigationpane') {
185
+ parent.selectedNodes = [];
186
+ parent.isSearchCut = true;
187
+ let i: number = 0;
188
+ while (i < parent.selectedItems.length) {
189
+ parent.selectedNodes.push(parent.selectedItems[i]);
190
+ i++;
191
+ }
192
+ }
193
+ return true;
194
+ }
195
+ /**
196
+ * Adds blur to the elements
197
+ *
198
+ * @param {Element} nodes - specifies the nodes.
199
+ * @returns {void}
200
+ * @private
201
+ */
202
+ export function addBlur(nodes: Element): void {
203
+ nodes.classList.add(CLS.BLUR);
204
+ }
205
+
206
+ /**
207
+ * Removes blur from elements
208
+ *
209
+ * @param {IFileManager} parent - specifies the parent element.
210
+ * @param {string} hover - specifies the hover string.
211
+ * @returns {void}
212
+ * @private
213
+ */
214
+ export function removeBlur(parent?: IFileManager, hover?: string): void {
215
+ const blurEle: NodeListOf<Element> = (!hover) ? parent.element.querySelectorAll('.' + CLS.BLUR) :
216
+ parent.element.querySelectorAll('.' + CLS.HOVER);
217
+ let i: number = 0;
218
+ while (i < blurEle.length) {
219
+ blurEle[i].classList.remove((!hover) ? CLS.BLUR : CLS.HOVER);
220
+ i++;
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Gets module name
226
+ *
227
+ * @param {IFileManager} parent - specifies the parent element.
228
+ * @param {Element} element - specifies the element.
229
+ * @returns {void}
230
+ * @private
231
+ */
232
+ export function getModule(parent: IFileManager, element: Element): void {
233
+ if (element) {
234
+ if (element.classList.contains(CLS.ROW)) {
235
+ parent.activeModule = 'detailsview';
236
+ } else if (closest(element, '.' + CLS.LARGE_ICON)) {
237
+ parent.activeModule = 'largeiconsview';
238
+ } else {
239
+ parent.activeModule = 'navigationpane';
240
+ }
241
+ }
242
+ }
243
+
244
+ /**
245
+ * Gets module name
246
+ *
247
+ * @param {IFileManager} parent - specifies the parent element.
248
+ * @param {string} value - specifies the value.
249
+ * @param {boolean} isLayoutChange - specifies the layout change.
250
+ * @returns {void}
251
+ * @private
252
+ */
253
+ export function searchWordHandler(parent: IFileManager, value: string, isLayoutChange: boolean): void {
254
+ let searchWord: string;
255
+ if (value.length === 0 && !parent.isFiltered) {
256
+ parent.notify(events.pathColumn, { args: parent });
257
+ }
258
+ if (parent.searchSettings.filterType === 'startsWith') {
259
+ searchWord = value + '*';
260
+ } else if (parent.searchSettings.filterType === 'endsWith') {
261
+ searchWord = '*' + value;
262
+ } else {
263
+ searchWord = '*' + value + '*';
264
+ }
265
+ parent.searchWord = searchWord;
266
+ parent.itemData = [getPathObject(parent)];
267
+ if (value.length > 0) {
268
+ const caseSensitive: boolean = parent.searchSettings.ignoreCase;
269
+ const hiddenItems: boolean = parent.showHiddenItems;
270
+ Search(parent, isLayoutChange ? events.layoutChange : events.search, parent.path, searchWord, hiddenItems, !caseSensitive);
271
+ } else {
272
+ if (!parent.isFiltered) {
273
+ if (parent.isSortByClicked) {
274
+ parent.notify(events.layoutChange, { files: parent.largeiconsviewModule.items });
275
+ parent.isSortByClicked = false;
276
+ } else {
277
+ read(parent, isLayoutChange ? events.layoutChange : events.search, parent.path);
278
+ }
279
+ } else {
280
+ filter(parent, events.layoutChange);
281
+ }
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Gets updated layout
287
+ *
288
+ * @param {IFileManager} parent - specifies the parent element.
289
+ * @param {string} view - specifies the view.
290
+ * @returns {void}
291
+ * @private
292
+ */
293
+ export function updateLayout(parent: IFileManager, view: string): void {
294
+ parent.setProperties({ view: view }, true);
295
+ if (parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) {
296
+ parent.layoutSelectedItems = parent.selectedItems;
297
+ }
298
+ let searchWord: string = '';
299
+ if (parent.breadcrumbbarModule.searchObj.element.value) {
300
+ searchWord = parent.breadcrumbbarModule.searchObj.element.value;
301
+ }
302
+ parent.isLayoutChange = true;
303
+ searchWordHandler(parent, searchWord, true);
304
+ }
305
+
306
+ /* istanbul ignore next */
307
+ /**
308
+ * Gets updated layout
309
+ *
310
+ * @param {IFileManager} parent - specifies the parent element.
311
+ * @param {Element} element - specifies the element.
312
+ * @returns {void}
313
+ * @private
314
+ */
315
+ export function getTargetModule(parent: IFileManager, element: Element): void {
316
+ let tartgetModule: string = '';
317
+ if (element) {
318
+ if (closest(element, '.' + CLS.ROOT + '.' + CLS.CONTROL + ' .' + CLS.GRID_CONTENT)) {
319
+ tartgetModule = 'detailsview';
320
+ } else if (closest(element, '.' + CLS.LARGE_ICONS)) {
321
+ tartgetModule = 'largeiconsview';
322
+ } else if (element.classList.contains('e-fullrow') ||
323
+ element.classList.contains('e-icon-expandable')) {
324
+ tartgetModule = 'navigationpane';
325
+ } else if (closest(element, '.e-address-list-item')) {
326
+ tartgetModule = 'breadcrumbbar';
327
+ } else {
328
+ tartgetModule = '';
329
+ }
330
+ }
331
+ parent.targetModule = tartgetModule;
332
+ }
333
+ /* istanbul ignore next */
334
+ /**
335
+ * refresh the layout
336
+ *
337
+ * @param {IFileManager} parent - specifies the parent element.
338
+ * @returns {void}
339
+ * @private
340
+ */
341
+ export function refresh(parent: IFileManager): void {
342
+ parent.itemData = [getPathObject(parent)];
343
+ if (!hasReadAccess(parent.itemData[0])) {
344
+ createDeniedDialog(parent, parent.itemData[0], events.permissionRead);
345
+ } else {
346
+ read(parent, events.refreshEnd, parent.path);
347
+ }
348
+ }
349
+
350
+ /**
351
+ * open action in the layout
352
+ *
353
+ * @param {IFileManager} parent - specifies the parent element.
354
+ * @returns {void}
355
+ * @private
356
+ */
357
+ export function openAction(parent: IFileManager): void {
358
+ read(parent, events.openEnd, parent.path);
359
+ }
360
+
361
+ /**
362
+ * open action in the layout
363
+ *
364
+ * @param {IFileManager} parent - specifies the parent element.
365
+ * @returns {Object} - returns the path data.
366
+ * @private
367
+ */
368
+ // eslint-disable-next-line
369
+ export function getPathObject(parent: IFileManager): Object {
370
+ return getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
371
+ }
372
+
373
+ /**
374
+ * Copy files
375
+ *
376
+ * @param {IFileManager} parent - specifies the parent element.
377
+ * @returns {void}
378
+ * @private
379
+ */
380
+ export function copyFiles(parent: IFileManager): void {
381
+ if (!activeElement('copy', parent)) {
382
+ return;
383
+ } else {
384
+ parent.fileAction = 'copy';
385
+ }
386
+ }
387
+
388
+ /**
389
+ * Cut files
390
+ *
391
+ * @param {IFileManager} parent - specifies the parent element.
392
+ * @returns {void}
393
+ * @private
394
+ */
395
+ export function cutFiles(parent: IFileManager): void {
396
+ if (!activeElement('cut', parent)) {
397
+ return;
398
+ } else {
399
+ parent.isCut = true;
400
+ parent.fileAction = 'move';
401
+ }
402
+ }
403
+
404
+ /**
405
+ * To add class for fileType
406
+ *
407
+ * @param {Object} file - specifies the file.
408
+ * @returns {string} - returns the file type.
409
+ * @private
410
+ */
411
+ // eslint-disable-next-line
412
+ export function fileType(file: Object): string {
413
+ const isFile: string = getValue('isFile', file);
414
+ if (!isFile) {
415
+ return CLS.FOLDER;
416
+ }
417
+ const imageFormat: string[] = ['bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jfif', 'gif', 'tif', 'tiff', 'png', 'ico'];
418
+ const audioFormat: string[] = ['mp3', 'wav', 'aac', 'ogg', 'wma', 'aif', 'fla', 'm4a'];
419
+ const videoFormat: string[] = ['webm', 'mkv', 'flv', 'vob', 'ogv', 'ogg', 'avi', 'wmv', 'mp4', '3gp'];
420
+ const knownFormat: string[] = ['css', 'exe', 'html', 'js', 'msi', 'pdf', 'pptx', 'ppt', 'rar', 'zip', 'txt', 'docx', 'doc',
421
+ 'xlsx', 'xls', 'xml', 'rtf', 'php'];
422
+ let filetype: string = getValue('type', file);
423
+ filetype = filetype.toLowerCase();
424
+ if (filetype.indexOf('.') !== -1) {
425
+ filetype = filetype.split('.').join('');
426
+ }
427
+ let iconType: string;
428
+ if (imageFormat.indexOf(filetype) !== -1) {
429
+ iconType = CLS.ICON_IMAGE;
430
+ } else if (audioFormat.indexOf(filetype) !== -1) {
431
+ iconType = CLS.ICON_MUSIC;
432
+ } else if (videoFormat.indexOf(filetype) !== -1) {
433
+ iconType = CLS.ICON_VIDEO;
434
+ } else if (knownFormat.indexOf(filetype) !== -1) {
435
+ iconType = 'e-fe-' + filetype;
436
+ } else {
437
+ iconType = 'e-fe-unknown e-fe-' + filetype;
438
+ }
439
+ return iconType;
440
+ }
441
+ /* istanbul ignore next */
442
+ /**
443
+ * To get the image URL
444
+ *
445
+ * @param {IFileManager} parent - specifies the parent element.
446
+ * @param {Object} item - specifies the item.
447
+ * @returns {string} - returns the image url.
448
+ * @private
449
+ */
450
+ // eslint-disable-next-line
451
+ export function getImageUrl(parent: IFileManager, item: Object): string {
452
+ const baseUrl: string = parent.ajaxSettings.getImageUrl ? parent.ajaxSettings.getImageUrl : parent.ajaxSettings.url;
453
+ let imgUrl: string;
454
+ const fileName: string = encodeURIComponent(getValue('name', item));
455
+ const fPath: string = getValue('filterPath', item);
456
+ if (parent.hasId) {
457
+ const imgId: string = getValue('id', item);
458
+ imgUrl = baseUrl + '?path=' + parent.path + '&id=' + imgId;
459
+ } else if (!isNOU(fPath)) {
460
+ imgUrl = baseUrl + '?path=' + fPath.replace(/\\/g, '/') + fileName;
461
+ } else {
462
+ imgUrl = baseUrl + '?path=' + parent.path + fileName;
463
+ }
464
+ imgUrl = imgUrl + '&time=' + (new Date().getTime()).toString();
465
+ const eventArgs: BeforeImageLoadEventArgs = {
466
+ fileDetails: [item],
467
+ imageUrl: imgUrl
468
+ };
469
+ parent.trigger('beforeImageLoad', eventArgs);
470
+ return eventArgs.imageUrl;
471
+ }
472
+ /* istanbul ignore next */
473
+ /**
474
+ * Gets the full path
475
+ *
476
+ * @param {IFileManager} parent - specifies the parent element.
477
+ * @param {Object} data - specifies the data.
478
+ * @param {string} path - specifies the path.
479
+ * @returns {string} - returns the image url.
480
+ * @private
481
+ */
482
+ // eslint-disable-next-line
483
+ export function getFullPath(parent: IFileManager, data: Object, path: string): string {
484
+ const filePath: string = getValue(parent.hasId ? 'id' : 'name', data) + '/';
485
+ const fPath: string = getValue(parent.hasId ? 'filterId' : 'filterPath', data);
486
+ if (!isNOU(fPath)) {
487
+ return fPath.replace(/\\/g, '/') + filePath;
488
+ } else {
489
+ return path + filePath;
490
+ }
491
+ }
492
+ /**
493
+ * Gets the name
494
+ *
495
+ * @param {IFileManager} parent - specifies the parent element.
496
+ * @param {Object} data - specifies the data.
497
+ * @returns {string} - returns the name.
498
+ * @private
499
+ */
500
+ // eslint-disable-next-line
501
+ export function getName(parent: IFileManager, data: Object): string {
502
+ let name: string = getValue('name', data);
503
+ let fPath: string = getValue('filterPath', data);
504
+ if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) && !isNOU(fPath)) {
505
+ fPath = fPath.replace(/\\/g, '/');
506
+ name = fPath.replace(parent.path, '') + name;
507
+ }
508
+ return name;
509
+ }
510
+
511
+ /**
512
+ * Gets the name
513
+ *
514
+ * @param {IFileManager} parent - specifies the parent element.
515
+ * @param {Object[]} items - specifies the item elements.
516
+ * @returns {Object[]} - returns the sorted data.
517
+ * @private
518
+ */
519
+ // eslint-disable-next-line
520
+ export function getSortedData(parent: IFileManager, items: Object[]): Object[] {
521
+ if (items.length === 0) { return items; }
522
+ let query: Query ;
523
+ if (parent.sortOrder !== 'None') {
524
+ query = new Query().sortBy(parent.sortBy, parent.sortOrder.toLowerCase(), true).group('isFile');
525
+ } else {
526
+ query = new Query().group('isFile');
527
+ }
528
+ // eslint-disable-next-line
529
+ const lists: Object[] = new DataManager(items).executeLocal(query);
530
+ return getValue('records', lists);
531
+ }
532
+ /**
533
+ * Gets the data object
534
+ *
535
+ * @param {IFileManager} parent - specifies the parent element.
536
+ * @param {string} key - specifies the key.
537
+ * @param {string} value - specifies the value.
538
+ * @returns {Object} - returns the sorted data.
539
+ * @private
540
+ */
541
+ // eslint-disable-next-line
542
+ export function getObject(parent: IFileManager, key: string, value: string): Object {
543
+ // eslint-disable-next-line
544
+ const currFiles: Object[] = getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
545
+ const query: Query = new Query().where(key, 'equal', value);
546
+ // eslint-disable-next-line
547
+ const lists: Object[] = new DataManager(currFiles).executeLocal(query);
548
+ return lists[0];
549
+ }
550
+
551
+ /**
552
+ * Creates empty element
553
+ *
554
+ * @param {IFileManager} parent - specifies the parent element.
555
+ * @param {HTMLElement} element - specifies the element.
556
+ * @param {ReadArgs | SearchArgs} args - specifies the args.
557
+ * @returns {void}
558
+ * @private
559
+ */
560
+ export function createEmptyElement(parent: IFileManager, element: HTMLElement, args: ReadArgs | SearchArgs): void {
561
+ let top: number;
562
+ const layoutElement: Element = select('#' + parent.element.id + CLS.LAYOUT_ID, parent.element);
563
+ const addressBarHeight: number = (<HTMLElement>select('#' + parent.element.id + CLS.BREADCRUMBBAR_ID, layoutElement)).offsetHeight;
564
+ top = (<HTMLElement>layoutElement).offsetHeight - addressBarHeight;
565
+ if (parent.view === 'Details') {
566
+ top = top - (<HTMLElement>select('.' + CLS.GRID_HEADER, layoutElement)).offsetHeight;
567
+ }
568
+ if (isNOU(element.querySelector('.' + CLS.EMPTY))) {
569
+ const emptyDiv: Element = createElement('div', { className: CLS.EMPTY });
570
+ const emptyFolder: Element = createElement('div', { className: CLS.LARGE_EMPTY_FOLDER });
571
+ const emptyEle: Element = createElement('div', { className: CLS.EMPTY_CONTENT });
572
+ const dragFile: Element = createElement('div', { className: CLS.EMPTY_INNER_CONTENT });
573
+ if (parent.view === 'Details') {
574
+ element.querySelector('.' + CLS.GRID_VIEW).appendChild(emptyDiv);
575
+ } else {
576
+ element.appendChild(emptyDiv);
577
+ }
578
+ emptyDiv.appendChild(emptyFolder);
579
+ emptyDiv.appendChild(emptyEle);
580
+ emptyDiv.appendChild(dragFile);
581
+ }
582
+ if (element.querySelector('.' + CLS.EMPTY)) {
583
+ if (!isNOU(args.error)) {
584
+ element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Access-Denied');
585
+ element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Access-Details');
586
+ } else if (parent.isFiltered) {
587
+ element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Empty');
588
+ element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Key');
589
+ } else if (parent.breadcrumbbarModule.searchObj.element.value !== '') {
590
+ element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Search-Empty');
591
+ element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Search-Key');
592
+ } else {
593
+ element.querySelector('.' + CLS.EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Folder-Empty');
594
+ element.querySelector('.' + CLS.EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'File-Upload');
595
+ }
596
+ }
597
+ const eDiv: HTMLElement = <HTMLElement>select('.' + CLS.EMPTY, element);
598
+ top = (top - eDiv.offsetHeight) / 2;
599
+ eDiv.style.marginTop = top + 'px';
600
+ }
601
+
602
+ /**
603
+ * Gets the directories
604
+ *
605
+ * @param {Object[]} files - specifies the file object.
606
+ * @returns {Object[]} - returns the sorted data.
607
+ * @private
608
+ */
609
+ // eslint-disable-next-line
610
+ export function getDirectories(files: Object[]): Object[] {
611
+ return new DataManager(files).executeLocal(new Query().where(events.isFile, 'equal', false, false));
612
+ }
613
+
614
+ /**
615
+ * set the Node ID
616
+ *
617
+ * @param {ReadArgs} result - specifies the result.
618
+ * @param {string} rootId - specifies the rootId.
619
+ * @returns {void}
620
+ * @private
621
+ */
622
+ export function setNodeId(result: ReadArgs, rootId: string): void {
623
+ // eslint-disable-next-line
624
+ const dirs: Object[] = getDirectories(result.files);
625
+ for (let i: number = 0, len: number = dirs.length; i < len; i++) {
626
+ setValue('_fm_id', rootId + '_' + i, dirs[i]);
627
+ }
628
+ }
629
+
630
+ /**
631
+ * set the date object
632
+ *
633
+ * @param {Object[]} args - specifies the file object.
634
+ * @returns {void}
635
+ * @private
636
+ */
637
+ // eslint-disable-next-line
638
+ export function setDateObject(args: Object[]): void {
639
+ for (let i: number = 0; i < args.length; i++) {
640
+ setValue('_fm_created', new Date(getValue('dateCreated', args[i])), args[i]);
641
+ setValue('_fm_modified', new Date(getValue('dateModified', args[i])), args[i]);
642
+ }
643
+ }
644
+
645
+ /**
646
+ * get the locale text
647
+ *
648
+ * @param {IFileManager} parent - specifies the parent element.
649
+ * @param {string} text - specifies the text.
650
+ * @returns {string} - returns the locale text.
651
+ * @private
652
+ */
653
+ export function getLocaleText(parent: IFileManager, text: string): string {
654
+ const locale: string = parent.localeObj.getConstant(text);
655
+ return (locale === '') ? text : locale;
656
+ }
657
+
658
+ /**
659
+ * get the CSS class
660
+ *
661
+ * @param {IFileManager} parent - specifies the parent element.
662
+ * @param {string} css - specifies the css.
663
+ * @returns {string} - returns the css classes.
664
+ * @private
665
+ */
666
+ export function getCssClass(parent: IFileManager, css: string): string {
667
+ let cssClass: string = parent.cssClass;
668
+ cssClass = (isNOU(cssClass) || cssClass === '') ? css : (cssClass + ' ' + css);
669
+ return cssClass;
670
+ }
671
+
672
+ /**
673
+ * sort on click
674
+ *
675
+ * @param {IFileManager} parent - specifies the parent element.
676
+ * @param {MenuEventArgs} args - specifies the menu event arguements.
677
+ * @returns {void}
678
+ * @private
679
+ */
680
+ export function sortbyClickHandler(parent: IFileManager, args: MenuEventArgs): void {
681
+ let tick: boolean;
682
+ parent.isSortByClicked = true;
683
+ if (args.item.id.indexOf('ascending') !== -1 || args.item.id.indexOf('descending') !== -1 || args.item.id.indexOf('none') !== -1) {
684
+ tick = true;
685
+ } else {
686
+ tick = false;
687
+ }
688
+ if (!tick) {
689
+ parent.sortBy = getSortField(args.item.id);
690
+ } else {
691
+ parent.sortOrder = <SortOrder>getSortField(args.item.id);
692
+ }
693
+ parent.itemData = [getPathObject(parent)];
694
+ if (parent.view === 'Details') {
695
+ if (parent.isMobile) {
696
+ updateLayout(parent, 'Details');
697
+ } else {
698
+ parent.notify(events.sortColumn, { module: 'detailsview' });
699
+ }
700
+ }
701
+ if (parent.view === 'LargeIcons') {
702
+ updateLayout(parent, 'LargeIcons');
703
+ }
704
+ parent.notify(events.sortByChange, {});
705
+ }
706
+
707
+ /**
708
+ * Gets the sorted fields
709
+ *
710
+ * @param {string} id - specifies the id.
711
+ * @returns {string} - returns the sorted fields
712
+ * @private
713
+ */
714
+ export function getSortField(id: string): string {
715
+ const text: string = id.substring(id.lastIndexOf('_') + 1);
716
+ let field: string = text;
717
+ switch (text) {
718
+ case 'date':
719
+ field = '_fm_modified';
720
+ break;
721
+ case 'ascending':
722
+ field = 'Ascending';
723
+ break;
724
+ case 'descending':
725
+ field = 'Descending';
726
+ break;
727
+ case 'none':
728
+ field = 'None';
729
+ break;
730
+ }
731
+ return field;
732
+ }
733
+
734
+ /**
735
+ * Sets the next path
736
+ *
737
+ * @param {IFileManager} parent - specifies the parent element.
738
+ * @param {string} path - specifies the path.
739
+ * @returns {void}
740
+ * @private
741
+ */
742
+ export function setNextPath(parent: IFileManager, path: string): void {
743
+ const currfolders: string[] = path.split('/');
744
+ const folders: string[] = parent.originalPath.split('/');
745
+ // eslint-disable-next-line
746
+ const root: Object = getValue(parent.pathId[0], parent.feParent);
747
+ const key: string = isNOU(getValue('id', root)) ? 'name' : 'id';
748
+ for (let i: number = currfolders.length - 1, len: number = folders.length - 1; i < len; i++) {
749
+ const eventName: string = (folders[i + 1] === '') ? events.finalizeEnd : events.initialEnd;
750
+ const newPath: string = (folders[i] === '') ? '/' : (parent.path + folders[i] + '/');
751
+ // eslint-disable-next-line
752
+ const data: Object = getObject(parent, key, folders[i]);
753
+ const id: string = getValue('_fm_id', data);
754
+ parent.setProperties({ path: newPath }, true);
755
+ parent.pathId.push(id);
756
+ parent.itemData = [data];
757
+ parent.pathNames.push(getValue('name', data));
758
+ read(parent, eventName, parent.path);
759
+ break;
760
+ }
761
+ }
762
+
763
+ /**
764
+ * Opens the searched folder
765
+ *
766
+ * @param {IFileManager} parent - specifies the parent element.
767
+ * @param {Object} data - specifies the data
768
+ * @returns {void}
769
+ * @private
770
+ */
771
+ // eslint-disable-next-line
772
+ export function openSearchFolder(parent: IFileManager, data: Object): void {
773
+ parent.notify(events.clearPathInit, { selectedNode: parent.pathId[parent.pathId.length - 1] });
774
+ parent.originalPath = getFullPath(parent, data, parent.path);
775
+ read(parent, (parent.path !== parent.originalPath) ? events.initialEnd : events.finalizeEnd, parent.path);
776
+ }
777
+
778
+ /**
779
+ * Paste handling function
780
+ *
781
+ * @param {IFileManager} parent - specifies the parent element.
782
+ * @returns {void}
783
+ * @private
784
+ */
785
+ export function pasteHandler(parent: IFileManager): void {
786
+ parent.isDragDrop = false;
787
+ if (parent.selectedNodes.length !== 0 && parent.enablePaste) {
788
+ const path: string = (parent.folderPath === '') ? parent.path : parent.folderPath;
789
+ // eslint-disable-next-line
790
+ const subFolder: boolean = validateSubFolder(parent, <{ [key: string]: Object; }[]>parent.actionRecords, path, parent.path);
791
+ if (!subFolder) {
792
+ if ((parent.fileAction === 'move' && parent.targetPath !== path) || parent.fileAction === 'copy') {
793
+ parent.notify(events.pasteInit, {});
794
+ paste(
795
+ parent, parent.targetPath, parent.selectedNodes, path, parent.fileAction, [], parent.actionRecords);
796
+ } else {
797
+ parent.enablePaste = false;
798
+ parent.notify(events.hidePaste, {});
799
+ removeBlur(parent);
800
+ }
801
+ }
802
+ }
803
+ }
804
+
805
+ /**
806
+ * Validates the sub folders
807
+ *
808
+ * @param {IFileManager} parent - specifies the parent element.
809
+ * @param {'{ [key: string]: Object; }[]'} data - specifies the data.
810
+ * @param {string} dropPath - specifies the drop path.
811
+ * @param {string} dragPath - specifies the drag path.
812
+ * @returns {boolean} - returns the validated sub folder.
813
+ * @private
814
+ */
815
+ // eslint-disable-next-line
816
+ export function validateSubFolder(parent: IFileManager, data: { [key: string]: Object; }[], dropPath: string, dragPath: string): boolean {
817
+ let subFolder: boolean = false;
818
+ for (let i: number = 0; i < data.length; i++) {
819
+ if (!getValue('isFile', data[i])) {
820
+ const tempTarget: string = getFullPath(parent, data[i], dragPath);
821
+ if (dropPath.indexOf(tempTarget) === 0) {
822
+ const result: ReadArgs = {
823
+ files: null,
824
+ error: {
825
+ code: '402',
826
+ message: getLocaleText(parent, 'Sub-Folder-Error'),
827
+ fileExists: null
828
+ }
829
+ };
830
+ createDialog(parent, 'Error', result);
831
+ subFolder = true;
832
+ break;
833
+ }
834
+ } else {
835
+ const srcData: string = parent.dragNodes[i];
836
+ let len: number = 0;
837
+ if (srcData) {
838
+ len = srcData.lastIndexOf('/');
839
+ }
840
+ let path: string = '';
841
+ if (len > 0) {
842
+ path = dragPath + srcData.substring(0, len + 1);
843
+ }
844
+ if (path === dropPath) {
845
+ const result: ReadArgs = {
846
+ files: null,
847
+ error: {
848
+ code: '402',
849
+ message: getLocaleText(parent, 'Same-Folder-Error'),
850
+ fileExists: null
851
+ }
852
+ };
853
+ createDialog(parent, 'Error', result);
854
+ subFolder = true;
855
+ break;
856
+ }
857
+ }
858
+ }
859
+ return subFolder;
860
+ }
861
+
862
+ /**
863
+ * Validates the drop handler
864
+ *
865
+ * @param {IFileManager} parent - specifies the parent element.
866
+ * @returns {void}
867
+ * @private
868
+ */
869
+ export function dropHandler(parent: IFileManager): void {
870
+ parent.isDragDrop = true;
871
+ if (parent.dragData.length !== 0) {
872
+ parent.dragPath = parent.dragPath.replace(/\\/g, '/');
873
+ parent.dropPath = parent.dropPath.replace(/\\/g, '/');
874
+ const subFolder: boolean = validateSubFolder(parent, parent.dragData, parent.dropPath, parent.dragPath);
875
+ if (!subFolder && (parent.dragPath !== parent.dropPath)) {
876
+ parent.itemData = [parent.dropData];
877
+ paste(
878
+ parent, parent.dragPath, parent.dragNodes, parent.dropPath, 'move', [], parent.dragData);
879
+ parent.notify(events.pasteInit, {});
880
+ }
881
+ }
882
+ }
883
+
884
+ /**
885
+ * Gets the parent path
886
+ *
887
+ * @param {string} oldPath - specifies the old path.
888
+ * @returns {string} - returns the parent path.
889
+ * @private
890
+ */
891
+ export function getParentPath(oldPath: string): string {
892
+ const path: string[] = oldPath.split('/');
893
+ let newPath: string = path[0] + '/';
894
+ for (let i: number = 1; i < path.length - 2; i++) {
895
+ newPath += path[i] + '/';
896
+ }
897
+ return newPath;
898
+ }
899
+
900
+ /**
901
+ * Gets the directory path
902
+ *
903
+ * @param {IFileManager} parent - specifies the parent.
904
+ * @param {ReadArgs} args - returns the read arguements.
905
+ * @returns {string} - returns the directory path
906
+ * @private
907
+ */
908
+ export function getDirectoryPath(parent: IFileManager, args: ReadArgs): string {
909
+ const filePath: string = getValue(parent.hasId ? 'id' : 'name', args.cwd) + '/';
910
+ const fPath: string = getValue(parent.hasId ? 'filterId' : 'filterPath', args.cwd);
911
+ if (!isNOU(fPath)) {
912
+ if (fPath === '') {
913
+ return parent.hasId ? filePath : '/';
914
+ }
915
+ return fPath.replace(/\\/g, '/') + filePath;
916
+ } else {
917
+ return parent.path + filePath;
918
+ }
919
+ }
920
+
921
+ /**
922
+ * Gets the do paste path
923
+ *
924
+ * @param {IFileManager} parent - specifies the parent.
925
+ * @param {string} operation - specifies the operations.
926
+ * @param {ReadArgs} result - returns the result.
927
+ * @returns {void}
928
+ * @private
929
+ */
930
+ export function doPasteUpdate(parent: IFileManager, operation: string, result: ReadArgs): void {
931
+ if (operation === 'move') {
932
+ if (!parent.isDragDrop) {
933
+ parent.enablePaste = false;
934
+ parent.notify(events.hidePaste, {});
935
+ parent.notify(events.cutEnd, result);
936
+ } else {
937
+ parent.notify(events.dragEnd, result);
938
+ }
939
+ }
940
+ if (parent.duplicateItems.length === 0) {
941
+ parent.pasteNodes = [];
942
+ }
943
+ const flag: boolean = false;
944
+ for (let count: number = 0; (count < result.files.length) && !flag; count++) {
945
+ parent.pasteNodes.push(<string>result.files[count][parent.hasId ? 'id' : 'name']);
946
+ if (parent.isDragDrop) {
947
+ parent.droppedObjects.push(result.files[count]);
948
+ }
949
+ }
950
+ parent.duplicateItems = [];
951
+ parent.duplicateRecords = [];
952
+ if (parent.isDragDrop && !parent.isPasteError) {
953
+ parent.isDropEnd = true;
954
+ } else {
955
+ parent.isDropEnd = false;
956
+ }
957
+ if (!parent.isDragDrop || (parent.path === parent.dragPath) || (parent.path === parent.dropPath)
958
+ || parent.isSearchDrag) {
959
+ parent.isPathDrag = false;
960
+ read(parent, events.pasteEnd, parent.path);
961
+ } else {
962
+ readDropPath(parent);
963
+ }
964
+ parent.trigger('success', { action: operation, result: result });
965
+ }
966
+
967
+ /**
968
+ * Reads the drop path
969
+ *
970
+ * @param {IFileManager} parent - specifies the parent.
971
+ * @returns {void}
972
+ * @private
973
+ */
974
+ export function readDropPath(parent: IFileManager): void {
975
+ const pathId: string = getValue('_fm_id', parent.dropData);
976
+ parent.expandedId = pathId;
977
+ parent.itemData = [parent.dropData];
978
+ if (parent.isPathDrag) {
979
+ parent.notify(events.pathDrag, parent.itemData);
980
+ } else {
981
+ if (parent.navigationpaneModule) {
982
+ const node: Element = select('[data-uid="' + pathId + '"]', parent.navigationpaneModule.treeObj.element);
983
+ updatePath(<HTMLLIElement>node, parent.dropData, parent);
984
+ }
985
+ read(parent, events.dropPath, parent.dropPath);
986
+ }
987
+ }
988
+
989
+ /**
990
+ * Gets the duplicated path
991
+ *
992
+ * @param {IFileManager} parent - specifies the parent.
993
+ * @param {string} name - specifies the name.
994
+ * @returns {object} - returns the duplicated path.
995
+ * @private
996
+ */
997
+ // eslint-disable-next-line
998
+ export function getDuplicateData(parent: IFileManager, name: string): object {
999
+ // eslint-disable-next-line
1000
+ let data: object = null;
1001
+ // eslint-disable-next-line
1002
+ const records: object[] = parent.isDragDrop ? parent.dragData : parent.actionRecords;
1003
+ for (let i: number = 0; i < records.length; i++) {
1004
+ if (getValue('name', records[i]) === name) {
1005
+ data = records[i];
1006
+ break;
1007
+ }
1008
+ }
1009
+ return data;
1010
+ }
1011
+
1012
+ /**
1013
+ * Gets the create the virtual drag element
1014
+ *
1015
+ * @param {IFileManager} parent - specifies the parent.
1016
+ * @returns {void}
1017
+ * @private
1018
+ */
1019
+ export function createVirtualDragElement(parent: IFileManager): void {
1020
+ parent.isSearchDrag = false;
1021
+ if (parent.breadcrumbbarModule.searchObj.element.value !== '') { parent.isSearchDrag = true; }
1022
+ if (parent.activeModule !== 'navigationpane') {
1023
+ parent.dragNodes = [];
1024
+ let i: number = 0;
1025
+ while (i < parent.selectedItems.length) {
1026
+ parent.dragNodes.push(parent.selectedItems[i]);
1027
+ i++;
1028
+ }
1029
+ if (parent.selectedItems.length === 0 && parent.dragData && parent.dragData.length === 1) {
1030
+ parent.dragNodes.push(getItemName(parent, parent.dragData[0]));
1031
+ }
1032
+ }
1033
+ const cloneIcon: HTMLElement = parent.createElement('div', {
1034
+ className: 'e-fe-icon ' + fileType(parent.dragData[0])
1035
+ });
1036
+ const cloneName: HTMLElement = parent.createElement('div', {
1037
+ className: 'e-fe-name',
1038
+ innerHTML: <string>parent.dragData[0].name
1039
+ });
1040
+ const virtualEle: HTMLElement = parent.createElement('div', {
1041
+ className: 'e-fe-content'
1042
+ });
1043
+ virtualEle.appendChild(cloneIcon);
1044
+ virtualEle.appendChild(cloneName);
1045
+ const ele: HTMLElement = parent.createElement('div', {
1046
+ className: CLS.CLONE
1047
+ });
1048
+ ele.appendChild(virtualEle);
1049
+ if (parent.dragNodes.length > 1) {
1050
+ const badge: HTMLElement = parent.createElement('span', {
1051
+ className: 'e-fe-count',
1052
+ innerHTML: (parent.dragNodes.length).toString(10)
1053
+ });
1054
+ ele.appendChild(badge);
1055
+ }
1056
+ parent.virtualDragElement = ele;
1057
+ parent.element.appendChild(parent.virtualDragElement);
1058
+ }
1059
+
1060
+ /**
1061
+ * Drops the stop handler
1062
+ *
1063
+ * @param {IFileManager} parent - specifies the parent.
1064
+ * @param {DragEventArgs} args - specifies the drag event arguements.
1065
+ * @returns {void}
1066
+ * @private
1067
+ */
1068
+ export function dragStopHandler(parent: IFileManager, args: DragEventArgs): void {
1069
+ const dragArgs: FileDragEventArgs = args;
1070
+ dragArgs.cancel = false;
1071
+ if (parent.treeExpandTimer != null) {
1072
+ window.clearTimeout(parent.treeExpandTimer);
1073
+ parent.treeExpandTimer = null;
1074
+ }
1075
+ removeDropTarget(parent);
1076
+ parent.element.classList.remove('e-fe-drop', 'e-no-drop');
1077
+ removeBlur(parent);
1078
+ parent.uploadObj.dropArea = <HTMLElement>select('#' + parent.element.id + CLS.CONTENT_ID, parent.element);
1079
+ const virtualEle: Element = select('.' + CLS.CLONE, parent.element);
1080
+ if (virtualEle) { detach(virtualEle); }
1081
+ getTargetModule(parent, args.target);
1082
+ parent.notify(events.dropInit, args);
1083
+ removeBlur(parent, 'hover');
1084
+ dragArgs.fileDetails = parent.dragData;
1085
+ parent.trigger('fileDragStop', dragArgs, (dragArgs: FileDragEventArgs) => {
1086
+ if (!dragArgs.cancel && !isNOU(parent.targetModule) && parent.targetModule !== '' && parent.dragCount > 2) {
1087
+ dropHandler(parent);
1088
+ }
1089
+ parent.dragCount = 0;
1090
+ });
1091
+ }
1092
+
1093
+ /**
1094
+ * Drag the start handler
1095
+ *
1096
+ * @param {IFileManager} parent - specifies the parent.
1097
+ * @param {'DragEventArgs'} args - specifies the drag event arguements.
1098
+ * @param {Draggable} dragObj - specifies the drag event arguements.
1099
+ * @returns {void}
1100
+ * @private
1101
+ */
1102
+ export function dragStartHandler(parent: IFileManager, args: DragEventArgs, dragObj: Draggable): void {
1103
+ const dragArgs: FileDragEventArgs = args;
1104
+ dragArgs.cancel = false;
1105
+ dragArgs.fileDetails = parent.dragData;
1106
+ parent.dragCount = 0;
1107
+ parent.droppedObjects = [];
1108
+ if (!parent.allowDragAndDrop || ((parent.activeModule === 'navigationpane') &&
1109
+ (closest(args.element, 'li').getAttribute('data-uid') === parent.pathId[0]))) {
1110
+ dragArgs.cancel = true;
1111
+ }
1112
+ if ((parent.activeModule === 'navigationpane') &&
1113
+ (parent.pathId.indexOf(closest(args.element, 'li').getAttribute('data-uid')) !== -1)) {
1114
+ parent.isPathDrag = true;
1115
+ } else {
1116
+ parent.isPathDrag = false;
1117
+ }
1118
+ removeBlur(parent);
1119
+ if (dragArgs.cancel) {
1120
+ dragObj.intDestroy(args.event);
1121
+ dragCancel(parent);
1122
+ } else if (!dragArgs.cancel) {
1123
+ let i: number = 0;
1124
+ while (i < parent.activeElements.length) {
1125
+ addBlur(parent.activeElements[i]);
1126
+ i++;
1127
+ }
1128
+ parent.trigger('fileDragStart', dragArgs, (dragArgs: FileDragEventArgs) => {
1129
+ if (dragArgs.cancel) {
1130
+ dragObj.intDestroy(args.event);
1131
+ dragCancel(parent);
1132
+ } else {
1133
+ parent.uploadObj.dropArea = null;
1134
+ }
1135
+ });
1136
+ }
1137
+ }
1138
+
1139
+ /**
1140
+ * Drag the cancel handler
1141
+ *
1142
+ * @param {IFileManager} parent - specifies the parent.
1143
+ * @returns {void}
1144
+ * @private
1145
+ */
1146
+ export function dragCancel(parent: IFileManager): void {
1147
+ removeBlur(parent);
1148
+ const virtualEle: Element = select('.' + CLS.CLONE, parent.element);
1149
+ if (virtualEle) { detach(virtualEle); }
1150
+ }
1151
+
1152
+ /**
1153
+ * Remove drop target handler
1154
+ *
1155
+ * @param {IFileManager} parent - specifies the parent.
1156
+ * @returns {void}
1157
+ * @private
1158
+ */
1159
+ export function removeDropTarget(parent: IFileManager): void {
1160
+ removeItemClass(parent, CLS.DROP_FOLDER);
1161
+ removeItemClass(parent, CLS.DROP_FILE);
1162
+ }
1163
+
1164
+ /**
1165
+ * Remove item class handler
1166
+ *
1167
+ * @param {IFileManager} parent - specifies the parent.
1168
+ * @param {string} value - specifies the value.
1169
+ * @returns {void}
1170
+ * @private
1171
+ */
1172
+ export function removeItemClass(parent: IFileManager, value: string): void {
1173
+ const ele: NodeListOf<Element> = parent.element.querySelectorAll('.' + value);
1174
+ for (let i: number = 0; i < ele.length; i++) {
1175
+ ele[i].classList.remove(value);
1176
+ }
1177
+ }
1178
+
1179
+ /**
1180
+ * Dragging handler
1181
+ *
1182
+ * @param {IFileManager} parent - specifies the parent.
1183
+ * @param {DragEventArgs} args - specifies the arguements.
1184
+ * @returns {void}
1185
+ * @private
1186
+ */
1187
+ export function draggingHandler(parent: IFileManager, args: DragEventArgs): void {
1188
+ const dragArgs: FileDragEventArgs = args;
1189
+ dragArgs.fileDetails = parent.dragData;
1190
+ let canDrop: boolean = false;
1191
+ getTargetModule(parent, args.target);
1192
+ removeDropTarget(parent);
1193
+ if (parent.treeExpandTimer != null) {
1194
+ window.clearTimeout(parent.treeExpandTimer);
1195
+ parent.treeExpandTimer = null;
1196
+ }
1197
+ removeBlur(parent, 'hover');
1198
+ let node: Element = null;
1199
+ if (parent.targetModule === 'navigationpane') {
1200
+ node = closest(args.target, 'li');
1201
+ node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
1202
+ canDrop = true;
1203
+ /* istanbul ignore next */
1204
+ parent.treeExpandTimer = window.setTimeout(() => { parent.notify(events.dragging, args); }, 800);
1205
+ } else if (parent.targetModule === 'detailsview') {
1206
+ node = closest(args.target, 'tr');
1207
+ if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1208
+ node.classList.add(CLS.DROP_FOLDER);
1209
+ } else if (node && !node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1210
+ node.classList.add(CLS.DROP_FILE);
1211
+ }
1212
+ canDrop = true;
1213
+ } else if (parent.targetModule === 'largeiconsview') {
1214
+ node = closest(args.target, 'li');
1215
+ if (node && node.querySelector('.' + CLS.FOLDER) && !node.classList.contains(CLS.BLUR)) {
1216
+ node.classList.add(CLS.HOVER, CLS.DROP_FOLDER);
1217
+ }
1218
+ canDrop = true;
1219
+ /* istanbul ignore next */
1220
+ } else if (parent.targetModule === 'breadcrumbbar') {
1221
+ canDrop = true;
1222
+ }
1223
+ parent.element.classList.remove('e-fe-drop', 'e-no-drop');
1224
+ parent.element.classList.add(canDrop ? 'e-fe-drop' : 'e-no-drop');
1225
+ parent.dragCount = parent.dragCount + 1;
1226
+ parent.trigger('fileDragging', dragArgs);
1227
+ }
1228
+
1229
+ /**
1230
+ * Object to string handler
1231
+ *
1232
+ * @param {Object} data - specifies the data.
1233
+ * @returns {string} returns string converted from Object.
1234
+ * @private
1235
+ */
1236
+ // Ignored the message key value in permission object
1237
+ // eslint-disable-next-line
1238
+ export function objectToString(data: Object): string {
1239
+ let str: string = '';
1240
+ const keys: string[] = Object.keys(data);
1241
+ for (let i: number = 0; i < keys.length; i++) {
1242
+ if (keys[i] !== 'message') {
1243
+ str += (i === 0 ? '' : ', ') + keys[i] + ': ' + getValue(keys[i], data);
1244
+ }
1245
+ }
1246
+ return str;
1247
+ }
1248
+
1249
+ /**
1250
+ * Get item name handler
1251
+ *
1252
+ * @param {IFileManager} parent - specifies the parent.
1253
+ * @param {Object} data - specifies the data.
1254
+ * @returns {string} returns the item name.
1255
+ * @private
1256
+ */
1257
+ // eslint-disable-next-line
1258
+ export function getItemName(parent: IFileManager, data: Object): string {
1259
+ if (parent.hasId) {
1260
+ return getValue('id', data);
1261
+ }
1262
+ return getName(parent, data);
1263
+ }
1264
+
1265
+ /**
1266
+ * Get item name handler
1267
+ *
1268
+ * @param {IFileManager} parent - specifies the parent.
1269
+ * @param {Object} data - specifies the data.
1270
+ * @returns {void}
1271
+ * @private
1272
+ */
1273
+ // eslint-disable-next-line
1274
+ export function updateRenamingData(parent: IFileManager, data: Object): void {
1275
+ parent.itemData = [data];
1276
+ parent.currentItemText = getValue('name', data);
1277
+ parent.isFile = getValue('isFile', data);
1278
+ parent.filterPath = getValue('filterPath', data);
1279
+ }
1280
+
1281
+ /**
1282
+ * Get item name handler
1283
+ *
1284
+ * @param {IFileManager} parent - specifies the parent.
1285
+ * @returns {void}
1286
+ * @private
1287
+ */
1288
+ export function doRename(parent: IFileManager): void {
1289
+ if (!hasEditAccess(parent.itemData[0])) {
1290
+ createDeniedDialog(parent, parent.itemData[0], events.permissionEdit);
1291
+ } else {
1292
+ createDialog(parent, 'Rename');
1293
+ }
1294
+ }
1295
+
1296
+ /* istanbul ignore next */
1297
+ /**
1298
+ * Download handler
1299
+ *
1300
+ * @param {IFileManager} parent - specifies the parent.
1301
+ * @returns {void}
1302
+ * @private
1303
+ */
1304
+ export function doDownload(parent: IFileManager): void {
1305
+ // eslint-disable-next-line
1306
+ const items: Object[] = parent.itemData;
1307
+ for (let i: number = 0; i < items.length; i++) {
1308
+ if (!hasDownloadAccess(items[i])) {
1309
+ createDeniedDialog(parent, items[i], events.permissionDownload);
1310
+ return;
1311
+ }
1312
+ }
1313
+ if (parent.selectedItems.length > 0) {
1314
+ Download(parent, parent.path, parent.selectedItems);
1315
+ }
1316
+ }
1317
+
1318
+ /**
1319
+ * Delete Files handler
1320
+ *
1321
+ * @param {IFileManager} parent - specifies the parent.
1322
+ * @param {Object[]} data - specifies the data.
1323
+ * @param {string[]} newIds - specifies the new Ids.
1324
+ * @returns {void}
1325
+ * @private
1326
+ */
1327
+ // eslint-disable-next-line
1328
+ export function doDeleteFiles(parent: IFileManager, data: Object[], newIds: string[]): void {
1329
+ for (let i: number = 0; i < data.length; i++) {
1330
+ if (!hasEditAccess(data[i])) {
1331
+ createDeniedDialog(parent, data[i], events.permissionEdit);
1332
+ return;
1333
+ }
1334
+ }
1335
+ parent.itemData = data;
1336
+ Delete(parent, newIds, parent.path, 'delete');
1337
+ }
1338
+ /* istanbul ignore next */
1339
+ /**
1340
+ * Download files handler
1341
+ *
1342
+ * @param {IFileManager} parent - specifies the parent.
1343
+ * @param {Object[]} data - specifies the data.
1344
+ * @param {string[]} newIds - specifies the new Ids.
1345
+ * @returns {void}
1346
+ * @private
1347
+ */
1348
+ // eslint-disable-next-line
1349
+ export function doDownloadFiles(parent: IFileManager, data: Object[], newIds: string[]): void {
1350
+ for (let i: number = 0; i < data.length; i++) {
1351
+ if (!hasDownloadAccess(data[i])) {
1352
+ createDeniedDialog(parent, data[i], events.permissionDownload);
1353
+ return;
1354
+ }
1355
+ }
1356
+ parent.itemData = data;
1357
+ if (newIds.length > 0) {
1358
+ Download(parent, parent.path, newIds);
1359
+ }
1360
+ }
1361
+
1362
+ /**
1363
+ * Download files handler
1364
+ *
1365
+ * @param {IFileManager} parent - specifies the parent.
1366
+ * @param {Object} data - specifies the data.
1367
+ * @param {string} action - specifies the actions.
1368
+ * @returns {void}
1369
+ * @private
1370
+ */
1371
+ // eslint-disable-next-line
1372
+ export function createDeniedDialog(parent: IFileManager, data: Object, action: string): void {
1373
+ let message: string = getValue('message', getValue('permission', data));
1374
+ if (message === '') {
1375
+ message = getLocaleText(parent, 'Access-Message').replace('{0}', getValue('name', data)).replace('{1}', action);
1376
+ }
1377
+ const response: ReadArgs = {
1378
+ error: {
1379
+ code: '401',
1380
+ fileExists: null,
1381
+ message: message
1382
+ }
1383
+ };
1384
+ createDialog(parent, 'Error', response);
1385
+ }
1386
+
1387
+ /**
1388
+ * Get Access Classes
1389
+ *
1390
+ * @param {Object} data - specifies the data.
1391
+ * @returns {string} - returns accesses classes.
1392
+ * @private
1393
+ */
1394
+ // eslint-disable-next-line
1395
+ export function getAccessClass(data: Object): string {
1396
+ return !hasReadAccess(data) ? 'e-fe-locked e-fe-hidden' : 'e-fe-locked';
1397
+ }
1398
+
1399
+ /**
1400
+ * Check read access handler
1401
+ *
1402
+ * @param {Object} data - specifies the data.
1403
+ * @returns {boolean} - returns read access.
1404
+ * @private
1405
+ */
1406
+ // eslint-disable-next-line
1407
+ export function hasReadAccess(data: Object): boolean {
1408
+ // eslint-disable-next-line
1409
+ const permission: Object = getValue('permission', data);
1410
+ return (permission && !getValue('read', permission)) ? false : true;
1411
+ }
1412
+
1413
+ /**
1414
+ * Check edit access handler
1415
+ *
1416
+ * @param {Object} data - specifies the data.
1417
+ * @returns {boolean} - returns edit access.
1418
+ * @private
1419
+ */
1420
+ // eslint-disable-next-line
1421
+ export function hasEditAccess(data: Object): boolean {
1422
+ // eslint-disable-next-line
1423
+ const permission: Object = getValue('permission', data);
1424
+ return permission ? ((getValue('read', permission) && getValue('write', permission))) : true;
1425
+ }
1426
+
1427
+ /**
1428
+ * Check content access handler
1429
+ *
1430
+ * @param {Object} data - specifies the data.
1431
+ * @returns {boolean} - returns content access.
1432
+ * @private
1433
+ */
1434
+ // eslint-disable-next-line
1435
+ export function hasContentAccess(data: Object): boolean {
1436
+ // eslint-disable-next-line
1437
+ const permission: Object = getValue('permission', data);
1438
+ return permission ? ((getValue('read', permission) && getValue('writeContents', permission))) : true;
1439
+ }
1440
+
1441
+ /**
1442
+ * Check upload access handler
1443
+ *
1444
+ * @param {Object} data - specifies the data.
1445
+ * @returns {boolean} - returns upload access.
1446
+ * @private
1447
+ */
1448
+ // eslint-disable-next-line
1449
+ export function hasUploadAccess(data: Object): boolean {
1450
+ // eslint-disable-next-line
1451
+ const permission: Object = getValue('permission', data);
1452
+ return permission ? ((getValue('read', permission) && getValue('upload', permission))) : true;
1453
+ }
1454
+
1455
+ /**
1456
+ * Check download access handler
1457
+ *
1458
+ * @param {Object} data - specifies the data.
1459
+ * @returns {boolean} - returns download access.
1460
+ * @private
1461
+ */
1462
+ // eslint-disable-next-line
1463
+ export function hasDownloadAccess(data: Object): boolean {
1464
+ // eslint-disable-next-line
1465
+ const permission: Object = getValue('permission', data);
1466
+ return permission ? ((getValue('read', permission) && getValue('download', permission))) : true;
1467
+ }
1468
+
1469
+ /**
1470
+ * Create new folder handler
1471
+ *
1472
+ * @param {IFileManager} parent - specifies the parent.
1473
+ * @returns {void}
1474
+ * @private
1475
+ */
1476
+ export function createNewFolder(parent: IFileManager): void {
1477
+ // eslint-disable-next-line
1478
+ const details: Object = parent.itemData[0];
1479
+ if (!hasContentAccess(details)) {
1480
+ createDeniedDialog(parent, details, events.permissionEditContents);
1481
+ } else {
1482
+ createDialog(parent, 'NewFolder');
1483
+ }
1484
+ }
1485
+
1486
+ /**
1487
+ * Upload item handler
1488
+ *
1489
+ * @param {IFileManager} parent - specifies the parent.
1490
+ * @returns {void}
1491
+ * @private
1492
+ */
1493
+ export function uploadItem(parent: IFileManager): void {
1494
+ // eslint-disable-next-line
1495
+ const details: Object = parent.itemData[0];
1496
+ if (!hasUploadAccess(details)) {
1497
+ createDeniedDialog(parent, details, events.permissionUpload);
1498
+ } else {
1499
+ const eleId: string = '#' + parent.element.id + CLS.UPLOAD_ID;
1500
+ const uploadEle: HTMLElement = document.querySelector(eleId);
1501
+ uploadEle.click();
1502
+ }
1503
+ }