Explorar el Código

[WebUI] Fix config editor read-only mode attribute

tags/2.7
moisseev hace 3 años
padre
commit
6c9bfdc2c2
Se han modificado 1 ficheros con 14 adiciones y 15 borrados
  1. 14
    15
      interface/js/app/config.js

+ 14
- 15
interface/js/app/config.js Ver fichero

@@ -152,11 +152,13 @@ define(["jquery", "codejar", "linenumbers", "prism"],
codejar: true,
elt: "div",
class: "editor language-clike",
readonly_attr: {contenteditable: false},
}
// Fallback to textarea if the browser does not support ES6
: {
elt: "textarea",
class: "form-control map-textarea",
readonly_attr: {readonly: true},
};

// Modal form for maps
@@ -168,11 +170,20 @@ define(["jquery", "codejar", "linenumbers", "prism"],
Map: item.map
},
success: function (data) {
var readonly = "";
$("<" + editor.elt + ' id="editor" class="' + editor.class + '" data-id="' + item.map + '">' +
rspamd.escapeHTML(data[0].data) +
"</" + editor.elt + ">").appendTo("#modalBody");

if (editor.codejar) {
jar = new CodeJar(
document.querySelector("#editor"),
withLineNumbers(Prism.highlightElement)
);
}

var icon = "fa-edit";
var text = rspamd.escapeHTML(data[0].data);
if (item.editable === false || rspamd.read_only) {
readonly = " readonly";
$("#editor").attr(editor.readonly_attr);
icon = "fa-eye";
$("#modalSaveGroup").hide();
} else {
@@ -181,18 +192,6 @@ define(["jquery", "codejar", "linenumbers", "prism"],
$("#modalDialog .modal-header").find("[data-fa-i2svg]").addClass(icon);
$("#modalTitle").html(item.uri);

$("<" + editor.elt + ' id="editor" class="' + editor.class + '"' + readonly +
' data-id="' + item.map + '">' +
text +
"</" + editor.elt + ">").appendTo("#modalBody");

if (editor.codejar) {
jar = new CodeJar(
document.querySelector("#editor"),
withLineNumbers(Prism.highlightElement)
);
}

$("#modalDialog").modal("show");
},
errorMessage: "Cannot receive maps data",

Cargando…
Cancelar
Guardar