refactored

This commit is contained in:
coderaiser 2012-12-13 14:11:21 -05:00
parent b413284925
commit 1d91b68070
4 changed files with 35 additions and 27 deletions

View file

@ -25,7 +25,7 @@ var CloudCommander, Util, DOM, CloudFunc;
'could not be none'
});
if(lRet_b)
if(lRet_b)
DOM.removeClass(pCurrentFile, getCurrentFile());
return lRet_b;
@ -758,19 +758,34 @@ var CloudCommander, Util, DOM, CloudFunc;
}
return lCurrent;
};
/**
* unified way to get current file content
*
* @pCallBack - callback function or data struct {sucess, error}
* @pCurrentFile
*/
DOM.getCurrentFileContent = function(pCallBack, pCurrentFile){
var lPath = DOM.getCurrentPath(pCurrentFile),
lRet = DOM.ajax({
url : lPath,
error : DOM.Images.showError,
success : Util.retExec(pCallBack)
});
DOM.getCurrentFileContent = function(pParams, pCurrentFile){
var lRet,
lParams = pParams ? pParams : {},
lPath = DOM.getCurrentPath(pCurrentFile),
lError = function(){
Util.exec(pParams.error);
DOM.Images.showError();
};
if( Util.isFunction(lParams) )
lParams = {
error : lError,
success : Util.retExec(pParams)
};
else
lParams.error = lError;
if(!lParams.url)
lParams.url = lPath;
lRet = DOM.ajax(lParams);
return lRet;
};

View file

@ -146,14 +146,12 @@ var CloudCommander, Util, DOM, CodeMirror;
400);
/* reading data from current file */
DOM.ajax({
url:lPath,
error: function(jqXHR, textStatus, errorThrown){
DOM.getCurrentFileContent({
error : function(){
Loading = false;
return DOM.Images.showError(jqXHR);
},
success:function(data, textStatus, jqXHR){
success : function(data){
/* if we got json - show it */
if(typeof data === 'object')
data = JSON.stringify(data, null, 4);

View file

@ -129,25 +129,20 @@ var CloudCommander, Util, DOM, CloudFunc, $;
callback: function(key, opt){
DOM.Images.showLoad();
var lCurrent = DOM.getCurrentFile(),
lLink = DOM.getByTag('a', lCurrent)[0].href;
var lPath = DOM.getCurrentPath(),
lId = DOM.getIdBySrc(lPath);
console.log('downloading file ' + lLink +'...');
Util.log('downloading file ' + lPath +'...');
lLink = lLink + '?download';
lLink = Util.removeStr( lLink, CloudFunc.NOJS );
var lId = DOM.getIdBySrc(lLink);
lPath = lPath + '?download';
if(!DOM.getById(lId)){
var lDownload = DOM.anyload({
name : 'iframe',
async : false,
className : 'hidden',
src : lLink,
func : function(){
DOM.Images.hideLoad();
}
src : lPath,
func : Util.retFunc(DOM.Images.hideLoad)
});
DOM.Images.hideLoad();
@ -155,7 +150,7 @@ var CloudCommander, Util, DOM, CloudFunc, $;
document.body.removeChild(lDownload);
}, 10000);
}
else
else
DOM.Images.showError({
responseText: 'Error: You trying to' +
'download same file to often'});

View file

@ -131,7 +131,7 @@ var CloudCommander, Util, DOM, CloudFunc, $;
*/
FancyBox.loadData = function(pA, pCallBack){
var lLink = pA.href;
/* убираем адрес хоста */
lLink = lLink.replace(cloudcmd.HOST, '');