refactor(dom) moveCurrent

This commit is contained in:
coderaiser 2014-02-24 06:47:49 -05:00
parent e63fa22c75
commit e57a0b186b

View file

@ -1636,30 +1636,35 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*
* @pCurrent
*/
this.moveCurrent = function(pCurrentFile) {
if (!Cmd.isCurrentFile(pCurrentFile))
pCurrentFile = null;
this.moveCurrent = function(current) {
var name, from, to, cmp, files;
var lCurrent = pCurrentFile || Cmd.getCurrentFile(),
lName = Cmd.getCurrentName(lCurrent),
lFromPath = Cmd.getCurrentPath(),
lToPath = Cmd.getNotCurrentDirPath() + lName;
if (!Cmd.isCurrentFile(current))
current = Cmd.getCurrentFile();
lToPath = Dialog.prompt('Rename/Move file "' + lName + '"', lToPath);
name = Cmd.getCurrentName(current),
from = Cmd.getCurrentPath(),
to = Cmd.getNotCurrentDirPath() + name;
if (lToPath && !Util.strCmp(lFromPath, lToPath)) {
var lFiles = {
from : lFromPath,
to : lToPath
to = Dialog.prompt('Rename/Move file "' + name + '"', to);
cmp = !Util.strCmp(from, to);
if (to && cmp) {
files = {
from : from,
to : to
};
RESTful.mv(lFiles, function() {
DOM.deleteCurrent(lCurrent);
RESTful.mv(files, function() {
var dotDot,
panel = DOM.getPanel(true),
id = panel.id,
name = '..(' + id + ')';
var lPanel = DOM.getPanel(true),
lDotDot = DOM.getById( '..(' + lPanel.id + ')');
dotDot = DOM.getById(name);
DOM.setCurrentFile ( lDotDot );
DOM.deleteCurrent(current);
DOM.setCurrentFile (dotDot);
CloudCmd.refresh();
});
}