mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(dom) moveCurrent
This commit is contained in:
parent
e63fa22c75
commit
e57a0b186b
1 changed files with 22 additions and 17 deletions
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue