mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
fix(cloudcmd) refresh: panel that would be refreshed depends on current file location
This commit is contained in:
parent
161a363b04
commit
e685b5739b
5 changed files with 36 additions and 13 deletions
|
|
@ -74,7 +74,7 @@ var Util, DOM, CloudFunc, join;
|
|||
if (panelChanged || isRefresh || !history)
|
||||
imgPosition = 'top';
|
||||
|
||||
Images.show.load(imgPosition);
|
||||
Images.show.load(imgPosition, panel);
|
||||
|
||||
/* загружаем содержимое каталога */
|
||||
ajaxLoad(link, {
|
||||
|
|
@ -328,11 +328,15 @@ var Util, DOM, CloudFunc, join;
|
|||
|
||||
this.refresh = function(panelParam, options, callback) {
|
||||
var panel = panelParam || Info.panel,
|
||||
noCurrent,
|
||||
NEEDREFRESH = true,
|
||||
path = DOM.getCurrentDirPath(panel),
|
||||
notSlashlLink = CloudFunc.rmLastSlash(path);
|
||||
|
||||
if (!callback) {
|
||||
if (options)
|
||||
noCurrent = options.noCurrent
|
||||
|
||||
if (!callback && typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
|
@ -342,7 +346,7 @@ var Util, DOM, CloudFunc, join;
|
|||
isRefresh : NEEDREFRESH,
|
||||
history : false,
|
||||
panel : panel,
|
||||
noCurrent : options.noCurrent
|
||||
noCurrent : noCurrent
|
||||
}, callback);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -87,13 +87,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
* Function shows loading spinner
|
||||
* position = {top: true};
|
||||
*/
|
||||
function load(position) {
|
||||
function load(position, panel) {
|
||||
var current,
|
||||
image = Images.loading(),
|
||||
parent = image.parentElement;
|
||||
|
||||
if (position === 'top') {
|
||||
current = DOM.getRefreshButton().parentElement;
|
||||
current = DOM.getRefreshButton(panel).parentElement;
|
||||
} else {
|
||||
current = DOM.getCurrentFile();
|
||||
current = DOM.getByDataName('js-name', current);
|
||||
|
|
@ -782,9 +782,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
/**
|
||||
* unified way to get RefreshButton
|
||||
*/
|
||||
this.getRefreshButton = function() {
|
||||
var panel = this.getPanel(),
|
||||
refresh = this.getByDataName('js-refresh', panel);
|
||||
this.getRefreshButton = function(panel) {
|
||||
var currentPanel = panel || this.getPanel(),
|
||||
refresh = this.getByDataName('js-refresh', currentPanel);
|
||||
|
||||
return refresh;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -491,7 +491,6 @@ var CloudCmd, Util, DOM;
|
|||
case Key.R:
|
||||
if (ctrlMeta) {
|
||||
CloudCmd.log('reloading page...\n');
|
||||
|
||||
CloudCmd.refresh();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,12 +75,21 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
pathElement = DOM.getByDataName('js-path', panel);
|
||||
|
||||
/* ставим загрузку гифа на клик*/
|
||||
Events.addClick(pathElement, onPathElementClick);
|
||||
Events.addClick(pathElement, getPathListener(panel));
|
||||
Events.add(filesElement, EventsFiles);
|
||||
};
|
||||
|
||||
function onPathElementClick(event) {
|
||||
function getPathListener(panel) {
|
||||
var fn = onPathElementClick.bind(null, panel);
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
function onPathElementClick(panel, event) {
|
||||
var link, href, url,
|
||||
namePanel,
|
||||
nameInfoPanel,
|
||||
noCurrent = false,
|
||||
element = event.target,
|
||||
attr = element.getAttribute('data-name');
|
||||
|
||||
|
|
@ -90,7 +99,16 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
break;
|
||||
|
||||
case 'js-refresh':
|
||||
CloudCmd.refresh();
|
||||
namePanel = panel.getAttribute('data-name');
|
||||
nameInfoPanel = Info.panel.getAttribute('data-name');
|
||||
|
||||
if (namePanel !== nameInfoPanel)
|
||||
noCurrent = true;
|
||||
|
||||
CloudCmd.refresh(panel, {
|
||||
noCurrent: noCurrent
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -321,7 +321,9 @@
|
|||
};
|
||||
|
||||
if (!Info.isOnePanel)
|
||||
CloudCmd.refresh(panelPassive, {noCurrent: true}, function() {});
|
||||
CloudCmd.refresh(panelPassive, {
|
||||
noCurrent: true
|
||||
});
|
||||
|
||||
CloudCmd.refresh(panel, setCurrent);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue