From e57a0b186b1aa32e1aba601ee10bd97a9f8544a6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 24 Feb 2014 06:47:49 -0500 Subject: [PATCH] refactor(dom) moveCurrent --- lib/client/dom.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index ed61f692..5f9d5cee 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -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(); }); }