Skip to content
Browse files

select and open file when uploading just one file

hide overwrite all/skip all buttons by default
  • Loading branch information...
1 parent ee639cb commit 8ebe09b1bedc422941279e702caf3630ceb3aa9c @linh81 linh81 committed Mar 27, 2012
Showing with 50 additions and 24 deletions.
  1. +19 −20 client/ext/dragdrop/dragdrop.js
  2. +31 −4 client/ext/uploadfiles/uploadfiles.xml
View
39 client/ext/dragdrop/dragdrop.js
@@ -239,6 +239,10 @@ module.exports = ext.register("ext/dragdrop/dragdrop", {
},
startUpload: function(files) {
+ // set number of files user wants to upload, used to check if we should
+ // select and open the file on upload complete
+ this.numFilesUploaded = files.length;
+
trFiles.addEventListener("beforeselect", this.checkSelectableFile);
var node = trFiles.selected;
if (!node)
@@ -374,26 +378,24 @@ module.exports = ext.register("ext/dragdrop/dragdrop", {
function check(exists) {
if (exists) {
if (_self.existingOverwriteAll) {
- upload();
+ _self.overwrite();
}
else if (_self.existingSkipAll) {
_self.removeCurrentUploadFile(filename);
_self.uploadNextFile();
}
else {
winUploadFileExists.show();
+ if (_self.uploadQueue.length) {
+ btnUploadOverwriteAll.show();
+ btnUploadSkipAll.show();
+ }
+ else {
+ btnUploadOverwriteAll.hide();
+ btnUploadSkipAll.hide();
+ }
uploadFileExistsMsg.$ext.innerHTML = "\"" + filename + "\" already exists, do you want to replace it?. Replacing it will overwrite it's current contents.";
}
-
-
- /*
- util.confirm(
- "Are you sure?",
- "\"" + file.name + "\" already exists, do you want to replace it?",
- "A file or folder with the same name already exists. "
- + "Replacing it will overwrite it's current contents.",
- removeExisting);
- */
}
else {
upload(file, e);
@@ -450,23 +452,20 @@ module.exports = ext.register("ext/dragdrop/dragdrop", {
if(!strXml)
_self.uploadNextFile();
- //strXml = strXml[1];
- //var oXml = apf.xmldb.appendChild(node, apf.getXml(strXml));
-
// change file from uploading to file to regular file in tree
apf.xmldb.setAttribute(file.treeNode, "type", "file");
//apf.xmldb.appendChild(node, apf.getXml(strXml));
-// trFiles.select(oXml);
+ if (_self.numFilesUploaded == 1) {
+ trFiles.select(file.treeNode);
-/* when open file?
- if (file.size < MAX_OPENFILE_SIZE)
- ide.dispatchEvent("openfile", {doc: ide.createDocument(oXml)});
-*/
+ if (file.size < MAX_OPENFILE_SIZE)
+ ide.dispatchEvent("openfile", {doc: ide.createDocument(file.treeNode)});
+ }
//setTimeout(function() {
_self.uploadNextFile();
- //}, 3000);
+ //}, 1000);
});
}
View
35 client/ext/uploadfiles/uploadfiles.xml
@@ -68,11 +68,38 @@
</a:vbox>
<a:hbox edge="6 10 10" pack="end" padding="8">
- <a:button id="btnUploadOverwriteAll" skin="btn-default-css3" class="btn-green" onclick="winUploadFileExists.hide();require('ext/dragdrop/dragdrop').overwriteAll()">Overwrite all</a:button>
- <a:button id="btnUploadSkipAll" skin="btn-default-css3" class="btn-red" onclick="winUploadFileExists.hide();require('ext/dragdrop/dragdrop').skipAll()">Skip all</a:button>
+ <a:button id="btnUploadOverwriteAll"
+ skin="btn-default-css3"
+ class="btn-green"
+ onclick="
+ winUploadFileExists.hide();
+ require('ext/dragdrop/dragdrop').overwriteAll()
+ "
+ visible="false">Overwrite all</a:button>
+ <a:button id="btnUploadSkipAll"
+ skin="btn-default-css3"
+ class="btn-red"
+ onclick="
+ winUploadFileExists.hide();
+ require('ext/dragdrop/dragdrop').skipAll()
+ "
+ visible="false">Skip all</a:button>
<a:filler/>
- <a:button id="btnUploadOverwrite" default="3" skin="btn-default-css3" class="btn-green" onclick="winUploadFileExists.hide();require('ext/dragdrop/dragdrop').overwrite()">Overwrite</a:button>
- <a:button id="btnUploadSkip" skin="btn-default-css3" class="btn-red" onclick="winUploadFileExists.hide();require('ext/dragdrop/dragdrop').skip()">Skip</a:button>
+ <a:button id="btnUploadOverwrite"
+ default="3"
+ skin="btn-default-css3"
+ class="btn-green"
+ onclick="
+ winUploadFileExists.hide();
+ require('ext/dragdrop/dragdrop').overwrite()
+ ">Overwrite</a:button>
+ <a:button id="btnUploadSkip"
+ skin="btn-default-css3"
+ class="btn-red"
+ onclick="
+ winUploadFileExists.hide();
+ require('ext/dragdrop/dragdrop').skip()
+ ">Skip</a:button>
</a:hbox>
</a:window>
</a:application>

0 comments on commit 8ebe09b

Please sign in to comment.
Something went wrong with that request. Please try again.