Commit 89ce15ec authored by Marcel Rieger's avatar Marcel Rieger
Browse files

file: fix upload.

parent 5d2de212
......@@ -429,40 +429,32 @@ define(["jquery", "jclass"], function($, JClass) {
},
upload: function(path) {
// bootstrap fileinput
var self = this;
if (path === undefined) {
path = this.FileBase.instance.getState("path");
}
// already existent?
if ($(".file-input", self.FileBase.view.node).length !== 0) return;
// create new input
var input = $("<input />");
input.attr({
"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 +
"&_workspaceId=" + String(self.FileBase.instance.getWorkspaceId())),
});
input = $(".file-input", self.FileBase.view.node);
// add close button
var closeButton = $("<div class='btn btn-danger'><i class='glyphicon glyphicon-remove'></i>close</div>")
.appendTo(".input-group-btn", input);
closeButton.on(vispa.hasTouch ? "tab" : "click", function() {
input.remove();
});
// events
// disable close button while upload, enable afterwards
input.on("filebatchpreupload", function() {
closeButton.toggleClass("disabled", true);
var $input = $("<input />");
$input.attr({
type : "file",
name : "files[]",
multiple: true
});
input.on("filereset", function() {
closeButton.toggleClass("disabled", false);
$input.fileupload({
url: vispa.url.dynamic("ajax/fs/upload?path=" + path +
"&_workspaceId=" + self.FileBase.instance.getWorkspaceId()),
done: function() {
//self.FileBase.updateView();
vispa.messenger.info("Upload succeeded", "glyphicon glyphicon-ok-sign");
$(this).remove();
},
fail: function() {
vispa.messenger.info("Upload failed", "glyphicon glyphicon-warning-sign");
$(this).remove();
}
});
$input.trigger("click");
},
filter: function() {
......
......@@ -6,7 +6,7 @@ define([
"css!../css/base/file-icons",
"css!../css/base/pathbar",
"css!../css/base/views/symbol/symbol",
"css!../css/base/views/table/table",
"css!../css/base/views/table/table"
], function(extensions, FileViews, Shortcuts) {
var FileExtension = extensions.Extension._extend({
......
Supports Markdown
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