Commit 6614c626 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

EditorPage: Display the rigth mimetype and editor even in case of error

parent 263e7eb6
......@@ -82,9 +82,12 @@
}
}
function displayDataInCodeEditor(gadget, code_editor, data, type) {
function displayDataInCodeEditor(gadget, code_editor, url, type) {
return RSVP.Queue()
.push(function () {
return gadget.crib_sw_get(url);
})
.push(function (data) {
return jIO.util.readBlobAsText(data, type);
})
.push(function (evt) {
......@@ -108,28 +111,22 @@
}
function getUrlTextContent(gadget, event, url) {
var type, code_editor;
var type = mimeType.lookup(url, false, "application/octet-stream"),
code_editor;
gadget.props.element.querySelector("form.crib-editor-save .mimetype")
.value = type;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget('codeeditor');
})
.push(function (editor) {
code_editor = editor;
return RSVP.all([
editor.getSupportedTypeList(),
gadget.crib_sw_get(url)
]);
return editor.getSupportedTypeList();
})
.push(function (result_list) {
var data = result_list[1];
type = data.type;
if (!type || type === "application/octet-stream") {
type = mimeType.lookup(url, false, "application/octet-stream");
}
gadget.props.element.querySelector("form.crib-editor-save .mimetype")
.value = type;
if (result_list[0].indexOf(type) !== -1) {
return displayDataInCodeEditor(gadget, code_editor, data, type);
if (result_list.indexOf(type) !== -1) {
return displayDataInCodeEditor(gadget, code_editor, url, type);
} else {
return displayFile(gadget, data, type);
}
......
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