feature(dom) setCurrentFile: add options

This commit is contained in:
coderaiser 2014-05-22 09:26:16 -04:00
parent d439bb0ef3
commit 89ae01fc6d
2 changed files with 27 additions and 19 deletions

View file

@ -37,14 +37,16 @@ var Util, DOM, CloudFunc;
*/
this.loadDir = function(params) {
var link, imgPosition, panelChanged, pathParams,
isRefresh, panel,
isRefresh, panel, nohistory,
p = params,
currentLink = DOM.getCurrentLink(),
href = currentLink.href;
if (params) {
pathParams = params.path;
isRefresh = params.isRefresh;
panel = params.panel;
pathParams = p.path;
isRefresh = p.isRefresh;
panel = p.panel;
nohistory = p.nohistory;
}
if (pathParams)
@ -66,8 +68,9 @@ var Util, DOM, CloudFunc;
Images.showLoad(imgPosition);
/* загружаем содержимое каталога */
CloudCmd.ajaxLoad(link, {
refresh: isRefresh
ajaxLoad(link, {
refresh : isRefresh,
nohistory : nohistory
}, panel);
}
};
@ -363,7 +366,7 @@ var Util, DOM, CloudFunc;
* @param pOptions
* { refresh, nohistory } - необходимость обновить данные о каталоге
*/
this.ajaxLoad = function(path, options, panel) {
function ajaxLoad(path, options, panel) {
var SLASH = '/',
fsPath = decodeURI(path),
cleanPath = Util.rmStrOnce(fsPath, CloudFunc.FS) || SLASH;
@ -376,23 +379,24 @@ var Util, DOM, CloudFunc;
Storage.get(cleanPath, function(json) {
var RESTful = DOM.RESTful,
obj = Util.parseJSON(json),
isRefresh = options.refresh;
isRefresh = options.refresh,
nohistory = options.nohistory;
if (!isRefresh && json)
CloudCmd.createFileTable(obj, panel);
CloudCmd.createFileTable(obj, panel, nohistory);
else
RESTful.read(cleanPath, 'json', function(json) {
CloudCmd.createFileTable(json, panel);
CloudCmd.createFileTable(json, panel, nohistory);
Storage.set(cleanPath, json);
});
});
};
}
/**
* Функция строит файловую таблицу
* @param pJSON - данные о файлах
*/
this.createFileTable = function(json, panelParam) {
this.createFileTable = function(json, panelParam, nohistory) {
var files,
panel = panelParam || DOM.getPanel(),
/* getting current element if was refresh */
@ -436,7 +440,9 @@ var Util, DOM, CloudFunc;
if (!found) /* .. */
current = files[0];
DOM.setCurrentFile(current);
DOM.setCurrentFile(current, {
nohistory: nohistory
});
Listeners.changeLinks(panel.id);
Listeners.setOnPanel(panel.id);

View file

@ -1057,8 +1057,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
/**
* unified way to set current file
*/
this.setCurrentFile = function(currentFile) {
this.setCurrentFile = function(currentFile, options) {
var ret, path, pathWas, title,
o = options,
FS = CloudFunc.FS,
CENTER = true,
currentFileWas = this.getCurrentFile();
@ -1077,12 +1078,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
title = CloudFunc.getTitle(path);
this.setTitle(title);
if (path !== '/')
path = FS + path;
DOM.setHistory(path, null, path);
if (o && !o.nohistory) {
if (path !== '/')
path = FS + path;
DOM.setHistory(path, null, path);
}
}
/* scrolling to current file */
this.scrollIntoViewIfNeeded(currentFile, CENTER);