mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(edit) add ability to drop file content
This commit is contained in:
parent
b73cdf19fa
commit
49944f3a43
1 changed files with 33 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
Session,
|
||||
Modelist,
|
||||
Msg,
|
||||
Events = DOM.Events,
|
||||
Dialog = DOM.Dialog,
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
|
|
@ -58,6 +59,13 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
});
|
||||
|
||||
initAce();
|
||||
|
||||
Events.add({
|
||||
drop : onDrop,
|
||||
dragover : function(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, Element);
|
||||
}
|
||||
|
||||
modesByName = Modelist.modesByName;
|
||||
|
|
@ -340,6 +348,31 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
|
|||
}
|
||||
}
|
||||
|
||||
function onDrop(event) {
|
||||
var reader, i, n, file, files,
|
||||
onLoad = function(event) {
|
||||
var data = event.target.result;
|
||||
|
||||
Ace.setValue(data);
|
||||
};
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
files = event.dataTransfer.files;
|
||||
|
||||
if (files.length) {
|
||||
n = files.length;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
reader = new FileReader();
|
||||
file = files[i];
|
||||
|
||||
DOM.Events.add('load', onLoad, reader);
|
||||
reader.readAsBinaryString(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.showMessage = function(text) {
|
||||
var parent,
|
||||
HIDE_TIME = 2000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue