mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
added ability to delete selected files from DOM
This commit is contained in:
parent
dcfc7d9fc1
commit
2442a26d20
2 changed files with 46 additions and 17 deletions
|
|
@ -52,6 +52,8 @@ from storage folder.
|
|||
|
||||
* Added ability to select files with Insert key.
|
||||
|
||||
* Added ability to delete selected files from DOM.
|
||||
|
||||
|
||||
2012.03.01, Version 0.1.9
|
||||
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
var lRet,
|
||||
lCurrent,
|
||||
lName,
|
||||
lMsg = 'Are you sure thet you wont delete ';
|
||||
lMsg = 'Are you sure thet you want delete ';
|
||||
|
||||
/* dom element passed and it is not event */
|
||||
if( Util.isObject(pCurrentFile) && !pCurrentFile.type)
|
||||
|
|
@ -979,7 +979,7 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
DOM.getSelectedFiles = function(){
|
||||
var lRet = DOM.getByClass(SELECTED_FILE);
|
||||
|
||||
return lRet.length ? lRet : !lRet;
|
||||
return lRet.length ? lRet : null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1427,19 +1427,20 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
* remove current file from file table
|
||||
* @pCurrent
|
||||
*/
|
||||
DOM.deleteCurrent = function(pCurrent){
|
||||
DOM.deleteCurrent = function(pCurrent, pNextFile, pPreviousFile, pNotSet){
|
||||
var lCurrent = pCurrent || DOM.getCurrentFile(),
|
||||
lParent = lCurrent.parentElement,
|
||||
lParent = lCurrent && lCurrent.parentElement,
|
||||
lName = DOM.getCurrentName(lCurrent);
|
||||
|
||||
if(lCurrent && lParent && lName !== '..'){
|
||||
var lNext = lCurrent.nextSibling,
|
||||
lPrevious = lCurrent.previousSibling;
|
||||
var lNext = pNextFile || lCurrent.nextSibling,
|
||||
lPrevious = pPreviousFile || lCurrent.previousSibling;
|
||||
|
||||
if(lNext)
|
||||
DOM.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
DOM.setCurrentFile(lPrevious);
|
||||
if(!pNotSet)
|
||||
if(lNext)
|
||||
DOM.setCurrentFile(lNext);
|
||||
else if(lPrevious)
|
||||
DOM.setCurrentFile(lPrevious);
|
||||
|
||||
lParent.removeChild(lCurrent);
|
||||
}
|
||||
|
|
@ -1447,6 +1448,29 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
return lCurrent;
|
||||
};
|
||||
|
||||
/**
|
||||
* remove selected files from file table
|
||||
* @Selected
|
||||
*/
|
||||
DOM.deleteSelected = function(pSelected){
|
||||
var lSelected = pSelected || DOM.getSelectedFiles();
|
||||
|
||||
if(lSelected){
|
||||
var n = lSelected.length,
|
||||
lLast = n-1,
|
||||
lNext = lSelected[lLast].nextSibling,
|
||||
lPrev = lSelected[0].previousSibling;
|
||||
|
||||
/* lSelected[0] - becouse lSelected is a link to DOM so
|
||||
* when we remove 0 element, it's removed from lSelected to
|
||||
*/
|
||||
for(var i = 0; i < n; i++)
|
||||
DOM.deleteCurrent( lSelected[0], lNext, lPrev, i !== lLast);
|
||||
}
|
||||
|
||||
return lSelected;
|
||||
};
|
||||
|
||||
/**
|
||||
* rename current file
|
||||
*
|
||||
|
|
@ -1566,15 +1590,18 @@ var CloudCommander, Util, DOM = {}, CloudFunc;
|
|||
* function gets time
|
||||
*/
|
||||
DOM.getTime = function(){
|
||||
var date = new Date(),
|
||||
hours = date.getHours(),
|
||||
minutes = date.getMinutes(),
|
||||
seconds = date.getSeconds();
|
||||
var lRet,
|
||||
lDate = new Date(),
|
||||
lHours = lDate.getHours(),
|
||||
lMinutes = lDate.getMinutes(),
|
||||
lSeconds = lDate.getSeconds();
|
||||
|
||||
minutes = minutes < 10 ? '0' + minutes : minutes;
|
||||
seconds = seconds < 10 ? '0' + seconds : seconds;
|
||||
lMinutes = lMinutes < 10 ? '0' + lMinutes : lMinutes;
|
||||
lSeconds = lSeconds < 10 ? '0' + lSeconds : lSeconds;
|
||||
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
lRet = lHours + ":" + lMinutes + ":" + lSeconds;
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
})(Util, DOM);
|
||||
Loading…
Add table
Add a link
Reference in a new issue