Commit 705a5cf7 authored by ThorbenQuast's avatar ThorbenQuast
Browse files

editor: - confirm before file is overwritten (fix #1962)

- complete revision 1827
parent 1e62c5f0
......@@ -284,19 +284,36 @@ var CodeEditor = Emitter.extend({
var args = {
"path": path,
callback: function(path) {
var fileExtension = path.split(".").pop().toLowerCase();
if (!~self.view._extension.fileExtensions.indexOf(fileExtension)) {
var msg = "<html>File extension '" + fileExtension +
"' is not supported! <br /> Save anyway?</html>";
self.view.confirm(msg, function(confirmed) {
if (confirmed) {
self.view.POST(vispa.url.dynamic("/ajax/fs/exists"), {
path: path
}).done(function(selectedType) {
var proceedSave = function() {
var fileExtension = path.split(".").pop().toLowerCase();
if (!~self.view._extension.fileExtensions.indexOf(fileExtension)) {
var msg = "<html>File extension '" + fileExtension +
"' is not supported! <br /> Save anyway?</html>";
self.view.confirm(msg, function(confirmed) {
if (confirmed) {
self.save(callback, "new", path);
}
});
} else {
self.save(callback, "new", path);
}
});
} else {
self.save(callback, "new", path);
}
};
if (selectedType == "f") { //selected element is an existing file
var msg = "<html> File exists already! <br />" +
"Do you want to overwrite it ? </html>";
self.view.confirm(msg, function(confirmed) {
if (confirmed)
proceedSave();
else
return;
});
} else
proceedSave();
});
},
sort: ["name", "ext"],
reverse: [false, false]
......
......@@ -29,7 +29,7 @@ var CodeEditorExtension = vispa.Extension.extend({
// register to listen to certain file extensions
this.fileExtensions = ["bsc", "c", "cc", "conf", "cpp", "csh", "css", "diff", "f", "f70",
"f90", "f95", "f03", "h", "hh", "hpp", "html", "ini", "java", "js", "less", "log", "json",
"md", "orig", "php", "py", "pyc", "rb", "sh", "tex", "txt", "xml", "yml", "yaml", "zsh"
"md", "orig", "php", "py", "rb", "sh", "tex", "txt", "xml", "yml", "yaml", "zsh"
];
$.each(this.fileExtensions, function(i, key) {
self.addFileHandler(key, function(workspaceId, 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