mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
refactored
This commit is contained in:
parent
5eaf783c83
commit
856d9bb293
7 changed files with 60 additions and 117 deletions
|
|
@ -759,6 +759,16 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
return lCurrent;
|
||||
};
|
||||
|
||||
|
||||
DOM.getCurrentSize = function(pCurrentFile){
|
||||
var lRet,
|
||||
lCurrent = pCurrentFile || DOM.getCurrentFile(),
|
||||
lSize = DOM.getByClass('size', lCurrent);
|
||||
lRet = lSize[0].textContent;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
/**
|
||||
* unified way to get current file content
|
||||
*
|
||||
|
|
@ -811,35 +821,28 @@ var CloudCommander, Util, DOM, CloudFunc;
|
|||
* unified way to set current file
|
||||
*/
|
||||
DOM.setCurrentFile = function(pCurrentFile){
|
||||
var lRet_b = true;
|
||||
var lRet = true,
|
||||
lCurrentFileWas = DOM.getCurrentFile();
|
||||
|
||||
if(!pCurrentFile){
|
||||
DOM.addCloudStatus({
|
||||
code : -1,
|
||||
msg : 'Error pCurrentFile in' +
|
||||
'setCurrentFile' +
|
||||
'could not be none'
|
||||
});
|
||||
if(!pCurrentFile)
|
||||
lRet = false;
|
||||
|
||||
if(lRet){
|
||||
if (pCurrentFile.className === 'path')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
lRet_b = false;
|
||||
if (pCurrentFile.className === 'fm_header')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if(lCurrentFileWas)
|
||||
UnSetCurrentFile(lCurrentFileWas);
|
||||
|
||||
DOM.addClass(pCurrentFile, getCurrentFile());
|
||||
|
||||
/* scrolling to current file */
|
||||
DOM.scrollIntoViewIfNeeded(pCurrentFile);
|
||||
}
|
||||
var lCurrentFileWas = DOM.getCurrentFile();
|
||||
|
||||
if (pCurrentFile.className === 'path')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if (pCurrentFile.className === 'fm_header')
|
||||
pCurrentFile = pCurrentFile.nextSibling;
|
||||
|
||||
if(lCurrentFileWas)
|
||||
UnSetCurrentFile(lCurrentFileWas);
|
||||
|
||||
DOM.addClass(pCurrentFile, getCurrentFile());
|
||||
|
||||
/* scrolling to current file */
|
||||
DOM.scrollIntoViewIfNeeded(pCurrentFile);
|
||||
|
||||
return lRet_b;
|
||||
return lRet;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -121,23 +121,11 @@ var CloudCommander, Util, DOM, CodeMirror;
|
|||
if(Loading)
|
||||
return;
|
||||
|
||||
/* getting link */
|
||||
var lCurrentFile = DOM.getCurrentFile(),
|
||||
lPath = DOM.getCurrentPath(lCurrentFile);
|
||||
|
||||
/* checking is this link is to directory */
|
||||
var lSize = DOM.getByClass('size', lCurrentFile);
|
||||
if(lSize){
|
||||
lSize = lSize[0].textContent;
|
||||
|
||||
/* when folder view
|
||||
* is no need to edit
|
||||
* data
|
||||
*/
|
||||
if (lSize === '<dir>')
|
||||
ReadOnly = true;
|
||||
|
||||
}
|
||||
/* checking is this link is to directory
|
||||
* when folder view is no need to edit data
|
||||
*/
|
||||
if ( DOM.getCurrentSize() === '<dir>' )
|
||||
ReadOnly = true;
|
||||
|
||||
Loading = true;
|
||||
setTimeout(function(){
|
||||
|
|
@ -153,7 +141,7 @@ var CloudCommander, Util, DOM, CodeMirror;
|
|||
|
||||
success : function(data){
|
||||
/* if we got json - show it */
|
||||
if(typeof data === 'object')
|
||||
if( Util.isObject(data) )
|
||||
data = JSON.stringify(data, null, 4);
|
||||
|
||||
var lHided = DOM.hidePanel();
|
||||
|
|
@ -184,7 +172,6 @@ var CloudCommander, Util, DOM, CodeMirror;
|
|||
DOM.showPanel();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* function calls all CodeMirror editor functions
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -260,38 +260,8 @@ var CloudCommander, Util, DOM;
|
|||
}
|
||||
|
||||
/* если нажали Enter - открываем папку*/
|
||||
else if(lKeyCode === KEY.ENTER){
|
||||
/* если ненайдены выделенные файлы - выходим*/
|
||||
if(!lCurrentFile)return;
|
||||
|
||||
/* из него достаём спан с именем файла*/
|
||||
lName = DOM.getByClass('name', lCurrentFile);
|
||||
|
||||
/* если нету (что вряд ли) - выходим*/
|
||||
if(!lName)return false;
|
||||
|
||||
/* достаём все ссылки*/
|
||||
var lATag = DOM.getByTag('a', lName[0]);
|
||||
|
||||
/* если нету - выходим */
|
||||
if(!lATag)return false;
|
||||
|
||||
/* вызываем ajaxload привязанный через changelinks
|
||||
* пробуем нажать на ссылку, если не получиться
|
||||
* (opera, ie), вызываем событие onclick,
|
||||
*/
|
||||
|
||||
if(lCurrentFile.onclick)
|
||||
lCurrentFile.onclick(true);
|
||||
else try{
|
||||
lATag[0].click();
|
||||
}
|
||||
catch(error){
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
else if(lKeyCode === KEY.ENTER)
|
||||
Util.exec(lCurrentFile.onclick, true);
|
||||
|
||||
/* если нажали <ctr>+r
|
||||
* обновляем страницу,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* object contains jQuery-contextMenu
|
||||
* https://github.com/medialize/jQuery-contextMenu
|
||||
*/
|
||||
var CloudCommander, Util, DOM, CloudFunc, $;
|
||||
var CloudCommander, Util, DOM, $;
|
||||
(function(){
|
||||
"use strict";
|
||||
|
||||
|
|
|
|||
|
|
@ -138,17 +138,12 @@ var CloudCommander, Util, DOM, CloudFunc, $;
|
|||
if (lLink.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length)
|
||||
lLink = Util.removeStr(lLink, CloudFunc.NOJS);
|
||||
|
||||
DOM.ajax({
|
||||
DOM.getCurrentFileContent({
|
||||
url : lLink,
|
||||
|
||||
error : function(jqXHR, textStatus, errorThrown){
|
||||
error : function(){
|
||||
FancyBox.loading = false;
|
||||
return DOM.Images.showError(jqXHR, textStatus, errorThrown);
|
||||
},
|
||||
|
||||
success :function(data, textStatus, jqXHR){
|
||||
Util.exec(pCallBack, data);
|
||||
}
|
||||
success : Util.retExec(pCallBack)
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue