mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
refactor(dom) deleteCurrent
This commit is contained in:
parent
8732b1b50a
commit
7efe125916
1 changed files with 23 additions and 17 deletions
|
|
@ -1553,27 +1553,33 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
/**
|
||||
* remove current file from file table
|
||||
* @pCurrent
|
||||
* @param current
|
||||
* @param notSet
|
||||
*
|
||||
*/
|
||||
this.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet) {
|
||||
var lCurrent = pCurrent || Cmd.getCurrentFile(),
|
||||
lParent = lCurrent && lCurrent.parentElement,
|
||||
lName = Cmd.getCurrentName(lCurrent);
|
||||
this.deleteCurrent = function(current, notSet) {
|
||||
var name, next, prev, parent;
|
||||
|
||||
if (lCurrent && lParent && lName !== '..') {
|
||||
var lNext = pNextFile || lCurrent.nextSibling,
|
||||
lPrevious = pPreviousFile || lCurrent.previousSibling;
|
||||
if (!current)
|
||||
Cmd.getCurrentFile();
|
||||
|
||||
parent = current && current.parentElement;
|
||||
name = Cmd.getCurrentName(current);
|
||||
|
||||
if (current && name !== '..') {
|
||||
next = current.nextSibling,
|
||||
prev = current.previousSibling;
|
||||
|
||||
if (!pNotSet)
|
||||
if (lNext)
|
||||
this.setCurrentFile(lNext);
|
||||
else if (lPrevious)
|
||||
this.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(lCurrent);
|
||||
if (!notSet)
|
||||
if (next)
|
||||
this.setCurrentFile(next);
|
||||
else if (prev)
|
||||
this.setCurrentFile(prev);
|
||||
|
||||
parent.removeChild(current);
|
||||
}
|
||||
|
||||
return lCurrent;
|
||||
return current;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1594,7 +1600,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
next = current.nextSibling,
|
||||
prev = current.previousSibling;
|
||||
|
||||
this.deleteCurrent(current, next, prev, i !== n-1);
|
||||
this.deleteCurrent(current, i !== n-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue