mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(dom) add sendDelete
This commit is contained in:
parent
e64f8d0b2b
commit
fd8791af9e
4 changed files with 56 additions and 37 deletions
|
|
@ -594,13 +594,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
|
||||
|
||||
/**
|
||||
* delete currentfile, prompt before it
|
||||
* prompt and delete current file or selected files
|
||||
*
|
||||
* @currentFile
|
||||
*/
|
||||
this.promptDeleteSelected = function(current) {
|
||||
var ret, type, isDir, path, query, msg,
|
||||
RESTful = DOM.RESTful,
|
||||
this.promptDelete = function(currentFile) {
|
||||
var ret, type, isDir, msg, current,
|
||||
name = '',
|
||||
msgAsk = 'Do you really want to delete the ',
|
||||
msgSel = 'selected ',
|
||||
|
|
@ -608,12 +607,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
names = Cmd.getSelectedNames(files),
|
||||
i, n = names && names.length;
|
||||
|
||||
if (!Cmd.isCurrentFile(current))
|
||||
if (!Cmd.isCurrentFile(currentFile))
|
||||
current = DOM.getCurrentFile();
|
||||
|
||||
if (n > 1) {
|
||||
path = Cmd.getCurrentDirPath();
|
||||
|
||||
if (n) {
|
||||
for (i = 0; i < 5 && i < n; i++)
|
||||
name += '\n' + names[i];
|
||||
|
||||
|
|
@ -621,15 +618,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
name += '\n...';
|
||||
|
||||
msg = msgAsk + msgSel + n + ' files/directoris?\n' + name ;
|
||||
query = '?files';
|
||||
} else {
|
||||
path = Cmd.getCurrentPath(current);
|
||||
isDir = Cmd.isCurrentIsDir(current);
|
||||
|
||||
if (isDir) {
|
||||
query = '?dir';
|
||||
if (isDir)
|
||||
type ='directory';
|
||||
} else
|
||||
else
|
||||
type = 'file';
|
||||
|
||||
type += ' ';
|
||||
|
|
@ -644,22 +638,53 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
Dialog.alert('No files selected!');
|
||||
|
||||
if (ret)
|
||||
RESTful.delete(path + query, names, function() {
|
||||
var Storage = DOM.Storage,
|
||||
dirPath = CurrentInfo.dirPath,
|
||||
dir = CloudFunc.rmLastSlash(dirPath);
|
||||
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(files);
|
||||
else
|
||||
DOM.deleteCurrent(current);
|
||||
|
||||
Storage.remove(dir);
|
||||
});
|
||||
DOM.sendDelete(files);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* delete current or selected files
|
||||
*
|
||||
* @files
|
||||
*/
|
||||
this.sendDelete = function(files) {
|
||||
var n, names, path,
|
||||
query = '',
|
||||
RESTful = DOM.RESTful,
|
||||
current = CurrentInfo.element,
|
||||
isDir = DOM.CurrentInfo.isDir;
|
||||
|
||||
if (!files)
|
||||
files = Cmd.getSelectedFiles();
|
||||
|
||||
if (isDir)
|
||||
query = '?dir';
|
||||
|
||||
names = DOM.getSelectedNames(files),
|
||||
n = names && names.length;
|
||||
|
||||
if (n) {
|
||||
path = Cmd.getCurrentDirPath();
|
||||
query = '?files';
|
||||
} else {
|
||||
path = Cmd.getCurrentPath(current);
|
||||
}
|
||||
|
||||
RESTful.delete(path + query, names, function() {
|
||||
var Storage = DOM.Storage,
|
||||
dirPath = CurrentInfo.dirPath,
|
||||
dir = CloudFunc.rmLastSlash(dirPath);
|
||||
|
||||
if (n > 1)
|
||||
DOM.deleteSelected(files);
|
||||
else
|
||||
DOM.deleteCurrent(current);
|
||||
|
||||
Storage.remove(dir);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* get current direcotory name
|
||||
|
|
|
|||
|
|
@ -201,16 +201,10 @@ var CloudCmd, Util, DOM;
|
|||
break;
|
||||
|
||||
case Key.DELETE:
|
||||
if (shift) {
|
||||
if (Info.isDir)
|
||||
path += '?dir';
|
||||
|
||||
DOM.RESTful.delete(path, function() {
|
||||
DOM.deleteCurrent(current);
|
||||
});
|
||||
}
|
||||
if (shift)
|
||||
DOM.sendDelete();
|
||||
else
|
||||
DOM.promptDeleteSelected(current);
|
||||
DOM.promptDelete(current);
|
||||
break;
|
||||
|
||||
case Key.ASTERISK:
|
||||
|
|
@ -269,7 +263,7 @@ var CloudCmd, Util, DOM;
|
|||
break;
|
||||
|
||||
case Key.F8:
|
||||
DOM.promptDeleteSelected(current);
|
||||
DOM.promptDelete(current);
|
||||
break;
|
||||
|
||||
case Key.F9:
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ var Util, DOM, CloudCmd;
|
|||
'f5' : DOM.copyCurrent,
|
||||
'f6' : DOM.moveCurrent,
|
||||
'f7' : DOM.promptNewDir,
|
||||
'f8' : DOM.promptDeleteSelected
|
||||
'f8' : DOM.promptDelete
|
||||
},
|
||||
|
||||
func = clickFuncs[id];
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
'Rename' : function() {
|
||||
setTimeout(DOM.renameCurrent, 100);
|
||||
},
|
||||
'Delete' : DOM.promptDeleteSelected,
|
||||
'Delete' : DOM.promptDelete,
|
||||
'(Un)Select All': DOM.toggleAllSelectedFiles,
|
||||
'Zip file' : DOM.zipFile
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue