fix(client) when none files in the root, menu doesn't work

This commit is contained in:
coderaiser 2015-07-01 03:03:17 -04:00
parent 6f7155e4d0
commit cbcda32df2
4 changed files with 45 additions and 24 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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();

View file

@ -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;
}