feature(client) loadDir: change params

This commit is contained in:
coderaiser 2014-05-07 14:26:50 -04:00
parent a42051057c
commit a41b26b458
3 changed files with 67 additions and 51 deletions

View file

@ -28,43 +28,52 @@ var Util, DOM, CloudFunc;
* Функция привязываеться ко всем ссылкам и
* загружает содержимое каталогов
*
* @param paramLink - ссылка
* @param needRefresh - необходимость обязательной загрузки данных с сервера
* @param params - {
* paramLink - ссылка
* needRefresh - необходимость обязательной загрузки данных с сервера
* panel
* }
* @param event
*/
this.loadDir = function(paramLink, needRefresh, panel) {
return function(event) {
var link, imgPosition, panelChanged,
currentLink = DOM.getCurrentLink(),
href = currentLink.href;
if (paramLink)
link = paramLink;
else
link = Util.rmStr(href, CloudCmd.HOST);
link += '?json';
if (link || currentLink.target !== '_blank') {
if (panel && panel !== Info.panel) {
DOM.changePanel();
panelChanged = true;
}
if (panelChanged || needRefresh)
imgPosition = {
top: true
};
Images.showLoad(imgPosition);
/* загружаем содержимое каталога */
CloudCmd.ajaxLoad(link, {
refresh: needRefresh
}, panel);
this.loadDir = function(params, event) {
var link, imgPosition, panelChanged, pathParams,
isRefresh, panel,
currentLink = DOM.getCurrentLink(),
href = currentLink.href;
if (params) {
pathParams = params.path;
isRefresh = params.isRefresh;
panel = params.panel;
}
if (pathParams)
link = pathParams;
else
link = Util.rmStr(href, CloudCmd.HOST);
link += '?json';
if (link || currentLink.target !== '_blank') {
if (panel && panel !== Info.panel) {
DOM.changePanel();
panelChanged = true;
}
DOM.preventDefault(event);
};
if (panelChanged || isRefresh)
imgPosition = {
top: true
};
Images.showLoad(imgPosition);
/* загружаем содержимое каталога */
CloudCmd.ajaxLoad(link, {
refresh: isRefresh
}, panel);
}
DOM.preventDefault(event);
};
@ -341,10 +350,13 @@ var Util, DOM, CloudFunc;
panel = panelParam || current && current.parentElement,
path = DOM.getCurrentDirPath(panel),
link = CloudFunc.FS + path,
notSlashlLink = CloudFunc.rmLastSlash(link),
load = CloudCmd.loadDir(notSlashlLink, NEEDREFRESH, panel);
notSlashlLink = CloudFunc.rmLastSlash(link);
load();
CloudCmd.loadDir({
path : notSlashlLink,
isRefresh : NEEDREFRESH,
panel: panel
});
};
/**
@ -500,7 +512,9 @@ var Util, DOM, CloudFunc;
path = parentPath;
path = CloudFunc.FS + CloudFunc.rmLastSlash(path);
Util.exec(CloudCmd.loadDir(path));
CloudCmd.loadDir({
path: path
});
}
};

View file

@ -370,7 +370,7 @@ var CloudCmd, Util, DOM;
/* открываем папку*/
case Key.ENTER:
if (Info.isDir)
Util.exec(CloudCmd.loadDir());
CloudCmd.loadDir();
break;
case Key.BACKSPACE:
@ -379,10 +379,10 @@ var CloudCmd, Util, DOM;
break;
case Key.BACKSLASH:
if (ctrl) {
path = '/';
Util.exec(CloudCmd.loadDir(path));
}
if (ctrl)
CloudCmd.loadDir({
path: '/'
});
break;
case Key.A:

View file

@ -97,7 +97,11 @@ var Util, DOM, CloudCmd;
for (i = 0; i < n; i++) {
ai = pathLinks[i];
link = Util.rmStr(ai.href, url),
loadDir = CloudCmd.loadDir(link, false, panel),
loadDir = Util.bind(CloudCmd.loadDir, {
path : link,
isRefresh : false,
panel : panel
}),
Events.addClick(loadDir, ai);
OnPathLinks.push(loadDir);
}
@ -194,24 +198,22 @@ var Util, DOM, CloudCmd;
function onDblClick(event) {
var current = getLIElement(event.target),
isDir = DOM.isCurrentIsDir(current),
loadDirOnce = CloudCmd.loadDir();
isDir = DOM.isCurrentIsDir(current);
if (isDir)
loadDirOnce(event);
CloudCmd.loadDir(null, event);
}
function onTouch(event) {
var isCurrent, loadDirOnce,
var isCurrent,
element = getLIElement(event.target),
isDir = DOM.isCurrentIsDir(element);
if (isDir) {
isCurrent = DOM.isCurrentFile(element),
loadDirOnce = CloudCmd.loadDir();
isCurrent = DOM.isCurrentFile(element);
if (isCurrent)
loadDirOnce(event);
CloudCmd.loadDir(null, event);
}
}