aboutsummaryrefslogtreecommitdiffstats
path: root/interface/js
diff options
context:
space:
mode:
authormoisseev <moiseev@mezonplus.ru>2020-10-27 18:18:00 +0300
committermoisseev <moiseev@mezonplus.ru>2020-10-27 18:18:00 +0300
commit6c9bfdc2c2e4ab952d7a48764a15c89c9a186513 (patch)
treeaf4630a80ffdab496afd594fa69b93f92615b904 /interface/js
parent0b3f5dcc9a8f6bebb0e18a58904e8946b378108a (diff)
downloadrspamd-6c9bfdc2c2e4ab952d7a48764a15c89c9a186513.tar.gz
rspamd-6c9bfdc2c2e4ab952d7a48764a15c89c9a186513.zip
[WebUI] Fix config editor read-only mode attribute
Diffstat (limited to 'interface/js')
-rw-r--r--interface/js/app/config.js29
1 files changed, 14 insertions, 15 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 101935c35..f6a54d65a 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -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",