@syncfusion/ej2-filemanager
Version:
Essential JS 2 FileManager Component
1,526 lines (1,515 loc) • 502 kB
JavaScript
import { ChildProperty, Property, initializeCSPTemplate, getValue, isNullOrUndefined, matches, select, closest, createElement, setValue, detach, extend, Ajax, Fetch, remove, Internationalization, selectAll, addClass, Draggable, KeyboardEvents, EventHandler, Touch, removeClass, isVisible, Component, getUniqueID, setStyleAttribute, formatUnit, Browser, L10n, Complex, Collection, Event, NotifyPropertyChanges, SanitizeHtmlHelper } from '@syncfusion/ej2-base';
import { Splitter } from '@syncfusion/ej2-layouts';
import { Dialog, showSpinner, hideSpinner, createSpinner } from '@syncfusion/ej2-popups';
import { DataManager, Query, DataUtil } from '@syncfusion/ej2-data';
import { getUid, Grid, Resize, ContextMenu as ContextMenu$2, Sort, VirtualScroll } from '@syncfusion/ej2-grids';
import { Input, TextBox, Uploader } from '@syncfusion/ej2-inputs';
import { CheckBox, createCheckBox } from '@syncfusion/ej2-buttons';
import { ListBase } from '@syncfusion/ej2-lists';
import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
import { ContextMenu as ContextMenu$1, Toolbar as Toolbar$1, TreeView } from '@syncfusion/ej2-navigations';
var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Specifies the Ajax settings of the File Manager.
*/
class AjaxSettings extends ChildProperty {
}
__decorate([
Property(null)
], AjaxSettings.prototype, "downloadUrl", void 0);
__decorate([
Property(null)
], AjaxSettings.prototype, "getImageUrl", void 0);
__decorate([
Property(null)
], AjaxSettings.prototype, "uploadUrl", void 0);
__decorate([
Property(null)
], AjaxSettings.prototype, "url", void 0);
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const defaultToolbarItems = ['NewFolder', 'Upload', 'Cut', 'Copy', 'Paste', 'Delete', 'Download', 'Rename',
'SortBy', 'Refresh', 'Selection', 'View', 'Details'];
/**
* Specifies the Toolbar settings of the FileManager.
*/
class ToolbarSettings extends ChildProperty {
}
__decorate$1([
Property(defaultToolbarItems)
], ToolbarSettings.prototype, "items", void 0);
__decorate$1([
Property(true)
], ToolbarSettings.prototype, "visible", void 0);
class ToolbarItem extends ChildProperty {
}
__decorate$1([
Property('')
], ToolbarItem.prototype, "id", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "text", void 0);
__decorate$1([
Property('auto')
], ToolbarItem.prototype, "width", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "cssClass", void 0);
__decorate$1([
Property(false)
], ToolbarItem.prototype, "showAlwaysInPopup", void 0);
__decorate$1([
Property(false)
], ToolbarItem.prototype, "disabled", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "prefixIcon", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "suffixIcon", void 0);
__decorate$1([
Property(true)
], ToolbarItem.prototype, "visible", void 0);
__decorate$1([
Property('None')
], ToolbarItem.prototype, "overflow", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "template", void 0);
__decorate$1([
Property('Button')
], ToolbarItem.prototype, "type", void 0);
__decorate$1([
Property('Both')
], ToolbarItem.prototype, "showTextOn", void 0);
__decorate$1([
Property(null)
], ToolbarItem.prototype, "htmlAttributes", void 0);
__decorate$1([
Property('')
], ToolbarItem.prototype, "tooltipText", void 0);
__decorate$1([
Property('Left')
], ToolbarItem.prototype, "align", void 0);
__decorate$1([
Property(-1)
], ToolbarItem.prototype, "tabIndex", void 0);
__decorate$1([
Property()
], ToolbarItem.prototype, "name", void 0);
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Specifies the Search settings of the File Manager.
*/
class SearchSettings extends ChildProperty {
}
__decorate$2([
Property(true)
], SearchSettings.prototype, "allowSearchOnTyping", void 0);
__decorate$2([
Property('contains')
], SearchSettings.prototype, "filterType", void 0);
__decorate$2([
Property(true)
], SearchSettings.prototype, "ignoreCase", void 0);
__decorate$2([
Property(null)
], SearchSettings.prototype, "placeholder", void 0);
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Specifies the columns in the details view of the file manager.
*/
const columnArray = [
{
field: 'name', headerText: 'Name', minWidth: 120,
template: '<span class="e-fe-text">${name}</span>',
customAttributes: { class: 'e-fe-grid-name' }
},
{
field: '_fm_modified', headerText: 'DateModified', type: 'dateTime',
format: 'MMMM dd, yyyy HH:mm', minWidth: 120, width: '190'
},
{
field: 'size', headerText: 'Size', minWidth: 90, width: '110',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
template: initializeCSPTemplate(function (data) {
return `<span class="e-fe-size">${data.size}</span>`;
}), format: 'n2'
}
];
/**
* Specifies the grid settings of the File Manager.
*/
class DetailsViewSettings extends ChildProperty {
}
__decorate$3([
Property(true)
], DetailsViewSettings.prototype, "columnResizing", void 0);
__decorate$3([
Property(columnArray)
], DetailsViewSettings.prototype, "columns", void 0);
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const fileItems = ['Open', '|', 'Cut', 'Copy', '|', 'Delete', 'Download', 'Rename', '|', 'Details'];
const folderItems = ['Open', '|', 'Cut', 'Copy', 'Paste', '|', 'Delete', 'Rename', 'Download', '|', 'Details'];
const layoutItems = [
'SortBy', 'View', 'Refresh', '|', 'Paste', '|', 'NewFolder', 'Upload', '|', 'Details', '|', 'SelectAll'
];
/**
* Specifies the ContextMenu settings of the File Manager.
*/
class ContextMenuSettings extends ChildProperty {
}
__decorate$4([
Property(fileItems)
], ContextMenuSettings.prototype, "file", void 0);
__decorate$4([
Property(folderItems)
], ContextMenuSettings.prototype, "folder", void 0);
__decorate$4([
Property(layoutItems)
], ContextMenuSettings.prototype, "layout", void 0);
__decorate$4([
Property(true)
], ContextMenuSettings.prototype, "visible", void 0);
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Specifies the navigationpane settings of the File Manager.
*/
class NavigationPaneSettings extends ChildProperty {
}
__decorate$5([
Property('650px')
], NavigationPaneSettings.prototype, "maxWidth", void 0);
__decorate$5([
Property('240px')
], NavigationPaneSettings.prototype, "minWidth", void 0);
__decorate$5([
Property(true)
], NavigationPaneSettings.prototype, "visible", void 0);
__decorate$5([
Property('None')
], NavigationPaneSettings.prototype, "sortOrder", void 0);
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Specifies the Ajax settings of the File Manager.
*/
class UploadSettings extends ChildProperty {
}
__decorate$6([
Property('')
], UploadSettings.prototype, "allowedExtensions", void 0);
__decorate$6([
Property(true)
], UploadSettings.prototype, "autoUpload", void 0);
__decorate$6([
Property(false)
], UploadSettings.prototype, "autoClose", void 0);
__decorate$6([
Property(false)
], UploadSettings.prototype, "directoryUpload", void 0);
__decorate$6([
Property(0)
], UploadSettings.prototype, "minFileSize", void 0);
__decorate$6([
Property(30000000)
], UploadSettings.prototype, "maxFileSize", void 0);
__decorate$6([
Property(0)
], UploadSettings.prototype, "chunkSize", void 0);
var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**
* Interface for a class Column
*/
/* istanbul ignore next */
class Column extends ChildProperty {
}
__decorate$7([
Property('')
], Column.prototype, "field", void 0);
__decorate$7([
Property('')
], Column.prototype, "headerText", void 0);
__decorate$7([
Property('')
], Column.prototype, "width", void 0);
__decorate$7([
Property('')
], Column.prototype, "minWidth", void 0);
__decorate$7([
Property('')
], Column.prototype, "maxWidth", void 0);
__decorate$7([
Property('Left')
], Column.prototype, "textAlign", void 0);
__decorate$7([
Property(null)
], Column.prototype, "headerTextAlign", void 0);
__decorate$7([
Property(null)
], Column.prototype, "type", void 0);
__decorate$7([
Property(null)
], Column.prototype, "format", void 0);
__decorate$7([
Property(null)
], Column.prototype, "template", void 0);
__decorate$7([
Property(null)
], Column.prototype, "sortComparer", void 0);
__decorate$7([
Property(null)
], Column.prototype, "headerTemplate", void 0);
__decorate$7([
Property(true)
], Column.prototype, "allowSorting", void 0);
__decorate$7([
Property(true)
], Column.prototype, "allowResizing", void 0);
__decorate$7([
Property(null)
], Column.prototype, "customAttributes", void 0);
__decorate$7([
Property('')
], Column.prototype, "hideAtMedia", void 0);
__decorate$7([
Property(null)
], Column.prototype, "customFormat", void 0);
__decorate$7([
Property(false)
], Column.prototype, "isPrimaryKey", void 0);
/**
* Specifies the File Manager internal ID's
*/
/** @hidden */
const TOOLBAR_ID = '_toolbar';
/** @hidden */
const LAYOUT_ID = '_layout';
/** @hidden */
const NAVIGATION_ID = '_navigation';
/** @hidden */
const TREE_ID = '_tree';
/** @hidden */
const GRID_ID = '_grid';
/** @hidden */
const LARGEICON_ID = '_largeicons';
/** @hidden */
const DIALOG_ID = '_dialog';
/** @hidden */
const ALT_DIALOG_ID = '_alt_dialog';
/** @hidden */
const IMG_DIALOG_ID = '_img_dialog';
/** @hidden */
const EXTN_DIALOG_ID = '_extn_dialog';
/** @hidden */
const UPLOAD_DIALOG_ID = '_upload_dialog';
/** @hidden */
const RETRY_DIALOG_ID = '_retry_dialog';
/** @hidden */
const CONTEXT_MENU_ID = '_contextmenu';
/** @hidden */
const SORTBY_ID = '_sortby';
/** @hidden */
const VIEW_ID = '_view';
/** @hidden */
const SPLITTER_ID = '_splitter';
/** @hidden */
const CONTENT_ID = '_content';
/** @hidden */
const BREADCRUMBBAR_ID = '_breadcrumbbar';
/** @hidden */
const UPLOAD_ID = '_upload';
/** @hidden */
const RETRY_ID = '_retry';
/** @hidden */
const SEARCH_ID = '_search';
/**
* Specifies the File Manager internal class names
*/
/** @hidden */
const ROOT = 'e-filemanager';
/** @hidden */
const CONTROL = 'e-control';
/** @hidden */
const CHECK_SELECT = 'e-fe-cb-select';
/** @hidden */
const ROOT_POPUP = 'e-fe-popup';
/** @hidden */
const MOBILE = 'e-fe-mobile';
/** @hidden */
const MOB_POPUP = 'e-fe-popup e-fe-mobile';
/** @hidden */
const MULTI_SELECT = 'e-fe-m-select';
/** @hidden */
const FILTER = 'e-fe-m-filter';
/** @hidden */
const LAYOUT = 'e-layout';
/** @hidden */
const NAVIGATION = 'e-navigation';
/** @hidden */
const LAYOUT_CONTENT = 'e-layout-content';
/** @hidden */
const LARGE_ICONS = 'e-large-icons';
/** @hidden */
const TB_ITEM = 'e-toolbar-item';
/** @hidden */
const LIST_ITEM = 'e-list-item';
/** @hidden */
const LIST_TEXT = 'e-list-text';
/** @hidden */
const LIST_PARENT = 'e-list-parent';
/** @hidden */
const TB_OPTION_TICK = 'e-icons e-fe-tick';
/** @hidden */
const TB_OPTION_DOT = 'e-icons e-fe-dot';
/** @hidden */
const BLUR = 'e-blur';
/** @hidden */
const ACTIVE = 'e-active';
/** @hidden */
const HOVER = 'e-hover';
/** @hidden */
const FOCUS = 'e-focus';
/** @hidden */
const FOCUSED = 'e-focused';
/** @hidden */
const CHECK = 'e-check';
/** @hidden */
const FRAME = 'e-frame';
/** @hidden */
const CB_WRAP = 'e-checkbox-wrapper';
/** @hidden */
const ROW = 'e-row';
/** @hidden */
const ROWCELL = 'e-rowcell';
/** @hidden */
const EMPTY = 'e-empty';
/** @hidden */
const EMPTY_CONTENT = 'e-empty-content';
/** @hidden */
const EMPTY_INNER_CONTENT = 'e-empty-inner-content';
/** @hidden */
const CLONE = 'e-fe-clone';
/** @hidden */
const DROP_FOLDER = 'e-fe-drop-folder';
/** @hidden */
const DROP_FILE = 'e-fe-drop-file';
/** @hidden */
const FOLDER = 'e-fe-folder';
/** @hidden */
const ICON_IMAGE = 'e-fe-image';
/** @hidden */
const ICON_MUSIC = 'e-fe-music';
/** @hidden */
const ICON_VIDEO = 'e-fe-video';
/** @hidden */
const LARGE_ICON = 'e-large-icon';
/** @hidden */
const LARGE_EMPTY_FOLDER = 'e-empty-icon e-fe-folder';
/** @hidden */
const LARGE_EMPTY_FOLDER_TWO = 'e-empty-icon.e-fe-folder';
/** @hidden */
const LARGE_ICON_FOLDER = 'e-fe-folder';
/** @hidden */
const SELECTED_ITEMS = 'e-items';
/** @hidden */
const TEXT_CONTENT = 'e-text-content';
/** @hidden */
const GRID_HEADER = 'e-gridheader';
/** @hidden */
const TEMPLATE_CELL = 'e-templatecell';
/** @hidden */
const TREE_VIEW = 'e-treeview';
/** @hidden */
const MENU_ITEM = 'e-menu-item';
/** @hidden */
const MENU_ICON = 'e-menu-icon';
/** @hidden */
const SUBMENU_ICON = 'e-caret';
/** @hidden */
const GRID_VIEW = 'e-content';
/** @hidden */
const GRID_CONTENT = 'e-gridcontent';
/** @hidden */
const ICON_VIEW = 'e-list-parent';
/** @hidden */
const ICON_OPEN = 'e-icons e-fe-open';
/** @hidden */
const ICON_UPLOAD = 'e-icons e-fe-upload';
/** @hidden */
const ICON_CUT = 'e-icons e-fe-cut';
/** @hidden */
const ICON_COPY = 'e-icons e-fe-copy';
/** @hidden */
const ICON_PASTE = 'e-icons e-fe-paste';
/** @hidden */
const ICON_DELETE = 'e-icons e-fe-delete';
/** @hidden */
const ICON_RENAME = 'e-icons e-fe-rename';
/** @hidden */
const ICON_NEWFOLDER = 'e-icons e-fe-newfolder';
/** @hidden */
const ICON_DETAILS = 'e-icons e-fe-details';
/** @hidden */
const ICON_SHORTBY = 'e-icons e-fe-sort';
/** @hidden */
const ICON_REFRESH = 'e-icons e-fe-refresh';
/** @hidden */
const ICON_SELECTALL = 'e-icons e-fe-select';
/** @hidden */
const ICON_DOWNLOAD = 'e-icons e-fe-download';
/** @hidden */
const ICON_OPTIONS = 'e-icons e-fe-options';
/** @hidden */
const ICON_GRID = 'e-icons e-fe-grid';
/** @hidden */
const ICON_LARGE = 'e-icons e-fe-large';
/** @hidden */
const ICON_BREADCRUMB = 'e-icons e-fe-breadcrumb';
/** @hidden */
const ICON_CLEAR = 'e-icons e-fe-clear';
/** @hidden */
const ICON_DROP_IN = 'e-icons e-fe-drop-in';
/** @hidden */
const ICON_DROP_OUT = 'e-icons e-fe-drop-out';
/** @hidden */
const ICON_NO_DROP = 'e-icons e-fe-no-drop';
/** @hidden */
const ICONS = 'e-icons';
/** @hidden */
const DETAILS_LABEL = 'e-detailslabel';
/** @hidden */
const ERROR_CONTENT = 'e-fe-errorcontent';
/** @hidden */
const STATUS = 'e-status';
/** @hidden */
const BREADCRUMBS = 'e-address';
/** @hidden */
const RTL = 'e-rtl';
/** @hidden */
const DISPLAY_NONE = 'e-display-none';
/** @hidden */
const COLLAPSED = 'e-node-collapsed';
/** @hidden */
const FULLROW = 'e-fullrow';
/** @hidden */
const ICON_COLLAPSIBLE = 'e-icon-collapsible';
/** @hidden */
const SPLIT_BAR = 'e-split-bar';
/** @hidden */
const HEADER_CHECK = 'e-headercheck';
/** @hidden */
const OVERLAY = 'e-fe-overlay';
/** @hidden */
const VALUE = 'e-fe-value';
/**
* Specifies the File Manager internal variables
*/
/** @hidden */
const isFile = 'isFile';
/**
* Specifies the File Manager internal events
*/
/** @hidden */
const modelChanged = 'model-changed';
/** @hidden */
const initialEnd = 'initial-end';
/** @hidden */
const finalizeEnd = 'finalize-end';
/** @hidden */
const createEnd = 'create-end';
/** @hidden */
const filterEnd = 'filter-end';
/** @hidden */
const beforeDelete = 'before-delete';
/** @hidden */
const pathDrag = 'path-drag';
/** @hidden */
const deleteInit = 'delete-init';
/** @hidden */
const deleteEnd = 'delete-end';
/** @hidden */
const refreshEnd = 'refresh-end';
/** @hidden */
const resizeEnd = 'resize-end';
/** @hidden */
const splitterResize = 'splitter-resize';
/** @hidden */
const pathChanged = 'path-changed';
/** @hidden */
const destroy = 'destroy';
/** @hidden */
const beforeRequest = 'before-request';
/** @hidden */
const upload = 'upload';
/** @hidden */
const skipUpload = 'skip-upload';
/** @hidden */
const afterRequest = 'after-request';
/** @hidden */
const download = 'download';
/** @hidden */
const layoutRefresh = 'layout-refresh';
/** @hidden */
const actionFailure = 'actionFailure';
/** @hidden */
const search = 'search';
/** @hidden */
const openInit = 'open-init';
/** @hidden */
const openEnd = 'open-end';
/** @hidden */
const selectionChanged = 'selection-changed';
/** @hidden */
const selectAllInit = 'select-all-init';
/** @hidden */
const clearAllInit = 'clear-all-init';
/** @hidden */
const clearPathInit = 'clear-path-init';
/** @hidden */
const layoutChange = 'layout-change';
/** @hidden */
const sortByChange = 'sort-by-change';
/** @hidden */
const nodeExpand = 'node-expand';
/** @hidden */
const detailsInit = 'details-init';
/** @hidden */
const menuItemData = 'menu-item-data';
/** @hidden */
const renameInit = 'rename-init';
/** @hidden */
const renameEndParent = 'rename-end-parent';
/** @hidden */
const renameEnd = 'rename-end';
/** @hidden */
const showPaste = 'show-paste';
/** @hidden */
const hidePaste = 'hide-paste';
/** @hidden */
const selectedData = 'selected-data';
/** @hidden */
const cutCopyInit = 'cut-copy-init';
/** @hidden */
const pasteInit = 'paste-init';
/** @hidden */
const pasteEnd = 'paste-end';
/** @hidden */
const cutEnd = 'cut-end';
/** @hidden */
const hideLayout = 'hide-layout';
/** @hidden */
const updateTreeSelection = 'update-tree-selection';
/** @hidden */
const treeSelect = 'select-node';
/** @hidden */
const sortColumn = 'sort-column';
/** @hidden */
const pathColumn = 'path-column';
/** @hidden */
const searchTextChange = 'search-change';
/** @hidden */
const beforeDownload = 'before-download';
/** @hidden */
const downloadInit = 'download-init';
/** @hidden */
const dropInit = 'drop-init';
/** @hidden */
const dragEnd = 'drag-end';
/** @hidden */
const dropPath = 'drop-path';
/** @hidden */
const dragHelper = 'drag-helper';
/** @hidden */
const dragging = 'dragging';
/** @hidden */
const updateSelectionData = 'update-selection-data';
/** @hidden */
const methodCall = 'method-call';
/** @hidden */
const permissionRead = 'read';
/** @hidden */
const permissionEdit = 'write';
/** @hidden */
const permissionEditContents = 'writeContents';
/** @hidden */
const permissionCopy = 'copy';
/** @hidden */
const permissionUpload = 'upload';
/** @hidden */
const permissionDownload = 'download';
/**
* Utility function to compare two strings in a way similar to Windows Explorer.
* Files and folders are sorted separately, with folders coming before files.
*
* @param {string} reference - The first string to compare. This could be a file or folder name.
* @param {string} comparer - The second string to compare. This could be a file or folder name.
* @returns {number} - A negative number if `reference` should come before `comparer`, a positive number if `comparer` should come before `reference`, and 0 if they are considered equal.
*/
function sortComparer(reference, comparer) {
// Check if reference and comparer are files or folders
const referenceIsFile = /\.\S+/.test(reference);
const comparerIsFile = /\.\S+/.test(comparer);
// If one is a file and the other is a folder, the folder should come first
if (referenceIsFile && !comparerIsFile) {
return 1;
}
if (!referenceIsFile && comparerIsFile) {
return -1;
}
const referenceParts = [];
const comparerParts = [];
(reference + '').replace(/(\d+)|(\D+)/g, function (_, $1, $2) { referenceParts.push([$1 || Infinity, $2 || '']); return ''; });
(comparer + '').replace(/(\d+)|(\D+)/g, function (_, $1, $2) { comparerParts.push([$1 || Infinity, $2 || '']); return ''; });
// Compare each part of reference and comparer
while (referenceParts.length && comparerParts.length) {
const referencePart = referenceParts.shift();
const comparerPart = comparerParts.shift();
if (referencePart && comparerPart) {
const comparisonResult = referencePart[0] - comparerPart[0] ||
referencePart[1].localeCompare(comparerPart[1]);
if (comparisonResult) {
return comparisonResult;
}
}
}
return referenceParts.length - comparerParts.length;
}
/**
* Utility file for common actions
*
* @param {HTMLLIElement} node - specifies the node.
* @param {Object} data - specifies the data.
* @param {IFileManager} instance - specifies the control instance.
* @returns {void}
* @private
*/
function updatePath(node, data, instance) {
const text = getValue('name', data);
const id = node.getAttribute('data-id');
const newText = isNullOrUndefined(id) ? text : id;
instance.setProperties({ path: getPath(node, newText, instance.hasId) }, true);
instance.pathId = getPathId(node);
instance.pathNames = getPathNames(node, text);
}
/**
* Functions for get path in FileManager
*
* @param {Element | Node} element - specifies the element.
* @param {string} text - specifies the text.
* @param {boolean} hasId - specifies the id.
* @returns {string} returns the path.
* @private
*/
function getPath(element, text, hasId) {
const matched = getParents(element, text, false, hasId);
let path = '/';
const len = matched.length - (2);
for (let i = len; i >= 0; i--) {
path += matched[i] + '/';
}
return path;
}
/**
* Functions for get path id in FileManager
*
* @param {Element} node - specifies the node element.
* @returns {string[]} returns the path ids.
* @private
*/
function getPathId(node) {
const matched = getParents(node, node.getAttribute('data-uid'), true);
const ids = [];
for (let i = matched.length - 1; i >= 0; i--) {
ids.push(matched[i]);
}
return ids;
}
/**
* Functions for get path names in FileManager
*
* @param {Element} element - specifies the node element.
* @param {string} text - specifies the text.
* @returns {string[]} returns the path names.
* @private
*/
function getPathNames(element, text) {
const matched = getParents(element, text, false);
const names = [];
for (let i = matched.length - 1; i >= 0; i--) {
names.push(matched[i]);
}
return names;
}
/**
* Functions for get path id in FileManager
*
* @param {Element} element - specifies the node element.
* @param {string} text - specifies the text.
* @param {boolean} isId - specifies the id.
* @param {boolean} hasId - checks the id exists.
* @returns {string[]} returns parent element.
* @private
*/
function getParents(element, text, isId, hasId) {
const matched = [text];
let el = element.parentNode;
while (!isNullOrUndefined(el)) {
if (matches(el, '.' + LIST_ITEM)) {
const parentText = isId ? el.getAttribute('data-uid') : (hasId ? el.getAttribute('data-id') :
select('.' + LIST_TEXT, el).textContent);
matched.push(parentText);
}
el = el.parentNode;
if (el.classList.contains(TREE_VIEW)) {
break;
}
}
return matched;
}
/**
* Functions for generate path
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function generatePath(parent) {
const key = parent.hasId ? 'id' : 'name';
let newPath = '/';
let i = 1;
for (i; i < parent.pathId.length; i++) {
const data = getValue(parent.pathId[parseInt(i.toString(), 10)], parent.feParent);
newPath += getValue(key, data) + '/';
}
parent.setProperties({ path: newPath }, true);
}
/**
* Functions for remove active element
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function removeActive(parent) {
if (parent.isCut) {
removeBlur(parent);
parent.selectedNodes = [];
parent.actionRecords = [];
parent.enablePaste = false;
parent.notify(hidePaste, {});
}
}
/**
* Selects active element in File Manager
*
* @param {string} action - specifies the action.
* @param {IFileManager} parent - specifies the parent element.
* @returns {boolean} - returns active element.
* @private
*/
function activeElement(action, parent) {
parent.isSearchCut = false;
parent.actionRecords = [];
parent.activeElements = [];
parent.notify(cutCopyInit, {});
if (parent.activeElements.length === 0) {
return false;
}
removeBlur(parent);
const blurEle = parent.activeElements;
if (parent.activeModule !== 'navigationpane') {
parent.targetPath = parent.path;
}
else {
parent.targetPath = getParentPath(parent.path);
}
let i = 0;
if (blurEle) {
getModule(parent, blurEle[0]);
if (action === 'cut') {
while (i < blurEle.length) {
addBlur(blurEle[i]);
i++;
}
}
}
i = 0;
parent.selectedNodes = [];
parent.enablePaste = true;
parent.notify(showPaste, {});
while (i < parent.activeRecords.length) {
parent.actionRecords.push(parent.activeRecords[i]);
parent.selectedNodes.push(getValue('name', parent.activeRecords[i]));
i++;
}
if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) &&
parent.activeModule !== 'navigationpane') {
parent.selectedNodes = [];
parent.isSearchCut = true;
let i = 0;
while (i < parent.selectedItems.length) {
parent.selectedNodes.push(parent.selectedItems[i]);
i++;
}
}
return true;
}
/**
* Adds blur to the elements
*
* @param {Element} nodes - specifies the nodes.
* @returns {void}
* @private
*/
function addBlur(nodes) {
nodes.classList.add(BLUR);
}
/**
* Removes blur from elements
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} hover - specifies the hover string.
* @returns {void}
* @private
*/
function removeBlur(parent, hover) {
const blurEle = (!hover) ? parent.element.querySelectorAll('.' + BLUR) :
parent.element.querySelectorAll('.' + HOVER);
let i = 0;
while (i < blurEle.length) {
blurEle[i].classList.remove((!hover) ? BLUR : HOVER);
i++;
}
}
/**
* Gets module name
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Element} element - specifies the element.
* @returns {void}
* @private
*/
function getModule(parent, element) {
if (element) {
if (element.classList.contains(ROW)) {
parent.activeModule = 'detailsview';
}
else if (closest(element, '.' + LARGE_ICON)) {
parent.activeModule = 'largeiconsview';
}
else {
parent.activeModule = 'navigationpane';
}
}
}
/**
* Get all child items
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string | number} parentId - specifies the parent ID.
* @returns {Object[]} An array of child items
* @private
*/
function getAllChildItems(parent, parentId) {
const children = parent.fileSystemData.filter((item) => String(item.parentId) === String(parentId));
let allChildren = [...children];
children.forEach((child) => {
const childId = child.id;
allChildren = allChildren.concat(getAllChildItems(parent, childId));
});
return allChildren;
}
/**
* Gets module name
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} value - specifies the value.
* @param {boolean} isLayoutChange - specifies the layout change.
* @returns {void}
* @private
*/
function searchWordHandler(parent, value, isLayoutChange) {
let searchWord;
if (value.length === 0 && !parent.isFiltered) {
parent.notify(pathColumn, { args: parent });
}
if (isFileSystemData(parent)) {
if (value === '') {
parent.itemData = parent.fileSystemData;
read(parent, isLayoutChange ? layoutChange : search, parent.path);
}
else {
parent.searchSettings.filterType = isNullOrUndefined(parent.searchSettings.filterType) ? 'contains' : parent.searchSettings.filterType;
const currData = getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
const parentId = getValue('id', currData);
const filteredData = getAllChildItems(parent, parentId);
const data = new DataManager(filteredData).
executeLocal(new Query().where('name', parent.searchSettings.filterType, value, parent.searchSettings.ignoreCase));
const searchValue = parent.searchSettings.ignoreCase ? value.toLowerCase() : value;
parent.itemData = data;
Search(parent, isLayoutChange ? layoutChange : search, parent.path, searchValue, parent.showHiddenItems, !parent.searchSettings.ignoreCase);
}
return;
}
if (parent.searchSettings.filterType === 'startsWith') {
searchWord = value + '*';
}
else if (parent.searchSettings.filterType === 'endsWith') {
searchWord = '*' + value;
}
else {
searchWord = '*' + value + '*';
}
parent.searchWord = searchWord;
parent.itemData = [getPathObject(parent)];
if (value.length > 0) {
const caseSensitive = parent.searchSettings.ignoreCase;
const hiddenItems = parent.showHiddenItems;
Search(parent, isLayoutChange ? layoutChange : search, parent.path, searchWord, hiddenItems, !caseSensitive);
}
else {
if (!parent.isFiltered) {
if (parent.isSortByClicked) {
parent.notify(layoutChange, { files: (parent.oldView === 'Details') ? parent.detailsviewModule.gridObj.dataSource : parent.largeiconsviewModule.allItems });
parent.isSortByClicked = false;
}
else {
read(parent, isLayoutChange ? layoutChange : search, parent.path);
}
}
else {
filter(parent, layoutChange);
}
}
}
/**
* Gets updated layout
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} view - specifies the view.
* @returns {void}
* @private
*/
function updateLayout(parent, view) {
parent.oldView = parent.view;
parent.setProperties({ view: view }, true);
if (parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) {
parent.layoutSelectedItems = parent.selectedItems;
}
let searchWord = '';
if (parent.breadcrumbbarModule.searchObj.element.value) {
searchWord = parent.breadcrumbbarModule.searchObj.element.value;
}
parent.isLayoutChange = true;
searchWordHandler(parent, searchWord, true);
}
/* istanbul ignore next */
/**
* Gets updated layout
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Element} element - specifies the element.
* @returns {void}
* @private
*/
function getTargetModule(parent, element) {
let tartgetModule = '';
if (element) {
if (closest(element, '.' + ROOT + '.' + CONTROL + ' .' + GRID_CONTENT)) {
tartgetModule = 'detailsview';
}
else if (closest(element, '.' + LARGE_ICONS)) {
tartgetModule = 'largeiconsview';
}
else if (element.classList.contains('e-fullrow') ||
element.classList.contains('e-icon-expandable')) {
tartgetModule = 'navigationpane';
}
else if (closest(element, '.e-address-list-item')) {
tartgetModule = 'breadcrumbbar';
}
else {
tartgetModule = '';
}
}
parent.targetModule = tartgetModule;
}
/* istanbul ignore next */
/**
* refresh the layout
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function refresh(parent) {
parent.itemData = [getPathObject(parent)];
if (!hasReadAccess(parent.itemData[0])) {
createDeniedDialog(parent, parent.itemData[0], permissionRead);
}
else {
read(parent, refreshEnd, parent.path);
}
}
/**
* open action in the layout
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function openAction(parent) {
read(parent, openEnd, parent.path);
}
/**
* open action in the layout
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {Object} - returns the path data.
* @private
*/
function getPathObject(parent) {
return getValue(parent.pathId[parent.pathId.length - 1], parent.feParent);
}
/**
* Copy files
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function copyFiles(parent) {
if (!activeElement('copy', parent)) {
return;
}
else {
parent.fileAction = 'copy';
}
}
/**
* Cut files
*
* @param {IFileManager} parent - specifies the parent element.
* @returns {void}
* @private
*/
function cutFiles(parent) {
if (!activeElement('cut', parent)) {
return;
}
else {
parent.isCut = true;
parent.fileAction = 'move';
}
}
/**
* To add class for fileType
*
* @param {Object} file - specifies the file.
* @returns {string} - returns the file type.
* @private
*/
function fileType(file) {
const isFile = getValue('isFile', file);
if (!isFile) {
return FOLDER;
}
const imageFormat = ['bmp', 'dib', 'jpg', 'jpeg', 'jpe', 'jfif', 'gif', 'tif', 'tiff', 'png', 'ico'];
const audioFormat = ['mp3', 'wav', 'aac', 'ogg', 'wma', 'aif', 'fla', 'm4a'];
const videoFormat = ['webm', 'mkv', 'flv', 'vob', 'ogv', 'ogg', 'avi', 'wmv', 'mp4', '3gp'];
const knownFormat = ['css', 'exe', 'html', 'js', 'msi', 'pdf', 'pptx', 'ppt', 'rar', 'zip', 'txt', 'docx', 'doc',
'xlsx', 'xls', 'xml', 'rtf', 'php'];
let filetype = getValue('type', file);
filetype = filetype.toLowerCase();
if (filetype.indexOf('.') !== -1) {
filetype = filetype.split('.').join('');
}
let iconType;
if (imageFormat.indexOf(filetype) !== -1) {
iconType = ICON_IMAGE;
}
else if (audioFormat.indexOf(filetype) !== -1) {
iconType = ICON_MUSIC;
}
else if (videoFormat.indexOf(filetype) !== -1) {
iconType = ICON_VIDEO;
}
else if (knownFormat.indexOf(filetype) !== -1) {
iconType = 'e-fe-' + filetype;
}
else {
iconType = 'e-fe-unknown e-fe-' + filetype;
}
return iconType;
}
/* istanbul ignore next */
/**
* To get the image URL
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Object} item - specifies the item.
* @returns {string} - returns the image url.
* @private
*/
function getImageUrl(parent, item) {
let imgUrl = isFileSystemData(parent) ? getValue('imageUrl', item) : '';
if (isFileSystemData(parent)) {
const eventArgs = {
fileDetails: [item],
imageUrl: imgUrl
};
parent.trigger('beforeImageLoad', eventArgs);
return eventArgs.imageUrl;
}
const baseUrl = parent.ajaxSettings.getImageUrl ? parent.ajaxSettings.getImageUrl : parent.ajaxSettings.url;
const pathUrl = (baseUrl.indexOf('?') !== -1) ? '&path=' : '?path=';
const fileName = encodeURIComponent(getValue('name', item));
const fPath = getValue('filterPath', item);
if (parent.hasId) {
const imgId = getValue('id', item);
imgUrl = baseUrl + pathUrl + parent.path + '&id=' + imgId;
}
else if (!isNullOrUndefined(fPath)) {
imgUrl = baseUrl + pathUrl + encodeURIComponent(fPath.replace(/\\/g, '/')) + fileName;
}
else {
imgUrl = baseUrl + pathUrl + parent.path + fileName;
}
imgUrl = imgUrl + '&time=' + (new Date().getTime()).toString();
const eventArgs = {
fileDetails: [item],
imageUrl: imgUrl
};
parent.trigger('beforeImageLoad', eventArgs);
return eventArgs.imageUrl;
}
/* istanbul ignore next */
/**
* Gets the full path
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Object} data - specifies the data.
* @param {string} path - specifies the path.
* @returns {string} - returns the image url.
* @private
*/
function getFullPath(parent, data, path) {
const filePath = getValue(parent.hasId ? 'id' : 'name', data) + '/';
const fPath = getValue(parent.hasId ? 'filterId' : 'filterPath', data);
if (!isNullOrUndefined(fPath)) {
return fPath.replace(/\\/g, '/').replace(/^.*?(?=\/)/, '') + filePath;
}
else {
return path + filePath;
}
}
/**
* Gets the name
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Object} data - specifies the data.
* @returns {string} - returns the name.
* @private
*/
function getName(parent, data) {
let name = getValue('name', data);
let fPath = getValue('filterPath', data);
if ((parent.breadcrumbbarModule.searchObj.element.value !== '' || parent.isFiltered) && !isNullOrUndefined(fPath)) {
fPath = fPath.replace(/\\/g, '/');
name = fPath.replace(parent.path, '') + name;
}
return name;
}
/**
* Gets the name
*
* @param {IFileManager} parent - specifies the parent element.
* @param {Object[]} items - specifies the item elements.
* @returns {Object[]} - returns the sorted data.
* @private
*/
function getSortedData(parent, items) {
if (items.length === 0) {
return items;
}
let query;
if (parent.sortOrder !== 'None' && !isNullOrUndefined(parent.sortOrder)) {
query = new Query().sortBy(parent.sortBy, parent.sortOrder.toLowerCase(), true).group('isFile');
}
else {
query = new Query().group('isFile');
}
const lists = new DataManager(items).executeLocal(query);
return getValue('records', lists);
}
/**
* Gets the data object
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} key - specifies the key.
* @param {string} value - specifies the value.
* @returns {Object} - returns the sorted data.
* @private
*/
function getObject(parent, key, value) {
const currFiles = getValue(parent.pathId[parent.pathId.length - 1], parent.feFiles);
const result = currFiles.filter((data) => data[key].toString() === value);
return result.length > 0 ? result[0] : null;
}
/**
* Creates empty element
*
* @param {IFileManager} parent - specifies the parent element.
* @param {HTMLElement} element - specifies the element.
* @param {ReadArgs | SearchArgs} args - specifies the args.
* @returns {void}
* @private
*/
function createEmptyElement(parent, element, args) {
let top;
const layoutElement = select('#' + parent.element.id + LAYOUT_ID, parent.element);
const addressBarHeight = select('#' + parent.element.id + BREADCRUMBBAR_ID, layoutElement).offsetHeight;
top = layoutElement.offsetHeight - addressBarHeight;
if (parent.view === 'Details') {
top = top - select('.' + GRID_HEADER, layoutElement).offsetHeight;
}
if (isNullOrUndefined(element.querySelector('.' + EMPTY))) {
const emptyDiv = createElement('div', { className: EMPTY });
const emptyFolder = createElement('div', { className: LARGE_EMPTY_FOLDER });
const emptyEle = createElement('div', { className: EMPTY_CONTENT });
const dragFile = createElement('div', { className: EMPTY_INNER_CONTENT });
if (parent.view === 'Details') {
element.querySelector('.' + GRID_VIEW).appendChild(emptyDiv);
}
else {
element.appendChild(emptyDiv);
}
emptyDiv.appendChild(emptyFolder);
emptyDiv.appendChild(emptyEle);
emptyDiv.appendChild(dragFile);
}
if (element.querySelector('.' + EMPTY)) {
if (!isNullOrUndefined(args.error)) {
element.querySelector('.' + EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Access-Denied');
element.querySelector('.' + EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Access-Details');
}
else if (parent.isFiltered) {
element.querySelector('.' + EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Empty');
element.querySelector('.' + EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Filter-Key');
}
else if (parent.breadcrumbbarModule.searchObj.element.value !== '') {
element.querySelector('.' + EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Search-Empty');
element.querySelector('.' + EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'Search-Key');
}
else {
element.querySelector('.' + EMPTY_CONTENT).innerHTML = getLocaleText(parent, 'Folder-Empty');
element.querySelector('.' + EMPTY_INNER_CONTENT).innerHTML = getLocaleText(parent, 'File-Upload');
}
}
const eDiv = select('.' + EMPTY, element);
top = (top - eDiv.offsetHeight) / 2;
eDiv.style.marginTop = top + 'px';
}
/**
* Gets the directories
*
* @param {Object[]} files - specifies the file object.
* @returns {Object[]} - returns the sorted data.
* @private
*/
function getDirectories(files) {
return new DataManager(files).executeLocal(new Query().where(isFile, 'equal', false, false));
}
/**
* set the Node ID
*
* @param {ReadArgs} result - specifies the result.
* @param {string} rootId - specifies the rootId.
* @returns {void}
* @private
*/
function setNodeId(result, rootId) {
const dirs = getDirectories(result.files);
for (let i = 0, len = dirs.length; i < len; i++) {
setValue('_fm_id', rootId + '_' + i, dirs[i]);
}
}
/**
* set the date object
*
* @param {Object[]} args - specifies the file object.
* @returns {void}
* @private
*/
function setDateObject(args) {
for (let i = 0; i < args.length; i++) {
const createdDate = new Date(getValue('dateCreated', args[i]));
const modifiedDate = new Date(getValue('dateModified', args[i]));
setValue('_fm_created', createdDate, args[i]);
setValue('_fm_modified', modifiedDate, args[i]);
}
}
/**
* get the locale text
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} text - specifies the text.
* @returns {string} - returns the locale text.
* @private
*/
function getLocaleText(parent, text) {
const locale = parent.localeObj.getConstant(text);
return (locale === '') ? text : locale;
}
/**
* get the CSS class
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} css - specifies the css.
* @returns {string} - returns the css classes.
* @private
*/
function getCssClass(parent, css) {
let cssClass = parent.cssClass;
cssClass = (isNullOrUndefined(cssClass) || cssClass === '') ? css : (cssClass + ' ' + css);
return cssClass;
}
/**
* sort on click
*
* @param {IFileManager} parent - specifies the parent element.
* @param {MenuEventArgs} args - specifies the menu event arguements.
* @returns {void}
* @private
*/
function sortbyClickHandler(parent, args) {
let tick;
parent.isSortByClicked = true;
if (args.item.id.indexOf('ascending') !== -1 || args.item.id.indexOf('descending') !== -1 || args.item.id.indexOf('none') !== -1) {
tick = true;
}
else {
tick = false;
}
if (!tick) {
parent.sortBy = getSortField(args.item.id, parent);
}
else {
parent.sortOrder = getSortField(args.item.id);
}
parent.itemData = [getPathObject(parent)];
if (parent.view === 'Details') {
if (parent.isMobile) {
updateLayout(parent, 'Details');
}
else {
parent.notify(sortColumn, { module: 'detailsview' });
parent.isSortByClicked = false;
}
}
if (parent.view === 'LargeIcons') {
updateLayout(parent, 'LargeIcons');
}
parent.notify(sortByChange, {});
}
/**
* Gets the sorted fields
*
* @param {string} id - specifies the id.
* @param {IFileManager} [parent] - optional parameter representing the parent IFileManager.
* @returns {string} - returns the sorted fields
* @private
*/
function getSortField(id, parent) {
const text = id.substring(id.lastIndexOf('_') + 1);
let field = text;
let column;
if (parent) {
column = parent.detailsViewSettings.columns;
}
switch (text) {
case 'date':
for (let i = 0, len = column.length; i < len; i++) {
if (column[i].field === 'dateModified' || column[i].field === 'dateCreated') {
field = column[i].field;
break;
}
else {
field = '_fm_modified';
}
}
break;
case 'ascending':
field = 'Ascending';
break;
case 'descending':
field = 'Descending';
break;
case 'none':
field = 'None';
break;
}
return field;
}
/**
* Sets the next path
*
* @param {IFileManager} parent - specifies the parent element.
* @param {string} path - specifies the path.
* @returns {void}
* @private
*/
function setNextPath(parent, path) {
const currfolders = path.split('/');
const folders = parent.originalPath.split('/');
const root = getValue(parent.pathId[0], parent.feParent);
const key = isNullOrUndefined(getValue('id', root)) ? 'name' : 'id';
for (let i = currfolders.length - 1, len = folders.length - 1; i < len; i++) {
const eventName = (folders[i + 1] === '') ? finalizeEnd : initialEnd;
const newPath = (folders[i] === '') ? '/' : (parent.path + folders[i] + '/');
const data = getObject(parent, key, folders[parseInt(i.toString(), 10)]);
if (!isNullOrUndefined(data)) {
const id = getValue('_fm_id', data);
parent.setProperties({ path: newPath }, true);
parent.pathId.push(id);
parent.itemData = [data];
parent.pathNa