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