mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
refactor(listeners) changeLinks
This commit is contained in:
parent
745be9e478
commit
3609c030c6
1 changed files with 38 additions and 32 deletions
|
|
@ -94,9 +94,9 @@ var Util, DOM, CloudCmd;
|
|||
/* назначаем кнопку очистить кэш и показываем её */
|
||||
var lPanel = DOM.getById(pPanelID),
|
||||
pathElement = DOM.getByClass('path', lPanel)[0],
|
||||
pathLinks = DOM.getByClass('links', pathElement)[0].children,
|
||||
clearStorage = DOM.getByClass('clear-storage', pathElement)[0],
|
||||
refresh = DOM.getByClass('refresh-icon', pathElement)[0],
|
||||
a = DOM.getByTag('a', lPanel),
|
||||
|
||||
fileClick = function (event) {
|
||||
var ctrl = event.ctrlKey;
|
||||
|
|
@ -171,6 +171,9 @@ var Util, DOM, CloudCmd;
|
|||
DOM.setCurrentFile(pElement);
|
||||
},
|
||||
|
||||
i, n, a, ai, file, link, loadDir,
|
||||
filesElement = DOM.getByClass('files', lPanel)[0],
|
||||
files = filesElement.children,
|
||||
lUrl = CloudCmd.HOST,
|
||||
lLoadDirOnce = CloudCmd.loadDir();
|
||||
|
||||
|
|
@ -178,39 +181,42 @@ var Util, DOM, CloudCmd;
|
|||
Events.addClick(CloudCmd.refresh, refresh);
|
||||
Events.addClick(Storage.clear, clearStorage);
|
||||
|
||||
/* start from 1 cous 0 is a refresh and it's setted up */
|
||||
for(var i = 1, n = a.length; i < n ; i++) {
|
||||
var ai = a[i],
|
||||
lLink = Util.removeStr(ai.href, lUrl),
|
||||
lLoadDir = CloudCmd.loadDir(lLink),
|
||||
lLi = ai.parentElement.parentElement;
|
||||
n = pathLinks.length;
|
||||
for (i = 0; i < n; i++) {
|
||||
ai = pathLinks[i];
|
||||
link = Util.removeStr(ai.href, lUrl),
|
||||
loadDir = CloudCmd.loadDir(link),
|
||||
|
||||
/* if we in path - set click event */
|
||||
if (lLi.className === 'path')
|
||||
Events.addClick(lLoadDir, ai);
|
||||
else {
|
||||
Events.addClick(loadDir, ai);
|
||||
}
|
||||
|
||||
a = DOM.getByTag('a', filesElement);
|
||||
|
||||
n = a.length;
|
||||
for (i = 0; i < n ; i++) {
|
||||
file = files[i];
|
||||
ai = a[i],
|
||||
|
||||
Events.add({
|
||||
'mousedown' : lSetCurrentFile_f,
|
||||
'contextmenu' : lOnContextMenu_f,
|
||||
'dragstart' : lOnDragStart_f
|
||||
}, file);
|
||||
|
||||
/* если на файл, а не на папку */
|
||||
if (ai.target === '_blank')
|
||||
Events.add({
|
||||
'mousedown' : lSetCurrentFile_f,
|
||||
'contextmenu' : lOnContextMenu_f,
|
||||
'dragstart' : lOnDragStart_f
|
||||
}, lLi);
|
||||
|
||||
/* если ссылка на папку, а не файл */
|
||||
if (ai.target === '_blank')
|
||||
Events.add({
|
||||
'click' : fileClick
|
||||
});
|
||||
else {
|
||||
Events.add({
|
||||
'dblclick' : lLoadDirOnce,
|
||||
'touchend' : lLoadDirOnce,
|
||||
'click' : DOM.preventDefault,
|
||||
}, lLi);
|
||||
}
|
||||
|
||||
lLi.id = (ai.title ? ai.title : ai.textContent) +
|
||||
'(' + pPanelID + ')';
|
||||
}
|
||||
'click' : fileClick
|
||||
});
|
||||
else
|
||||
Events.add({
|
||||
'dblclick' : lLoadDirOnce,
|
||||
'touchend' : lLoadDirOnce,
|
||||
'click' : DOM.preventDefault,
|
||||
}, file);
|
||||
|
||||
file.id = (ai.title ? ai.title : ai.textContent) +
|
||||
'(' + pPanelID + ')';
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue