Commit 080a932f authored by Fabian-Andree Heidemann's avatar Fabian-Andree Heidemann
Browse files

Fileuplaod: disable close button while uploading

parent 61108880
define(["jquery", "jclass"], function($, JClass) {
var FileBaseActions = JClass._extend({
init: function(FileBase) {
this.FileBase = FileBase;
......@@ -7,7 +7,7 @@ define(["jquery", "jclass"], function($, JClass) {
this.removebool = false;
this.entries = [];
},
// Reimplemented by the actions of the filebrowser / -selector
openFolder: function(data) {
// Make the function callable with a string or a selection.
......@@ -23,11 +23,11 @@ define(["jquery", "jclass"], function($, JClass) {
.data.realpath || newPath;
this.FileBase.instance.setState("path", newPath);
},
openFile: function(data) {
var self = this;
var path = null;
if (typeof data == "string") {
path = this.FileBase.helper.abspath(data);
} else {
......@@ -37,12 +37,12 @@ define(["jquery", "jclass"], function($, JClass) {
});
return;
}
var selectionElem = this.FileBase.selections.entries[path];
if (selectionElem && selectionElem.data().data.symlink) {
path = this.FileBase.selections.entries[path].data().data.realpath;
}
var ext = this.FileBase.helper.strExtension(path);
if (ext !== null && ext.toLowerCase() == "pdf") {
var target = vispa.url.dynamic("fs/getfile/?path=" + path +
......@@ -50,9 +50,9 @@ define(["jquery", "jclass"], function($, JClass) {
window.open(target, "_blank");
return;
}
var handlers = vispa.extensions.getFileHandlers(ext, true);
if (!handlers.length) {
// search for the link with the right id and trigger the lightbox plugin
var boxId = this.FileBase.helper.makeIDfromPath(path);
......@@ -61,7 +61,7 @@ define(["jquery", "jclass"], function($, JClass) {
if (!box.length) return;
box.trigger("click");
};
//noinspection JSLint
if (~self.FileBase.helper.isBrowserFile(path)) {
lb();
......@@ -77,13 +77,13 @@ define(["jquery", "jclass"], function($, JClass) {
self._openWithCodeEditor(path);
} else {
self.FileBase.instance.confirm("Do you want to download \"" + name +
" (" +
size + ")\"?",
function(res2) {
if (res2 === true) {
self.download();
}
});
" (" +
size + ")\"?",
function(res2) {
if (res2 === true) {
self.download();
}
});
}
}
);
......@@ -93,11 +93,13 @@ define(["jquery", "jclass"], function($, JClass) {
handlers[0].callback(this.FileBase.view.instance.getWorkspaceId(), path);
}
},
_openWithCodeEditor: function(path) {
this.FileBase.view.spawnInstance("codeeditor", "CodeEditor", {path: path});
this.FileBase.view.spawnInstance("codeeditor", "CodeEditor", {
path: path
});
},
rename: function() {
var self = this;
var fullpaths = Object.keys(this.FileBase.selections.entries);
......@@ -115,7 +117,7 @@ define(["jquery", "jclass"], function($, JClass) {
undefined) {
return;
}
var dfd = self.FileBase.instance.GET("/ajax/fs/rename", {
"path": self.FileBase.instance.getState("path"),
"name": name,
......@@ -129,9 +131,9 @@ define(["jquery", "jclass"], function($, JClass) {
defaultValue: name
});
});
},
_rename: function(path, name, newName) {
var self = this;
if (newName === null || newName === "" || newName === undefined) {
......@@ -151,7 +153,7 @@ define(["jquery", "jclass"], function($, JClass) {
});
return true;
},
copy: function() {
$(".file-node").css("opacity", "1.0");
this.removebool = false;
......@@ -163,7 +165,7 @@ define(["jquery", "jclass"], function($, JClass) {
path: "/"
});
},
cut: function() {
$(".file-node").css("opacity", "1.0");
this.removebool = true;
......@@ -178,18 +180,18 @@ define(["jquery", "jclass"], function($, JClass) {
$(this.FileBase.selections.entries[this.entries[i]]).css("opacity", "0.4");
}
},
paste: function() {
var self = this;
var cookie = $.cookie("vispaFile");
if (cookie === undefined || cookie === null) {
return;
}
var src = JSON.parse(cookie);
var paths = src.fileEntries;
var cut = src.fileRemove;
var dfd = self.FileBase.instance.POST("/ajax/fs/paste", {
"path": this.FileBase.instance.getState("path"),
"paths": JSON.stringify(paths),
......@@ -207,7 +209,7 @@ define(["jquery", "jclass"], function($, JClass) {
this.entries = [];
});
},
move: function(source, destination) {
var self = this;
self.FileBase.instance.GET("/ajax/fs/move", {
......@@ -215,8 +217,8 @@ define(["jquery", "jclass"], function($, JClass) {
"destination": JSON.stringify(destination)
});
},
remove: function() {
var self = this;
this.entries = Object.keys(this.FileBase.selections.entries);
......@@ -233,9 +235,9 @@ define(["jquery", "jclass"], function($, JClass) {
} else {
self._remove();
}
},
_remove: function() {
var self = this;
var dfd = self.FileBase.instance.POST("/ajax/fs/remove", {
......@@ -247,7 +249,7 @@ define(["jquery", "jclass"], function($, JClass) {
self.FileBase.selections.entries = {};
});
},
download: function() {
var path = Object.keys(this.FileBase.selections.entries);
if (path.length != 1) {
......@@ -267,17 +269,17 @@ define(["jquery", "jclass"], function($, JClass) {
}
},
compress: function() {
var self = this;
this.entries = Object.keys(this.FileBase.selections.entries);
self.FileBase.instance.prompt("Enter a name for the zip-file", function(newName) {
if (newName == name || newName === null || newName === "") { //noinspection JSLint
return;
}
self.FileBase.instance.GET("/ajax/fs/compress", {
path: self.FileBase.instance.getState("path"),
paths: JSON.stringify(self.entries),
......@@ -286,10 +288,10 @@ define(["jquery", "jclass"], function($, JClass) {
//self.FileBase.updateView();
});
});
return this;
},
info: function() {
var self = this;
var sizeSuffix = null;
......@@ -300,7 +302,7 @@ define(["jquery", "jclass"], function($, JClass) {
var numberOfSelectedItems = Object.keys(this.FileBase.selections.entries).length;
var infoObject = null;
if (numberOfSelectedItems > 0) {
// get name, size etc.
$.each(this.FileBase.selections.entries, function() {
var value = this;
......@@ -322,7 +324,7 @@ define(["jquery", "jclass"], function($, JClass) {
} else if (extension === null && value.data().data.type == "f") {
extension = "unknown file type";
}
// fill data to object
infoObject = {
"name": name,
......@@ -364,9 +366,9 @@ define(["jquery", "jclass"], function($, JClass) {
});
}
}
},
createFile: function() {
var self = this;
var newName = null;
......@@ -381,7 +383,7 @@ define(["jquery", "jclass"], function($, JClass) {
});
});
},
createFolder: function() {
var self = this;
var newName = null;
......@@ -396,7 +398,7 @@ define(["jquery", "jclass"], function($, JClass) {
});
});
},
upload: function(path) {
// bootstrap fileinput
var self = this;
......@@ -405,23 +407,31 @@ define(["jquery", "jclass"], function($, JClass) {
}
var input = $("<input />");
input.attr({
"type": "file",
"multiple": true,
"data-show-preview": false,
"type": "file",
"multiple": true,
"data-show-preview": false,
});
input.appendTo(this.FileBase.instance._nodes.content)
input.fileinput({
uploadUrl: vispa.url.dynamic("ajax/fs/upload?path=" + path +
"uploadUrl": vispa.url.dynamic("ajax/fs/upload?path=" + path +
"&_workspaceId=" + String(self.FileBase.instance.getWorkspaceId())),
});
// add close button
var closeButton = $("<div class='btn btn-danger'><i class='glyphicon glyphicon-remove'></i>close</div>")
.appendTo(input.parent().parent());
closeButton.on(vispa.hasTouch? "tab": "click", function(event) {
$(".file-input").remove();
closeButton.on(vispa.hasTouch ? "tab" : "click", function(event) {
$(".file-input", self.FileBase.view.node).remove();
});
// events
// disable close button while upload, enable afterwards
$(".file-input", self.FileBase.view.node).on("filebatchpreupload", function() {
closeButton.toggleClass("disabled", true);
});
$(".file-input", self.FileBase.view.node).on("filereset", function() {
closeButton.toggleClass("disabled", false);
});
},
filter: function() {
var self = this;
// if (content.filelist) {};
......@@ -456,6 +466,6 @@ define(["jquery", "jclass"], function($, JClass) {
});
}
});
return FileBaseActions;
});
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment