added ability to move files

This commit is contained in:
coderaiser 2013-03-05 15:38:04 -05:00
parent 21ce3358f3
commit 2bb20f9c80
5 changed files with 60 additions and 13 deletions

View file

@ -17,6 +17,8 @@ and get them out to file system.
* Fixed bug with multiple click events on f3 and f4 buttons.
* Added ability to move files.
2012.03.01, Version 0.1.9

View file

@ -123,11 +123,8 @@ CloudCmd._editFileName = function(pParent){
* backs
*/
DOM.addOneTimeListener('click', function(){
var lA = DOM.getCurrentLink(pParent);
if (lA && lA.textContent !== '..')
lA.contentEditable = false;
KeyBinding && KeyBinding.set();
//lA.contentEditable = false;
//KeyBinding && KeyBinding.set();
});
}
};
@ -282,11 +279,11 @@ function initKeysPanel(pCallBack){
lFuncs =[
null,
null, /* f1 */
DOM.renameCurrentFile, /* f2 */
DOM.renameCurrent, /* f2 */
CloudCmd.Viewer, /* f3 */
CloudCmd.Editor, /* f4 */
null, /* f5 */
null, /* f6 */
DOM.moveCurrent, /* f6 */
DOM.promptNewFolder, /* f7 */
DOM.promptDeleteCurrent,/* f8 */
];

View file

@ -931,6 +931,20 @@ var CloudCommander, Util,
return lRet;
};
/**
* get current direcotory path
*/
DOM.getNotCurrentDirPath = function(){
var lPanel = DOM.getPanel(true),
lPath = DOM.getByClass('path', lPanel)[0],
lRet;
if(lPath)
lRet = lPath.textContent;
return lRet;
};
/**
* unified way to get current file
*
@ -1171,7 +1185,7 @@ var CloudCommander, Util,
return lRet;
};
/**
/**
* get link from current (or param) file
*
* @param pCurrentFile - current file by default
@ -1180,7 +1194,7 @@ var CloudCommander, Util,
var lCurrent = pCurrentFile || DOM.getCurrentFile(),
lPath = DOM.getCurrentLink( lCurrent ).href;
lPath = decodeURI(lPath);
lPath = decodeURI(lPath);
/* убираем адрес хоста*/
lPath = Util.removeStr( lPath, [CloudCommander.HOST, CloudFunc.FS] );
@ -1387,14 +1401,15 @@ var CloudCommander, Util,
*
* @pCurrent
*/
DOM.renameCurrentFile = function(pCurrentFile){
DOM.renameCurrent = function(pCurrentFile){
if( !DOM.isCurrentFile(pCurrentFile) )
pCurrentFile = null;
var lCurrent = pCurrentFile || DOM.getCurrentFile(),
lFrom = DOM.getCurrentName(lCurrent),
lTo = prompt("Rename", lFrom) || lFrom,
lTo = prompt('Rename', lFrom) || lFrom,
lDirPath = DOM.getCurrentDirPath();
if( !Util.strCmp(lFrom, lTo) ){
var lFiles = {
from : lDirPath + lFrom,
@ -1407,6 +1422,33 @@ var CloudCommander, Util,
}
};
/**
* move current file
*
* @pCurrent
*/
DOM.moveCurrent = function(pCurrentFile){
if( !DOM.isCurrentFile(pCurrentFile) )
pCurrentFile = null;
var lCurrent = pCurrentFile || DOM.getCurrentFile(),
lName = DOM.getCurrentName(lCurrent),
lFromPath = DOM.getCurrentPath(),
lToPath = DOM.getNotCurrentDirPath() + lName,
lTo = prompt( 'Rename/Move file "' + lName + '"', lToPath );
if( lTo && !Util.strCmp(lFromPath, lToPath) ){
var lFiles = {
from : lFromPath,
to : lToPath
};
DOM.RESTfull.mv(lFiles, function(){
CloudCommander.refresh();
});
}
};
/**
* unified way to scrollIntoViewIfNeeded
* (native suporte by webkit only)

View file

@ -34,6 +34,8 @@ var CloudCommander, Util, DOM;
F2 : 113,
F3 : 114,
F4 : 115,
F6 : 117,
F7 : 118,
F10 : 121,
@ -127,7 +129,7 @@ var CloudCommander, Util, DOM;
break;
case KEY.F2:
DOM.renameCurrentFile(lCurrentFile);
DOM.renameCurrent(lCurrentFile);
break;
case KEY.F3:
@ -143,6 +145,10 @@ var CloudCommander, Util, DOM;
DOM.preventDefault(pEvent);
break;
case KEY.F6:
DOM.moveCurrent();
break;
case KEY.F7:
DOM.promptNewFolder();
break;

View file

@ -156,7 +156,7 @@ var CloudCommander, Util, DOM, CloudFunc, $;
'View' : Util.retExec(showEditor, true),
'Edit' : Util.retExec(showEditor, false),
'Rename' : function(){
setTimeout( Util.retExec(DOM.renameCurrentFile), 100);
setTimeout( Util.retExec(DOM.renameCurrent), 100);
},
'Delete' : Util.retExec(DOM.promptDeleteCurrent)
};