{"version":3,"file":"filemanager.js","sources":["../sources/views/actions.js","../sources/types.js","../sources/locale.js","../sources/widgets/filelist.js","../sources/widgets/filemenu.js","../sources/widgets/filetree.js","../sources/widgets/filetable.js","../sources/widgets/fileview.js","../sources/widgets/path.js","../sources/defaults.js","../sources/history.js","../sources/sort.js","../sources/load.js","../sources/path.js","../sources/save.js","../sources/views/modes.js","../sources/views/modeviews.js","../sources/views/table.js","../sources/views/toggle.js","../sources/views/tree.js","../sources/ui.js","../sources/views/mainlayout.js","../sources/views/toolbar.js","../sources/views/menu.js","../sources/views/back.js","../sources/views/forward.js","../sources/views/up.js","../sources/views/path.js","../sources/views/search.js","../sources/views/bodylayout.js","../sources/views/treelayout.js","../sources/views/panel.js","../sources/views/treetoolbar.js","../sources/views/expandall.js","../sources/views/collapseall.js","../sources/views/files.js","../sources/views/columns.js","../sources/views/upload.js","../sources/filemanager.js","../sources/tree.js"],"sourcesContent":["function getData(){\n\treturn [\n\t\t{id: \"copy\", batch: \"item\", method: \"markCopy\", icon: \"fm-copy\", value: webix.i18n.filemanager.copy},\n\t\t{id: \"cut\", batch: \"item\", method: \"markCut\", icon: \"fm-cut\", value: webix.i18n.filemanager.cut},\n\t\t{id: \"paste\", method: \"pasteFile\", icon: \"fm-paste\", value: webix.i18n.filemanager.paste},\n\t\t{ $template:\"Separator\" },\n\t\t{id: \"create\", method: \"createFolder\", icon: \"fm-folder\", value: webix.i18n.filemanager.create},\n\t\t{id: \"remove\", batch: \"item\", method: \"deleteFile\", icon: \"fm-delete\", value: webix.i18n.filemanager.remove},\n\t\t{id: \"edit\", batch: \"item\", method: \"editFile\", icon: \"fm-edit\", value: webix.i18n.filemanager.rename},\n\t\t{id: \"upload\", method: \"uploadFile\", event:\"UploadDialog\", icon: \"fm-upload\", value: webix.i18n.filemanager.upload}\n\t];\n}\n\nexport function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\tvar templateName = view.config.templateName;\n\tvar data = getData();\n\n\n\tvar popup = {\n\t\tview: \"filemenu\",\n\t\tid:\"actions\",\n\t\twidth: 200,\n\t\tpadding:0,\n\t\tautofocus: false,\n\t\tcss: \"webix_fmanager_actions\",\n\t\ttemplate: function(obj,common){\n\t\t\tvar name = templateName(obj,common);\n\t\t\tvar icon = obj.icon.indexOf(\"fm-\") == -1?obj.icon:\"webix_fmanager_icon \"+obj.icon;\n\t\t\treturn \" \"+name+\"\";\n\t\t},\n\t\tdata: data\n\t};\n\n\n\tview.callEvent(\"onViewInit\", [\"actions\", popup]);\n\tview._contextMenu = view.ui(popup);\n\tview.attachEvent(\"onDestruct\",function(){\n\t\tview._contextMenu.destructor();\n\t});\n}\n\nfunction ready(view){\n\tvar menu = view.getMenu();\n\tif(menu){\n\t\tmenu.attachEvent(\"onItemClick\",function(id,e){\n\t\t\tvar obj = this.getItem(id);\n\t\t\tvar method = view[obj.method]||view[id];\n\t\t\tif(method){\n\t\t\t\tvar active = view.getActive();\n\t\t\t\tif(view.callEvent(\"onbefore\"+(obj.event||obj.method||id),[active])){\n\t\t\t\t\tif(!(id==\"upload\" && view.config.legacyUploader)){\n\t\t\t\t\t\tif(view._uploadPopup)\n\t\t\t\t\t\t\tview._uploadPopup.hide();\n\t\t\t\t\t\tmenu.hide();\n\t\t\t\t\t}\n\t\t\t\t\tvar args = [active];\n\t\t\t\t\tif(id==\"upload\"){\n\t\t\t\t\t\te = webix.html.pos(e);\n\t\t\t\t\t\targs.push(e);\n\t\t\t\t\t}\n\t\t\t\t\twebix.delay(function(){\n\t\t\t\t\t\tmethod.apply(view,args);\n\t\t\t\t\t\tview.callEvent(\"onafter\"+(obj.event||obj.method||id),[]);\n\t\t\t\t\t});\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t});\n\t\tmenu.attachEvent(\"onBeforeShow\",function(e){\n\t\t\tmenu.filter(\"\");\n\t\t\tmenu.hide();\n\t\t\tvar c = menu.getContext();\n\n\t\t\t//context menu over empty area \n\t\t\tif(c && c.obj && !c.id)\n\t\t\t\tc.obj.unselectAll();\n\t\t\t\n\t\t\tif(c && c.obj)\n\t\t\t\treturn c.obj.callEvent(\"onBeforeMenuShow\",[c.id,e]);\n\n\t\t\treturn true;\n\t\t});\n\n\t}\n}\n","// tree type\nwebix.type(webix.ui.tree,{\n\tname: \"FileTree\",\n\tcss: \"webix_fmanager_tree\",\n\tdragTemplate: webix.template(\"#value#\"),\n\ticon:function(obj){\n\t\tvar html = \"\";\n\t\tfor(var i =1; i < obj.$level; i++){\n\t\t\thtml += \"
\";\n\t\t}\n\t\tif(obj.webix_child_branch && !obj.$count){\n\t\t\thtml += \"
\";\n\t\t}\n\t\telse if (obj.$count>0){\n\t\t\tif (obj.open)\n\t\t\t\thtml += \"
\";\n\t\t\telse\n\t\t\t\thtml += \"
\";\n\t\t} else\n\t\t\thtml += \"
\";\n\t\treturn html;\n\t},\n\tfolder:function(obj){\n\t\tif (obj.$count && obj.open)\n\t\t\treturn \"
\";\n\t\treturn \"
\";\n\t}\n});\n// dataview type\nwebix.type(webix.ui.dataview, {\n\tname:\"FileView\",\n\tcss: \"webix_fmanager_files\",\n\theight: 110,\n\tmargin: 10,\n\twidth: 150,\n\ttemplate: function(obj,common){\n\t\tvar css = \"webix_fmanager_data_icon\";\n\t\tvar name = common.templateName(obj,common);\n\t\treturn \"
\"+common.templateIcon(obj,common)+\"
\"+name+\"
\";\n\t}\n});","// locale values\nwebix.i18n.filemanager = {\n\tactions: \"Actions\",\n\tback: \"Back\",\n\tforward: \"Forward\",\n\tlevelUp: \"Level Up\",\n\tname: \"Name\",\n\tsize: \"Size\",\n\ttype: \"Type\",\n\tdate: \"Date\",\n\tcopy: \"Copy\",\n\tcut: \"Cut\",\n\tpaste: \"Paste\",\n\tupload: \"Upload\",\n\tremove: \"Delete\",\n\tcreate: \"Create Folder\",\n\trename: \"Rename\",\n\tlocation: \"Location\",\n\tselect: \"Select Files\",\n\tsizeLabels: [\"B\",\"KB\",\"MB\",\"GB\"],\n\ticonsView: \"Icons View\",\n\ttableView: \"Table View\",\n\thideTree: \"Hide Tree\",\n\tshowTree: \"Show Tree\",\n\tcollapseTree: \"Collapse Tree\",\n\texpandTree: \"Expand Tree\",\n\tsaving: \"Saving...\",\n\terrorResponse: \"Error: changes were not saved!\",\n\treplaceConfirmation: \"The folder already contains files with such names. Would you like to replace existing files ?\",\n\tcreateConfirmation: \"The folder with such a name already exists. Would you like to replace it ?\",\n\trenameConfirmation: \"The file with such a name already exists. Would you like to replace it ?\",\n\tyes: \"Yes\",\n\tno: \"No\",\n\ttypes:{\n\t\tfolder: \"Folder\",\n\t\tdoc: \"Document\",\n\t\texcel: \"Excel\",\n\t\tpdf: \"PDF\",\n\t\tpp: \"PowerPoint\",\n\t\ttext: \"Text File\",\n\t\tvideo: \"Video File\",\n\t\timage: \"Image\",\n\t\tcode: \"Code\",\n\t\taudio: \"Audio\",\n\t\tarchive: \"Archive\",\n\t\tfile: \"File\"\n\t}\n};\n","webix.protoUI({\n\tname:\"filelist\"\n}, webix.EditAbility, webix.ui.list);","webix.protoUI({\n\tname:\"filemenu\"\n}, webix.ContextHelper, webix.ui.submenu);","// editable Tree\nwebix.protoUI({\n\tname:\"filetree\",\n\t$dragHTML:function(item, pos){\n\t\tvar ctx = webix.DragControl.getContext();\n\t\tvar type = this.type;\n\t\tvar text = type.dragTemplate(item,type);\n\t\tvar size = webix.html.getTextSize(text);\n\t\tvar posView = webix.html.offset(this.$view);\n\t\tvar offset = pos.x - posView.x;\n\t\tctx.x_offset = offset > size.width? - size.width/4 : -offset;\n\t\tctx.y_offset = - size.height/2;\n\t\treturn \"
\"+text+\"
\";\n\t}\n}, webix.EditAbility, webix.ui.tree);","// Datatable with customized drag element\nwebix.protoUI({\n\tname:\"filetable\",\n\t$dragHTML:function(item, pos){\n\t\tvar ctx = webix.DragControl.getContext();\n\t\tvar index = this.getColumnIndex(\"value\");\n\t\tvar text = this.config.columns[index].template(item,this.type);\n\t\tvar size = webix.html.getTextSize(text);\n\n\t\tvar posView = webix.html.offset(this.$view);\n\t\tvar offset = pos.clientX - posView.x;\n\t\t\n\t\tctx.x_offset = offset > size.width? - size.width/4 : -offset;\n\t\tctx.y_offset = - size.height/2;\n\n\t\tvar html=\"
\";\n\t\thtml += \"
\"+ text+\"
\";\n\t\treturn html+\"
\";\n\t}\n}, webix.ui.datatable);","// editable Dataview\nwebix.protoUI({\n\tname:\"fileview\"\n}, webix.EditAbility, webix.ui.dataview);","// a new view for path display, based on List view\nwebix.protoUI({\n\tname: \"path\",\n\tdefaults:{\n\t\tlayout: \"x\",\n\t\tseparator: \",\",\n\t\tscroll: false\n\t},\n\t$skin:function(){\n\t\tthis.type.height = webix.skin.$active.buttonHeight||webix.skin.$active.inputHeight;\n\t},\n\t$init: function(){\n\t\tthis.$view.className += \" webix_path\";\n\t},\n\tvalue_setter: function(value){\n\t\tthis.setValue();\n\t\treturn \tvalue;\n\t},\n\tsetValue: function(values){\n\t\tthis.clearAll();\n\t\tif(values){\n\t\t\tif(typeof(values) == \"string\"){\n\t\t\t\tvalues = values.split(this.config.separator);\n\t\t\t}\n\t\t\tthis.parse(webix.copy(values));\n\t\t}\n\t},\n\tgetValue: function(){\n\t\treturn this.serialize();\n\t}\n},webix.ui.list);","export const values = {\n\tmodes: [\"table\",\"files\"],\n\tmode: \"table\",\n\thandlers: {},\n\tstructure:{},\n\tfsIds: true,\n\ttemplateName: webix.template(\"#value#\"),\n\ttemplateSize: function(obj){\n\t\tvar value = obj.size;\n\t\tvar labels = webix.i18n.filemanager.sizeLabels;\n\t\tvar pow = 0;\n\t\twhile(value/1024 >1){\n\t\t\tvalue = value/1024;\n\t\t\tpow++;\n\t\t}\n\t\tvar isInt = (parseInt(value,10) == value);\n\n\t\tvar format = webix.Number.numToStr({\n\t\t\tdecimalDelimiter:webix.i18n.decimalDelimiter,\n\t\t\tgroupDelimiter:webix.i18n.groupDelimiter,\n\t\t\tdecimalSize : isInt?0:webix.i18n.groupSize\n\t\t});\n\n\t\treturn format(value)+\"\"+labels[pow];\n\t},\n\ttemplateType: function(obj){\n\t\tvar types = webix.i18n.filemanager.types;\n\t\treturn types&&types[obj.type]?types[obj.type]:obj.type;\n\t},\n\ttemplateDate: function(obj){\n\t\tvar date = obj.date;\n\t\tif(typeof(date) != \"object\"){\n\t\t\tdate = new Date(parseInt(obj.date,10)*1000);\n\t\t}\n\t\treturn webix.i18n.fullDateFormatStr(date);\n\t},\n\ttemplateCreate: function(){\n\t\treturn {value: \"newFolder\", type: \"folder\", date: new Date()};\n\t},\n\ttemplateIcon: function(obj,common){\n\t\treturn \"
\";\n\t},\n\tuploadProgress: {\n\t\ttype:\"icon\",\n\t\thide:false\n\t},\n\t//idChange: true,\n\ticons: {\n\t\tfolder: \"folder\",\n\t\texcel: \"file-excel\",\n\t\tpdf: \"file-pdf\",\n\t\tpp: \"file-powerpoint\",\n\t\ttext: \"file-text\",\n\t\tvideo: \"file-video\",\n\t\timage: \"file-image\",\n\t\tcode: \"file-code\",\n\t\taudio: \"file-audio\",\n\t\tarchive: \"file-archive\",\n\t\tdoc: \"file-word\",\n\t\tfile: \"file\"\n\t}\n};","export function init(view){\n\tview._cursorHistory = [];\n\tview.$ready.push(()=>setHandlers(view));\n}\n\nfunction setHandlers(view){\n\n\tview.attachEvent(\"onAfterCursorChange\", function(id){\n\t\tif(!view._historyIgnore){\n\t\t\tif(!view._historyCursor )\n\t\t\t\tview._cursorHistory.splice(1);\n\t\t\tif(view._cursorHistory[this._historyCursor] != id){\n\t\t\t\tif(view._cursorHistory.length==20)\n\t\t\t\t\tview._cursorHistory.splice(0,1);\n\t\t\t\tview._cursorHistory.push(id);\n\t\t\t\tview._historyCursor = this._cursorHistory.length-1;\n\t\t\t}\n\t\t}\n\t\tview._historyIgnore = false;\n\t\tview.callEvent(\"onHistoryChange\",[id, view._cursorHistory,view._historyCursor]);\n\t});\n}\n\n\nexport function changeCursor(view, step){\n\tif(view._cursorHistory.length>1){\n\t\tvar index = view._historyCursor + step;\n\t\tif(index>-1 && index < view._cursorHistory.length){\n\t\t\tview._historyIgnore = true;\n\t\t\tview._historyCursor = index;\n\t\t\tview.setCursor(view._cursorHistory[index]);\n\t\t}\n\t}\n\treturn view.getCursor();\n}","export function sortData(sort, data){\n\tvar sorter = webix.DataStore.prototype.sorting.create(sort);\n\tvar folders = [];\n\tvar files = [];\n\tfor(var i =0; i < data.length; i++){\n\t\tif(data[i].type == \"folder\")\n\t\t\tfolders.push(data[i]);\n\t\telse\n\t\t\tfiles.push(data[i]);\n\t}\n\tfolders.sort(sorter);\n\tfiles.sort(sorter);\n\treturn folders.concat(files);\n}","import * as sorting from \"./sort\";\n\nexport function init(view){\n\tview.attachEvent(\"onBeforeCursorChange\", function(){\n\t\tview.$skipDynLoading = false;\n\t\treturn true;\n\t});\n\tsetDataParsers(view);\n}\n\nfunction setDataParsers(view){\n\tview.dataParser = {\n\t\tfiles: function(obj, data){\n\t\t\tif(this.config.noFileCache){\n\t\t\t\tclearBranch(this, obj.id);\n\t\t\t}\n\t\t\telse\n\t\t\t\tobj.webix_files = 0;\n\n\t\t\tparseData(this, data);\n\t\t},\n\t\tbranch : function(obj, data){\n\t\t\tif(this.config.noFileCache){\n\t\t\t\tclearBranch(this, obj.id);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tobj.webix_branch = 0;\n\t\t\t\tobj.webix_child_branch = 0;\n\t\t\t}\n\n\t\t\tparseData(this, data);\n\t\t}\n\t};\n}\nexport function loadDynData(view, url, obj, mode, open){\n\tview.showProgress();\n\tif(view.callEvent(\"onBeforeDynLoad\", [url, obj, mode, open])){\n\t\tif (url.load)\n\t\t\treturn url.load(null, { action: mode, source: obj.id})\n\t\t\t\t.then(\n\t\t\t\t\tfunction(data){\n\t\t\t\t\t\tview.hideProgress();\n\t\t\t\t\t\tdata = convertData(view, data);\n\t\t\t\t\t\tif(open)\n\t\t\t\t\t\t\tobj.open = true;\n\n\t\t\t\t\t\tif(view.callEvent(\"onBeforeDynParse\", [obj, data, mode])){\n\t\t\t\t\t\t\tview.dataParser[mode].call(view, obj, data);\n\t\t\t\t\t\t\tview.callEvent(\"onAfterDynParse\", [obj, data, mode]);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tview.hideProgress();\n\t\t\t\t\t\tview.callEvent(\"onDynLoadError\",[]);\n\t\t\t\t\t}\n\t\t\t\t);\n\t}\n}\n\nexport function clearBranch(view, id){\n\tvar items = [];\n\n\tview.data.eachChild(id,function(item){\n\t\tif(!view.data.branch[item.id] && item.type != \"folder\")\n\t\t\titems.push(item.id);\n\t},view,true);\n\n\tfor(var i=0; i< items.length; i++){\n\t\tview.remove(items[i]);\n\t}\n}\n\nexport function parseData(view, data){\n\tview.parse(data);\n\tview.$skipDynLoading = true;\n\tview._refreshActiveFolder();\n\tview.$skipDynLoading = false;\n}\n\nexport function openFolders(view, folders){\n\tvar dynMode, i, pItem;\n\tvar defer = webix.promise.defer();\n\tdynMode = getDynMode(view);\n\n\tif(dynMode && folders.length){\n\t\tfor(i =0; i < folders.length; i++){\n\t\t\tpItem = view.getItem(folders[i]);\n\t\t\tif(!(pItem && !pItem[\"webix_\" + dynMode])){\n\t\t\t\topenDynFolder(view,folders.slice(i), dynMode, defer);\n\t\t\t\treturn defer;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tpItem.open = true;\n\t\t\t\tif(view.$$(\"tree\"))\n\t\t\t\t\tview.$$(\"tree\").refresh(folders[i]);\n\t\t\t}\n\t\t}\n\t\tdefer.resolve(folders[i]);\n\t}\n\telse{\n\t\tdefer.reject();\n\t}\n\treturn defer;\n}\nfunction openDynFolder(view,ids, mode, defer){\n\tvar obj = view.getItem(ids[0]);\n\tview.showProgress();\n\tvar url = view.config.handlers[mode];\n\tif (url.load)\n\t\treturn url.load(null, { action: mode, source: ids[0]})\n\t\t\t.then(\n\t\t\t\tfunction(data){\n\t\t\t\t\tview.hideProgress();\n\t\t\t\t\tdata = convertData(view, data);\n\t\t\t\t\tif(view.callEvent(\"onBeforeDynParse\", [obj, data, mode])){\n\t\t\t\t\t\tobj.open = true;\n\t\t\t\t\t\tview.dataParser[mode].call(view, obj, data);\n\n\t\t\t\t\t\tvar lastId = ids.shift();\n\t\t\t\t\t\tif(ids.length && view.getItem(ids[0]).type == \"folder\"){\n\t\t\t\t\t\t\topenDynFolder(view,ids, mode, defer);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\tview.refreshCursor();\n\t\t\t\t\t\t\tdefer.resolve(lastId);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tview.callEvent(\"onAfterDynParse\", [obj, data, mode]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n}\n\nexport function getDynMode(view){\n\tfor(var mode in view.dataParser){\n\t\tif (view.config.handlers[mode]) {\n\t\t\treturn mode;\n\t\t}\n\t}\n\treturn null;\n}\nexport function loadSearchData(view, url, id, value){\n\tvar params = { action:\"search\", source: id, text: value};\n\tif(view.callEvent(\"onBeforeSearchRequest\",[id, params])){\n\t\tif (url.load)\n\t\t\treturn url.load(null, params)\n\t\t\t\t.then(\n\t\t\t\t\tfunction(data){\n\t\t\t\t\t\tview.hideProgress();\n\t\t\t\t\t\tdata = convertData(view, data);\n\t\t\t\t\t\tparseSearchData(view, data);\n\t\t\t\t\t\tview.$searchValue = value;\n\t\t\t\t\t},\n\t\t\t\t\tfunction(){\n\t\t\t\t\t\tview.hideProgress();\n\t\t\t\t\t}\n\t\t\t\t);\n\t}\n}\nexport function parseSearchData(view, data){\n\tview.callEvent(\"onShowSearchResults\",[]);\n\tview.$searchResults = true;\n\tvar cell = view.$$(view.config.mode);\n\tif(cell && cell.filter){\n\t\tcell.clearAll();\n\t\tif(view.sortState && view.sortState.view == cell.config.id)\n\t\t\tdata = sorting.sortData(view.sortState.sort, data);\n\t\tcell.parse(data);\n\t}\n}\n\nfunction convertData(view, data){\n\tif (data && typeof data.text === \"function\")\n\t\tdata = data.text();\n\treturn view.data.driver.toObject(data);\n}","export function getPath(view, id){\n\tid = id||view.getCursor();\n\tvar path = [];\n\twhile(id && view.getItem(id)){\n\t\tpath.push(id);\n\t\tid = view.getParentId(id);\n\t}\n\treturn path.reverse();\n}\n\nexport function getPathNames(view, id){\n\tid = id||view.getCursor();\n\tvar item = null;\n\tvar path = [];\n\twhile(id && view.getItem(id)){\n\t\titem = view.getItem(id);\n\t\tpath.push({id:id, value:view.config.templateName(item)});\n\t\tid = view.getParentId(id);\n\t}\n\treturn path.reverse();\n}\n\n\nexport function setPath(view, id){\n\tvar pId = id;\n\twhile(pId && view.getItem(pId)){\n\t\tview.callEvent(\"onPathLevel\",[pId]);\n\t\tpId = view.getParentId(pId);\n\t}\n\tif(view.getItem(id)){\n\t\tif(id!= view.getCursor()){\n\t\t\tview.setCursor(id);\n\t\t\tview.callEvent(\"onPathComplete\",[id]);\n\t\t}\n\n\t}else{\n\t\t// dynamic loading\n\t\tvar folders = getParentFolders(id);\n\t\tview.openFolders(folders).then(function(){\n\t\t\tview.setCursor(id);\n\t\t\tview.callEvent(\"onPathComplete\",[id]);\n\t\t});\n\t}\n\n}\n\nexport function getParentFolders(id){\n\tvar i, parts,\n\t\tids = [];\n\tif(typeof id == \"string\"){\n\t\tparts = id.replace(/^\\//,\"\").split(\"/\");\n\t\tfor(i=0; i< parts.length; i++){\n\t\t\tids.push(parts.slice(0, i+1).join(\"/\"));\n\t\t}\n\t}\n\treturn ids;\n}","export function makeSaveRequest(view, url, obj, callback){\n\tif(view.callEvent(\"onBeforeRequest\",[url, obj])){\n\t\tshowSaveMessage(view);\n\t\tif(url.load){\n\t\t\turl.load(null, webix.copy(obj))\n\t\t\t\t.then(\n\t\t\t\t\tfunction(data){\n\t\t\t\t\t\tif (data && typeof data.text === \"function\")\n\t\t\t\t\t\t\tdata = data.text();\n\t\t\t\t\t\tdata = view.data.driver.toObject(data);\n\t\t\t\t\t\thideSaveMessage(view);\n\t\t\t\t\t\tif(view.callEvent(\"onSuccessResponse\",[obj,data]) && callback)\n\t\t\t\t\t\t\tcallback.call(view,obj,data);\n\t\t\t\t\t},\n\t\t\t\t\tfunction(error){\n\t\t\t\t\t\tif(view.callEvent(\"onErrorResponse\", [obj, error]))\n\t\t\t\t\t\t\terrorHandler(view, error);\n\t\t\t\t\t}\t\n\t\t\t\t);\n\t\t}\n\t}\n}\n\nfunction showSaveMessage(view, message){\n\tview._saveMessageDate = new Date();\n\tif (!view._saveMessage){\n\t\tview._saveMessage = webix.html.create(\"DIV\",{ \"class\":\"webix_fmanager_save_message\"},\"\");\n\t\tview.$view.style.position = \"relative\";\n\t\twebix.html.insertBefore(view._saveMessage, view.$view);\n\t}\n\tvar msg = \"\";\n\tif (!message) {\n\t\tmsg = webix.i18n.filemanager.saving;\n\t} else{\n\t\tmsg = webix.i18n.filemanager.errorResponse;\n\t}\n\n\tview._saveMessage.innerHTML = msg;\n}\n\nfunction hideSaveMessage(view){\n\tif (view._saveMessage){\n\t\twebix.html.remove(view._saveMessage);\n\t\tview._saveMessage = null;\n\t}\n}\n\nexport function errorHandler(view){\n\t// reload data on error response\n\tconst url = view.data.url;\n\tif(url){\n\t\tshowSaveMessage(view, true);\n\t\twebix.ajax(url)\n\t\t\t.then((data)=>{\n\t\t\t\tif (data && typeof data.text === \"function\")\n\t\t\t\t\tdata = data.text();\n\t\t\t\tdata = view.data.driver.toObject(data);\n\t\t\t\tif (data){\n\t\t\t\t\tview.clearAll();\n\t\t\t\t\tview.parse(data);\n\t\t\t\t\tview.data.url = url;\n\t\t\t\t}\n\t\t\t});\n\t}\n}","export function init(view,settings){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\tvar options = [];\n\n\tsettings.modes.forEach(function(mode){\n\t\tif(mode == \"table\")\n\t\t\toptions.push(getModeConfig(mode, \"table\"));\n\t\telse if(mode == \"files\")\n\t\t\toptions.push(getModeConfig(mode, \"icons\"));\n\t});\n\n\tvar config = { view: \"segmented\", width: 70, options: options, css:\"webix_fmanager_modes\", value: settings.mode};\n\n\treturn config;\n}\n\nfunction getModeConfig(mode, tooltip){\n\treturn {\n\t\tid: mode,\n\t\twidth: 32,\n\t\tvalue: \"
\",\n\t\ttooltip:webix.i18n.filemanager[tooltip+\"View\"]\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"modes\")){\n\t\tview.$$(\"modes\").attachEvent(\"onBeforeTabClick\",function(id){\n\t\t\tvar value = view.$$(\"modes\").getValue();\n\t\t\tif(view.callEvent(\"onBeforeModeChange\",[value,id])){\n\t\t\t\tif(view.$$(id)){\n\t\t\t\t\tview.config.mode = id;\n\t\t\t\t\tview.$$(id).show();\n\t\t\t\t\tview.callEvent(\"onAfterModeChange\",[value,id]);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t}\n}","import * as sorting from \"../sort\";\n\nexport function init(view, settings){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn {\n\t\tanimate: false,\n\t\tcells: (settings.modes?webix.copy(settings.modes):[])\n\t};\n}\n\nfunction ready(view){\n\tvar i, mCell,\n\t\tcell = view.$$(view.config.mode),\n\t\tmodes = view.config.modes;\n\n\tif(cell){\n\t\tcell.show();\n\t\tview.attachEvent(\"onBeforeCursorChange\", function(){\n\t\t\tvar cell = view.$$(view.config.mode);\n\t\t\tif(cell)\n\t\t\t\tcell.unselect();\n\t\t\treturn true;\n\t\t});\n\t\tview.attachEvent(\"onAfterCursorChange\", function(){\n\t\t\tvar cell = view.$$(view.config.mode);\n\t\t\tif(cell)\n\t\t\t\tcell.editStop();\n\t\t});\n\t}\n\n\tif(modes){\n\t\tfor(i =0; i < modes.length; i++) {\n\t\t\tmCell = view.$$(modes[i]);\n\t\t\tif (mCell && mCell.filter) {\n\t\t\t\taddCellConfig(view, mCell);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction addCellConfig(view, cell){\n\tbindData(view, cell);\n\tapplyTemplates(view, cell);\n\tsetCellHandlers(view, cell);\n\t// link with context menu\n\tvar menu = view.getMenu();\n\tif (menu && !view.config.readonly)\n\t\taddMenuHandlers(view, cell, menu);\n\t//read-only\n\tif(view.config.readonly){\n\t\tcell.define(\"drag\",false);\n\t\tcell.define(\"editable\",false);\n\t}\n}\n\nfunction bindData(view, cell){\n\tview.data.attachEvent(\"onClearAll\", () => cell.clearAll());\n\n\tview.data.attachEvent(\"onIdChange\",(oldId,newId) => {\n\t\tif(cell.data.pull[oldId])\n\t\t\tcell.data.changeId(oldId,newId);\n\t});\n\n\t// we do not need call binding on row selection\n\tcell.attachEvent(\"onBeforeSelect\", function(){\n\t\tcell.$skipBinding = true;\n\t});\n\tview.attachEvent(\"onBeforeCursorChange\", function(){\n\t\tcell.$skipBinding = false;\n\t});\n\tview.attachEvent(\"onAfterCursorChange\", function(){\n\t\tcell.$skipBinding = false;\n\t});\n\tcell.bind(view, \"$data\", (obj, source) => {\n\t\tvar url;\n\t\tif(cell.$skipBinding)\n\t\t\treturn false;\n\t\tif (!obj) return cell.clearAll();\n\n\t\tif (!view.$searchResults) {\n\t\t\tif(!view.$skipDynLoading){\n\t\t\t\tfor(var mode in view.dataParser){\n\t\t\t\t\tif(!url && obj[\"webix_\"+mode]) {\n\t\t\t\t\t\turl = view.config.handlers[mode];\n\t\t\t\t\t\tif (url) {\n\t\t\t\t\t\t\tview.$skipDynLoading = true;\n\t\t\t\t\t\t\tview.loadDynData(url, obj, mode);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// import child items\n\t\t\timportSelectedBranch(view, cell, source, obj);\n\t\t}\n\t});\n}\n\nfunction importSelectedBranch(view, target, source, obj){\n\tvar data = [].concat(webix.copy(source.data.getBranch(obj.id))).concat(obj.files || []);\n\tif(view.sortState && view.sortState.view == target.config.id)\n\t\tdata = sorting.sortData(view.sortState.sort, data);\n\ttarget.data.importData(data, true);\n}\n\n\n\nfunction applyTemplates(view, cell){\n\tcell.type.icons = view.config.icons;\n\tcell.type.templateIcon = view.config.templateIcon;\n\tcell.type.templateName = view.config.templateName;\n\tcell.type.templateSize = view.config.templateSize;\n\tcell.type.templateDate = view.config.templateDate;\n\tcell.type.templateType = view.config.templateType;\n}\n\nfunction addMenuHandlers(view,cell,menu){\n\tcell.on_context.webix_view = function(e,id){\n\t\tid = this.locate(e.target|| e.srcElement);\n\t\tif(!id){\n\t\t\tif(menu.setContext)\n\t\t\t\tmenu.setContext({ obj:webix.$$(e)});\n\t\t\tmenu.show(e);\n\t\t\twebix.html.preventEvent(e);\n\t\t}\n\n\t};\n\tmenu.attachTo(cell);\n\n\tcell.attachEvent(\"onBeforeMenuShow\", function () {\n\t\tvar context = menu.getContext();\n\t\tvar type = \"\";\n\t\tif (context.id)\n\t\t\ttype = view.getItem(context.id).type === \"folder\" ? \"folder\" : \"file\";\n\n\t\tmenu.filter(function(obj){\n\t\t\tvar res = true;\n\n\t\t\tif (obj.batch){\n\t\t\t\tif(!type){\n\t\t\t\t\tres = (obj.batch == \"empty\");\n\t\t\t\t} else {\n\t\t\t\t\tres = (obj.batch == type || obj.batch == \"item\" || obj.batch == \"empty\");\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif(view.config.menuFilter)\n\t\t\t\tres = res && view.config.menuFilter(obj);\n\n\t\t\treturn res;\n\t\t});\n\n\t\tif(menu.count() && context.id){\n\t\t\twebix.UIManager.setFocus(this);\n\t\t\tvar sel = this.getSelectedId();\n\t\t\tvar found = false;\n\t\t\tif(webix.isArray(sel)){\n\t\t\t\tfor(var i =0; !found && i < sel.length; i++){\n\t\t\t\t\tif(\"\"+sel[i] == \"\"+context.id)\n\t\t\t\t\t\tfound = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!found && this.exists(context.id))\n\t\t\t\tthis.select(context.id);\n\t\t}\n\n\t\treturn menu.count()>0;\n\t});\n\n\tcell.attachEvent(\"onAfterMenuShow\", function (id) {\n\t\tif(id){\n\t\t\tvar selected = this.getSelectedId(true);\n\t\t\tvar isSelected = false;\n\t\t\tfor (var i = 0; ( i < selected.length) && !isSelected; i++) {\n\t\t\t\tif (selected[i].toString() == id.toString()) {\n\t\t\t\t\tisSelected = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!isSelected)\n\t\t\t\tthis.select(id.toString());\n\n\t\t\twebix.UIManager.setFocus(this);\n\t\t}\n\t\telse{\n\t\t\tthis.unselect();\n\t\t}\n\t});\n}\nfunction setCellHandlers(view, cell){\n\n\tcell.attachEvent(\"onAfterSelect\", (id) => {\n\t\tif(view.getItem(id))\n\t\t\tview.callEvent(\"onItemSelect\",[id]);\n\t});\n\n\t// double-click handlers\n\tcell.attachEvent(\"onItemDblClick\", function(id) {\n\t\tview._onFileDblClick(id);\n\t});\n\n\t// focus and blur styling\n\tview._addElementHotKey(\"tab\", function(cell){\n\t\tif (!cell.getSelectedId()) {\n\t\t\tvar id = cell.getFirstId();\n\t\t\tif (id){\n\t\t\t\tcell.select(id);\n\t\t\t}\n\t\t}\n\t},cell);\n\tcell.attachEvent(\"onFocus\", function(){\n\t\tview._activeView = this;\n\t\twebix.html.removeCss(this.$view, \"webix_blur\");\n\t});\n\tcell.attachEvent(\"onBlur\", function() {\n\t\tif (!view.getMenu() || !view.getMenu().isVisible())\n\t\t\twebix.html.addCss(cell.$view, \"webix_blur\");\n\t});\n\n\t// editing (rename)\n\tcell.attachEvent(\"onBeforeEditStop\", function (state, editor) {\n\t\treturn this.getTopParentView().callEvent(\"onBeforeEditStop\", [editor.id || editor.row, state, editor, this]);\n\t});\n\tcell.attachEvent(\"onAfterEditStop\", function (state, editor) {\n\t\tvar view = this.getTopParentView();\n\t\tif (view.callEvent(\"onAfterEditStop\", [editor.id || editor.row, state, editor, this])) {\n\t\t\tif(!editor.column || editor.column == \"value\")\n\t\t\t\tview.renameFile(editor.id || editor.row, state.value);\n\t\t\telse if(editor.column){\n\t\t\t\tview.getItem(editor.id || editor.row)[editor.column] = state.value;\n\t\t\t}\n\t\t}\n\t});\n\n\t// drag-n-drop\n\tcell.attachEvent(\"onBeforeDrop\", function (context, e) {\n\t\tif (view.callEvent(\"onBeforeDrop\", [context])) {\n\t\t\tif (context.from) { //from different component\n\t\t\t\tview.moveFile(context.source, context.target);\n\t\t\t\tview.callEvent(\"onAfterDrop\",[context,e]);\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t});\n\tcell.attachEvent(\"onBeforeDrag\", function (context, e) {\n\t\treturn !view.config.readonly&&view.callEvent(\"onBeforeDrag\", [context, e]);\n\t});\n\tcell.attachEvent(\"onBeforeDragIn\", function (context, e) {\n\t\treturn !view.config.readonly&&view.callEvent(\"onBeforeDragIn\", [context, e]);\n\t});\n\n\t// enter hot key\n\tview._addElementHotKey(\"enter\", function (sview) {\n\t\tvar selected = sview.getSelectedId(true);\n\t\tfor (var i = 0; i < selected.length; i++) {\n\t\t\tview._onFileDblClick(selected[i]);\n\t\t}\n\t\twebix.UIManager.setFocus(sview);\n\t\tselected = sview.getSelectedId(true);\n\t\tif (!selected.length) {\n\t\t\tvar id0 = sview.getFirstId();\n\t\t\tif (id0)\n\t\t\t\tsview.select(id0);\n\t\t}\n\t}, cell);\n\n\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn {\n\t\tview: \"filetable\",\n\t\tcss: \"webix_fmanager_table\",\n\t\tcolumns: \"columns\",\n\t\theaderRowHeight: 34,\n\t\teditable: true,\n\t\teditaction: false,\n\t\tselect: \"multiselect\",\n\t\tdrag: true,\n\t\tnavigation: true,\n\t\tresizeColumn:true,\n\t\ttabFocus: true,\n\t\tonContext:{}\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"table\")){\n\t\tview.attachEvent(\"onHideSearchResults\", function(){\n\t\t\tif(view.$$(\"table\").isColumnVisible(\"location\"))\n\t\t\t\tview.$$(\"table\").hideColumn(\"location\");\n\t\t});\n\t\tview.attachEvent(\"onShowSearchResults\", function(){\n\t\t\tif(!view.$$(\"table\").isColumnVisible(\"location\"))\n\t\t\t\tview.$$(\"table\").showColumn(\"location\");\n\t\t});\n\n\t\tview.$$(\"table\").attachEvent(\"onBeforeEditStart\", function(id){\n\t\t\tif(typeof(id) != \"object\"){\n\t\t\t\tthis.edit({row:id,column: \"value\"});\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t\t// sorting\n\t\tview.$$(\"table\").data.attachEvent(\"onBeforeSort\", function(by, dir, as, sort){\n\t\t\tview.sortState = {\n\t\t\t\tview: view.$$(\"table\").config.id,\n\t\t\t\tsort: sort\n\t\t\t};\n\t\t\tif(view.$searchResults && view.$$(\"search\")){\n\t\t\t\tview.showSearchResults(view.$$(\"search\").getValue());\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\tview.data.attachEvent(\"onClearAll\", function(){\n\t\t\tview.sortState = null;\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_toggle\",\n\t\tlabel: \"
\", width: 30,\n\t\ttooltip: webix.i18n.filemanager.hideTree\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"hideTree\")){\n\t\tview.$$(\"hideTree\").attachEvent(\"onItemClick\", function(){\n\t\t\tview.hideTree();\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn {\n\t\twidth: 251,\n\t\tview: \"filetree\",\n\t\tid: \"tree\",\n\t\tselect: true,\n\t\tfilterMode:{\n\t\t\tshowSubItems:false,\n\t\t\topenParents:false\n\t\t},\n\t\ttype: \"FileTree\",\n\t\tnavigation: true,\n\t\teditor:\"text\",\n\t\teditable: true,\n\t\teditaction: false,\n\t\tdrag: true,\n\t\ttabFocus: true,\n\t\tonContext:{}\n\t};\n}\n\nfunction ready(view){\n\tvar tree = view.$$(\"tree\");\n\tvar state;\n\n\tif(tree){\n\n\n\t\ttree.type.icons = view.config.icons;\n\n\t\t// data source definition (syncing with main data source)\n\t\ttree.sync(view,function(){\n\t\t\tthis.filter(function(obj){\n\n\t\t\t\treturn (obj.$count||obj.type==\"folder\");\n\t\t\t});\n\t\t});\n\n\n\t\t// customize for current widget only\n\t\ttree.on_click = webix.extend({}, tree.on_click);\n\t\ttree.on_click.webix_tree_child_branch = function(ev, id){\n\t\t\tvar url = view.config.handlers.branch;\n\t\t\tif(url){\n\t\t\t\tview.loadDynData(url, this.getItem(id), \"branch\", true);\n\t\t\t}\n\t\t};\n\n\t\tview.attachEvent(\"onBeforeDynParse\", function(){\n\t\t\tstate = tree.getState();\n\t\t});\n\n\t\tview.attachEvent(\"onAfterDynParse\", function(obj,data,mode){\n\t\t\tif(state){\n\t\t\t\ttree.setState(state);\n\t\t\t\tstate = null;\n\t\t\t}\n\t\t\tif(mode == \"branch\" && obj.open){\n\t\t\t\ttree.open(obj.id);\n\t\t\t}\n\t\t});\n\n\t\ttree.attachEvent(\"onAfterSelect\", function(id){\n\t\t\tview.callEvent(\"onFolderSelect\",[id]);\n\t\t});\n\n\t\tview.attachEvent(\"onAfterCursorChange\", function(id){\n\t\t\tif (id){\n\t\t\t\ttree.select(id);\n\t\t\t\ttree.showItem(id);\n\t\t\t}\n\t\t});\n\n\t\t// hide search results on click\n\t\ttree.attachEvent(\"onItemClick\",function(){\n\t\t\tif(view.$searchResults){\n\t\t\t\tview.hideSearchResults();\n\t\t\t}\n\t\t});\n\n\t\tview.attachEvent(\"onItemRename\", function(id){\n\t\t\ttree.refresh(id);\n\t\t});\n\n\t\t// open/close on double-click\n\t\ttree.attachEvent(\"onItemDblClick\",function(id){\n\t\t\tif(this.isBranchOpen(id)){\n\t\t\t\tthis.close(id);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tthis.open(id);\n\t\t\t}\n\t\t});\n\n\t\ttree.attachEvent(\"onBlur\",function(){\n\t\t\tif(!view.getMenu()||!view.getMenu().isVisible()){\n\t\t\t\twebix.html.addCss(this.$view,\"webix_blur\");\n\t\t\t}\n\t\t});\n\n\t\ttree.attachEvent(\"onFocus\",function(){\n\t\t\tview._activeView = tree;\n\t\t\twebix.html.removeCss(tree.$view,\"webix_blur\");\n\t\t\t// clear sub view selection\n\t\t\tview.$$(view.config.mode).unselect();\n\t\t});\n\n\n\t\t// setting path (history support)\n\t\tview.attachEvent(\"onPathComplete\",function(id){\n\t\t\ttree.showItem(id);\n\t\t});\n\n\t\t// context menu\n\t\tif(!view.config.readonly){\n\t\t\tif(view.getMenu())\n\t\t\t\tview.getMenu().attachTo(tree);\n\t\t\ttree.attachEvent(\"onBeforeMenuShow\",function(id){\n\t\t\t\tvar menu = view.getMenu();\n\n\t\t\t\tvar context = menu.getContext();\n\t\t\t\tvar type = \"\";\n\t\t\t\tif (context.id)\n\t\t\t\t\ttype = this.getParentId(context.id) ? \"folder\" : \"root\";\n\n\t\t\t\tmenu.filter(function(obj){\n\t\t\t\t\tvar res = true;\n\n\t\t\t\t\tif (obj.batch){\n\t\t\t\t\t\tif(!type){\n\t\t\t\t\t\t\tres = (obj.batch == \"empty\");\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tres = obj.batch == type;\n\t\t\t\t\t\t\tif(type != \"root\")\n\t\t\t\t\t\t\t\tres = res || obj.batch == \"item\" || obj.batch == \"empty\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif(view.config.menuFilter)\n\t\t\t\t\t\tres = res && view.config.menuFilter(obj);\n\n\t\t\t\t\treturn res;\n\t\t\t\t});\n\t\t\t\tthis.select(id);\n\t\t\t\twebix.UIManager.setFocus(this);\n\t\t\t\treturn menu.count()>0;\n\t\t\t});\n\t\t}\n\n\t\t// editing (rename)\n\t\ttree.attachEvent(\"onBeforeEditStop\",function(state,editor){\n\t\t\treturn view.callEvent(\"onBeforeEditStop\",[editor.id,state,editor,tree]);\n\t\t});\n\t\ttree.attachEvent(\"onAfterEditStop\",function(state,editor){\n\t\t\tif(view.callEvent(\"onAfterEditStop\",[editor.id,state,editor,tree])){\n\t\t\t\tview.renameFile(editor.id,state.value);\n\t\t\t}\n\t\t});\n\n\t\t// drag-n-drop\n\t\ttree.attachEvent(\"onBeforeDrag\",function(context,e){\n\t\t\treturn !view.config.readonly&&view.callEvent(\"onBeforeDrag\",[context,e]);\n\t\t});\n\t\ttree.attachEvent(\"onBeforeDragIn\",function(context,e){\n\t\t\treturn !view.config.readonly&&view.callEvent(\"onBeforeDragIn\",[context,e]);\n\t\t});\n\t\ttree.attachEvent(\"onBeforeDrop\",function(context,e){\n\t\t\tif(view.callEvent(\"onBeforeDrop\",[context,e])){\n\t\t\t\tif (context.from){\t//from different component\n\t\t\t\t\tview.moveFile(context.source, context.target);\n\t\t\t\t\tview.callEvent(\"onAfterDrop\",[context,e]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\n\t\t// focus\n\t\tvar setTreeCursor = function(){\n\t\t\tif(tree)\n\t\t\t\twebix.UIManager.setFocus(tree);\n\t\t};\n\t\tview.attachEvent(\"onAfterBack\",setTreeCursor);\n\t\tview.attachEvent(\"onAfterForward\",setTreeCursor);\n\t\tview.attachEvent(\"onAfterLevelUp\",setTreeCursor);\n\t\tview.attachEvent(\"onAfterPathClick\",setTreeCursor);\n\n\t\t// read-only mode\n\t\tif(view.config.readonly){\n\t\t\ttree.define(\"drag\",false);\n\t\t\ttree.define(\"editable\",false);\n\t\t}\n\t}\n}","import * as back from \"./views/back\";\nimport * as bodyLayout from \"./views/bodylayout\";\nimport * as collapse from \"./views/collapseall\";\nimport * as columns from \"./views/columns\";\nimport * as expand from \"./views/expandall\";\nimport * as files from \"./views/files\";\nimport * as forward from \"./views/forward\";\nimport * as mainLayout from \"./views/mainlayout\";\nimport * as menu from \"./views/menu\";\nimport * as modes from \"./views/modes\";\nimport * as modeViews from \"./views/modeviews\";\nimport * as path from \"./views/path\";\nimport * as search from \"./views/search\";\nimport * as sidePanel from \"./views/panel\";\nimport * as table from \"./views/table\";\nimport * as treeLayout from \"./views/treelayout\";\nimport * as treeToolbar from \"./views/treetoolbar\";\nimport * as toggle from \"./views/toggle\";\nimport * as toolbar from \"./views/toolbar\";\nimport * as tree from \"./views/tree\";\nimport * as up from \"./views/up\";\n\nexport function init(view, config){\n\tview.structure = {\n\t\t\"mainLayout\": mainLayout.init(view),\n\t\t\"toolbar\": toolbar.init(view),\n\t\t\"menu\": menu.init(view),\n\t\t\"back\": back.init(view),\n\t\t\"forward\": forward.init(view),\n\t\t\"up\": up.init(view),\n\t\t\"path\": path.init(view),\n\t\t\"search\": search.init(view),\n\t\t\"bodyLayout\": bodyLayout.init(view),\n\t\t\"treeLayout\": treeLayout.init(view),\n\t\t\"sidePanel\": sidePanel.init(view),\n\t\t\"treeToolbar\": treeToolbar.init(view),\n\t\t\"showTree\": toggle.init(view),\n\t\t\"hideTree\": toggle.init(view),\n\t\t\"expandAll\": expand.init(view),\n\t\t\"collapseAll\": collapse.init(view),\n\t\t\"tree\": tree.init(view),\n\t\t\"modeViews\":{\n\t\t\tconfig: function(settings){\n\t\t\t\treturn modeViews.init(view,settings);\n\t\t\t}\n\t\t},\n\t\t\"modes\":{\n\t\t\tconfig:function(settings){\n\t\t\t\treturn modes.init(view,settings);\n\t\t\t}\n\t\t},\n\t\t\"files\": {\n\t\t\tconfig: files.init(view)\n\t\t},\n\n\t\t\"table\": {\n\t\t\tconfig: table.init(view)\n\t\t},\n\t\t\"columns\": {\n\t\t\tconfig: columns.init(view)\n\t\t}\n\t};\n\n\tchangeStructure(view, config);\n}\n\n\nexport function getViews(view, struct, config){\n\tvar cells, found, i, id,\n\t\tarrName = \"\",\n\t\tarrs = [\"rows\",\"cols\",\"elements\",\"cells\",\"columns\",\"options\",\"data\"];\n\n\tfor(i =0; i< arrs.length;i++){\n\t\tif(struct[arrs[i]]){\n\t\t\tarrName = arrs[i];\n\t\t\tcells = struct[arrName];\n\t\t}\n\t}\n\tif(cells){\n\t\tif(typeof(cells) == \"string\"){\n\t\t\tif(view.structure[cells]){\n\t\t\t\tstruct[arrName] = getCellConfig(view, view.structure[cells],config);\n\t\t\t\tcells = struct[arrName];\n\t\t\t}\n\t\t}\n\n\t\tfor(i=0; i< cells.length;i++){\n\t\t\tfound = null;\n\t\t\tif(typeof(cells[i]) == \"string\"){\n\t\t\t\tfound = id = cells[i];\n\t\t\t\tif(view.structure[id]){\n\t\t\t\t\tcells[i] = getCellConfig(view, webix.extend({},view.structure[id]),config);\n\t\t\t\t\tcells[i].id = id;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tcells[i] = { };\n\t\t\t}\n\t\t\tgetViews(view, cells[i], config);\n\t\t\tif (found){\n\t\t\t\tif(config.on && config.on.onViewInit){\n\t\t\t\t\tconfig.on.onViewInit.apply(this,[found,cells[i]]);\n\t\t\t\t}\n\t\t\t\twebix.callEvent(\"onViewInit\",[found,cells[i],this]);\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport function getCellConfig(view, defConfig, config){\n\tvar cellConfig = defConfig.config||defConfig;\n\treturn (typeof(cellConfig)==\"function\"?cellConfig.call(view,config):webix.copy(cellConfig));\n}\n\nfunction isSVG(){\n\treturn (typeof SVGRect != \"undefined\");\n}\n\nexport function getUI(view, config){\n\tvar layoutConf = view.structure.mainLayout;\n\tvar structure = webix.extend({},layoutConf.config || layoutConf);\n\tgetViews(view, structure, config);\n\n\tif(config.on && config.on.onViewInit){\n\t\tconfig.on.onViewInit.apply(view,[config.id||\"mainLayout\",structure]);\n\t}\n\twebix.callEvent(\"onViewInit\",[config.id||\"mainLayout\",structure,view]);\n\tif(!isSVG())\n\t\tconfig.css = config.css?config.css+\" webix_nosvg\":\"webix_nosvg\";\n\treturn structure;\n}\n\nfunction changeStructure(view, config){\n\tvar newView, vName,\n\t\tnewViews = config.structure;\n\n\tif(newViews){\n\t\tfor(vName in newViews){\n\t\t\tif(newViews.hasOwnProperty(vName)){\n\t\t\t\tnewView = webix.copy(newViews[vName]);\n\t\t\t\tif(view.structure[vName] && view.structure[vName].config){\n\t\t\t\t\tview.structure[vName].config = newView.config||newView;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tview.structure[vName] = newView.config||newView;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}","export function init(){\n\tvar config = {\n\t\ttype: \"clean\",\n\t\trows:[\n\t\t\t\"toolbar\",\n\t\t\t\"bodyLayout\"\n\t\t]\n\t};\n\tif(typeof SVGRect == \"undefined\")\n\t\tconfig.css = \"webix_nosvg\";\n\treturn config;\n}","export function init(){\n\treturn {\n\t\tcss: \"webix_fmanager_toolbar\",\n\t\tpaddingX: 10,\n\t\tpaddingY:5,\n\t\tmargin: 7,\n\t\tcols:[\n\t\t\t\"menu\",\n\t\t\t{id: \"menuSpacer\", width: 75},\n\t\t\t{margin:0, cols:[\"back\",\"forward\"]},\"up\",\n\t\t\t\"path\",\"search\",\"modes\"\n\t\t]\n\t};\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\treturn { view: \"button\", type:\"htmlbutton\", label: \"
\",\n\t\tcss: \"webix_fmanager_menu\", icon: \"bars\", width: 37,\n\t\ttooltip: webix.i18n.filemanager.actions\n\t};\n}\n\nfunction ready(view){\n\tvar btn = view.$$(\"menu\");\n\tif(btn){\n\t\tbtn.attachEvent(\"onItemClick\", function(){\n\t\t\tif(view.callEvent(\"onBeforeMenu\", [])){\n\t\t\t\tvar tree = view.$$(\"tree\");\n\t\t\t\tview.getMenu().setContext({obj: tree, id: tree.getSelectedId()});\n\t\t\t\tview.getMenu().show(btn.$view);\n\t\t\t\tview.callEvent(\"onAfterMenu\", []);\n\t\t\t}\n\t\t});\n\n\t\tif(view.config.readonly){\n\t\t\tbtn.hide();\n\t\t\tif(view.$$(\"menuSpacer\"))\n\t\t\t\tview.$$(\"menuSpacer\").hide();\n\t\t}\n\t}\n}\n","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_back\",\n\t\tlabel: \"
\", width: 37,\n\t\ttooltip: webix.i18n.filemanager.back\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"back\")){\n\t\tview.$$(\"back\").attachEvent(\"onItemClick\", function(){\n\t\t\tif(view.callEvent(\"onBeforeBack\", [])){\n\t\t\t\tview.goBack();\n\t\t\t\tview.callEvent(\"onAfterBack\", []);\n\t\t\t}\n\t\t});\n\t\tview.attachEvent(\"onHistoryChange\", function(path, ids, cursor){\n\t\t\tif(!cursor)\n\t\t\t\tview.$$(\"back\").disable();\n\t\t\telse\n\t\t\t\tview.$$(\"back\").enable();\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_forward\",\n\t\tlabel: \"
\", width: 37,\n\t\ttooltip: webix.i18n.filemanager.forward\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"forward\")){\n\t\tview.$$(\"forward\").attachEvent(\"onItemClick\", function(){\n\t\t\tif(view.callEvent(\"onBeforeForward\", [])){\n\t\t\t\tview.goForward();\n\t\t\t\tview.callEvent(\"onAfterForward\", []);\n\t\t\t}\n\t\t});\n\t\tview.attachEvent(\"onHistoryChange\", function(path, ids, cursor){\n\t\t\tif(ids.length ==1 || cursor == ids.length-1)\n\t\t\t\tview.$$(\"forward\").disable();\n\t\t\telse\n\t\t\t\tview.$$(\"forward\").enable();\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_up\",\n\t\tlabel: \"
\", width: 37,\n\t\ttooltip: webix.i18n.filemanager.levelUp\n\t};\n}\n\nfunction ready(view){\n\tif(view.$$(\"up\")){\n\t\tview.$$(\"up\").attachEvent(\"onItemClick\", function(){\n\t\t\tif(view.callEvent(\"onBeforeLevelUp\", [])){\n\t\t\t\tview.levelUp();\n\t\t\t\tview.callEvent(\"onAfterLevelUp\", []);\n\t\t\t}\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"path\", borderless: true};\n}\n\nfunction ready(view){\n\tif(view.$$(\"path\")){\n\t\tview.attachEvent(\"onFolderSelect\",function(id){\n\t\t\tview.$$(\"path\").setValue(view.getPathNames(id));\n\t\t});\n\t\tview.$$(\"path\").attachEvent(\"onItemClick\",function(id){\n\t\t\tvar targetIndex = view.$$(\"path\").getIndexById(id);\n\t\t\tvar levelUp = view.$$(\"path\").count()-targetIndex-1;\n\n\t\t\tif(view.$searchResults)\n\t\t\t\tview.hideSearchResults();\n\n\t\t\tif(levelUp){\n\t\t\t\tid = view.getCursor();\n\t\t\t\twhile(levelUp){\n\t\t\t\t\tid = view.getParentId(id);\n\t\t\t\t\tlevelUp--;\n\t\t\t\t}\n\t\t\t\tview.setCursor(id);\n\t\t\t}\n\t\t\tview.callEvent(\"onAfterPathClick\",[id]);\n\t\t});\n\n\t\tview.data.attachEvent(\"onClearAll\",function(){\n\t\t\tview.$$(\"path\").clearAll();\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"search\", gravity: 0.3, minWidth: 80, css: \"webix_fmanager_search\", icon:\" webix_fmanager_icon\" };\n}\n\nfunction ready(view){\n\tvar search = view.$$(\"search\");\n\tif(search){\n\t\tview.attachEvent(\"onHideSearchResults\", function(){\n\t\t\tsearch.setValue(\"\");\n\t\t});\n\t\tview.attachEvent(\"onBeforeCursorChange\", function(){\n\t\t\tif(view.$searchResults){\n\t\t\t\tview.hideSearchResults(true);\n\t\t\t}\n\t\t});\n\t\tsearch.attachEvent(\"onTimedKeyPress\", function(){\n\t\t\tif(this._code != 9){\n\t\t\t\tvar value = search.getValue();\n\t\t\t\tif(value){\n\t\t\t\t\tif(view.callEvent(\"onBeforeSearch\", [value])){\n\t\t\t\t\t\tview.showSearchResults(value);\n\t\t\t\t\t\tview.callEvent(\"onAfterSearch\", [value]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(view.$searchResults){\n\t\t\t\t\tview.hideSearchResults();\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t});\n\t\tsearch.attachEvent(\"onKeyPress\", function(code){\n\t\t\tthis._code = code;\n\t\t});\n\n\t\tview.attachEvent(\"onAfterModeChange\",function(){\n\t\t\tif(view.$searchResults)\n\t\t\t\tview.showSearchResults(search.getValue());\n\t\t});\n\t}\n}","export function init(){\n\treturn {\n\t\tcss: \"webix_fmanager_body\",\n\t\tcols:[\n\t\t\t\"sidePanel\",\n\t\t\t\"treeLayout\",\n\t\t\t{view:\"resizer\", id: \"resizer\", width:3},\n\t\t\t\"modeViews\"\n\t\t]\n\t};\n}","export function init(){\n\treturn {\n\t\trows:[\n\t\t\t\"treeToolbar\",\n\t\t\t\"tree\"\n\t\t]\n\t};\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\treturn {\n\t\thidden:true,\n\t\tcss:\"webix_fmanager_panel\",\n\t\ttype: \"clean\",\n\t\trows:[\n\t\t\t{\n\t\t\t\theight: 34,\n\t\t\t\tpaddingY:1,\n\t\t\t\tpaddingX:0,\n\t\t\t\tview: \"form\",\n\t\t\t\tcols:[\n\t\t\t\t\t{ view: \"button\", id: \"showTree\", type:\"htmlbutton\", css: \"webix_fmanager_toggle\",\n\t\t\t\t\t\tlabel: \"
\", width: 30,\n\t\t\t\t\t\ttooltip: webix.i18n.filemanager.showTree\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{ template:\" \"}\n\t\t]\n\t};\n}\nfunction ready(view){\n\tif(view.$$(\"showTree\")){\n\t\tview.$$(\"showTree\").attachEvent(\"onItemClick\", function(){\n\t\t\tview.showTree();\n\t\t});\n\t}\n}\n","export function init(){\n\treturn {\n\t\tcss: \"webix_fmanager_tree_toolbar\",\n\t\theight: 34,\n\t\tpaddingX: 8,\n\t\tpaddingY:1,\n\t\tmargin: 7,\n\t\tcols:[\n\t\t\t\"hideTree\",\n\t\t\t{id: \"treeSpacer\"},\n\t\t\t\"expandAll\",\"collapseAll\"\n\t\t]\n\t};\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_expand\",\n\t\tlabel: \"
\", width: 30,\n\t\ttooltip: webix.i18n.filemanager.expandTree\n\t};\n}\n\nfunction ready(view){\n\tif(view._getDynMode() && view.$$(\"expandAll\")){\n\t\tview.$$(\"expandAll\").hide();\n\t}\n\tif(view.$$(\"expandAll\") && view.$$(\"tree\")){\n\t\tview.$$(\"expandAll\").attachEvent(\"onItemClick\", function(){\n\t\t\tview.$$(\"tree\").openAll();\n\t\t});\n\t}\n}","export function init(view){\n\tview.attachEvent(\"onComponentInit\", () => ready(view));\n\n\treturn { view: \"button\", type:\"htmlbutton\", css: \"webix_fmanager_collapse\",\n\t\tlabel: \"
\", width: 30, tooltip: webix.i18n.filemanager.collapseTree\n\t};\n}\n\nfunction ready(view){\n\tif(view._getDynMode() && view.$$(\"collapseAll\")){\n\t\tview.$$(\"collapseAll\").hide();\n\t}\n\tif(view.$$(\"collapseAll\") && view.$$(\"tree\")){\n\t\tview.$$(\"collapseAll\").attachEvent(\"onItemClick\", function(){\n\t\t\tview.$$(\"tree\").closeAll();\n\t\t});\n\t}\n}","export function init(){\n\treturn {\n\t\tview: \"fileview\",\n\t\ttype: \"FileView\",\n\t\tselect: \"multiselect\",\n\t\teditable:true,\n\t\teditaction: false,\n\t\teditor:\"text\",\n\t\teditValue:\"value\",\n\t\tdrag: true,\n\t\tnavigation: true,\n\t\ttabFocus: true,\n\t\tonContext:{}\n\t};\n}\n\n","export function init(view){\n\tvar locale = webix.i18n.filemanager;\n\treturn [\n\t\t{ id:\"value\",\theader: locale.name, fillspace:3, sort: \"string\", template: function(obj,common){\n\t\t\tvar name = common.templateName(obj,common);\n\t\t\treturn common.templateIcon(obj,common)+name;\n\t\t}, editor: \"text\"},\n\t\t{ id:\"date\",\theader: locale.date, fillspace:2, sort: \"int\", template: function(obj,common){\n\t\t\treturn common.templateDate(obj,common);\n\t\t}},\n\t\t{ id:\"type\",\theader: locale.type, fillspace:1, sort: \"string\", template: function(obj,common){\n\t\t\treturn common.templateType(obj);\n\t\t}},\n\t\t{ id:\"size\",\theader: locale.size, fillspace:1, sort: \"int\", css:{\"text-align\":\"right\"}, template: function(obj,common){\n\t\t\treturn obj.type==\"folder\"?\"\":common.templateSize(obj);\n\t\t}},\n\t\t{ id:\"location\",\theader: locale.location, fillspace:2, sort: \"string\", template: function(obj){\n\t\t\treturn view._getLocation(obj);\n\t\t},hidden:true}\n\t];\n}","import * as save from \"../save.js\";\n\nfunction getConfig(legacy){\n\tvar config = {};\n\tif (legacy){\n\t\tconfig = {\n\t\t\tview: \"uploader\",\n\t\t\tcss: \"webix_upload_select_ie\",\n\t\t\ttype: \"iconButton\",\n\t\t\ticon:\"check\",\n\t\t\tlabel: webix.i18n.filemanager.select,\n\t\t\tformData:{ action:\"upload\" },\n\t\t\turlData:{}\n\t\t};\n\t}\n\telse{\n\t\tconfig = {\n\t\t\tview:\"uploader\",\n\t\t\tapiOnly:true,\n\t\t\tformData:{ action:\"upload\" },\n\t\t\turlData:{}\n\t\t};\n\t}\n\treturn config;\n}\n\nexport function init(view){\n\tvar legacy = view.config.legacyUploader;\n\tvar config = getConfig(legacy);\n\n\tif(config){\n\t\tif (legacy){\n\t\t\tcreateFlashUploader(view, webix.copy(config));\n\t\t}\n\t\telse{\n\t\t\tview._uploader = webix.ui(config);\n\t\t\tview.attachEvent(\"onDestruct\", function(){\n\t\t\t\tview._uploader.destructor();\n\t\t\t});\n\t\t}\n\t}\n\tsetUploadHandlers(view);\n}\n\n\n\nfunction setUploadHandlers(view){\n\tvar uploader = getUploader(view);\n\tif(uploader){\n\t\t// define url\n\t\tuploader.config.upload = view.config.handlers.upload;\n\t\t// add drop areas\n\t\tvar modes = view.config.modes;\n\t\tif(modes && !view.config.readonly){\n\t\t\tfor(var i =0; i < modes.length; i++){\n\t\t\t\tif(view.$$(modes[i]))\n\t\t\t\t\tuploader.addDropZone(view.$$(modes[i]).$view);\n\t\t\t}\n\t\t}\n\n\t\t// handlers\n\t\tuploader.attachEvent(\"onBeforeFileAdd\",function(file){\n\t\t\tvar target = \"\"+getUploadFolder(view);\n\n\t\t\tuploader.config.formData.target = target;\n\t\t\tuploader.config.urlData.target = target;\n\t\t\t//reset upload script each time, so we can be sure that active config is used\n\t\t\tuploader.config.upload = view.config.handlers.upload;\n\n\t\t\treturn view.callEvent(\"onBeforeFileUpload\",[file]);\n\t\t});\n\t\tuploader.attachEvent(\"onAfterFileAdd\", function(file){\n\t\t\tview._uploaderFolder = null;\n\t\t\tfile.oldId = file.id;\n\t\t\tview.add({\n\t\t\t\t\"id\" : file.id,\n\t\t\t\t\"value\": file.name,\n\t\t\t\t\"type\" : file.type,\n\t\t\t\tsize : file.size,\n\t\t\t\tdate : Math.round((new Date()).valueOf()/1000)\n\t\t\t}, -1, uploader.config.formData.target);\n\n\t\t\tif(view.config.uploadProgress){\n\t\t\t\tview.showProgress(view.config.uploadProgress);\n\t\t\t}\n\t\t\tview._refreshActiveFolder();\n\t\t});\n\n\t\tuploader.attachEvent(\"onUploadComplete\",function(file){\n\t\t\tif(view._uploadPopup){\n\t\t\t\tview.getMenu().hide();\n\t\t\t\tview._uploadPopup.hide();\n\t\t\t}\n\t\t\tview.hideProgress();\n\t\t\tview.callEvent(\"onAfterFileUpload\",[file]);\n\t\t});\n\t\tuploader.attachEvent(\"onFileUpload\",function(item){\n\t\t\tif(item.oldId)\n\t\t\t\tview.data.changeId(item.oldId,item.id);\n\t\t\tif(item.value)\n\t\t\t\tview.getItem(item.id).value = item.value;\n\n\t\t\tview.getItem(item.id).type = item.type;\n\t\t\tview._refreshActiveFolder();\n\t\t});\n\t\tuploader.attachEvent(\"onFileUploadError\",function(item, response){\n\t\t\tif(view.callEvent(\"onErrorResponse\", [item, response]))\n\t\t\t\tsave.errorHandler(view, response);\n\t\t\tview.hideProgress();\n\n\t\t});\n\t}\n}\n\nfunction createFlashUploader(view, config){\n\tif(!config){\n\t\tconfig = getConfig(view.config.legacyUploader);\n\t}\n\tview._uploadPopup = webix.ui({\n\t\tview:\"popup\",\n\t\tpadding:0,\n\t\twidth:250,\n\t\tbody: config\n\t});\n\tview._uploader = view._uploadPopup.getBody();\n\tview.attachEvent(\"onDestruct\", function(){\n\t\tview._uploadPopup.destructor();\n\t});\n}\n\nfunction getUploadFolder(view){\n\treturn \tview._uploaderFolder||view.getCursor();\n}\n\nexport function getUploader(view){\n\treturn \tview._uploader;\n}\n\nexport function uploadFile(view,id,e){\n\n\tif(!view.data.branch[id] && view.getItem(id).type != \"folder\"){\n\t\tid = view.getParentId(id);\n\t}\n\n\tview._uploaderFolder = id;\n\tif(view._uploadPopup){\n\t\tview._uploadPopup.destructor();\n\t\tcreateFlashUploader(view);\n\t\tsetUploadHandlers(view);\n\t\tview._uploadPopup.show(e,{x:20,y:5});\n\t}\n\telse{\n\t\tif(view._uploader)\n\t\t\tview._uploader.fileDialog();\n\t}\n}","import \"./types\";\nimport \"./locale\";\nimport \"./widgets\";\n\nimport * as context from \"./views/actions\";\nimport * as defaults from \"./defaults\";\nimport * as history from \"./history\";\nimport * as loader from \"./load\";\nimport * as path from \"./path\";\nimport * as save from \"./save\";\nimport * as tree from \"./tree\";\nimport * as ui from \"./ui\";\nimport * as uploader from \"./views/upload\";\n\n\nwebix.protoUI({\n\tname:\"filemanager\",\n\t$init: function(config) {\n\t\tthis.$view.className += \" webix_fmanager\";\n\t\twebix.extend(this.data, webix.TreeStore, true);\n\t\tthis.data.provideApi(this,true);\n\t\twebix.extend(config,this.defaults);\n\n\t\tconfig.mode = config.mode || config.modes[0];\n\n\t\tui.init(this,config);\n\t\thistory.init(this);\n\t\tloader.init(this);\n\n\t\tconfig.legacyUploader = config.legacyUploader || webix.isUndefined(XMLHttpRequest) || webix.isUndefined((new XMLHttpRequest()).upload);\n\n\t\tthis.$ready.push(()=>{\n\t\t\tthis._beforeInit();\n\t\t\tthis.callEvent(\"onComponentInit\",[]);\n\t\t});\n\t\twebix.UIManager.tabControl = true;\n\t\twebix.extend(config, ui.getUI(this,config));\n\n\t\tthis.attachEvent(\"onAfterLoad\",function(){\n\t\t\t// default cursor\n\t\t\tif(!this.getCursor || !this.getCursor()){\n\t\t\t\tvar selection = this.config.defaultSelection;\n\t\t\t\tselection = selection?selection.call(this):this.getFirstChildId(0);\n\t\t\t\tif(this.setCursor)\n\t\t\t\t\tthis.setCursor(selection);\n\t\t\t\telse //data:[], binding is not yet applied\n\t\t\t\t\tthis.attachEvent(\"onComponentInit\", ()=>{\n\t\t\t\t\t\tthis.setCursor(selection);\n\t\t\t\t\t});\n\t\t\t}\n\t\t});\n\t},\n\thandlers_setter: function(handlers){\n\t\tif(typeof handlers == \"string\")\n\t\t\thandlers = this.setDefaultHandlers(handlers);\n\t\tfor(var h in handlers){\n\t\t\tvar url = handlers[h];\n\t\t\tif (typeof url == \"string\"){\n\t\t\t\tif(url.indexOf(\"->\") != -1){\n\t\t\t\t\tvar parts = url.split(\"->\");\n\t\t\t\t\turl = webix.proxy(parts[0], parts[1]);\n\t\t\t\t}\n\t\t\t\telse if(h != \"upload\" && h != \"download\")\n\t\t\t\t\turl = webix.proxy(\"post\", url);\n\t\t\t}\n\t\t\thandlers[h] = url;\n\t\t}\n\t\treturn handlers;\n\t},\n\tsetDefaultHandlers: function(url){\n\t\treturn {\n\t\t\tupload: url,\n\t\t\tdownload: url,\n\t\t\tcopy: url,\n\t\t\tmove: url,\n\t\t\tremove: url,\n\t\t\trename: url,\n\t\t\tcreate: url\n\t\t};\n\t},\n\t_beforeInit: function(){\n\t\tcontext.init(this);\n\t\tuploader.init(this);\n\n\t\tthis.attachEvent(\"onFolderSelect\", function(id){\n\t\t\tthis.setCursor(id);\n\t\t});\n\n\t\tthis.attachEvent(\"onBeforeDragIn\",function(context){\n\t\t\tvar target = context.target;\n\t\t\tif(target){\n\t\t\t\tvar ids = context.source;\n\t\t\t\tfor(var i=0; i < ids.length; i++){\n\t\t\t\t\twhile(target){\n\t\t\t\t\t\tif(target==ids[i]){\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttarget = this._getParentId(target);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t});\n\n\t},\n\t_getParentId: function(id){\n\t\tif(!this.getItem(id)){\n\t\t\tvar activeView = this.$$(this.config.mode);\n\t\t\tvar item = activeView.getItem(id);\n\t\t\tif(item && item.parent && this.getItem(item.parent)){\n\t\t\t\treturn item.parent;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn webix.TreeStore.getParentId.apply(this,arguments);\n\t},\n\tgetMenu: function(){\n\t\treturn this._contextMenu;\n\t},\n\tgetPath: function(id){\n\t\treturn path.getPath(this,id);\n\t},\n\tgetPathNames: function(id){\n\t\treturn path.getPathNames(this,id);\n\t},\n\tsetPath: function(id){\n\t\treturn path.setPath(this,id);\n\t},\n\t_getLocation: function(obj){\n\t\tvar location = \"\", path;\n\t\tif(this.getItem(obj.id) || obj.parent && this.getItem(obj.parent)){\n\t\t\tif(obj.parent){\n\t\t\t\tpath = this.getPathNames(obj.parent);\n\t\t\t\tpath.shift();\n\t\t\t}\n\t\t\telse{\n\t\t\t\tpath = this.getPathNames(obj.id);\n\t\t\t\tpath.shift();\n\t\t\t\tpath.pop();\n\t\t\t}\n\t\t\tvar names = [];\n\t\t\tfor(var i=0; i < path.length;i++){\n\t\t\t\tnames.push(path[i].value);\n\t\t\t}\n\t\t\tlocation = \"/\"+names.join(\"/\");\n\t\t}\n\t\telse if(obj.location){\n\t\t\tlocation = obj.location;\n\t\t}\n\t\telse if(typeof obj.id == \"string\"){\n\t\t\tvar parts = obj.id.split(\"/\");\n\t\t\tparts.pop();\n\t\t\tlocation = \"/\"+parts.join(\"/\");\n\t\t}\n\t\treturn location;\n\t},\n\tgetSearchData: function(id,value){\n\t\tvar found = [];\n\t\tthis.data.each(function(obj){\n\t\t\tvar text = this.config.templateName(obj);\n\t\t\tif(text.toLowerCase().indexOf(value.toLowerCase())>=0){\n\t\t\t\tfound.push(webix.copy(obj));\n\t\t\t}\n\t\t},this,true,id);\n\t\treturn found;\n\t},\n\tshowSearchResults: function(value){\n\t\tvar id = this.getCursor();\n\t\tif(this.config.handlers.search){\n\t\t\tloader.loadSearchData(this,this.config.handlers.search, id, value);\n\t\t}\n\t\telse{\n\t\t\tvar data = \tthis.getSearchData(id, value);\n\t\t\tloader.parseSearchData(this,data);\n\t\t}\n\t},\n\thideSearchResults: function(skipRefresh){\n\t\tif(this.$searchResults){\n\t\t\tthis.callEvent(\"onHideSearchResults\",[]);\n\t\t\tthis.$searchResults = false;\n\t\t\t// refresh cursor\n\t\t\tif(!skipRefresh){\n\t\t\t\tvar id = this.getCursor();\n\t\t\t\tthis.blockEvent();\n\t\t\t\tthis.setCursor(null);\n\t\t\t\tthis.unblockEvent();\n\t\t\t\tthis.setCursor(id);\n\t\t\t}\n\t\t}\n\t},\n\tgoBack: function(step){\n\t\tstep = (step?(-1)*Math.abs(step):-1);\n\t\treturn history.changeCursor(this, step);\n\t},\n\tgoForward: function(step){\n\t\treturn history.changeCursor(this, step||1);\n\t},\n\tlevelUp: function(id){\n\t\tid = id||this.getCursor();\n\t\tif(id){\n\t\t\tid = this.getParentId(id);\n\t\t\tthis.setCursor(id);\n\t\t}\n\t},\n\tmarkCopy: function(ids){\n\t\tif(ids){\n\t\t\tif(!webix.isArray(ids)){\n\t\t\t\tids = [ids];\n\t\t\t}\n\t\t\tthis._moveData = ids;\n\t\t\tthis._copyFiles = true;\n\t\t}\n\t},\n\tmarkCut: function(ids){\n\t\tif(ids){\n\t\t\tif(!webix.isArray(ids)){\n\t\t\t\tids = [ids];\n\t\t\t}\n\t\t\tthis._moveData = ids;\n\t\t\tthis._copyFiles = false;\n\t\t}\n\t},\n\tpasteFile: function(id){\n\t\tif(webix.isArray(id)){\n\t\t\tid = id[0];\n\t\t}\n\t\tif(id){\n\t\t\tid = id.toString();\n\t\t\tif(this.getItem(id) && this.getItem(id).type == \"folder\"){\n\t\t\t\tif(this._moveData){\n\t\t\t\t\tif(this._copyFiles){\n\t\t\t\t\t\tthis.copyFile(this._moveData,id);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.moveFile(this._moveData,id);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tdownload:function(id){\n\t\tvar url = this.config.handlers.download;\n\t\tif (url)\n\t\t\twebix.send(url, { action:\"download\", source: id });\n\t},\n\tfileExists: function(name,target,id){\n\t\tvar result = false;\n\t\tthis.data.eachChild(target, webix.bind(function(obj){\n\t\t\tif(name == obj.value&&!(id && obj.id==id)){\n\t\t\t\tresult = obj.id;\n\t\t\t}\n\t\t},this));\n\t\treturn result;\n\t},\n\t_refreshActiveFolder: function(){\n\t\tthis.$skipDynLoading = true;\n\t\tthis.$$(this.config.mode).$skipBinding = false;\n\t\tthis.refreshCursor();\n\t},\n\t_setFSId: function(item){\n\t\tvar newId = this.getParentId(item.id)+\"/\"+item.value;\n\t\tif(item.id != newId)\n\t\t\tthis.data.changeId( item.id, newId );\n\t},\n\t_changeChildIds: function(id){\n\t\tthis.data.eachSubItem(id,webix.bind(function(item){\n\t\t\tif(item.value)\n\t\t\t\tthis._setFSId(item);\n\t\t},this));\n\t},\n\t_callbackRename: function(id, value){\n\t\tvar item = this.getItem(id);\n\t\tif(item.value != value){\n\t\t\titem.value = value;\n\t\t\tthis.$$(\"tree\").updateItem(id, { value });\n\t\t\tthis._refreshActiveFolder();\n\t\t\tthis.callEvent(\"onItemRename\", [id]);\n\t\t}\n\t},\n\t_moveFile: function(source,target,copy){\n\t\tvar action = (copy?\"copy\":\"move\"),\n\t\t\tids = [];\n\t\tsource.reverse();\n\t\tfor(var i=0; i