refactor(dom) copyCurrent

This commit is contained in:
coderaiser 2014-02-25 07:01:12 -05:00
parent 6ea42da3bb
commit 7dc59f727d

View file

@ -1675,29 +1675,32 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
/**
* copy current file
*
* @pCurrent
* @param current
*/
this.copyCurrent = function(pCurrentFile) {
if (!Cmd.isCurrentFile(pCurrentFile))
pCurrentFile = null;
this.copyCurrent = function(current) {
var name, from, to, files, cmp;
var lCurrent = pCurrentFile || Cmd.getCurrentFile(),
lName = Cmd.getCurrentName(lCurrent),
lFromPath = Cmd.getCurrentPath(),
lToPath = Cmd.getNotCurrentDirPath() + lName;
lToPath = Dialog.prompt( 'Copy file "' + lName + '" to', lToPath );
if (!Cmd.isCurrentFile(current))
current = Cmd.getCurrentFile();
if (lToPath && !Util.strCmp(lFromPath, lToPath)) {
var lFiles = {
from : lFromPath,
to : lToPath
name = Cmd.getCurrentName(current),
from = Cmd.getCurrentPath(),
to = Cmd.getNotCurrentDirPath() + name;
to = Dialog.prompt('Copy file "' + name + '" to', to);
cmp = Util.strCmp(from, to);
if (!cmp) {
files = {
from : from,
to : to
};
RESTful.cp(lFiles, function() {
var lPanel = DOM.getPanel(true),
lDotDot = DOM.getById( '..(' + lPanel.id + ')');
RESTful.cp(files, function() {
var panel = DOM.getPanel(true),
id = panel.id,
dotDot = DOM.getById( '..(' + id + ')');
DOM.setCurrentFile ( lDotDot );
DOM.setCurrentFile(dotDot);
CloudCmd.refresh();
});
}