mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(dom) uploadFiles: add
This commit is contained in:
parent
209af01671
commit
d59083eb6d
3 changed files with 34 additions and 46 deletions
|
|
@ -404,6 +404,31 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
return DOM.loadRemote('menu', callback);
|
||||
};
|
||||
|
||||
this.uploadFiles = function(files) {
|
||||
var func = CloudCmd.refresh,
|
||||
dir = CurrentInfo.dirPath,
|
||||
load = function(file, callback) {
|
||||
var Images = DOM.Images,
|
||||
name = file.name,
|
||||
path = dir + name;
|
||||
|
||||
Images.showLoad({top: true});
|
||||
Images.setProgress(0, name);
|
||||
|
||||
DOM.RESTful.write(path, file, callback);
|
||||
};
|
||||
|
||||
Util.checkArgs(files);
|
||||
|
||||
if (files.length) {
|
||||
Util.forEach(files, function(file) {
|
||||
func = Util.exec.with(load, file, func);
|
||||
});
|
||||
|
||||
func();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* create new folder
|
||||
*
|
||||
|
|
|
|||
|
|
@ -289,31 +289,10 @@ var Util, DOM, CloudFunc, CloudCmd;
|
|||
});
|
||||
},
|
||||
onDrop = function (event) {
|
||||
var files,
|
||||
func = CloudCmd.refresh,
|
||||
dir = Info.dirPath,
|
||||
load = function(file, callback) {
|
||||
var Images = DOM.Images,
|
||||
name = file.name,
|
||||
path = dir + name;
|
||||
|
||||
Images.showLoad({top: true});
|
||||
Images.setProgress(0, name);
|
||||
|
||||
DOM.RESTful.write(path, file, callback);
|
||||
};
|
||||
var files = event.dataTransfer.files;
|
||||
|
||||
preventDefault(event);
|
||||
|
||||
files = event.dataTransfer.files;
|
||||
|
||||
if (files.length) {
|
||||
Util.forEach(files, function(file) {
|
||||
func = Util.exec.with(load, file, func);
|
||||
});
|
||||
|
||||
func();
|
||||
}
|
||||
DOM.uploadFiles(files);
|
||||
};
|
||||
|
||||
Events.add(['dragenter', 'dragleave', 'drop'], toggle);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
function UploadProto() {
|
||||
var Images = DOM.Images,
|
||||
RESTful = DOM.RESTful,
|
||||
Files = DOM.Files,
|
||||
|
||||
Upload = this;
|
||||
|
|
@ -54,28 +53,13 @@ var CloudCmd, Util, DOM;
|
|||
|
||||
Images.hide();
|
||||
|
||||
DOM.Events.add('change', button, uploadFiles);
|
||||
}
|
||||
|
||||
function uploadFiles(event) {
|
||||
var path,
|
||||
func = CloudCmd.refresh,
|
||||
dir = DOM.CurrentInfo.dirPath,
|
||||
files = event.target.files,
|
||||
n = files.length;
|
||||
|
||||
Upload.hide();
|
||||
|
||||
if (n)
|
||||
Util.forEach(files, function(file) {
|
||||
var name = file.name;
|
||||
path = dir + name;
|
||||
|
||||
Images.showLoad({top: true});
|
||||
Images.setProgress(0, name);
|
||||
|
||||
RESTful.write(path, file, func);
|
||||
});
|
||||
DOM.Events.add('change', button, function(event) {
|
||||
var files = event.target.files;
|
||||
|
||||
Upload.hide();
|
||||
|
||||
DOM.uploadFiles(files);
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue