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

[filebrowser] merge different dialogs of unknown file to one dialog: one can...

[filebrowser] merge different dialogs of unknown file to one dialog: one can chose between cancel, code editor and download.
[filebrowser] fix function for opening with code editor
parent 976b3ab0
......@@ -95,36 +95,59 @@ define(["jquery", "jclass"], function($, JClass) {
if (~self.FileBase.helper.isBrowserFile(path)) {
lb();
} else {
var name = selectionElem.data().data.name;
var size = selectionElem.data().data.size;
var sizeFormat = self.FileBase.helper.convertSize(size);
size = sizeFormat.size + " " + sizeFormat.sizeSuffix;
self.FileBase.instance.confirm(
"Do you want to open \"" + name + " (" + size + ")\" with the codeeditor?",
function(result) {
if (result === true) {
self._openWithCodeEditor(path);
} else {
self.FileBase.instance.confirm("Do you want to download \"" + name +
" (" +
size + ")\"?",
function(res2) {
if (res2 === true) {
self.download();
}
});
self.FileBase.instance.getTemplate("html/openDialog.html", function (err, tmpl) {
var $body = $(tmpl).children().first();
var $footer = $(tmpl).children().last();
var dialog = null;
var clicktype = vispa.device.hasTouch ? "tap" : "click";
var name = selectionElem.data().data.name;
var size = selectionElem.data().data.size;
var sizeFormat = self.FileBase.helper.convertSize(size);
size = sizeFormat.size + " " + sizeFormat.sizeSuffix;
// render body
$body.html("What do you want to do with \"" + name + " (" + size + ")\"?");
// footer clicks
// just close for cancel
$("#cancel", $footer).on(clicktype, function (event) {
event.stopPropagation();
dialog.close();
});
// open with code editor
$("#codeeditor", $footer).on(clicktype, function (event) {
event.stopPropagation();
self._openWithCodeEditor(path);
dialog.close();
});
// just close for cancel
$("#download", $footer).on(clicktype, function (event) {
event.stopPropagation();
self.download();
dialog.close();
});
// create dialog
self.FileBase.instance.dialog({
"header": "Open file",
"body": $body,
"footer": $footer,
beforeClose: function (cb) {
cb();
},
onRender: function () {
dialog = this;
}
}
);
});
});
}
// })
} else {
handlers[0].callback(this.FileBase.view.instance.getWorkspaceId(), path);
}
},
_openWithCodeEditor: function(path) {
this.FileBase.view.spawnInstance("codeeditor", "CodeEditor", {
this.FileBase.instance.spawnInstance("codeeditor", "CodeEditor", {
path: path
});
},
......
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