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

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