diff --git a/lib/client.js b/lib/client.js index 4b46cfe9..b9fd8e91 100644 --- a/lib/client.js +++ b/lib/client.js @@ -419,16 +419,20 @@ var Util, DOM, CloudFunc, join; names = ['file', 'path', 'link', 'pathLink']; Files.get(names, function(error, templFile, templPath, templLink, templPathLink) { - var Dialog = DOM.Dialog, + var childNodes, i, + Dialog = DOM.Dialog, current, - panel = panelParam || Info.panel, - dir = Info.dir, - name = Info.name, - i = panel.childNodes.length; + panel = panelParam || DOM.getPanel(), + + dir = Info.dir, + name = Info.name; if (error) { Dialog.alert(error.responseText); } else { + childNodes = panel.childNodes; + i = childNodes.length; + while (i--) panel.removeChild(panel.lastChild); @@ -467,21 +471,18 @@ var Util, DOM, CloudFunc, join; * используеться при первом заходе в корень */ function getJSONfromFileTable() { - var current, name, size, owner, mode, ret, + var name, size, owner, mode, ret, path = DOM.getCurrentDirPath(), - infoFiles = Info.files, + infoFiles = Info.files || [], fileTable = { path : path, files : [] }, - files = fileTable.files, - - i, n = infoFiles.length; + files = fileTable.files; - for (i = 0; i < n; i++) { - current = infoFiles[i]; + [].forEach.call(infoFiles, function(current) { name = DOM.getCurrentName(current); size = DOM.getCurrentSize(current); owner = DOM.getCurrentOwner(current); @@ -494,7 +495,7 @@ var Util, DOM, CloudFunc, join; mode : mode, owner : owner }); - } + }); ret = Util.json.stringify(fileTable); diff --git a/lib/client/dom.js b/lib/client/dom.js index 33aac2cf..327569ee 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -90,13 +90,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; function load(position, panel) { var current, image = Images.loading(), - parent = image.parentElement; + parent = image.parentElement, + refreshButton = DOM.getRefreshButton(panel); if (position === 'top') { - current = DOM.getRefreshButton(panel).parentElement; + current = refreshButton.parentElement; } else { current = DOM.getCurrentFile(); - current = DOM.getByDataName('js-name', current); + + if (current) + current = DOM.getByDataName('js-name', current); + else + current = refreshButton.parentElement; } if (!parent || (parent && parent !== current)) @@ -1077,8 +1082,11 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param currentFile */ this.getCurrentName = function(currentFile) { - var name = '', - current = currentFile || this.getCurrentFile(), + var link, + name = '', + current = currentFile || this.getCurrentFile(); + + if (current) link = this.getCurrentLink(current); if (link) { @@ -1243,7 +1251,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; current = this.getCurrentFile(); if (!current) { - panel = this.getByDataName('left'); + panel = this.getByDataName('js-left'); } else { files = current.parentElement, panel = files.parentElement, diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 9868325e..656a06d7 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -89,6 +89,7 @@ var Util, DOM, CloudFunc, CloudCmd; var link, href, url, namePanel, nameInfoPanel, + infoPanel = Info.panel, noCurrent = false, element = event.target, attr = element.getAttribute('data-name'); @@ -99,8 +100,10 @@ var Util, DOM, CloudFunc, CloudCmd; break; case 'js-refresh': - namePanel = panel.getAttribute('data-name'); - nameInfoPanel = Info.panel.getAttribute('data-name'); + namePanel = panel.getAttribute('data-name'); + + if (infoPanel) + nameInfoPanel = infoPanel.getAttribute('data-name'); if (namePanel !== nameInfoPanel) noCurrent = true; @@ -322,9 +325,14 @@ var Util, DOM, CloudFunc, CloudCmd; function resize() { Events.add('resize', function() { - var is = window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH, - name = Info.panel.getAttribute('data-name'), + var name, isLeft, + is = window.innerWidth < CloudCmd.MIN_ONE_PANEL_WIDTH, + panel = Info.panel; + + if (panel) { + name = panel.getAttribute('data-name'), isLeft = name === 'js-left'; + } if (is && !isLeft) DOM.changePanel(); diff --git a/lib/client/menu.js b/lib/client/menu.js index 6d75d675..5e3adbe1 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -189,10 +189,14 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; } function isPath(x, y) { - var panel = Info.panel, + var el, elements, is, + panel = Info.panel; + + if (panel) { el = document.elementFromPoint(x, y), elements = panel.querySelectorAll('[data-name="js-path"] *'), is = ~[].indexOf.call(elements, el); + } return is; }